Search in sources :

Example 66 with IdentityProvider

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

the class IdPManagementUIUtil method buildGoogleProvisioningConfiguration.

/**
 * @param fedIdp
 * @param paramMap
 * @throws IdentityApplicationManagementException
 */
private static void buildGoogleProvisioningConfiguration(IdentityProvider fedIdp, Map<String, String> paramMap) throws IdentityApplicationManagementException {
    ProvisioningConnectorConfig proConnector = new ProvisioningConnectorConfig();
    proConnector.setName("googleapps");
    Property domainName = null;
    Property emailClaim = null;
    Property givenNameClaim = null;
    Property givenNameDefaultVal = null;
    Property familyNameClaim = null;
    Property familyNameDefault = null;
    Property serviceAccEmail = null;
    Property privateKey = null;
    Property adminEmail = null;
    Property appName = null;
    Property googleProvPatten = null;
    Property googleProvSeparator = null;
    Property uniqueID = null;
    String oldGooglePvtKey = null;
    String newGooglePvtKey = null;
    if (paramMap.get("googleProvEnabled") != null && "on".equals(paramMap.get("googleProvEnabled"))) {
        proConnector.setEnabled(true);
    } else {
        proConnector.setEnabled(false);
    }
    if (paramMap.get("googleProvDefault") != null && "on".equals(paramMap.get("googleProvDefault"))) {
        fedIdp.setDefaultProvisioningConnectorConfig(proConnector);
    }
    if (paramMap.get("google_prov_domain_name") != null) {
        domainName = new Property();
        domainName.setName("google_prov_domain_name");
        domainName.setValue(paramMap.get("google_prov_domain_name"));
    }
    if (paramMap.get("google_prov_email_claim_dropdown") != null) {
        emailClaim = new Property();
        emailClaim.setName("google_prov_email_claim_dropdown");
        emailClaim.setValue(paramMap.get("google_prov_email_claim_dropdown"));
    }
    if (paramMap.get("google_prov_givenname_claim_dropdown") != null) {
        givenNameClaim = new Property();
        givenNameClaim.setName("google_prov_givenname_claim_dropdown");
        givenNameClaim.setValue(paramMap.get("google_prov_givenname_claim_dropdown"));
    }
    if (paramMap.get("google_prov_givenname") != null) {
        givenNameDefaultVal = new Property();
        givenNameDefaultVal.setName("google_prov_givenname");
        givenNameDefaultVal.setValue(paramMap.get("google_prov_givenname"));
    }
    if (paramMap.get("google_prov_familyname_claim_dropdown") != null) {
        familyNameClaim = new Property();
        familyNameClaim.setName("google_prov_familyname_claim_dropdown");
        familyNameClaim.setValue(paramMap.get("google_prov_familyname_claim_dropdown"));
    }
    if (paramMap.get("google_prov_familyname") != null) {
        familyNameDefault = new Property();
        familyNameDefault.setName("google_prov_familyname");
        familyNameDefault.setValue(paramMap.get("google_prov_familyname"));
    }
    if (paramMap.get("google_prov_service_acc_email") != null) {
        serviceAccEmail = new Property();
        serviceAccEmail.setName("google_prov_service_acc_email");
        serviceAccEmail.setValue(paramMap.get("google_prov_service_acc_email"));
    }
    if (paramMap.get("old_google_prov_private_key") != null) {
        oldGooglePvtKey = paramMap.get("old_google_prov_private_key");
    }
    // get the value of the uploaded certificate.
    if (paramMap.get("google_prov_private_key") != null) {
        newGooglePvtKey = paramMap.get("google_prov_private_key");
    }
    if (newGooglePvtKey == null && oldGooglePvtKey != null) {
        newGooglePvtKey = oldGooglePvtKey;
    }
    if (newGooglePvtKey != null) {
        privateKey = new Property();
        privateKey.setName("google_prov_private_key");
        privateKey.setValue(newGooglePvtKey);
        privateKey.setType(IdentityApplicationConstants.ConfigElements.PROPERTY_TYPE_BLOB);
    }
    if (paramMap.get("google_prov_admin_email") != null) {
        adminEmail = new Property();
        adminEmail.setName("google_prov_admin_email");
        adminEmail.setValue(paramMap.get("google_prov_admin_email"));
    }
    if (paramMap.get("google_prov_application_name") != null) {
        appName = new Property();
        appName.setName("google_prov_application_name");
        appName.setValue(paramMap.get("google_prov_application_name"));
    }
    if (paramMap.get("google_prov_pattern") != null) {
        googleProvPatten = new Property();
        googleProvPatten.setName("google_prov_pattern");
        googleProvPatten.setValue(paramMap.get("google_prov_pattern"));
    }
    if (paramMap.get("google_prov_separator") != null) {
        googleProvSeparator = new Property();
        googleProvSeparator.setName("google_prov_separator");
        googleProvSeparator.setValue(paramMap.get("google_prov_separator"));
    }
    if (paramMap.get("google-unique-id") != null) {
        uniqueID = new Property();
        uniqueID.setName("UniqueID");
        uniqueID.setValue(paramMap.get("google-unique-id"));
    }
    Property[] proProperties = new Property[] { appName, adminEmail, privateKey, serviceAccEmail, familyNameDefault, familyNameClaim, givenNameDefaultVal, givenNameClaim, emailClaim, domainName, googleProvPatten, googleProvSeparator, uniqueID };
    proConnector.setProvisioningProperties(proProperties);
    ProvisioningConnectorConfig[] proConnectors = fedIdp.getProvisioningConnectorConfigs();
    if (proConnector.getName() != null) {
        if (proConnectors == null || proConnectors.length == 0) {
            fedIdp.setProvisioningConnectorConfigs(new ProvisioningConnectorConfig[] { proConnector });
        } else {
            fedIdp.setProvisioningConnectorConfigs(concatArrays(new ProvisioningConnectorConfig[] { proConnector }, proConnectors));
        }
    }
}
Also used : Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.ProvisioningConnectorConfig)

Example 67 with IdentityProvider

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

the class IdPManagementUIUtil method buildPassiveSTSAuthenticationConfiguration.

/**
 * @param fedIdp
 * @param paramMap
 * @throws IdentityApplicationManagementException
 */
private static void buildPassiveSTSAuthenticationConfiguration(IdentityProvider fedIdp, Map<String, String> paramMap) throws IdentityApplicationManagementException {
    FederatedAuthenticatorConfig passiveSTSAuthnConfig = new FederatedAuthenticatorConfig();
    passiveSTSAuthnConfig.setName("PassiveSTSAuthenticator");
    passiveSTSAuthnConfig.setDisplayName("passivests");
    if ("on".equals(paramMap.get("passiveSTSEnabled"))) {
        passiveSTSAuthnConfig.setEnabled(true);
    }
    if ("on".equals(paramMap.get("passiveSTSDefault"))) {
        fedIdp.setDefaultAuthenticatorConfig(passiveSTSAuthnConfig);
    }
    Property[] properties = new Property[6];
    Property property = new Property();
    property.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.REALM_ID);
    property.setValue(paramMap.get("passiveSTSRealm"));
    properties[0] = property;
    property = new Property();
    property.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IDENTITY_PROVIDER_URL);
    property.setValue(paramMap.get("passiveSTSUrl"));
    properties[1] = property;
    property = new Property();
    property.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IS_USER_ID_IN_CLAIMS);
    properties[2] = property;
    if ("1".equals(paramMap.get("passive_sts_user_id_location"))) {
        property.setValue("true");
        ;
    } else {
        property.setValue("false");
    }
    property = new Property();
    property.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IS_ENABLE_ASSERTION_SIGNATURE_VALIDATION);
    properties[3] = property;
    if ("on".equals(paramMap.get("isEnablePassiveSTSAssertionSignatureValidation"))) {
        property.setValue("true");
    } else {
        property.setValue("false");
    }
    property = new Property();
    property.setName(IdentityApplicationConstants.Authenticator.PassiveSTS.IS_ENABLE_ASSERTION_AUDIENCE_VALIDATION);
    properties[4] = property;
    if ("on".equals(paramMap.get("isEnablePassiveSTSAssertionAudienceValidation"))) {
        property.setValue("true");
    } else {
        property.setValue("false");
    }
    property = new Property();
    property.setName("commonAuthQueryParams");
    if (paramMap.get("passiveSTSQueryParam") != null && paramMap.get("passiveSTSQueryParam").trim().length() > 0) {
        property.setValue(paramMap.get("passiveSTSQueryParam"));
    }
    properties[5] = property;
    passiveSTSAuthnConfig.setProperties(properties);
    FederatedAuthenticatorConfig[] authenticators = fedIdp.getFederatedAuthenticatorConfigs();
    if (paramMap.get("passiveSTSUrl") != null && !"".equals(paramMap.get("passiveSTSUrl"))) {
        if (authenticators == null || authenticators.length == 0) {
            fedIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { passiveSTSAuthnConfig });
        } else {
            fedIdp.setFederatedAuthenticatorConfigs(concatArrays(new FederatedAuthenticatorConfig[] { passiveSTSAuthnConfig }, authenticators));
        }
    }
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)

Example 68 with IdentityProvider

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

the class IdPManagementUIUtil method buildClaimConfiguration.

/**
 * @param fedIdp
 * @param paramMap
 * @throws IdentityApplicationManagementException
 */
private static void buildClaimConfiguration(IdentityProvider fedIdp, Map<String, String> paramMap, List<String> idpClaims, ClaimMapping[] currentClaimMapping) throws IdentityApplicationManagementException {
    ClaimConfig claimConfiguration = new ClaimConfig();
    if (idpClaims != null && idpClaims.size() > 0) {
        List<Claim> idPClaimList = new ArrayList<Claim>();
        for (Iterator<String> iterator = idpClaims.iterator(); iterator.hasNext(); ) {
            String claimUri = iterator.next();
            Claim idpClaim = new Claim();
            idpClaim.setClaimUri(claimUri);
            idPClaimList.add(idpClaim);
        }
        claimConfiguration.setIdpClaims(idPClaimList.toArray(new Claim[idPClaimList.size()]));
    }
    claimConfiguration.setUserClaimURI(paramMap.get("user_id_claim_dropdown"));
    claimConfiguration.setRoleClaimURI(paramMap.get("role_claim_dropdown"));
    ClaimConfig claimConfigurationUpdated = claimMappingFromUI(claimConfiguration, paramMap);
    fedIdp.setClaimConfig(claimConfigurationUpdated);
}
Also used : ClaimConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.ClaimConfig) ArrayList(java.util.ArrayList) Claim(org.wso2.carbon.identity.application.common.model.idp.xsd.Claim)

Example 69 with IdentityProvider

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

the class CacheBackedIdPMgtDAO method deleteIdPByResourceId.

/**
 * @param resourceId
 * @param tenantId
 * @param tenantDomain
 * @throws IdentityProviderManagementException
 */
public void deleteIdPByResourceId(String resourceId, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
    IdentityProvider identityProvider = this.getIdPByResourceId(resourceId, tenantId, tenantDomain);
    if (identityProvider != null) {
        String idPName = identityProvider.getIdentityProviderName();
        if (idPMgtDAO.isIdpReferredBySP(idPName, tenantId)) {
            String data = "Identity Provider '" + idPName + "' cannot be deleted as it is referred by Service " + "Providers.";
            throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.ERROR_CODE_DELETE_IDP, data);
        }
        idPMgtDAO.deleteIdPByResourceId(resourceId, tenantId, tenantDomain);
        clearIdpCache(idPName, resourceId, tenantId, tenantDomain);
    } else {
        if (log.isDebugEnabled()) {
            log.debug(String.format("IDP with resource ID: %s of tenantDomain:%s is not found is cache or DB", resourceId, tenantDomain));
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider)

Example 70 with IdentityProvider

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

the class CacheBackedIdPMgtDAO method forceDeleteIdP.

public void forceDeleteIdP(String idPName, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Force deleting IDP:%s of tenantDomain:%s started.", idPName, tenantDomain));
    }
    // Remove cache entries related to the force deleted idps.
    IdentityProvider identityProvider = this.getIdPByName(null, idPName, tenantId, tenantDomain);
    if (identityProvider != null) {
        idPMgtDAO.forceDeleteIdP(idPName, tenantId, tenantDomain);
        clearIdpCache(idPName, tenantId, tenantDomain);
    } else {
        if (log.isDebugEnabled()) {
            log.debug(String.format("IDP:%s of tenantDomain:%s is not found is cache or DB", idPName, tenantDomain));
        }
    }
    if (log.isDebugEnabled()) {
        log.debug(String.format("Force deleting IDP:%s of tenantDomain:%s completed.", idPName, tenantDomain));
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider)

Aggregations

IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)191 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