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);
}
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);
}
}
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);
}
}
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);
}
};
}
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));
}
};
}
Aggregations