Search in sources :

Example 1 with CreateBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandler method defaultFailureEvent.

@Override
protected Selectable defaultFailureEvent(Long resourceId, Exception e, Event<CreateKerberosBindUserEvent> event) {
    CreateBindUserEvent eventData = event.getData();
    String failureMsg = String.format("Kerberos bind user creation failed for %s with %s", eventData.getSuffix(), e.getMessage());
    return new CreateBindUserFailureEvent(CreateBindUserFlowEvent.CREATE_BIND_USER_FAILED_EVENT.event(), eventData, failureMsg, e);
}
Also used : CreateBindUserFailureEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserFailureEvent) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)

Example 2 with CreateBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<CreateKerberosBindUserEvent> event) {
    CreateBindUserEvent data = event.getData();
    Optional<KerberosConfig> kerberosConfig = kerberosConfigService.find(data.getEnvironmentCrn(), data.getAccountId(), data.getSuffix());
    if (kerberosConfig.isPresent()) {
        LOGGER.info("Kerberos configuration already exist: {}", kerberosConfig.get());
        return new CreateBindUserEvent(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), data);
    } else {
        return createKerberosBindUser(event.getEvent(), data);
    }
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)

Example 3 with CreateBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandler method createKerberosBindUser.

private Selectable createKerberosBindUser(Event<CreateKerberosBindUserEvent> event, CreateBindUserEvent data) {
    Stack stack = stackService.getByEnvironmentCrnAndAccountId(data.getEnvironmentCrn(), data.getAccountId());
    MDCBuilder.buildMdcContext(stack);
    LOGGER.info("Create Kerberos bind user for [{}]", data.getSuffix());
    try {
        kerberosConfigV1Service.createNewKerberosConfig(data.getEnvironmentCrn(), data.getSuffix(), stack, true);
        return new CreateBindUserEvent(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), data);
    } catch (FreeIpaClientException e) {
        LOGGER.error("Couldn't create Kerberos bind user: {}", data, e);
        return defaultFailureEvent(data.getResourceId(), e, event);
    }
}
Also used : CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 4 with CreateBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent in project cloudbreak by hortonworks.

the class CreateBindUserActions method createBindUserFinishedAction.

@Bean("CREATE_BIND_USER_FINISHED_STATE")
public Action<?, ?> createBindUserFinishedAction() {
    return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {

        @Inject
        private OperationService operationService;

        @Override
        protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) throws Exception {
            LOGGER.info("Bind user creation successfully finished with payload: {}", payload);
            SuccessDetails successDetails = new SuccessDetails(payload.getEnvironmentCrn());
            successDetails.getAdditionalDetails().put("suffix", List.of(payload.getSuffix()));
            operationService.completeOperation(payload.getAccountId(), payload.getOperationId(), Set.of(successDetails), Set.of());
            LOGGER.debug("Finalizing user creation finished");
            sendEvent(context, CreateBindUserFlowEvent.CREATE_BIND_USER_FINISHED_EVENT.event(), payload);
        }
    };
}
Also used : SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) CommonContext(com.sequenceiq.flow.core.CommonContext) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 5 with CreateBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent in project cloudbreak by hortonworks.

the class CreateBindUserActions method createLdapBindUserAction.

@Bean("CREATE_LDAP_BIND_USER_STATE")
public Action<?, ?> createLdapBindUserAction() {
    return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {

        @Override
        protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Sending request to create LDAP bind user for {}", payload.getSuffix());
            sendEvent(context, new CreateLdapBindUserEvent(payload));
        }
    };
}
Also used : CommonContext(com.sequenceiq.flow.core.CommonContext) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) CreateLdapBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

CreateBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)19 Test (org.junit.jupiter.api.Test)9 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)6 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 CreateKerberosBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent)5 CreateLdapBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent)5 CreateBindUserFailureEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserFailureEvent)4 CommonContext (com.sequenceiq.flow.core.CommonContext)3 Map (java.util.Map)3 Bean (org.springframework.context.annotation.Bean)3 KerberosConfig (com.sequenceiq.freeipa.kerberos.KerberosConfig)2 LdapConfig (com.sequenceiq.freeipa.ldap.LdapConfig)2 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)1 BindUserCreateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)1 Operation (com.sequenceiq.freeipa.entity.Operation)1 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)1