Skip to content

Commit

Permalink
Introduce role properties object to store role related properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanChathusanda93 committed Dec 11, 2024
1 parent ed0296a commit 9459b46
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ private RoleConstants() {
public static final String NEW_ROLE_NAME = "newRoleName";
public static final String FAILURE_REASON = "failureReason";

// Role properties
public static final String IS_SHARED_ROLE_PROP_NAME = "isSharedRole";

/**
* Grouping of constants related to database table names.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleAudience;
import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleBasicInfo;
import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleDTO;
import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleProperty;
import org.wso2.carbon.identity.role.v2.mgt.core.model.UserBasicInfo;
import org.wso2.carbon.identity.role.v2.mgt.core.util.GroupIDResolver;
import org.wso2.carbon.identity.role.v2.mgt.core.util.UserIDResolver;
Expand Down Expand Up @@ -400,6 +401,12 @@ private List<Role> getRolesRequestedAttributes(List<RoleBasicInfo> roles, List<S
role.setAudienceId(roleBasicInfo.getAudienceId());
role.setAudienceName(roleBasicInfo.getAudienceName());
role.setAudience(roleBasicInfo.getAudience());

RoleProperty roleProperty = new RoleProperty();
roleProperty.setName(RoleConstants.IS_SHARED_ROLE_PROP_NAME);
roleProperty.setValue(String.valueOf(isSharedRole(roleBasicInfo.getId(), tenantDomain)));
role.setRoleProperty(roleProperty);

if (requiredAttributes != null && !requiredAttributes.isEmpty()) {
if (requiredAttributes.contains(USERS)) {
role.setUsers(getUserListOfRole(roleBasicInfo.getId(), tenantDomain));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.wso2.carbon.identity.role.v2.mgt.core.model;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -37,6 +38,7 @@ public class Role {
private String audienceId;
private String audienceName;
private List<AssociatedApplication> associatedApplications;
private List<RoleProperty> roleProperties = new ArrayList<>();

public Role() {

Expand Down Expand Up @@ -281,4 +283,34 @@ public void setAssociatedApplications(List<AssociatedApplication> associatedAppl

this.associatedApplications = associatedApplications;
}

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

return roleProperties;
}

/**
* Set the role properties.
*
* @param roleProperties properties list of a role.
*/
public void setRoleProperties(List<RoleProperty> roleProperties) {

this.roleProperties = roleProperties;
}

/**
* Set a role property to the role properties list.
*
* @param roleProperty a property of a role.
*/
public void setRoleProperty(RoleProperty roleProperty) {

this.roleProperties.add(roleProperty);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.wso2.carbon.identity.role.v2.mgt.core.model;

import java.io.Serializable;

/**
* Role property object to store the role specific property details.
*/
public class RoleProperty implements Serializable {

private String name;
private String value;
private String displayName;

/**
* Get the value of the property.
*
* @return value.
*/
public String getValue() {

return value;
}

/**
* Set the value of the property.
*
* @param value Value of the property.
*/
public void setValue(String value) {

this.value = value;
}

/**
* Get the display name of the property.
*
* @return Display name.
*/
public String getDisplayName() {

return displayName;
}

/**
* Set display name of the property.
*
* @param displayName Display name.
*/
public void setDisplayName(String displayName) {

this.displayName = displayName;
}

/**
* Get the name of the property.
*
* @return Name (This is the key).
*/
public String getName() {

return name;
}

/**
* Set the name of the property.
*
* @param name (This is the key).
*/
public void setName(String name) {

this.name = name;
}
}

0 comments on commit 9459b46

Please sign in to comment.