use of org.wso2.carbon.identity.role.mgt.core.Role in project charon by wso2.
the class Role method setGroup.
/**
* Set a group to the role, where user will have three default attributes such as name, value and $ref.
*
* @param group Group object.
* @throws BadRequestException BadRequestException.
* @throws CharonException CharonException.
*/
public void setGroup(Group group) throws BadRequestException, CharonException {
if (this.isAttributeExist(SCIMConstants.RoleSchemaConstants.GROUPS)) {
MultiValuedAttribute groups = (MultiValuedAttribute) this.attributeList.get(SCIMConstants.RoleSchemaConstants.GROUPS);
ComplexAttribute complexAttribute = processGroup(group);
groups.setAttributeValue(complexAttribute);
} else {
MultiValuedAttribute groups = new MultiValuedAttribute(SCIMConstants.RoleSchemaConstants.GROUPS);
DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.GROUPS, groups);
ComplexAttribute complexAttribute = processGroup(group);
groups.setAttributeValue(complexAttribute);
this.setAttribute(groups);
}
}
use of org.wso2.carbon.identity.role.mgt.core.Role in project charon by wso2.
the class User method replaceRoles.
/**
* deletes the role attributes and exchanges it with the given values
*/
public void replaceRoles(List<MultiValuedComplexType> multiValuedComplexTypeList) {
SCIMAttributeSchema complexDefinition = SCIMSchemaDefinitions.SCIMUserSchemaDefinition.ROLES;
SCIMAttributeSchema valueDefinition = SCIMSchemaDefinitions.SCIMUserSchemaDefinition.ROLES_VALUE;
SCIMAttributeSchema displayDefinition = SCIMSchemaDefinitions.SCIMUserSchemaDefinition.ROLES_DISPLAY;
SCIMAttributeSchema typeDefinition = SCIMSchemaDefinitions.SCIMUserSchemaDefinition.ROLES_TYPE;
addMultivaluedComplexAtribute(multiValuedComplexTypeList, complexDefinition, valueDefinition, displayDefinition, typeDefinition, null, null);
}
use of org.wso2.carbon.identity.role.mgt.core.Role in project charon by wso2.
the class Role method setSystemRole.
/**
* Set the systemRole attribute of the meta attribute.
*
* @param isSystemRole Whether this is a read only system role.
* @throws CharonException CharonException.
* @throws BadRequestException BadRequestException.
*/
public void setSystemRole(boolean isSystemRole) throws CharonException, BadRequestException {
// Create the systemRole attribute as defined in schema.
SimpleAttribute systemRoleAttribute = (SimpleAttribute) DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.SYSTEM_ROLE, new SimpleAttribute(SCIMConstants.CommonSchemaConstants.SYSTEM_ROLE, isSystemRole));
// Check whether the meta complex attribute already exist.
if (getMetaAttribute() != null) {
ComplexAttribute metaAttribute = getMetaAttribute();
// Check whether the systemRole attribute already exist.
if (metaAttribute.isSubAttributeExist(systemRoleAttribute.getName())) {
String error = "Tried to modify a read only attribute.";
throw new CharonException(error);
} else {
metaAttribute.setSubAttribute(systemRoleAttribute);
}
} else {
// Create the meta attribute and set the sub attribute.
createMetaAttribute();
getMetaAttribute().setSubAttribute(systemRoleAttribute);
}
}
use of org.wso2.carbon.identity.role.mgt.core.Role in project charon by wso2.
the class Role method setUser.
/**
* Set a user to the role, where user will have three default attributes such as name, value and $ref.
*
* @param user User object.
* @throws BadRequestException BadRequestException.
* @throws CharonException CharonException.
*/
public void setUser(User user) throws BadRequestException, CharonException {
if (this.isAttributeExist(SCIMConstants.RoleSchemaConstants.USERS)) {
MultiValuedAttribute users = (MultiValuedAttribute) this.attributeList.get(SCIMConstants.RoleSchemaConstants.USERS);
ComplexAttribute complexAttribute = processUser(user);
users.setAttributeValue(complexAttribute);
} else {
MultiValuedAttribute users = new MultiValuedAttribute(SCIMConstants.RoleSchemaConstants.USERS);
DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.SCIMRoleSchemaDefinition.USERS, users);
ComplexAttribute complexAttribute = processUser(user);
users.setAttributeValue(complexAttribute);
this.setAttribute(users);
}
}
use of org.wso2.carbon.identity.role.mgt.core.Role in project carbon-business-process by wso2.
the class CommonTaskUtil method calculateRole.
/**
* Calculates the Role.
*
* @param evalCtx : The evaluation context.
* @param roleExpression : the role expression
* @param expressionLanguage : Expression language associated with the argument named "role"
* @return : The task priority
*/
public static String calculateRole(EvaluationContext evalCtx, String roleExpression, String expressionLanguage) {
ExpressionLanguageRuntime expLangRuntime = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getExpressionLanguageRuntime(expressionLanguage);
String role = expLangRuntime.evaluateAsString(roleExpression, evalCtx);
if (role == null) {
log.warn(String.format("Role cannot be null"));
}
return role;
}
Aggregations