use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class HealthCheckAvailabilityCheckerTest method testAppVersionIsBlank.
@Test
public void testAppVersionIsBlank() {
Stack stack = new Stack();
assertFalse(underTest.isCdpFreeIpaHeathAgentAvailable(stack));
stack.setAppVersion("");
assertFalse(underTest.isCdpFreeIpaHeathAgentAvailable(stack));
stack.setAppVersion(" ");
assertFalse(underTest.isCdpFreeIpaHeathAgentAvailable(stack));
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class KeytabCleanupService method deleteServicePrincipal.
public void deleteServicePrincipal(ServicePrincipalRequest request, String accountId) throws FreeIpaClientException, DeleteException {
LOGGER.debug("Request to delete service principal for account {}: {}", accountId, request);
Stack freeIpaStack = keytabCommonService.getFreeIpaStackWithMdcContext(request.getEnvironmentCrn(), accountId);
String realm = keytabCommonService.getRealm(freeIpaStack);
String canonicalPrincipal = keytabCommonService.constructPrincipal(request.getServiceName(), request.getServerHostName(), realm);
FreeIpaClient ipaClient = freeIpaClientFactory.getFreeIpaClientForStack(freeIpaStack);
deleteService(canonicalPrincipal, ipaClient);
VaultPathBuilder vaultPathBuilder = new VaultPathBuilder().withSecretType(VaultPathBuilder.SecretType.SERVICE_KEYTAB).withAccountId(accountId).withEnvironmentCrn(request.getEnvironmentCrn()).withClusterCrn(request.getClusterCrn()).withServerHostName(request.getServerHostName()).withServiceName(request.getServiceName());
vaultComponent.recursivelyCleanupVault(vaultPathBuilder.withSubType(VaultPathBuilder.SecretSubType.SERVICE_PRINCIPAL).build());
vaultComponent.recursivelyCleanupVault(vaultPathBuilder.withSubType(VaultPathBuilder.SecretSubType.KEYTAB).build());
roleComponent.deleteRoleIfItIsNoLongerUsed(request.getRoleName(), ipaClient);
keytabCacheService.deleteByEnvironmentCrnAndPrincipal(request.getEnvironmentCrn(), canonicalPrincipal);
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class ServiceKeytabService method getExistingServiceKeytab.
public ServiceKeytabResponse getExistingServiceKeytab(ServiceKeytabRequest request, String accountId) throws FreeIpaClientException {
LOGGER.debug("Request to get service keytab for account {}: {}", accountId, request);
validateRoleRequestNotPresent(request);
Stack freeIpaStack = keytabCommonService.getFreeIpaStackWithMdcContext(request.getEnvironmentCrn(), accountId);
String realm = keytabCommonService.getRealm(freeIpaStack);
String servicePrincipal = keytabCommonService.constructPrincipal(request.getServiceName(), request.getServerHostName(), realm);
Optional<KeytabCache> keytabCacheOptional = keytabCacheService.findByEnvironmentCrnAndPrincipal(request.getEnvironmentCrn(), servicePrincipal);
if (keytabCacheOptional.isPresent()) {
LOGGER.debug("Keytab is found in cache, using it");
return createServiceKeytabResponse(keytabCacheOptional.get());
} else {
LOGGER.debug("Keytab is not found in cache.");
FreeIpaClient ipaClient = freeIpaClientFactory.getFreeIpaClientForStack(freeIpaStack);
KeytabCache serviceKeytab = keytabCommonService.getExistingKeytab(request.getEnvironmentCrn(), servicePrincipal, request.getServerHostName(), ipaClient);
return createServiceKeytabResponse(serviceKeytab);
}
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class HostKeytabService method generateHostKeytab.
public HostKeytabResponse generateHostKeytab(HostKeytabRequest request, String accountId) throws FreeIpaClientException {
LOGGER.debug("Request to generate host keytab: {}", request);
Stack freeIpaStack = keytabCommonService.getFreeIpaStackWithMdcContext(request.getEnvironmentCrn(), accountId);
FreeIpaClient ipaClient = freeIpaClientFactory.getFreeIpaClientForStack(freeIpaStack);
if (!roleComponent.privilegesExist(request.getRoleRequest(), ipaClient)) {
throw new BadRequestException(PRIVILEGE_DOES_NOT_EXIST);
} else {
Host host = keytabCommonService.addHost(request.getServerHostName(), request.getRoleRequest(), ipaClient);
KeytabCache hostKeytab = fetchKeytab(request, ipaClient, host);
return createHostKeytabResponse(hostKeytab);
}
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class HostKeytabService method getExistingHostKeytab.
public HostKeytabResponse getExistingHostKeytab(HostKeytabRequest request, String accountId) throws FreeIpaClientException {
LOGGER.debug("Request to get host keytab for account {}: {}", accountId, request);
if (request.getRoleRequest() != null) {
throw new BadRequestException(ROLE_NOT_ALLOWED);
} else {
Stack freeIpaStack = keytabCommonService.getFreeIpaStackWithMdcContext(request.getEnvironmentCrn(), accountId);
FreeIpaClient ipaClient = freeIpaClientFactory.getFreeIpaClientForStack(freeIpaStack);
String hostPrincipal = ipaClient.showHost(request.getServerHostName()).getKrbprincipalname();
KeytabCache hostKeytab = keytabCommonService.getExistingKeytab(request.getEnvironmentCrn(), hostPrincipal, request.getServerHostName(), ipaClient);
return createHostKeytabResponse(hostKeytab);
}
}
Aggregations