Search in sources :

Example 36 with FederatedAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.

the class IdentityProviderMgtServiceTestCase method testUpdateResidentIdP.

@Test(priority = 21, groups = "wso2.is", description = "test updateResidentIdP operation")
public void testUpdateResidentIdP() throws Exception {
    String samlEntityId = "samlssoIdp";
    String residentIdpRealm = "testHomeRealm";
    IdentityProvider residentProvider = idpMgtServiceClient.getResidentIdP();
    // get default value
    residentIdpEnable = residentProvider.getEnable();
    residentIdpPrimary = residentProvider.getPrimary();
    residentIdpName = residentProvider.getIdentityProviderName();
    residentIDPDefaultRealm = residentProvider.getHomeRealmId();
    idpProperties = residentProvider.getIdpProperties();
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setEnable(true);
    identityProvider.setPrimary(true);
    identityProvider.setIdentityProviderName("LOCAL");
    identityProvider.setHomeRealmId("testHomeRealm");
    FederatedAuthenticatorConfig samlFedAuthn = new FederatedAuthenticatorConfig();
    samlFedAuthn.setName(SAML2SSO_NAME);
    Property[] properties = new Property[1];
    Property property = new Property();
    property.setName(SAML2SSO_IDP_ENTITY_ID);
    property.setValue(samlEntityId);
    properties[0] = property;
    samlFedAuthn.setProperties(properties);
    FederatedAuthenticatorConfig[] federatedAuthenticators = new FederatedAuthenticatorConfig[1];
    federatedAuthenticators[0] = samlFedAuthn;
    identityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticators);
    idpMgtServiceClient.updateResidentIdP(identityProvider);
    // check changes
    IdentityProvider changedResidentIdp = idpMgtServiceClient.getResidentIdP();
    Assert.assertNotNull(changedResidentIdp, "Resident idp retrieval failed");
    Assert.assertEquals(changedResidentIdp.getHomeRealmId(), residentIdpRealm);
    Assert.assertEquals(changedResidentIdp.getEnable(), true, "Resident idp enable failed");
    Assert.assertEquals(changedResidentIdp.getPrimary(), true, "Resident idp primary failed");
    boolean found = false;
    for (FederatedAuthenticatorConfig fedConfig : changedResidentIdp.getFederatedAuthenticatorConfigs()) {
        if (fedConfig.getName().equals(SAML2SSO_NAME)) {
            for (Property prop : fedConfig.getProperties()) {
                if (prop.getName().equals(SAML2SSO_IDP_ENTITY_ID)) {
                    found = true;
                    Assert.assertEquals(prop.getValue(), samlEntityId, "Updating federated authenticator property failed");
                    break;
                }
            }
            break;
        }
    }
    Assert.assertTrue(found, "Resident idp saml sso properties not found");
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 37 with FederatedAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.

the class ApplicationManagementTestCase method testOutboundAuthenticatorConfiguration.

@Test(alwaysRun = true, description = "Testing update Outbound Authenticator Configuration")
public void testOutboundAuthenticatorConfiguration() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType("federated");
        AuthenticationStep authStep = new AuthenticationStep();
        IdentityProvider idp = new IdentityProvider();
        idp.setIdentityProviderName("fed_idp");
        FederatedAuthenticatorConfig customConfig = new FederatedAuthenticatorConfig();
        customConfig.setName("test_auth");
        customConfig.setEnabled(true);
        idp.setDefaultAuthenticatorConfig(customConfig);
        createIdp(idp);
        authStep.setFederatedIdentityProviders(new IdentityProvider[] { idp });
        serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
        serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSubjectClaimUri("subject_claim_uri");
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps()[0].getFederatedIdentityProviders()[0].getIdentityProviderName(), "fed_idp", "Failed update Authentication step");
        Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getSubjectClaimUri(), "subject_claim_uri", "Failed update subject claim uri");
    } catch (Exception e) {
        Assert.fail("Error while trying to update Outbound Authenticator Configuration", e);
    }
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 38 with FederatedAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.

the class ApplicationManagementTestCase method createIdp.

private void createIdp(IdentityProvider idp) throws Exception {
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    IdentityProviderMgtServiceClient identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL, configContext);
    org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider identityProvider = new org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider();
    identityProvider.setIdentityProviderName(idp.getIdentityProviderName());
    org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig federatedAuthenticatorConfig = new org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig();
    federatedAuthenticatorConfig.setName(idp.getDefaultAuthenticatorConfig().getName());
    federatedAuthenticatorConfig.setEnabled(idp.getDefaultAuthenticatorConfig().getEnabled());
    identityProvider.setFederatedAuthenticatorConfigs(new org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig[] { federatedAuthenticatorConfig });
    identityProvider.setDefaultAuthenticatorConfig(federatedAuthenticatorConfig);
    identityProviderMgtServiceClient.addIdP(identityProvider);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) org.wso2.carbon.identity.application.common.model.xsd(org.wso2.carbon.identity.application.common.model.xsd) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)

Example 39 with FederatedAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.

the class SelfSignUpConsentTest method updateResidentIDP.

private void updateResidentIDP(IdentityProvider residentIdentityProvider, boolean isSuperTenant) throws Exception {
    FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = residentIdentityProvider.getFederatedAuthenticatorConfigs();
    for (FederatedAuthenticatorConfig authenticatorConfig : federatedAuthenticatorConfigs) {
        if (!authenticatorConfig.getName().equalsIgnoreCase("samlsso")) {
            federatedAuthenticatorConfigs = (FederatedAuthenticatorConfig[]) ArrayUtils.removeElement(federatedAuthenticatorConfigs, authenticatorConfig);
        }
    }
    residentIdentityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticatorConfigs);
    if (isSuperTenant) {
        superTenantIDPMgtClient.updateResidentIdP(residentIdentityProvider);
    } else {
        tenantIDPMgtClient.updateResidentIdP(residentIdentityProvider);
    }
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig)

Example 40 with FederatedAuthenticatorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.

the class EmailOTPTestCase method getEmailOTPIdP.

/**
 * This method is to create and get the email otp identity provider.
 *
 * @return Identity provider.
 * @throws Exception Error when adding Identity Provider information.
 */
private IdentityProvider getEmailOTPIdP() throws Exception {
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setIdentityProviderName(IDENTITY_PROVIDER_NAME);
    identityProvider.setAlias(IDENTITY_PROVIDER_ALIAS);
    identityProvider.setEnable(true);
    FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig();
    federatedAuthenticatorConfig.setName(AUTHENTICATOR_NAME);
    federatedAuthenticatorConfig.setEnabled(true);
    identityProvider.setDefaultAuthenticatorConfig(federatedAuthenticatorConfig);
    identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { federatedAuthenticatorConfig });
    createIdP(identityProvider);
    return identityProvider;
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider)

Aggregations

FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)60 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)36 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig)29 Property (org.wso2.carbon.identity.application.common.model.Property)28 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)25 ArrayList (java.util.ArrayList)21 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)17 IdentityProvider (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider)16 Test (org.testng.annotations.Test)14 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)14 HashMap (java.util.HashMap)12 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)11 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)10 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)10 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)9 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)8 LocalRole (org.wso2.carbon.identity.application.common.model.LocalRole)8 PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)8 Map (java.util.Map)7 DataProvider (org.testng.annotations.DataProvider)7