use of com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordResult in project cloudbreak by hortonworks.
the class SetPasswordHandler method accept.
@Override
public void accept(Event<SetPasswordRequest> setPasswordRequestEvent) {
SetPasswordRequest request = setPasswordRequestEvent.getData();
LOGGER.info("SetPasswordHandler accepting request {}", request);
try {
Stack stack = stackService.getStackById(request.getResourceId());
MDCBuilder.buildMdcContext(stack);
FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack);
if (FreeIpaCapabilities.hasSetPasswordHashSupport(freeIpaClient.getConfig())) {
LOGGER.info("IPA has password hash support. Credentials information from UMS will be used.");
WorkloadCredential workloadCredential = umsCredentialProvider.getCredentials(request.getUserCrn(), MDCUtils.getRequestId());
setPasswordHash(stack, request, freeIpaClient, workloadCredential);
if (StringUtils.isBlank(workloadCredential.getHashedPassword())) {
LOGGER.info("IPA has password hash support but user does not have a password set in UMS; using the provided password directly.");
freeIpaClient.userSetPasswordWithExpiration(request.getUsername(), request.getPassword(), request.getExpirationInstant());
}
} else {
LOGGER.info("IPA does not have password hash support; using the provided password directly.");
freeIpaClient.userSetPasswordWithExpiration(request.getUsername(), request.getPassword(), request.getExpirationInstant());
}
SetPasswordResult result = new SetPasswordResult(request);
request.getResult().onNext(result);
} catch (Exception e) {
request.getResult().onError(e);
}
}
Aggregations