Search in sources :

Example 1 with LdapSSOConfigurationFailed

use of com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationFailed in project cloudbreak by hortonworks.

the class LdapSSOConfigurationHandler method accept.

@Override
public void accept(Event<LdapSSOConfigurationRequest> ldapConfigurationRequestEvent) {
    Long stackId = ldapConfigurationRequestEvent.getData().getResourceId();
    Selectable response;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(stackId);
        GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
        LdapView ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
        String environmentCrnForVirtualGroups = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
        VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(environmentCrnForVirtualGroups, ldapView != null ? ldapView.getAdminGroup() : "");
        clusterApiConnectors.getConnector(stack).clusterSecurityService().setupLdapAndSSO(primaryGatewayConfig.getPublicAddress(), ldapView, virtualGroupRequest);
        response = new LdapSSOConfigurationSuccess(stackId);
    } catch (Exception e) {
        LOGGER.info("Error during LDAP configuration, stackId: " + stackId, e);
        response = new LdapSSOConfigurationFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(ldapConfigurationRequestEvent.getHeaders(), response));
}
Also used : LdapSSOConfigurationFailed(com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) LdapSSOConfigurationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationSuccess) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 LdapView (com.sequenceiq.cloudbreak.dto.LdapView)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 LdapSSOConfigurationFailed (com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationFailed)1 LdapSSOConfigurationSuccess (com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationSuccess)1