Search in sources :

Example 1 with KeytabCreationException

use of com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException in project cloudbreak by hortonworks.

the class KerberosMgmtVaultComponent method getSecretResponseForKeytab.

public SecretResponse getSecretResponseForKeytab(HostKeytabRequest request, String accountId, String keytab) {
    try {
        String path = new VaultPathBuilder().withSecretType(VaultPathBuilder.SecretType.HOST_KEYTAB).withAccountId(accountId).withSubType(VaultPathBuilder.SecretSubType.KEYTAB).withEnvironmentCrn(request.getEnvironmentCrn()).withClusterCrn(request.getClusterCrn()).withServerHostName(request.getServerHostName()).build();
        String secret = secretService.put(path, keytab);
        return stringToSecretResponseConverter.convert(secret);
    } catch (Exception exception) {
        LOGGER.warn("Failure while updating vault.", exception);
        throw new KeytabCreationException(VAULT_UPDATE_FAILED);
    }
}
Also used : KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException) KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException)

Example 2 with KeytabCreationException

use of com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException in project cloudbreak by hortonworks.

the class KerberosMgmtVaultComponent method getSecretResponseForKeytab.

public SecretResponse getSecretResponseForKeytab(ServiceKeytabRequest request, String accountId, String keytab) {
    try {
        String path = new VaultPathBuilder().withSecretType(VaultPathBuilder.SecretType.SERVICE_KEYTAB).withAccountId(accountId).withSubType(VaultPathBuilder.SecretSubType.KEYTAB).withEnvironmentCrn(request.getEnvironmentCrn()).withClusterCrn(request.getClusterCrn()).withServerHostName(request.getServerHostName()).withServiceName(request.getServiceName()).build();
        String secret = secretService.put(path, keytab);
        return stringToSecretResponseConverter.convert(secret);
    } catch (Exception exception) {
        LOGGER.warn("Failure while updating vault.", exception);
        throw new KeytabCreationException(VAULT_UPDATE_FAILED);
    }
}
Also used : KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException) KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException)

Example 3 with KeytabCreationException

use of com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException in project cloudbreak by hortonworks.

the class KerberosMgmtVaultComponent method getSecretResponseForPrincipal.

public SecretResponse getSecretResponseForPrincipal(HostKeytabRequest request, String accountId, String principal) {
    try {
        String path = new VaultPathBuilder().withSecretType(VaultPathBuilder.SecretType.HOST_KEYTAB).withAccountId(accountId).withSubType(VaultPathBuilder.SecretSubType.SERVICE_PRINCIPAL).withEnvironmentCrn(request.getEnvironmentCrn()).withClusterCrn(request.getClusterCrn()).withServerHostName(request.getServerHostName()).build();
        String secret = secretService.put(path, principal);
        return stringToSecretResponseConverter.convert(secret);
    } catch (Exception exception) {
        LOGGER.warn("Failure while updating vault.", exception);
        throw new KeytabCreationException(VAULT_UPDATE_FAILED);
    }
}
Also used : KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException) KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException)

Example 4 with KeytabCreationException

use of com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException in project cloudbreak by hortonworks.

the class KeytabCommonService method addHost.

public Host addHost(String hostname, RoleRequest roleRequest, FreeIpaClient ipaClient) throws FreeIpaClientException, KeytabCreationException {
    try {
        Host host = fetchOrCreateHost(hostname, ipaClient);
        allowHostKeytabRetrieval(hostname, ipaClient);
        roleComponent.addRoleAndPrivileges(Optional.empty(), Optional.of(host), roleRequest, ipaClient);
        return host;
    } catch (RetryableFreeIpaClientException e) {
        LOGGER.error(HOST_CREATION_FAILED + " " + e.getLocalizedMessage(), e);
        throw new RetryableFreeIpaClientException(HOST_CREATION_FAILED, e, new KeytabCreationException(HOST_CREATION_FAILED));
    } catch (FreeIpaClientException e) {
        LOGGER.error(HOST_CREATION_FAILED + " " + e.getLocalizedMessage(), e);
        throw new KeytabCreationException(HOST_CREATION_FAILED);
    }
}
Also used : RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) Host(com.sequenceiq.freeipa.client.model.Host)

Example 5 with KeytabCreationException

use of com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException in project cloudbreak by hortonworks.

the class KeytabCommonService method getKeytab.

public KeytabCache getKeytab(String environmentCrn, String canonicalPrincipal, String hostName, FreeIpaClient ipaClient) throws FreeIpaClientException, KeytabCreationException {
    try {
        LOGGER.debug("Fetching keytab from FreeIPA");
        Keytab keytab = ipaClient.getKeytab(canonicalPrincipal);
        return keytabCacheService.saveOrUpdate(environmentCrn, canonicalPrincipal, hostName, keytab.getKeytab());
    } catch (RetryableFreeIpaClientException e) {
        LOGGER.error(KEYTAB_GENERATION_FAILED + " " + e.getLocalizedMessage(), e);
        throw new RetryableFreeIpaClientException(KEYTAB_GENERATION_FAILED, e, new KeytabCreationException(KEYTAB_GENERATION_FAILED));
    } catch (FreeIpaClientException e) {
        LOGGER.error(KEYTAB_GENERATION_FAILED + " " + e.getLocalizedMessage(), e);
        throw new KeytabCreationException(KEYTAB_GENERATION_FAILED);
    }
}
Also used : RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) Keytab(com.sequenceiq.freeipa.client.model.Keytab) KeytabCreationException(com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException)

Aggregations

KeytabCreationException (com.sequenceiq.freeipa.kerberosmgmt.exception.KeytabCreationException)10 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)5 RetryableFreeIpaClientException (com.sequenceiq.freeipa.client.RetryableFreeIpaClientException)5 Host (com.sequenceiq.freeipa.client.model.Host)2 Keytab (com.sequenceiq.freeipa.client.model.Keytab)2 KeytabCache (com.sequenceiq.freeipa.entity.KeytabCache)2 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)1 Stack (com.sequenceiq.freeipa.entity.Stack)1