Search in sources :

Example 36 with IdentityProvider

use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-apimgt by wso2.

the class APIAdminImpl method updateClaims.

private void updateClaims(IdentityProvider idp, Object claims) {
    if (claims != null) {
        ClaimConfig claimConfig = new ClaimConfig();
        List<ClaimMapping> claimMappings = new ArrayList<>();
        List<org.wso2.carbon.identity.application.common.model.Claim> idpClaims = new ArrayList<>();
        JsonArray claimArray = (JsonArray) claims;
        claimConfig.setLocalClaimDialect(false);
        for (JsonElement claimMappingEntry : claimArray) {
            if (claimMappingEntry instanceof JsonObject) {
                JsonElement idpClaimUri = ((JsonObject) claimMappingEntry).get("remoteClaim");
                JsonElement localClaimUri = ((JsonObject) claimMappingEntry).get("localClaim");
                ClaimMapping internalMapping = new ClaimMapping();
                org.wso2.carbon.identity.application.common.model.Claim remoteClaim = new org.wso2.carbon.identity.application.common.model.Claim();
                remoteClaim.setClaimUri(idpClaimUri.getAsString());
                org.wso2.carbon.identity.application.common.model.Claim localClaim = new org.wso2.carbon.identity.application.common.model.Claim();
                localClaim.setClaimUri(localClaimUri.getAsString());
                internalMapping.setRemoteClaim(remoteClaim);
                internalMapping.setLocalClaim(localClaim);
                claimMappings.add(internalMapping);
                idpClaims.add(remoteClaim);
            }
        }
        claimConfig.setClaimMappings(claimMappings.toArray(new ClaimMapping[0]));
        claimConfig.setIdpClaims(idpClaims.toArray(new org.wso2.carbon.identity.application.common.model.Claim[0]));
        idp.setClaimConfig(claimConfig);
    }
}
Also used : ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) JsonArray(com.google.gson.JsonArray) ClaimMapping(org.wso2.carbon.identity.application.common.model.ClaimMapping) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) JsonElement(com.google.gson.JsonElement)

Example 37 with IdentityProvider

use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.

the class FileBasedConfigurationBuilder method processIdPConfigElement.

private ExternalIdPConfig processIdPConfigElement(OMElement idpConfigElem) {
    OMAttribute nameAttr = idpConfigElem.getAttribute(new QName("name"));
    // if the name is not given, do not register this config
    if (nameAttr == null) {
        log.warn("Each IDP configuration should have a unique name attribute");
        return null;
    }
    // read the config parameters
    Map<String, String> parameterMap = new HashMap<>();
    for (Iterator paramIterator = idpConfigElem.getChildrenWithLocalName("Parameter"); paramIterator.hasNext(); ) {
        OMElement paramElem = (OMElement) paramIterator.next();
        OMAttribute paramNameAttr = paramElem.getAttribute(new QName("name"));
        if (paramNameAttr == null) {
            log.warn("A Parameter should have a name attribute. Skipping the parameter.");
            continue;
        }
        parameterMap.put(paramNameAttr.getAttributeValue(), paramElem.getText());
    }
    IdentityProvider fedIdp = new IdentityProvider();
    fedIdp.setIdentityProviderName(nameAttr.getAttributeValue());
    ExternalIdPConfig externalIdPConfig = new ExternalIdPConfig(fedIdp);
    externalIdPConfig.setParameterMap(parameterMap);
    return externalIdPConfig;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) OMElement(org.apache.axiom.om.OMElement) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) ExternalIdPConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ExternalIdPConfig) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 38 with IdentityProvider

use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.

the class UIBasedConfigurationLoader method loadLocalAuthenticators.

protected void loadLocalAuthenticators(AuthenticationStep authenticationStep, StepConfig stepConfig) {
    LocalAuthenticatorConfig[] localAuthenticators = authenticationStep.getLocalAuthenticatorConfigs();
    if (localAuthenticators != null) {
        IdentityProvider localIdp = new IdentityProvider();
        localIdp.setIdentityProviderName(FrameworkConstants.LOCAL_IDP_NAME);
        // assign it to the step
        for (LocalAuthenticatorConfig localAuthenticator : localAuthenticators) {
            String actualAuthenticatorName = localAuthenticator.getName();
            loadStepAuthenticator(stepConfig, localIdp, actualAuthenticatorName);
        }
    }
}
Also used : LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider)

Example 39 with IdentityProvider

use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.

the class UIBasedConfigurationLoader method loadFederatedAuthenticators.

protected void loadFederatedAuthenticators(AuthenticationStep authenticationStep, StepConfig stepConfig, String tenantDomain) throws FrameworkException {
    IdentityProvider[] federatedIDPs = authenticationStep.getFederatedIdentityProviders();
    if (federatedIDPs != null) {
        // for each idp in the step
        for (IdentityProvider federatedIDP : federatedIDPs) {
            FederatedAuthenticatorConfig federatedAuthenticator = federatedIDP.getDefaultAuthenticatorConfig();
            // retrieve the federated IDP and load
            if (federatedAuthenticator == null) {
                try {
                    federatedAuthenticator = IdentityProviderManager.getInstance().getIdPByName(federatedIDP.getIdentityProviderName(), tenantDomain).getDefaultAuthenticatorConfig();
                } catch (IdentityProviderManagementException e) {
                    throw new FrameworkException("Failed to load the default authenticator for IDP : " + federatedIDP.getIdentityProviderName(), e);
                }
            }
            String actualAuthenticatorName = federatedAuthenticator.getName();
            // assign it to the step
            loadStepAuthenticator(stepConfig, federatedIDP, actualAuthenticatorName);
        }
    }
}
Also used : FrameworkException(org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 40 with IdentityProvider

use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.

the class ConfigurationFacade method getIdPConfigByName.

public ExternalIdPConfig getIdPConfigByName(String idpName, String tenantDomain) throws IdentityProviderManagementException {
    ExternalIdPConfig externalIdPConfig = null;
    IdentityProvider idpDO = null;
    if (log.isDebugEnabled()) {
        log.debug("Trying to find the IdP for name: " + idpName);
    }
    try {
        IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
        idpDO = idpManager.getEnabledIdPByName(idpName, tenantDomain);
        if (idpDO != null) {
            if (log.isDebugEnabled()) {
                log.debug("A registered IdP was found");
            }
            externalIdPConfig = new ExternalIdPConfig(idpDO);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("A registered IdP was not found the given name");
            }
        }
    } catch (IdentityProviderManagementException e) {
        throw new IdentityProviderManagementException("Exception while getting IdP by name", e);
    }
    return externalIdPConfig;
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) ExternalIdPConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ExternalIdPConfig) IdentityProviderManager(org.wso2.carbon.idp.mgt.IdentityProviderManager) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Aggregations

IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)190 Test (org.testng.annotations.Test)103 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)65 ArrayList (java.util.ArrayList)64 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)54 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)53 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)47 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)47 API (org.wso2.carbon.apimgt.core.models.API)43 IdentityProvider (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider)37 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)35 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)34 Property (org.wso2.carbon.identity.application.common.model.Property)29 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig)29 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)27 Connection (java.sql.Connection)25 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)22 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)22 HashMap (java.util.HashMap)20 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)20