Search in sources :

Example 6 with FileBasedIdPMgtDAO

use of org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO in project carbon-identity-framework by wso2.

the class IdentityProviderManager method getIdPByAuthenticatorPropertyValue.

/**
 * @param property      IDP authenticator property (E.g.: IdPEntityId)
 * @param value         Value associated with given Property
 * @param tenantDomain
 * @param authenticator
 * @return <code>IdentityProvider</code> Identity Provider information
 * @throws IdentityProviderManagementException Error when getting Identity Provider
 *                                             information by authenticator property value
 */
public IdentityProvider getIdPByAuthenticatorPropertyValue(String property, String value, String tenantDomain, String authenticator, boolean ignoreFileBasedIdps) throws IdentityProviderManagementException {
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    if (StringUtils.isEmpty(property) || StringUtils.isEmpty(value) || StringUtils.isEmpty(authenticator)) {
        String msg = "Invalid argument: Authenticator property, property value or authenticator name is empty";
        throw new IdentityProviderManagementException(msg);
    }
    IdentityProvider identityProvider = dao.getIdPByAuthenticatorPropertyValue(null, property, value, authenticator, tenantId, tenantDomain);
    if (identityProvider == null && !ignoreFileBasedIdps) {
        identityProvider = new FileBasedIdPMgtDAO().getIdPByAuthenticatorPropertyValue(property, value, tenantDomain, authenticator);
    }
    return identityProvider;
}
Also used : FileBasedIdPMgtDAO(org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider)

Example 7 with FileBasedIdPMgtDAO

use of org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO in project carbon-identity-framework by wso2.

the class IdentityProviderManager method getIdPByRealmId.

/**
 * Retrieves Identity provider information about a given tenant by realm identifier
 *
 * @param realmId      Unique realm identifier of the Identity provider of whose information is
 *                     requested
 * @param tenantDomain Tenant domain whose information is requested
 * @throws IdentityProviderManagementException Error when getting Identity Provider
 *                                             information by IdP home realm identifier
 */
@Override
public IdentityProvider getIdPByRealmId(String realmId, String tenantDomain) throws IdentityProviderManagementException {
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    if (StringUtils.isEmpty(realmId)) {
        String msg = "Invalid argument: Identity Provider Home Realm Identifier value is empty";
        throw new IdentityProviderManagementException(msg);
    }
    IdentityProvider identityProvider = dao.getIdPByRealmId(realmId, tenantId, tenantDomain);
    if (identityProvider == null) {
        identityProvider = new FileBasedIdPMgtDAO().getIdPByRealmId(realmId, tenantDomain);
    }
    return identityProvider;
}
Also used : FileBasedIdPMgtDAO(org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider)

Example 8 with FileBasedIdPMgtDAO

use of org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO in project carbon-identity-framework by wso2.

the class IdentityProviderManager method getMappedIdPClaims.

/**
 * Retrieves Identity provider information about a given tenant
 *
 * @param idPName        Unique Name of the IdP to which the given local claim URIs need to be mapped
 * @param tenantDomain   The tenant domain of whose local claim URIs to be mapped
 * @param localClaimURIs Local claim URIs which need to be mapped to IdP's claim URIs
 * @throws IdentityProviderManagementException Error when getting claim mappings
 */
@Override
public Set<ClaimMapping> getMappedIdPClaims(String idPName, String tenantDomain, List<String> localClaimURIs) throws IdentityProviderManagementException {
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    if (StringUtils.isEmpty(idPName)) {
        String msg = "Invalid argument: Identity Provider Name value is empty";
        throw new IdentityProviderManagementException(msg);
    }
    IdentityProvider identityProvider = dao.getIdPByName(null, idPName, tenantId, tenantDomain);
    if (identityProvider == null) {
        identityProvider = new FileBasedIdPMgtDAO().getIdPByName(idPName, tenantDomain);
    }
    if (identityProvider == null) {
        identityProvider = IdPManagementServiceComponent.getFileBasedIdPs().get(IdentityApplicationConstants.DEFAULT_IDP_CONFIG);
    }
    ClaimConfig claimConfiguration = identityProvider.getClaimConfig();
    if (claimConfiguration != null) {
        ClaimMapping[] claimMappings = claimConfiguration.getClaimMappings();
        if (claimMappings != null && claimMappings.length > 0 && localClaimURIs != null) {
            Set<ClaimMapping> returnSet = new HashSet<ClaimMapping>();
            for (String localClaimURI : localClaimURIs) {
                for (ClaimMapping claimMapping : claimMappings) {
                    if (claimMapping.getLocalClaim().getClaimUri().equals(localClaimURI)) {
                        returnSet.add(claimMapping);
                        break;
                    }
                }
            }
            return returnSet;
        }
    }
    return new HashSet<ClaimMapping>();
}
Also used : FileBasedIdPMgtDAO(org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO) ClaimMapping(org.wso2.carbon.identity.application.common.model.ClaimMapping) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) HashSet(java.util.HashSet)

Aggregations

IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)8 FileBasedIdPMgtDAO (org.wso2.carbon.idp.mgt.dao.FileBasedIdPMgtDAO)8 HashSet (java.util.HashSet)4 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)2 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)2 PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)2 RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)2 LocalRole (org.wso2.carbon.identity.application.common.model.LocalRole)1