Search in sources :

Example 6 with Group

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

the class MockUserManagementService method listWorkloadAdministrationGroups.

@Override
public void listWorkloadAdministrationGroups(ListWorkloadAdministrationGroupsRequest request, StreamObserver<ListWorkloadAdministrationGroupsResponse> responseObserver) {
    mockCrnService.ensureInternalActor();
    String accountId = request.getAccountId();
    LOGGER.info("List workload administration groups: {}", accountId);
    ListWorkloadAdministrationGroupsResponse.Builder responseBuilder = ListWorkloadAdministrationGroupsResponse.newBuilder();
    for (UmsVirtualGroupRight right : UmsVirtualGroupRight.values()) {
        Group group = mockGroupManagementService.createGroup(accountId, mockGroupManagementService.generateWorkloadGroupName(right.getRight()));
        responseBuilder.addWorkloadAdministrationGroup(WorkloadAdministrationGroup.newBuilder().setWorkloadAdministrationGroupName(group.getGroupName()).setRightName(right.getRight()).setResource(MOCK_RESOURCE).build());
    }
    responseObserver.onNext(responseBuilder.build());
    responseObserver.onCompleted();
}
Also used : UmsVirtualGroupRight(com.sequenceiq.cloudbreak.auth.altus.UmsVirtualGroupRight) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) WorkloadAdministrationGroup(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup) ListWorkloadAdministrationGroupsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsResponse)

Example 7 with Group

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

the class MockUserManagementService method buildGetRightsResponse.

private GetRightsResponse buildGetRightsResponse(String accountId) {
    List<Group> workloadGroups = List.copyOf(mockGroupManagementService.getOrCreateWorkloadGroups(accountId));
    List<Group> userGroups = List.copyOf(mockGroupManagementService.getOrCreateUserGroups(accountId));
    PolicyStatement policyStatement = PolicyStatement.newBuilder().addRight(ALL_RIGHTS_AND_RESOURCES).addResource(ALL_RIGHTS_AND_RESOURCES).build();
    PolicyDefinition policyDefinition = PolicyDefinition.newBuilder().addStatement(policyStatement).build();
    Policy powerUserPolicy = Policy.newBuilder().setCrn(mockCrnService.createCrn(ACCOUNT_ID_ALTUS, CrnResourceDescriptor.POLICY, "PowerUserPolicy").toString()).setCreationDateMs(CREATION_DATE_MS).setPolicyDefinition(policyDefinition).build();
    Role powerUserRole = Role.newBuilder().setCrn("crn:altus:iam:us-west-1:altus:role:PowerUser").setCreationDateMs(CREATION_DATE_MS).addPolicy(powerUserPolicy).build();
    RoleAssignment roleAssignment = RoleAssignment.newBuilder().setRole(powerUserRole).build();
    GetRightsResponse.Builder rightsBuilder = GetRightsResponse.newBuilder().addRoleAssignment(roleAssignment);
    workloadGroups.forEach(group -> rightsBuilder.addGroupCrn(group.getCrn()));
    userGroups.forEach(group -> rightsBuilder.addGroupCrn(group.getCrn()));
    return rightsBuilder.build();
}
Also used : WorkloadPasswordPolicy(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadPasswordPolicy) Policy(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Policy) Role(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Role) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) WorkloadAdministrationGroup(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup) RoleAssignment(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.RoleAssignment) PolicyDefinition(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyDefinition) GetRightsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsResponse) PolicyStatement(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyStatement)

Example 8 with Group

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

the class MockGroupManagementService method createWorkloadGroups.

private Map<String, Group> createWorkloadGroups(String accountId) {
    Map<String, Group> groups = new HashMap<>();
    for (UmsVirtualGroupRight right : UmsVirtualGroupRight.values()) {
        Group group = createGroup(accountId, generateWorkloadGroupName(right.getRight()));
        groups.put(group.getCrn(), group);
    }
    LOGGER.info("workload groups for user: {}", groups);
    return groups;
}
Also used : UmsVirtualGroupRight(com.sequenceiq.cloudbreak.auth.altus.UmsVirtualGroupRight) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

Group (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group)8 WorkloadAdministrationGroup (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup)6 GetRightsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsResponse)2 ListGroupsRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsRequest)2 ListGroupsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsResponse)2 ListWorkloadAdministrationGroupsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsResponse)2 UmsVirtualGroupRight (com.sequenceiq.cloudbreak.auth.altus.UmsVirtualGroupRight)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 UserManagementProto (com.cloudera.thunderhead.service.usermanagement.UserManagementProto)1 Account (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Account)1 Actor (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Actor)1 AddMemberToGroupRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AddMemberToGroupRequest)1 AddMemberToGroupResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.AddMemberToGroupResponse)1 CreateAccessKeyRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyRequest)1 CreateAccessKeyResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse)1 CreateGroupRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateGroupRequest)1 CreateGroupResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateGroupResponse)1