Search in sources :

Example 1 with UnsupportedException

use of com.sequenceiq.freeipa.controller.exception.UnsupportedException in project cloudbreak by hortonworks.

the class UserKeytabService method validateFreeIpaState.

private void validateFreeIpaState(String workloadUsername, String environmentCrn) {
    String accountId = Crn.safeFromString(environmentCrn).getAccountId();
    FreeIpaClient freeIpaClient;
    try {
        freeIpaClient = freeIpaClientFactory.getFreeIpaClientByAccountAndEnvironment(environmentCrn, accountId);
        if (!FreeIpaCapabilities.hasSetPasswordHashSupport(freeIpaClient.getConfig())) {
            throw new UnsupportedException("User keytab retrieval requires a newer environment and FreeIPA version");
        }
        Optional<User> user = freeIpaClient.userFind(workloadUsername);
        if (user.isEmpty()) {
            throw new NotFoundException(String.format("Workload user %s has not been synced into environment %s", workloadUsername, environmentCrn));
        }
    } catch (FreeIpaClientException e) {
        throw new RuntimeException(e);
    }
}
Also used : UnsupportedException(com.sequenceiq.freeipa.controller.exception.UnsupportedException) User(com.sequenceiq.freeipa.client.model.User) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException)

Aggregations

NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)1 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)1 User (com.sequenceiq.freeipa.client.model.User)1 UnsupportedException (com.sequenceiq.freeipa.controller.exception.UnsupportedException)1