Search in sources :

Example 1 with RoleConfig

use of org.wso2.carbon.identity.api.server.application.management.v1.RoleConfig in project identity-api-server by wso2.

the class ServerIdpManagementService method createRoleResponse.

private Roles createRoleResponse(IdentityProvider identityProvider) {
    PermissionsAndRoleConfig permissionsAndRoleConfig = identityProvider.getPermissionAndRoleConfig();
    Roles roleConfig = new Roles();
    List<org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping> apiRoleMappings = new ArrayList<>();
    if (permissionsAndRoleConfig != null) {
        if (permissionsAndRoleConfig.getRoleMappings() != null) {
            for (RoleMapping roleMapping : permissionsAndRoleConfig.getRoleMappings()) {
                org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping apiRoleMapping = new org.wso2.carbon.identity.api.server.idp.v1.model.RoleMapping();
                apiRoleMapping.setIdpRole(roleMapping.getRemoteRole());
                apiRoleMapping.setLocalRole(IdentityUtil.addDomainToName(roleMapping.getLocalRole().getLocalRoleName(), roleMapping.getLocalRole().getUserStoreId()));
                apiRoleMappings.add(apiRoleMapping);
            }
        }
    }
    roleConfig.setMappings(apiRoleMappings);
    String provRoles = identityProvider.getProvisioningRole();
    if (StringUtils.isNotBlank(provRoles)) {
        roleConfig.setOutboundProvisioningRoles(Arrays.asList(provRoles.split(",")));
    }
    return roleConfig;
}
Also used : ArrayList(java.util.ArrayList) Roles(org.wso2.carbon.identity.api.server.idp.v1.model.Roles) RoleMapping(org.wso2.carbon.identity.application.common.model.RoleMapping) PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)

Example 2 with RoleConfig

use of org.wso2.carbon.identity.api.server.application.management.v1.RoleConfig 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 3 with RoleConfig

use of org.wso2.carbon.identity.api.server.application.management.v1.RoleConfig in project identity-api-server by wso2.

the class UpdateClaimConfiguration method updateRoleClaimConfigs.

private void updateRoleClaimConfigs(RoleConfig roleApiModel, ServiceProvider application) {
    if (roleApiModel != null) {
        ClaimConfig claimConfig = getClaimConfig(application);
        if (roleApiModel.getClaim() != null) {
            claimConfig.setRoleClaimURI(roleApiModel.getClaim().getUri());
        }
        PermissionsAndRoleConfig permissionAndRoleConfig = getPermissionAndRoleConfig(application);
        permissionAndRoleConfig.setRoleMappings(getRoleMappings(roleApiModel));
        LocalAndOutboundAuthenticationConfig localAndOutboundConfig = getLocalAndOutboundConfig(application);
        setIfNotNull(roleApiModel.getIncludeUserDomain(), localAndOutboundConfig::setUseUserstoreDomainInRoles);
    }
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)

Aggregations

PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)2 RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)2 ArrayList (java.util.ArrayList)1 RoleConfig (org.wso2.carbon.identity.api.server.application.management.v1.RoleConfig)1 Roles (org.wso2.carbon.identity.api.server.idp.v1.model.Roles)1 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)1 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)1