Search in sources :

Example 1 with PolicyDefinition

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyDefinition 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)

Aggregations

GetRightsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.GetRightsResponse)1 Group (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group)1 Policy (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Policy)1 PolicyDefinition (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyDefinition)1 PolicyStatement (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.PolicyStatement)1 Role (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Role)1 RoleAssignment (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.RoleAssignment)1 WorkloadAdministrationGroup (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup)1 WorkloadPasswordPolicy (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadPasswordPolicy)1