Search in sources :

Example 21 with LocalRole

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;
}
Also used : RoleConfig(org.wso2.carbon.identity.api.server.application.management.v1.RoleConfig) RoleMapping(org.wso2.carbon.identity.application.common.model.RoleMapping)

Example 22 with LocalRole

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(), ","));
    }
}
Also used : ArrayList(java.util.ArrayList) RoleMapping(org.wso2.carbon.identity.application.common.model.RoleMapping) PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig) LocalRole(org.wso2.carbon.identity.application.common.model.LocalRole)

Aggregations

RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)17 LocalRole (org.wso2.carbon.identity.application.common.model.LocalRole)15 PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)10 Claim (org.wso2.carbon.identity.application.common.model.Claim)8 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)8 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)8 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)7 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)7 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)7 ArrayList (java.util.ArrayList)6 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)6 Property (org.wso2.carbon.identity.application.common.model.Property)6 DataProvider (org.testng.annotations.DataProvider)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 Test (org.testng.annotations.Test)2 LocalRole (org.wso2.carbon.identity.application.common.model.idp.xsd.LocalRole)2