Java Code Examples for org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants#LOCAL_ROLE_CLAIM_URI

The following examples show how to use org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants#LOCAL_ROLE_CLAIM_URI . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultSequenceHandlerUtils.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Used to get the service provider mapped local role claim URI.
 *
 * @param appConfig ApplicationConfig.
 * @return Service Provider mapped role claim URI.
 */
private static String getSPMappedLocalRoleClaimURI(ApplicationConfig appConfig) {

    String spRoleClaimUri = appConfig.getRoleClaim();
    if (StringUtils.isNotBlank(spRoleClaimUri)) {

        Map<String, String> spToLocalClaimMapping = appConfig.getClaimMappings();
        if (MapUtils.isNotEmpty(spToLocalClaimMapping)) {

            for (Map.Entry<String, String> entry : spToLocalClaimMapping.entrySet()) {
                if (spRoleClaimUri.equals(entry.getKey())) {
                    return entry.getValue();
                }
            }
        }
    }
    return FrameworkConstants.LOCAL_ROLE_CLAIM_URI;
}
 
Example 2
Source File: DefaultRequestPathBasedSequenceHandlerTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@DataProvider(name = "spClaimMappingProvider")
public Object[][] getSpClaimMappingProvider() {
    return new Object[][]{
            {       // SP mapped role claim
                    new HashMap<String, String>() {{
                        put("SP_ROLE_CLAIM", FrameworkConstants.LOCAL_ROLE_CLAIM_URI);
                    }},
                    "SP_ROLE_CLAIM"
            },
            {       // Role claim not among SP mapped claims
                    new HashMap<String, String>() {{
                        put("SP_CLAIM", "LOCAL_CLAIM");
                    }},
                    FrameworkConstants.LOCAL_ROLE_CLAIM_URI
            },
            {      // No SP mapped claims
                    new HashMap<>(), FrameworkConstants.LOCAL_ROLE_CLAIM_URI
            },
            {
                    null, FrameworkConstants.LOCAL_ROLE_CLAIM_URI
            }
    };
}
 
Example 3
Source File: DefaultStepBasedSequenceHandlerTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@DataProvider(name = "spClaimMappingProvider")
public Object[][] getSpClaimMappingProvider() {
    return new Object[][]{
            {       // SP mapped role claim
                    new HashMap<String, String>() {{
                        put("SP_ROLE_CLAIM", FrameworkConstants.LOCAL_ROLE_CLAIM_URI);
                    }},
                    "SP_ROLE_CLAIM"
            },
            {       // Role claim not among SP mapped claims
                    new HashMap<String, String>() {{
                        put("SP_CLAIM", "LOCAL_CLAIM");
                    }},
                    FrameworkConstants.LOCAL_ROLE_CLAIM_URI
            },
            {      // No SP mapped claims
                    new HashMap<>(), FrameworkConstants.LOCAL_ROLE_CLAIM_URI
            },
            {
                    null, FrameworkConstants.LOCAL_ROLE_CLAIM_URI
            }
    };
}
 
Example 4
Source File: DefaultRequestPathBasedSequenceHandler.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * @param appConfig
 * @return
 */
protected String getSpRoleClaimUri(ApplicationConfig appConfig) throws FrameworkException {
    // get external identity provider role claim uri.
    String spRoleClaimUri = appConfig.getRoleClaim();

    if (spRoleClaimUri == null) {
        // no role claim uri defined
        // we can still try to find it out - lets have a look at the claim
        // mapping.
        Map<String, String> spToLocalClaimMapping = appConfig.getClaimMappings();

        if (spToLocalClaimMapping != null && !spToLocalClaimMapping.isEmpty()) {

            for (Entry<String, String> entry : spToLocalClaimMapping.entrySet()) {
                if (FrameworkConstants.LOCAL_ROLE_CLAIM_URI.equals(entry.getValue())) {
                    return entry.getKey();
                }
            }
        }
    }

    if (spRoleClaimUri == null) {
        spRoleClaimUri = FrameworkConstants.LOCAL_ROLE_CLAIM_URI;
        if (log.isDebugEnabled()) {
            String serviceProvider = appConfig.getApplicationName();
            log.debug("Service Provider Role Claim URI not configured for SP: " + serviceProvider +
                    ". Defaulting to " + spRoleClaimUri);
        }
    }

    return spRoleClaimUri;
}
 
Example 5
Source File: DefaultSequenceHandlerUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get the standard role claim URI used for the given dialect.
 *
 * @param standardDialect Dialect URI.
 * @param tenantDomain    Tenant domain.
 * @return Matching role claim uri of the given dialect.
 * @throws FrameworkException
 */
private static String getStandardRoleClaimURI(String standardDialect, String tenantDomain)
        throws FrameworkException {

    String roleClaim = getStandardClaimURIFromLocal(standardDialect, tenantDomain, FrameworkConstants
            .LOCAL_ROLE_CLAIM_URI);
    if (StringUtils.isBlank(roleClaim)) {
        return FrameworkConstants.LOCAL_ROLE_CLAIM_URI;
    }
    return roleClaim;
}
 
Example 6
Source File: DefaultSequenceHandlerUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get the role claim URI of the service provider form application config.
 *
 * @param appConfig ApplicationConfig.
 * @return Role claim URI of the service provider.
 */
public static String getSpRoleClaimUri(ApplicationConfig appConfig) {

    // Get external identity provider role claim uri.
    String spRoleClaimUri = appConfig.getRoleClaim();

    if (StringUtils.isEmpty(spRoleClaimUri)) {
        // No role claim uri defined
        // we can still try to find it out - lets have a look at the claim
        // mapping.
        Map<String, String> spToLocalClaimMapping = appConfig.getClaimMappings();

        if (MapUtils.isNotEmpty(spToLocalClaimMapping)) {
            for (Map.Entry<String, String> entry : spToLocalClaimMapping.entrySet()) {
                if (FrameworkConstants.LOCAL_ROLE_CLAIM_URI.equals(entry.getValue())) {
                    spRoleClaimUri = entry.getKey();
                    break;
                }
            }
        }
    }

    if (StringUtils.isEmpty(spRoleClaimUri)) {
        spRoleClaimUri = FrameworkConstants.LOCAL_ROLE_CLAIM_URI;
        if (log.isDebugEnabled()) {
            String serviceProvider = appConfig.getApplicationName();
            log.debug("Service Provider Role Claim URI not configured for SP: " + serviceProvider +
                    ". Defaulting to " + spRoleClaimUri);
        }
    }

    return spRoleClaimUri;
}
 
Example 7
Source File: DefaultRequestPathBasedSequenceHandlerTest.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@DataProvider(name = "spRoleClaimUriProvider")
private Object[][] getSpRoleClaimUriData() {
    return new Object[][]{
            {"SP_ROLE_CLAIM", "SP_ROLE_CLAIM"},
            {null, FrameworkConstants.LOCAL_ROLE_CLAIM_URI}
    };
}
 
Example 8
Source File: DefaultStepBasedSequenceHandlerTest.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@DataProvider(name = "spRoleClaimUriProvider")
private Object[][] getSpRoleClaimUriData() {
    return new Object[][]{
            {"SP_ROLE_CLAIM", "SP_ROLE_CLAIM"},
            {null, FrameworkConstants.LOCAL_ROLE_CLAIM_URI},
            {"", FrameworkConstants.LOCAL_ROLE_CLAIM_URI}
    };
}
 
Example 9
Source File: DefaultRequestPathBasedSequenceHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param appConfig
 * @return
 */
protected String getSpRoleClaimUri(ApplicationConfig appConfig) throws FrameworkException {
    // get external identity provider role claim uri.
    String spRoleClaimUri = appConfig.getRoleClaim();

    if (spRoleClaimUri == null) {
        // no role claim uri defined
        // we can still try to find it out - lets have a look at the claim
        // mapping.
        Map<String, String> spToLocalClaimMapping = appConfig.getClaimMappings();

        if (spToLocalClaimMapping != null && !spToLocalClaimMapping.isEmpty()) {

            for (Entry<String, String> entry : spToLocalClaimMapping.entrySet()) {
                if (FrameworkConstants.LOCAL_ROLE_CLAIM_URI.equals(entry.getValue())) {
                    return entry.getKey();
                }
            }
        }
    }

    if (spRoleClaimUri == null) {
        return FrameworkConstants.LOCAL_ROLE_CLAIM_URI;
    }

    return null;
}