use of org.wso2.carbon.identity.application.common.model.xsd.LocalRole in project identity-api-server by wso2.
the class ServiceProviderToApiModel method buildRoleConfig.
private RoleConfig buildRoleConfig(ServiceProvider application) {
RoleConfig roleConfig = new RoleConfig();
if (application.getClaimConfig() != null) {
String roleClaimId = application.getClaimConfig().getRoleClaimURI();
if (StringUtils.isBlank(roleClaimId)) {
if (application.getClaimConfig().isLocalClaimDialect()) {
roleConfig.claim(buildClaimModel(FrameworkConstants.LOCAL_ROLE_CLAIM_URI));
}
} else {
roleConfig.claim(buildClaimModel(roleClaimId));
}
}
if (application.getLocalAndOutBoundAuthenticationConfig() != null) {
roleConfig.includeUserDomain(application.getLocalAndOutBoundAuthenticationConfig().isUseUserstoreDomainInRoles());
}
if (application.getPermissionAndRoleConfig() != null) {
RoleMapping[] roleMappings = application.getPermissionAndRoleConfig().getRoleMappings();
arrayToStream(roleMappings).forEach(roleMapping -> roleConfig.addMappingsItem(new org.wso2.carbon.identity.api.server.application.management.v1.RoleMapping().applicationRole(roleMapping.getRemoteRole()).localRole(roleMapping.getLocalRole().getLocalRoleName())));
}
return roleConfig;
}
use of org.wso2.carbon.identity.application.common.model.xsd.LocalRole in project identity-api-server by wso2.
the class ServerIdpManagementService method updateRoles.
private void updateRoles(IdentityProvider idp, Roles roles) {
if (roles != null) {
PermissionsAndRoleConfig permissionsAndRoleConfig = new PermissionsAndRoleConfig();
List<org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping> mappings = roles.getMappings();
List<RoleMapping> internalMappings = new ArrayList<>();
List<String> idpRoles = new ArrayList<>();
if (mappings != null) {
for (org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping mapping : mappings) {
RoleMapping internalMapping = new RoleMapping();
internalMapping.setLocalRole(new LocalRole(mapping.getLocalRole()));
internalMapping.setRemoteRole(mapping.getIdpRole());
idpRoles.add(mapping.getIdpRole());
internalMappings.add(internalMapping);
}
}
permissionsAndRoleConfig.setIdpRoles(idpRoles.toArray(new String[0]));
permissionsAndRoleConfig.setRoleMappings(internalMappings.toArray(new RoleMapping[0]));
idp.setPermissionAndRoleConfig(permissionsAndRoleConfig);
idp.setProvisioningRole(StringUtils.join(roles.getOutboundProvisioningRoles(), ","));
}
}
Aggregations