Search in sources :

Example 1 with Account

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

the class MockUserManagementService method listUsers.

@Override
public void listUsers(ListUsersRequest request, StreamObserver<ListUsersResponse> responseObserver) {
    LOGGER.info("List users for account: {}", request.getAccountId());
    Builder userBuilder = ListUsersResponse.newBuilder();
    if (request.getUserIdOrCrnCount() == 0) {
        if (isNotEmpty(request.getAccountId())) {
            ofNullable(accountUsers.get(request.getAccountId())).orElse(Set.of()).stream().map(userName -> createUser(request.getAccountId(), userName)).forEach(userBuilder::addUser);
            for (int i = 0; i < MOCK_USER_COUNT; i++) {
                User user = createUser(request.getAccountId(), "fakeMockUser" + i);
                userBuilder.addUser(user);
            }
        }
        responseObserver.onNext(userBuilder.build());
    } else {
        String userIdOrCrn = request.getUserIdOrCrn(0);
        String[] splittedCrn = userIdOrCrn.split(":");
        String userName = splittedCrn[6];
        String accountId = splittedCrn[4];
        responseObserver.onNext(userBuilder.addUser(createUser(accountId, userName)).build());
    }
    responseObserver.onCompleted();
}
Also used : CDP_SDX_HBASE_CLOUD_STORAGE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_SDX_HBASE_CLOUD_STORAGE) StringUtils(org.apache.commons.lang3.StringUtils) NotifyResourceDeletedResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.NotifyResourceDeletedResponse) ResourceAssignment(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ResourceAssignment) OJDBC_TOKEN_DH(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.OJDBC_TOKEN_DH) AuthenticateRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AuthenticateRequest) GetIdPMetadataForWorkloadSSOResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetIdPMetadataForWorkloadSSOResponse) MachineUser(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.MachineUser) CDP_CB_AWS_NATIVE_DATALAKE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE_DATALAKE) Map(java.util.Map) GetEventGenerationIdsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetEventGenerationIdsRequest) CreateMachineUserResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateMachineUserResponse) DeleteAccessKeyRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteAccessKeyRequest) PolicyStatement(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyStatement) Status(io.grpc.Status) ListTermsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListTermsRequest) CrnHelper(com.sequenceiq.thunderhead.util.CrnHelper) Path(java.nio.file.Path) CDP_CM_BULK_HOSTS_REMOVAL(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CM_BULK_HOSTS_REMOVAL) CreateAccessKeyRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyRequest) GetAssigneeAuthorizationInformationResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAssigneeAuthorizationInformationResponse) DATAHUB_FLOW_SCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_FLOW_SCALING) GetIdPMetadataForWorkloadSSORequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetIdPMetadataForWorkloadSSORequest) CDP_CB_AWS_NATIVE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE) CDP_CB_AZURE_ENCRYPTION_AT_HOST(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AZURE_ENCRYPTION_AT_HOST) ListResourceAssigneesResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListResourceAssigneesResponse) JsonFormat(com.google.protobuf.util.JsonFormat) AssignRoleResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AssignRoleResponse) EPHEMERAL_DISKS_FOR_TEMP_DATA(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.EPHEMERAL_DISKS_FOR_TEMP_DATA) CDP_SAAS(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_SAAS) AuthenticateResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AuthenticateResponse) CDP_SAAS_SDX_INTEGRATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_SAAS_SDX_INTEGRATION) CDP_PUBLIC_ENDPOINT_ACCESS_GATEWAY_AZURE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_PUBLIC_ENDPOINT_ACCESS_GATEWAY_AZURE) User(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.User) CDP_CB_DATABASE_WIRE_ENCRYPTION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_DATABASE_WIRE_ENCRYPTION) AccessKey(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AccessKey) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ListResourceAssigneesRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListResourceAssigneesRequest) Strings(com.google.common.base.Strings) ListMachineUsersResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersResponse) SetWorkloadAdministrationGroupNameResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.SetWorkloadAdministrationGroupNameResponse) JwtHelper.decodeAndVerify(org.springframework.security.jwt.JwtHelper.decodeAndVerify) Service(org.springframework.stereotype.Service) ListWorkloadAdministrationGroupsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsResponse) GetAccountRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest) CreateAccessKeyResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse) ListRolesResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListRolesResponse) Charsets(com.google.common.base.Charsets) CDP_ALLOW_HA_REPAIR(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_ALLOW_HA_REPAIR) UnassignRoleRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.UnassignRoleRequest) Resources(com.google.common.io.Resources) ListRolesRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListRolesRequest) CDP_DATAHUB_NODESTATUS_CHECK(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATAHUB_NODESTATUS_CHECK) IOException(java.io.IOException) CDP_ENDPOINT_GATEWAY_SKIP_VALIDATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_ENDPOINT_GATEWAY_SKIP_VALIDATION) CDP_CM_HA(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CM_HA) CDP_CONCLUSION_CHECKER_SEND_USER_EVENT(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CONCLUSION_CHECKER_SEND_USER_EVENT) CDP_EXPERIENCE_DELETION_BY_ENVIRONMENT(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_EXPERIENCE_DELETION_BY_ENVIRONMENT) CDP_CLOUD_STORAGE_VALIDATION_GCP(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CLOUD_STORAGE_VALIDATION_GCP) GetAccountResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse) CDP_ALLOW_HA_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_ALLOW_HA_UPGRADE) CDP_CB_AZURE_DISK_SSE_WITH_CMK(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AZURE_DISK_SSE_WITH_CMK) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) CDP_AZURE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_AZURE) CDP_AZURE_IMAGE_MARKETPLACE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_AZURE_IMAGE_MARKETPLACE) CDP_UNBOUND_ELIMINATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_UNBOUND_ELIMINATION) DATAHUB_AWS_AUTOSCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_AWS_AUTOSCALING) StreamObserver(io.grpc.stub.StreamObserver) CDP_RUNTIME_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_RUNTIME_UPGRADE) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) CDP_CB_AWS_NATIVE_FREEIPA(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE_FREEIPA) ResourceAssignee(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ResourceAssignee) DeleteMachineUserResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteMachineUserResponse) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AccountType(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AccountType) JsonUtil(com.sequenceiq.thunderhead.util.JsonUtil) UUID(java.util.UUID) DATAHUB_AZURE_AUTOSCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_AZURE_AUTOSCALING) Collectors(java.util.stream.Collectors) GetRightsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsResponse) CacheLoader(com.google.common.cache.CacheLoader) CDP_FREEIPA_SELECT_INSTANCE_TYPE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FREEIPA_SELECT_INSTANCE_TYPE) Builder(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse.Builder) CDP_CCM_V1_TO_V2_JUMPGATE_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CCM_V1_TO_V2_JUMPGATE_UPGRADE) UI_EDP_PROGRESS_BAR(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.UI_EDP_PROGRESS_BAR) CreateWorkloadMachineUserResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateWorkloadMachineUserResponse) CDP_CLOUD_STORAGE_VALIDATION_AZURE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CLOUD_STORAGE_VALIDATION_AZURE) MessageDigest(java.security.MessageDigest) CDP_MICRO_DUTY_SDX(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_MICRO_DUTY_SDX) CDP_CLOUD_IDENTITY_MAPPING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CLOUD_IDENTITY_MAPPING) CDP_CCM_V2_JUMPGATE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CCM_V2_JUMPGATE) CDP_VM_DIAGNOSTICS(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_VM_DIAGNOSTICS) AssignResourceRoleRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AssignResourceRoleRequest) Inject(javax.inject.Inject) UnassignRoleResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.UnassignRoleResponse) VerifyInteractiveUserSessionTokenRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.VerifyInteractiveUserSessionTokenRequest) CDP_CB_GCP_DISK_ENCRYPTION_WITH_CMEK(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_GCP_DISK_ENCRYPTION_WITH_CMEK) FMS_FREEIPA_BATCH_CALL(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.FMS_FREEIPA_BATCH_CALL) CDP_DATALAKE_BACKUP_ON_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATALAKE_BACKUP_ON_UPGRADE) WorkloadPasswordPolicy(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadPasswordPolicy) Logger(org.slf4j.Logger) CDP_ALLOW_DIFFERENT_DATAHUB_VERSION_THAN_DATALAKE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_ALLOW_DIFFERENT_DATAHUB_VERSION_THAN_DATALAKE) CDP_RUNTIME_UPGRADE_DATAHUB(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_RUNTIME_UPGRADE_DATAHUB) Optional.ofNullable(java.util.Optional.ofNullable) SetWorkloadAdministrationGroupNameRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.SetWorkloadAdministrationGroupNameRequest) CDP_PUBLIC_ENDPOINT_ACCESS_GATEWAY_GCP(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_PUBLIC_ENDPOINT_ACCESS_GATEWAY_GCP) PolicyDefinition(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyDefinition) CDP_FMS_RECIPE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FMS_RECIPE) DeleteMachineUserRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteMachineUserRequest) CDP_DATALAKE_ZDU_OS_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATALAKE_ZDU_OS_UPGRADE) UmsVirtualGroupRight(com.sequenceiq.cloudbreak.auth.altus.UmsVirtualGroupRight) ListGroupsForMemberResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsForMemberResponse) FileReader(java.io.FileReader) DATAHUB_GCP_AUTOSCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_GCP_AUTOSCALING) AccessKeyType(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AccessKeyType) LoadingCache(com.google.common.cache.LoadingCache) CDP_BASE_IMAGE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_BASE_IMAGE) NotifyResourceDeletedRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.NotifyResourceDeletedRequest) GetUserResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetUserResponse) CDP_FREEIPA_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FREEIPA_UPGRADE) WORKLOAD_IAM_SYNC(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.WORKLOAD_IAM_SYNC) Policy(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Policy) DATAHUB_AWS_STOP_START_SCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_AWS_STOP_START_SCALING) CDP_AZURE_UAE_CENTRAL(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_AZURE_UAE_CENTRAL) ListMachineUsersRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersRequest) DeleteWorkloadAdministrationGroupNameResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteWorkloadAdministrationGroupNameResponse) GetWorkloadAdministrationGroupNameResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetWorkloadAdministrationGroupNameResponse) CDP_DATA_LAKE_LOAD_BALANCER_AZURE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATA_LAKE_LOAD_BALANCER_AZURE) Role(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Role) CDP_DATA_LAKE_AWS_EFS(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATA_LAKE_AWS_EFS) CDP_DATA_LAKE_LOAD_BALANCER(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATA_LAKE_LOAD_BALANCER) ListWorkloadAdministrationGroupsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsRequest) Set(java.util.Set) Entitlement(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Entitlement) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) AssignResourceRoleResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AssignResourceRoleResponse) StandardCharsets(java.nio.charset.StandardCharsets) DeleteAccessKeyResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteAccessKeyResponse) CDP_FMS_USERSYNC_THREAD_TIMEOUT(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FMS_USERSYNC_THREAD_TIMEOUT) SanitizerUtil(com.sequenceiq.cloudbreak.util.SanitizerUtil) Jwt(org.springframework.security.jwt.Jwt) CreateWorkloadMachineUserRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateWorkloadMachineUserRequest) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CDP_DATALAKE_SELECT_INSTANCE_TYPE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATALAKE_SELECT_INSTANCE_TYPE) ListWorkloadAdministrationGroupsForMemberRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberRequest) ListGroupsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsResponse) GetRightsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsRequest) CDP_CCM_V2(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CCM_V2) MacSigner(org.springframework.security.jwt.crypto.sign.MacSigner) SshPublicKey(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.SshPublicKey) Value(org.springframework.beans.factory.annotation.Value) CrnResourceDescriptor(com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor) AssignRoleRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AssignRoleRequest) ListAccessKeysRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListAccessKeysRequest) CDP_SHOW_CLI(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_SHOW_CLI) CDP_AUTOMATIC_USERSYNC_POLLER(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_AUTOMATIC_USERSYNC_POLLER) IniUtil(com.sequenceiq.thunderhead.util.IniUtil) CDP_DATALAKE_RESIZE_RECOVERY(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATALAKE_RESIZE_RECOVERY) GetActorWorkloadCredentialsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsResponse) Properties(java.util.Properties) GetWorkloadAdministrationGroupNameRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetWorkloadAdministrationGroupNameRequest) CDP_RAW_S3(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_RAW_S3) Files(java.nio.file.Files) ListUsersResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse) UnassignResourceRoleResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.UnassignResourceRoleResponse) CDP_CLOUD_STORAGE_VALIDATION_AWS(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CLOUD_STORAGE_VALIDATION_AWS) ListWorkloadAdministrationGroupsForMemberResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse) CDP_FMS_DELAYED_STOP_START(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FMS_DELAYED_STOP_START) ListAccessKeysResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListAccessKeysResponse) ListServicePrincipalCloudIdentitiesResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesResponse) Paths(java.nio.file.Paths) CreateMachineUserRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateMachineUserRequest) CDP_CB_AWS_VARIANT_MIGRATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_VARIANT_MIGRATION) ListGroupsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsRequest) RoleAssignment(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.RoleAssignment) CDP_AZURE_SINGLE_RESOURCE_GROUP_DEDICATED_STORAGE_ACCOUNT(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_AZURE_SINGLE_RESOURCE_GROUP_DEDICATED_STORAGE_ACCOUNT) GetAssigneeAuthorizationInformationRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAssigneeAuthorizationInformationRequest) DATAHUB_AZURE_STOP_START_SCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_AZURE_STOP_START_SCALING) LOCAL_DEV(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.LOCAL_DEV) LoggerFactory(org.slf4j.LoggerFactory) CDP_USER_SYNC_CREDENTIALS_UPDATE_OPTIMIZATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_USER_SYNC_CREDENTIALS_UPDATE_OPTIMIZATION) ListGroupsForMemberRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsForMemberRequest) ListServicePrincipalCloudIdentitiesRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesRequest) GetEventGenerationIdsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetEventGenerationIdsResponse) CDP_FREEIPA_HA_REPAIR(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FREEIPA_HA_REPAIR) UserManagementImplBase(com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementImplBase) DeleteWorkloadAdministrationGroupNameRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteWorkloadAdministrationGroupNameRequest) GrpcActorContext(com.sequenceiq.thunderhead.grpc.GrpcActorContext) CDP_AZURE_SINGLE_RESOURCE_GROUP(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_AZURE_SINGLE_RESOURCE_GROUP) AltusToken(com.sequenceiq.thunderhead.model.AltusToken) Base64(java.util.Base64) List(java.util.List) UnassignResourceRoleRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.UnassignResourceRoleRequest) PostConstruct(javax.annotation.PostConstruct) E2E_TEST_ONLY(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.E2E_TEST_ONLY) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) GetActorWorkloadCredentialsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetActorWorkloadCredentialsRequest) Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) CDP_USE_CM_SYNC_COMMAND_POLLER(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_USE_CM_SYNC_COMMAND_POLLER) CDP_ALLOW_INTERNAL_REPOSITORY_FOR_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_ALLOW_INTERNAL_REPOSITORY_FOR_UPGRADE) CDP_OS_UPGRADE_DATAHUB(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_OS_UPGRADE_DATAHUB) VerifyInteractiveUserSessionTokenResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.VerifyInteractiveUserSessionTokenResponse) DATA_LAKE_LIGHT_TO_MEDIUM_MIGRATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATA_LAKE_LIGHT_TO_MEDIUM_MIGRATION) CLOUDERA_INTERNAL_ACCOUNT(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CLOUDERA_INTERNAL_ACCOUNT) Collections.newSetFromMap(java.util.Collections.newSetFromMap) CDP_FREEIPA_REBUILD(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_FREEIPA_REBUILD) UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) CDP_TARGETED_UPSCALE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_TARGETED_UPSCALE) CDP_CCM_V2_TO_V2_JUMPGATE_UPGRADE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CCM_V2_TO_V2_JUMPGATE_UPGRADE) CDP_NODESTATUS_ENABLE_SALT_PING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_NODESTATUS_ENABLE_SALT_PING) CDP_DATALAKE_BACKUP_ON_RESIZE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATALAKE_BACKUP_ON_RESIZE) CDP_ENABLE_DISTROX_INSTANCE_TYPES(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_ENABLE_DISTROX_INSTANCE_TYPES) GetUserRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetUserRequest) CDP_CB_AWS_DISK_ENCRYPTION_WITH_CMK(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_DISK_ENCRYPTION_WITH_CMK) DATAHUB_STREAMING_SCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_STREAMING_SCALING) ListUsersRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersRequest) TimeUnit(java.util.concurrent.TimeUnit) CDP_GCP(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_GCP) DATAHUB_GCP_STOP_START_SCALING(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.DATAHUB_GCP_STOP_START_SCALING) ListTermsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListTermsResponse) CDP_CLOUD_STORAGE_VALIDATION(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CLOUD_STORAGE_VALIDATION) CDP_DATAHUB_CUSTOM_CONFIGS(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_DATAHUB_CUSTOM_CONFIGS) WorkloadAdministrationGroup(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup) VisibleForTesting(com.google.common.annotations.VisibleForTesting) CDP_CCM_V2_USE_ONE_WAY_TLS(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CCM_V2_USE_ONE_WAY_TLS) MachineUser(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.MachineUser) User(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.User) Builder(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse.Builder) CacheBuilder(com.google.common.cache.CacheBuilder)

Example 2 with Account

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

the class MockUserManagementServiceTest method getAccountTestIncludesFixedEntitlements.

@Test
void getAccountTestIncludesFixedEntitlements() {
    ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE);
    underTest.initializeWorkloadPasswordPolicy();
    GetAccountRequest req = GetAccountRequest.getDefaultInstance();
    StreamRecorder<GetAccountResponse> observer = StreamRecorder.create();
    underTest.getAccount(req, observer);
    assertThat(observer.getValues().size()).isEqualTo(1);
    GetAccountResponse res = observer.getValues().get(0);
    assertThat(res.hasAccount()).isTrue();
    Account account = res.getAccount();
    List<String> entitlements = account.getEntitlementsList().stream().map(Entitlement::getEntitlementName).collect(Collectors.toList());
    assertThat(entitlements).contains("CDP_AZURE", "CDP_GCP", "CDP_AUTOMATIC_USERSYNC_POLLER", "CLOUDERA_INTERNAL_ACCOUNT", "DATAHUB_AZURE_AUTOSCALING", "DATAHUB_AWS_AUTOSCALING", "DATAHUB_GCP_AUTOSCALING", "LOCAL_DEV", "DATAHUB_FLOW_SCALING", "DATAHUB_STREAMING_SCALING", "CDP_CM_ADMIN_CREDENTIALS");
}
Also used : GetAccountResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse) Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) GetAccountRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with Account

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

the class MockUserManagementServiceTest method getAccountTestIncludesConditionalEntitlement.

@ParameterizedTest(name = "{0}")
@MethodSource("conditionalEntitlementDataProvider")
void getAccountTestIncludesConditionalEntitlement(String testCaseName, String conditionFieldName, boolean condition, String entitlementName, boolean entitlementPresentExpected) {
    ReflectionTestUtils.setField(underTest, "cbLicense", VALID_LICENSE);
    underTest.initializeWorkloadPasswordPolicy();
    ReflectionTestUtils.setField(underTest, conditionFieldName, condition);
    GetAccountRequest req = GetAccountRequest.getDefaultInstance();
    StreamRecorder<GetAccountResponse> observer = StreamRecorder.create();
    underTest.getAccount(req, observer);
    assertThat(observer.getValues().size()).isEqualTo(1);
    GetAccountResponse res = observer.getValues().get(0);
    assertThat(res.hasAccount()).isTrue();
    Account account = res.getAccount();
    List<String> entitlements = account.getEntitlementsList().stream().map(Entitlement::getEntitlementName).collect(Collectors.toList());
    if (entitlementPresentExpected) {
        assertThat(entitlements).contains(entitlementName);
    } else {
        assertThat(entitlements).doesNotContain(entitlementName);
    }
}
Also used : GetAccountResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse) Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) GetAccountRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with Account

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

the class ClusterHostServiceRunner method decoratePillarWithClouderaManagerLicense.

public Optional<String> decoratePillarWithClouderaManagerLicense(Long stackId, Map<String, SaltPillarProperties> servicePillar) {
    String accountId = Crn.safeFromString(stackService.get(stackId).getResourceCrn()).getAccountId();
    Account account = umsClient.getAccountDetails(accountId, MDCUtils.getRequestId(), regionAwareInternalCrnGeneratorFactory);
    Optional<String> licenseOpt = Optional.ofNullable(account.getClouderaManagerLicenseKey());
    if (licenseOpt.isPresent() && isNotEmpty(licenseOpt.get())) {
        String license = licenseOpt.get();
        servicePillar.put("cloudera-manager-license", new SaltPillarProperties("/cloudera-manager/license.sls", singletonMap("cloudera-manager", singletonMap("license", license))));
    }
    return licenseOpt;
}
Also used : Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 5 with Account

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

the class UmsClient method createGroup.

/**
 * Create new user group if it does not exist.
 *
 * @param requestId the request ID for the request
 * @param accountId the account ID
 * @param groupName the newly created group name
 * @return the new or existing user group.
 */
public Group createGroup(String requestId, String accountId, String groupName) {
    checkNotNull(requestId, "requestId should not be null.");
    checkNotNull(groupName, "groupName should not be null.");
    validateAccountIdWithWarning(accountId);
    try {
        CreateGroupResponse createGroupResponse = newStub(requestId).createGroup(CreateGroupRequest.newBuilder().setAccountId(accountId).setGroupName(groupName).build());
        LOGGER.info("New user group has been created: \nId: {} \nCrn: {} \nName: {}.", createGroupResponse.getGroup().getGroupId(), createGroupResponse.getGroup().getCrn(), createGroupResponse.getGroup().getGroupName());
        return createGroupResponse.getGroup();
    } catch (StatusRuntimeException e) {
        if (e.getStatus().getCode().equals(io.grpc.Status.ALREADY_EXISTS.getCode())) {
            Group existingGroup = listGroups(requestId, accountId, List.of(groupName)).stream().filter(foundGroup -> foundGroup.getGroupName().equals(groupName)).findAny().orElse(null);
            LOGGER.info("User group already exists: \nId: {} \nCrn: {} \nName: {}.", existingGroup.getGroupId(), existingGroup.getCrn(), existingGroup.getGroupName());
            return existingGroup;
        } else {
            throw e;
        }
    }
}
Also used : ManagedChannel(io.grpc.ManagedChannel) LoggerFactory(org.slf4j.LoggerFactory) UserManagementGrpc(com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc) PagingProto(com.cloudera.thunderhead.service.common.paging.PagingProto) ListGroupsForMemberRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsForMemberRequest) GetIdPMetadataForWorkloadSSOResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetIdPMetadataForWorkloadSSOResponse) MachineUser(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.MachineUser) AddMemberToGroupResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AddMemberToGroupResponse) ListMachineUsersRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersRequest) GrpcUtil(com.sequenceiq.cloudbreak.grpc.util.GrpcUtil) UmsAuthenticationException(com.sequenceiq.cloudbreak.auth.altus.exception.UmsAuthenticationException) Status(io.grpc.Status) ListServicePrincipalCloudIdentitiesRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesRequest) GetUserSyncStateModelResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetUserSyncStateModelResponse) CreateAccessKeyRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyRequest) ListGroupMembersResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupMembersResponse) CrnChecker.warnIfAccountIdIsInternal(com.sequenceiq.cloudbreak.auth.altus.service.CrnChecker.warnIfAccountIdIsInternal) GetIdPMetadataForWorkloadSSORequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetIdPMetadataForWorkloadSSORequest) ListWorkloadAdministrationGroupsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsRequest) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) Collectors(java.util.stream.Collectors) GetRightsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsResponse) Sets(com.google.common.collect.Sets) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) CreateGroupResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateGroupResponse) List(java.util.List) AddMemberToGroupRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AddMemberToGroupRequest) RemoveMemberFromGroupRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.RemoveMemberFromGroupRequest) UserManagementBlockingStub(com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub) Optional(java.util.Optional) NullableScalarTypeProto(com.cloudera.thunderhead.service.NullableScalarTypeProto) ListWorkloadAdministrationGroupsForMemberRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberRequest) Account(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account) Actor(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Actor) ListGroupsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsResponse) User(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.User) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) GetRightsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsRequest) CreateGroupRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateGroupRequest) UmsClientConfig(com.sequenceiq.cloudbreak.auth.altus.config.UmsClientConfig) ArrayList(java.util.ArrayList) ListGroupMembersRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupMembersRequest) ListMachineUsersResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersResponse) UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) DeleteGroupResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteGroupResponse) ListWorkloadAdministrationGroupsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsResponse) GetAccountRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest) AltusMetadataInterceptor(com.sequenceiq.cloudbreak.grpc.altus.AltusMetadataInterceptor) GetUserSyncStateModelRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetUserSyncStateModelRequest) CreateAccessKeyResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse) RemoveMemberFromGroupResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.RemoveMemberFromGroupResponse) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) ListUsersResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse) CallingServiceNameInterceptor(com.sequenceiq.cloudbreak.grpc.altus.CallingServiceNameInterceptor) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) GetUserRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetUserRequest) ListUsersRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersRequest) ListWorkloadAdministrationGroupsForMemberResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse) StatusRuntimeException(io.grpc.StatusRuntimeException) ListServicePrincipalCloudIdentitiesResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesResponse) ListGroupsForMemberResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsForMemberResponse) ListGroupsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsRequest) RightsCheck(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.RightsCheck) WorkloadAdministrationGroup(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup) DeleteGroupRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.DeleteGroupRequest) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) WorkloadAdministrationGroup(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup) CreateGroupResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateGroupResponse) StatusRuntimeException(io.grpc.StatusRuntimeException)

Aggregations

Account (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account)7 GetAccountRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountRequest)6 GetAccountResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetAccountResponse)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 UserManagementProto (com.cloudera.thunderhead.service.usermanagement.UserManagementProto)2 CreateAccessKeyRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyRequest)2 CreateAccessKeyResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse)2 GetIdPMetadataForWorkloadSSORequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetIdPMetadataForWorkloadSSORequest)2 GetIdPMetadataForWorkloadSSOResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetIdPMetadataForWorkloadSSOResponse)2 GetRightsRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsRequest)2 GetRightsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsResponse)2 GetUserRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetUserRequest)2 Test (org.junit.jupiter.api.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 NullableScalarTypeProto (com.cloudera.thunderhead.service.NullableScalarTypeProto)1 PagingProto (com.cloudera.thunderhead.service.common.paging.PagingProto)1 UserManagementGrpc (com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc)1 UserManagementBlockingStub (com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub)1 UserManagementImplBase (com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementImplBase)1 AccessKey (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AccessKey)1