@Test void testWithPasswordHashSupport() throws FreeIpaClientException { SetPasswordRequest request = new SetPasswordRequest(1L, "environment", "username", "userCrn", "password", Optional.empty()); FreeIpaClient mockFreeIpaClient = newfreeIpaClient(true); when(freeIpaClientFactory.getFreeIpaClientForStack(any())).thenReturn(mockFreeIpaClient); underTest.accept(new Event<>(request)); verify(mockFreeIpaClient, times(0)).userSetPasswordWithExpiration(any(), any(), any()); }
@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())) { WorkloadCredential workloadCredential = umsCredentialProvider.getCredentials(request.getUserCrn(), MDCUtils.getRequestId()); LOGGER.info("IPA has password hash support. Credentials information from UMS will be used."); workloadCredentialService.setWorkloadCredential(freeIpaClient, request.getUsername(), 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); } }
SetPasswordHandler implements EventHandler<SetPasswordRequest> { @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())) { WorkloadCredential workloadCredential = umsCredentialProvider.getCredentials(request.getUserCrn(), MDCUtils.getRequestId()); LOGGER.info("IPA has password hash support. Credentials information from UMS will be used."); workloadCredentialService.setWorkloadCredential(freeIpaClient, request.getUsername(), 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); } } }
SetPasswordHandler implements EventHandler<SetPasswordRequest> { @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())) { WorkloadCredential workloadCredential = umsCredentialProvider.getCredentials(request.getUserCrn(), MDCUtils.getRequestId()); LOGGER.info("IPA has password hash support. Credentials information from UMS will be used."); workloadCredentialService.setWorkloadCredential(freeIpaClient, request.getUsername(), 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); } }  }
SetPasswordHandler implements EventHandler<SetPasswordRequest> { @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())) { WorkloadCredential workloadCredential = umsCredentialProvider.getCredentials(request.getUserCrn(), MDCUtils.getRequestId()); LOGGER.info("IPA has password hash support. Credentials information from UMS will be used."); workloadCredentialService.setWorkloadCredential(freeIpaClient, request.getUsername(), 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); } }  @Override String selector(); @Override void accept(Event<SetPasswordRequest> setPasswordRequestEvent); }
SetPasswordHandler implements EventHandler<SetPasswordRequest> { @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())) { WorkloadCredential workloadCredential = umsCredentialProvider.getCredentials(request.getUserCrn(), MDCUtils.getRequestId()); LOGGER.info("IPA has password hash support. Credentials information from UMS will be used."); workloadCredentialService.setWorkloadCredential(freeIpaClient, request.getUsername(), 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); } }  @Override String selector(); @Override void accept(Event<SetPasswordRequest> setPasswordRequestEvent);  }