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