Java Code Examples for org.wso2.carbon.user.core.UserRealm#getClaimManager()

The following examples show how to use org.wso2.carbon.user.core.UserRealm#getClaimManager() . 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: IdentityClaimManager.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Returns all supported claims.
 *
 * @param realm user realm
 * @return array of all supported claims
 * @throws IdentityException if error occurs while building supported claims
 */
public Claim[] getAllSupportedClaims(UserRealm realm) throws IdentityException {
    try {
        ClaimManager claimAdmin = realm.getClaimManager();
        ClaimMapping[] mappings = claimAdmin.getAllSupportClaimMappingsByDefault();
        Claim[] claims = new Claim[0];
        if (mappings != null) {
            claims = new Claim[mappings.length];
            for (int i = 0; i < mappings.length; i++) {
                claims[i] = (Claim) mappings[i].getClaim();
            }
        }
        return claims;
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        log.error("Error occurred while loading supported claims", e);
        getException("Error occurred while loading supported claima", e);
    }

    return new Claim[0];
}
 
Example 2
Source File: IdentityClaimManager.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Returns all supported claims.
 *
 * @return
 * @throws IdentityException
 */
public Claim[] getAllSupportedClaims(UserRealm realm) throws IdentityException {
    try {
        ClaimManager claimAdmin = realm.getClaimManager();
        ClaimMapping[] mappings = claimAdmin.getAllSupportClaimMappingsByDefault();
        Claim[] claims = new Claim[0];
        if (mappings != null) {
            claims = new Claim[mappings.length];
            for (int i = 0; i < mappings.length; i++) {
                claims[i] = (Claim) mappings[i].getClaim();
            }
        }
        return claims;
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        log.error("Error occurred while loading supported claims", e);
        getException("Error occurred while loading supported claima", e);
    }

    return new Claim[0];
}
 
Example 3
Source File: DefaultClaimHandler.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private ClaimManager getClaimManager(String tenantDomain, UserRealm realm) throws FrameworkException {
    ClaimManager claimManager = null;
    try {
        claimManager = realm.getClaimManager();
    } catch (UserStoreException e) {
        throw new FrameworkException("Error occurred while retrieving the ClaimManager " +
                                     "from Realm for " + tenantDomain + " to handle local claims", e);
    }
    return claimManager;
}
 
Example 4
Source File: IdentityClaimManager.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Returns all supported claims for the given dialect.
 *
 * @param dialectUri claim dialect URI
 * @param realm user realm
 * @return array of all supported claims
 * @throws IdentityException if error occurs while building supported claims
 */
public Claim[] getAllSupportedClaims(String dialectUri, UserRealm realm)
        throws IdentityException {

    ClaimManager claimAdmin;
    List<Claim> requiredClaims = new ArrayList<>();

    try {

        claimAdmin = realm.getClaimManager();

        ClaimMapping[] mappings = claimAdmin.getAllClaimMappings(dialectUri);

        if (mappings != null) {
            for (int i = 0; i < mappings.length; i++) {
                if (mappings[i].getClaim().isSupportedByDefault()) {
                    requiredClaims.add((Claim) mappings[i].getClaim());
                }
            }
        }
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        log.error("Error occurred while loading supported claims from the dialect "
                + dialectUri, e);
        getException("Error occurred while loading supported claims from the dialect "
                + dialectUri, e);
    }
    return requiredClaims.toArray(new Claim[requiredClaims.size()]);
}
 
Example 5
Source File: DefaultClaimHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private ClaimManager getClaimManager(String tenantDomain, UserRealm realm) throws FrameworkException {
    ClaimManager claimManager = null;
    try {
        claimManager = realm.getClaimManager();
    } catch (UserStoreException e) {
        throw new FrameworkException("Error occurred while retrieving the ClaimManager " +
                                     "from Realm for " + tenantDomain + " to handle local claims", e);
    }
    return claimManager;
}
 
Example 6
Source File: IdentityClaimManager.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Returns all supported claims for the given dialect.
 *
 * @return
 * @throws IdentityException
 */
public Claim[] getAllSupportedClaims(String dialectUri, UserRealm realm)
        throws IdentityException {
    Claim[] claims = new Claim[0];
    ClaimManager claimAdmin;
    ArrayList<Claim> requiredClaims = null;

    try {

        claimAdmin = realm.getClaimManager();
        requiredClaims = new ArrayList<Claim>();

        ClaimMapping[] mappings = claimAdmin.getAllClaimMappings(dialectUri);
        ;

        if (mappings != null) {
            claims = new Claim[mappings.length];
            for (int i = 0; i < mappings.length; i++) {
                if (mappings[i].getClaim().isSupportedByDefault()) {
                    requiredClaims.add((Claim) mappings[i].getClaim());
                }
            }
        }

        return requiredClaims.toArray(new Claim[requiredClaims.size()]);
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        log.error("Error occurred while loading supported claims from the dialect "
                + dialectUri, e);
        getException("Error occurred while loading supported claims from the dialect "
                + dialectUri, e);
    }
    return claims;
}
 
Example 7
Source File: ClaimManagerService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private ClaimManager getClaimManager() throws UserStoreException {
    try {
        UserRealm realm = super.getUserRealm();
        if (realm == null) {
            throw new UserStoreException(NULL_REALM_MESSAGE);
        }
        return realm.getClaimManager();
    } catch (Exception e) {
        throw new UserStoreException(e);
    }
}