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