Search in sources :

Example 1 with GetActorWorkloadCredentialsResponse

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse in project cloudbreak by hortonworks.

the class UserKeytabService method getKeytabBase64.

public String getKeytabBase64(String userCrn, String environmentCrn) {
    String userAccountId = Crn.safeFromString(userCrn).getAccountId();
    validateSameAccount(userAccountId, environmentCrn);
    String realm = getKerberosRealm(userAccountId, environmentCrn);
    GetActorWorkloadCredentialsResponse getActorWorkloadCredentialsResponse = grpcUmsClient.getActorWorkloadCredentials(userCrn, MDCUtils.getRequestId(), regionAwareInternalCrnGeneratorFactory);
    validateHasCredentials(getActorWorkloadCredentialsResponse);
    String workloadUsername = getActorWorkloadCredentialsResponse.getWorkloadUsername();
    validateFreeIpaState(workloadUsername, environmentCrn);
    List<ActorKerberosKey> actorKerberosKeys = getActorWorkloadCredentialsResponse.getKerberosKeysList();
    return userKeytabGenerator.generateKeytabBase64(workloadUsername, realm, actorKerberosKeys);
}
Also used : GetActorWorkloadCredentialsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse) ActorKerberosKey(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ActorKerberosKey)

Example 2 with GetActorWorkloadCredentialsResponse

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse in project cloudbreak by hortonworks.

the class UmsCredentialProviderTest method testGetCredentialsNoExpiration.

@Test
void testGetCredentialsNoExpiration() {
    GetActorWorkloadCredentialsResponse response = GetActorWorkloadCredentialsResponse.newBuilder().setPasswordHash(PASSWORD_HASH).addAllKerberosKeys(ACTOR_KERBEROS_KEY_LIST).setPasswordHashExpirationDate(0).setWorkloadCredentialsVersion(WORKLOAD_CREDENTIALS_VERSION).build();
    when(grpcUmsClient.getActorWorkloadCredentials(eq("user"), any(), any())).thenReturn(response);
    WorkloadCredential credential = underTest.getCredentials("user", Optional.empty());
    assertEquals(credential.getExpirationDate(), Optional.empty());
    assertEquals(WORKLOAD_CREDENTIALS_VERSION, credential.getVersion());
}
Also used : GetActorWorkloadCredentialsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse) WorkloadCredential(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential) Test(org.junit.jupiter.api.Test)

Example 3 with GetActorWorkloadCredentialsResponse

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse in project cloudbreak by hortonworks.

the class UserKeytabServiceTest method setupGrpcResponse.

private void setupGrpcResponse() {
    GetActorWorkloadCredentialsResponse response = GetActorWorkloadCredentialsResponse.newBuilder().setWorkloadUsername("workloadUserName").addAllKerberosKeys(newActorKerberosKeys()).build();
    when(grpcUmsClient.getActorWorkloadCredentials(any(), any(), any())).thenReturn(response);
}
Also used : GetActorWorkloadCredentialsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse)

Example 4 with GetActorWorkloadCredentialsResponse

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse in project cloudbreak by hortonworks.

the class UmsCredentialProviderTest method testGetCredentials.

@Test
void testGetCredentials() {
    GetActorWorkloadCredentialsResponse response = GetActorWorkloadCredentialsResponse.newBuilder().setPasswordHash(PASSWORD_HASH).addAllKerberosKeys(ACTOR_KERBEROS_KEY_LIST).setPasswordHashExpirationDate(EXPIRATION_DATE).setWorkloadCredentialsVersion(WORKLOAD_CREDENTIALS_VERSION).build();
    when(grpcUmsClient.getActorWorkloadCredentials(eq("user"), any(), any())).thenReturn(response);
    WorkloadCredential credential = underTest.getCredentials("user", Optional.empty());
    assertEquals(credential.getHashedPassword(), PASSWORD_HASH);
    assertEquals(credential.getExpirationDate(), Optional.of(Instant.ofEpochMilli(EXPIRATION_DATE)));
    assertTrue(credential.getKeys().containsAll(ACTOR_KERBEROS_KEY_LIST));
    assertEquals(WORKLOAD_CREDENTIALS_VERSION, credential.getVersion());
}
Also used : GetActorWorkloadCredentialsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse) WorkloadCredential(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential) Test(org.junit.jupiter.api.Test)

Example 5 with GetActorWorkloadCredentialsResponse

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse in project cloudbreak by hortonworks.

the class UserKeytabServiceTest method testGetKeytabBase64MissingCredentialKeys.

@Test
void testGetKeytabBase64MissingCredentialKeys() {
    String keytabBase64 = "keytabBase64...";
    setupKerberosConfig();
    GetActorWorkloadCredentialsResponse response = GetActorWorkloadCredentialsResponse.newBuilder().setWorkloadUsername("workloadUserName").clearKerberosKeys().build();
    when(grpcUmsClient.getActorWorkloadCredentials(any(), any(), any())).thenReturn(response);
    Exception exception = assertThrows(NotFoundException.class, () -> underTest.getKeytabBase64(USER_CRN, ENV_CRN));
    assertEquals("Could not retrieve workload credentials. A workload password may not have been set for this user or machine user.", exception.getMessage());
}
Also used : GetActorWorkloadCredentialsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) UnsupportedException(com.sequenceiq.freeipa.controller.exception.UnsupportedException) Test(org.junit.jupiter.api.Test)

Aggregations

GetActorWorkloadCredentialsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse)7 Test (org.junit.jupiter.api.Test)4 WorkloadCredential (com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential)2 ActorKerberosKey (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ActorKerberosKey)1 GetActorWorkloadCredentialsRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsRequest)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)1 UnsupportedException (com.sequenceiq.freeipa.controller.exception.UnsupportedException)1 Path (java.nio.file.Path)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1