Skip to content

Commit

Permalink
Create complex object to store role properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanChathusanda93 committed Dec 11, 2024
1 parent f394957 commit 1082ef9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,34 @@ public void setAssociatedApplications(List<MultiValuedComplexType> associatedApp
displayDefinition, null, null, refDefinition);
}

/**
* Set the role properties of the role.
*
* @param rolePropertiesList List of role properties.
*/
public void setRoleProperties(List<MultiValuedComplexType> rolePropertiesList) {

SCIMAttributeSchema complexDefinition = SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.ROLE_V2_PROPERTIES;
SCIMAttributeSchema valueDefinition = SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.ROLE_V2_PROPERTY_VALUE;
SCIMAttributeSchema displayDefinition = SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.ROLE_V2_PROPERTY_NAME;
addMultivaluedComplexAtribute(rolePropertiesList, complexDefinition, valueDefinition, displayDefinition,
null, null, null);
}

/**
* Get the role properties of the role.
*
* @return List of role properties.
*/
public List<MultiValuedComplexType> getRoleProperties() {

SCIMAttributeSchema complexDefinition = SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.ROLE_V2_PROPERTIES;
SCIMAttributeSchema valueDefinition = SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.ROLE_V2_PROPERTY_VALUE;
SCIMAttributeSchema displayDefinition = SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.ROLE_V2_PROPERTY_NAME;
return getMultivaluedComplexType(complexDefinition, valueDefinition, displayDefinition, null,
null, null).orElse(Collections.emptyList());
}

/**
* Get the audience of the role.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ public static class RoleSchemaConstants {
public static final String DISPLAY = "display";
public static final String VALUE = "value";
public static final String TYPE = "type";
public static final String ROLE_PROPERTIES_URI =
"urn:ietf:params:scim:schemas:extension:2.0:Role:roleProperties";
public static final String ROLE_PROPERTIES = "roleProperties";
public static final String ROLE_PROPERTY_NAME = "name";

// Possible canonical values for audience type attribute.
public static final String APPLICATION = "application";
Expand Down Expand Up @@ -583,6 +587,9 @@ public static class RoleSchemaConstants {
public static final String TYPE_DESC = "A label indicating the type of resource, e.g. 'User' or 'Group'";
public static final String AUDIENCE_TYPE_DESC =
"A label indicating the resource type of the role's usable audience.";
public static final String ROLE_PROPERTY_NAME_DESC = "Name of the role property.";
public static final String ROLE_PROPERTY_VALUE_DESC = "Value of the role property.";
public static final String ROLE_PROPERTIES_DESC = "A list of properties of the role.";

// URIs of sub and multivalued attributes.
public static final String USERS_VALUE_URI = "urn:ietf:params:scim:schemas:extension:2.0:Role:users.value";
Expand Down Expand Up @@ -612,6 +619,11 @@ public static class RoleSchemaConstants {
public static final String AUDIENCE_DISPLAY_URI =
"urn:ietf:params:scim:schemas:extension:2.0:Role:audience.display";
public static final String AUDIENCE_TYPE_URI = "urn:ietf:params:scim:schemas:extension:2.0:Role:audience.type";
public static final String ROLE_PROPERTY_NAME_URI =
"urn:ietf:params:scim:schemas:extension:2.0:Role:roleProperties.name";
public static final String ROLE_PROPERTY_VALUE_URI =
"urn:ietf:params:scim:schemas:extension:2.0:Role:roleProperties.value";

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,21 @@ public static class SCIMRoleSchemaDefinition {
Arrays.asList(SCIMConstants.RoleSchemaConstants.APPLICATION,
SCIMConstants.RoleSchemaConstants.ORGANIZATION)), null, null);

public static final SCIMAttributeSchema ROLE_V2_PROPERTY_NAME =
SCIMAttributeSchema.createSCIMAttributeSchema(SCIMConstants.RoleSchemaConstants.ROLE_PROPERTY_NAME_URI,
SCIMConstants.RoleSchemaConstants.ROLE_PROPERTY_NAME, SCIMDefinitions.DataType.STRING, false,
SCIMConstants.RoleSchemaConstants.ROLE_PROPERTY_NAME_DESC, false, false,
SCIMDefinitions.Mutability.IMMUTABLE, SCIMDefinitions.Returned.DEFAULT,
SCIMDefinitions.Uniqueness.NONE, null, null, null);

public static final SCIMAttributeSchema ROLE_V2_PROPERTY_VALUE =
SCIMAttributeSchema.createSCIMAttributeSchema(
SCIMConstants.RoleSchemaConstants.ROLE_PROPERTY_VALUE_URI,
SCIMConstants.RoleSchemaConstants.VALUE, SCIMDefinitions.DataType.STRING, false,
SCIMConstants.RoleSchemaConstants.ROLE_PROPERTY_VALUE_DESC, false, false,
SCIMDefinitions.Mutability.IMMUTABLE, SCIMDefinitions.Returned.DEFAULT,
SCIMDefinitions.Uniqueness.NONE, null, null, null);

// Attribute schemas of the attributes defined in role schema.

// A human-readable name for the Role. REQUIRED.
Expand Down Expand Up @@ -1207,6 +1222,14 @@ public static class SCIMRoleSchemaDefinition {
SCIMDefinitions.Mutability.READ_ONLY, SCIMDefinitions.Returned.DEFAULT,
SCIMDefinitions.Uniqueness.NONE, null, null, new ArrayList<>(
Arrays.asList(ASC_APPLICATIONS_VALUE, ASC_APPLICATIONS_DISPLAY, ASC_APPLICATIONS_REF)));

public static final SCIMAttributeSchema ROLE_V2_PROPERTIES =
SCIMAttributeSchema.createSCIMAttributeSchema(SCIMConstants.RoleSchemaConstants.ROLE_PROPERTIES_URI,
SCIMConstants.RoleSchemaConstants.ROLE_PROPERTIES, SCIMDefinitions.DataType.COMPLEX, true,
SCIMConstants.RoleSchemaConstants.ROLE_PROPERTIES_DESC, false, false,
SCIMDefinitions.Mutability.READ_ONLY, SCIMDefinitions.Returned.DEFAULT,
SCIMDefinitions.Uniqueness.NONE, null, null, new ArrayList<>(
Arrays.asList(ROLE_V2_PROPERTY_NAME, ROLE_V2_PROPERTY_VALUE)));
}

/**
Expand Down

0 comments on commit 1082ef9

Please sign in to comment.