Search in sources :

Example 21 with ProvisioningConnectorConfig

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

the class ProvisioningConnectorConfigTest method shouldGenerateDifferentHashCodesForDifferentNames.

@Test
public void shouldGenerateDifferentHashCodesForDifferentNames() {
    ProvisioningConnectorConfig config1 = new ProvisioningConnectorConfig();
    config1.setName("Name1");
    config1.setProvisioningProperties(new Property[0]);
    ProvisioningConnectorConfig config2 = new ProvisioningConnectorConfig();
    config2.setName("Name2");
    config2.setProvisioningProperties(new Property[0]);
    assertNotEquals(config1.hashCode(), config2.hashCode());
}
Also used : ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) Test(org.testng.annotations.Test)

Example 22 with ProvisioningConnectorConfig

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

the class ProvisioningConnectorConfigTest method shouldReturnFalseByEqualsForDifferentNames.

@Test
public void shouldReturnFalseByEqualsForDifferentNames() {
    ProvisioningConnectorConfig config1 = new ProvisioningConnectorConfig();
    config1.setName("Name1");
    config1.setProvisioningProperties(new Property[0]);
    ProvisioningConnectorConfig config2 = new ProvisioningConnectorConfig();
    config2.setName("Name2");
    config2.setProvisioningProperties(new Property[0]);
    assertFalse(config1.equals(config2));
}
Also used : ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) Test(org.testng.annotations.Test)

Example 23 with ProvisioningConnectorConfig

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

the class ApplicationBean method updateLocalSp.

/**
 * @param request
 */
public void updateLocalSp(HttpServletRequest request) {
    // update basic info.
    serviceProvider.setApplicationName(request.getParameter("spName"));
    serviceProvider.setDescription(request.getParameter("sp-description"));
    String provisioningUserStore = request.getParameter("scim-inbound-userstore");
    InboundProvisioningConfig inBoundProConfig = new InboundProvisioningConfig();
    inBoundProConfig.setProvisioningUserStore(provisioningUserStore);
    inBoundProConfig.setDumbMode(Boolean.parseBoolean(request.getParameter(DUMB)));
    serviceProvider.setInboundProvisioningConfig(inBoundProConfig);
    String[] provisioningProviders = request.getParameterValues("provisioning_idp");
    List<IdentityProvider> provisioningIdps = new ArrayList<IdentityProvider>();
    if (serviceProvider.getOutboundProvisioningConfig() == null || provisioningProviders == null || provisioningProviders.length == 0) {
        serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
    }
    if (provisioningProviders != null && provisioningProviders.length > 0) {
        for (String proProvider : provisioningProviders) {
            String connector = request.getParameter("provisioning_con_idp_" + proProvider);
            String jitEnabled = request.getParameter("provisioning_jit_" + proProvider);
            String blocking = request.getParameter("blocking_prov_" + proProvider);
            String rulesEnabled = request.getParameter("rules_enabled_" + proProvider);
            JustInTimeProvisioningConfig jitpro = new JustInTimeProvisioningConfig();
            if ("on".equals(jitEnabled)) {
                jitpro.setProvisioningEnabled(true);
            }
            if (connector != null) {
                IdentityProvider proIdp = new IdentityProvider();
                proIdp.setIdentityProviderName(proProvider);
                ProvisioningConnectorConfig proCon = new ProvisioningConnectorConfig();
                if ("on".equals(blocking)) {
                    proCon.setBlocking(true);
                }
                if ("on".equals(rulesEnabled)) {
                    proCon.setRulesEnabled(true);
                }
                proCon.setName(connector);
                proIdp.setJustInTimeProvisioningConfig(jitpro);
                proIdp.setDefaultProvisioningConnectorConfig(proCon);
                provisioningIdps.add(proIdp);
            }
        }
        if (CollectionUtils.isNotEmpty(provisioningIdps)) {
            OutboundProvisioningConfig outboundProConfig = new OutboundProvisioningConfig();
            outboundProConfig.setProvisioningIdentityProviders(provisioningIdps.toArray(new IdentityProvider[provisioningIdps.size()]));
            serviceProvider.setOutboundProvisioningConfig(outboundProConfig);
        }
    }
}
Also used : InboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundProvisioningConfig) JustInTimeProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.JustInTimeProvisioningConfig) ArrayList(java.util.ArrayList) IdentityProvider(org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig)

Example 24 with ProvisioningConnectorConfig

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

the class ApplicationManagementServiceImplTest method addApplicationConfigurations.

private void addApplicationConfigurations(ServiceProvider serviceProvider) {
    serviceProvider.setDescription("Created for testing");
    serviceProvider.setSaasApp(TRUE);
    // Inbound Authentication Configurations.
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    InboundAuthenticationRequestConfig authRequestConfig = new InboundAuthenticationRequestConfig();
    authRequestConfig.setInboundAuthKey("auth key");
    authRequestConfig.setInboundAuthType("oauth2");
    InboundAuthenticationRequestConfig[] authRequests = new InboundAuthenticationRequestConfig[] { authRequestConfig };
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(authRequests);
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    // Inbound Provisioning Configurations.
    InboundProvisioningConfig provisioningConfig = new InboundProvisioningConfig();
    provisioningConfig.setProvisioningUserStore("UserStore");
    serviceProvider.setInboundProvisioningConfig(provisioningConfig);
    // OutBound Provisioning Configurations.
    IdentityProvider provisioningIdP = new IdentityProvider();
    provisioningIdP.setIdentityProviderName("Provisioning IdP");
    OutboundProvisioningConfig outboundProvisioningConfig = new OutboundProvisioningConfig();
    outboundProvisioningConfig.setProvisioningIdentityProviders(new IdentityProvider[] { provisioningIdP });
    ProvisioningConnectorConfig provisioningConnectorConfig = new ProvisioningConnectorConfig();
    provisioningConnectorConfig.setName("Provisioning connector");
    provisioningIdP.setDefaultProvisioningConnectorConfig(provisioningConnectorConfig);
    serviceProvider.setOutboundProvisioningConfig(outboundProvisioningConfig);
    // Local And OutBound Authentication Configuration.
    LocalAndOutboundAuthenticationConfig authenticationConfig = new LocalAndOutboundAuthenticationConfig();
    AuthenticationStep authenticationStep = new AuthenticationStep();
    IdentityProvider identityProvider = new IdentityProvider();
    identityProvider.setIdentityProviderName(IDP_NAME_1);
    FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig();
    federatedAuthenticatorConfig.setName("Federated authenticator");
    identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { federatedAuthenticatorConfig });
    authenticationStep.setFederatedIdentityProviders(new IdentityProvider[] { identityProvider });
    LocalAuthenticatorConfig localAuthenticatorConfig = new LocalAuthenticatorConfig();
    localAuthenticatorConfig.setName("Local authenticator");
    authenticationStep.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[] { localAuthenticatorConfig });
    authenticationConfig.setAuthenticationSteps(new AuthenticationStep[] { authenticationStep });
    serviceProvider.setLocalAndOutBoundAuthenticationConfig(authenticationConfig);
    // Request Path Authenticator Configuration.
    RequestPathAuthenticatorConfig requestPathAuthenticatorConfig = new RequestPathAuthenticatorConfig();
    requestPathAuthenticatorConfig.setName("Request path authenticator");
    serviceProvider.setRequestPathAuthenticatorConfigs(new RequestPathAuthenticatorConfig[] { requestPathAuthenticatorConfig });
    // Claim Configurations.
    ClaimConfig claimConfig = new ClaimConfig();
    claimConfig.setRoleClaimURI("Role claim uri");
    claimConfig.setSpClaimDialects(new String[] { "SP claim dialect" });
    ClaimMapping claimMapping = new ClaimMapping();
    Claim localClaim = new Claim();
    localClaim.setClaimUri("Local claim uri");
    Claim remoteClaim = new Claim();
    remoteClaim.setClaimUri("Remote claim uri");
    claimMapping.setLocalClaim(localClaim);
    claimMapping.setRemoteClaim(remoteClaim);
    claimConfig.setClaimMappings(new ClaimMapping[] { claimMapping });
    serviceProvider.setClaimConfig(claimConfig);
    // Permission Role Configurations.
    PermissionsAndRoleConfig permissionsAndRoleConfig = new PermissionsAndRoleConfig();
    RoleMapping roleMapping = new RoleMapping();
    LocalRole localRole = new LocalRole("Local role");
    roleMapping.setLocalRole(localRole);
    roleMapping.setRemoteRole("Remote role");
    RoleMapping[] roleMappings = new RoleMapping[] { roleMapping };
    permissionsAndRoleConfig.setRoleMappings(roleMappings);
}
Also used : InboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.InboundProvisioningConfig) InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.AuthenticationStep) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) RoleMapping(org.wso2.carbon.identity.application.common.model.RoleMapping) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig) ClaimMapping(org.wso2.carbon.identity.application.common.model.ClaimMapping) LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) PermissionsAndRoleConfig(org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig) RequestPathAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig) LocalRole(org.wso2.carbon.identity.application.common.model.LocalRole) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) Claim(org.wso2.carbon.identity.application.common.model.Claim)

Example 25 with ProvisioningConnectorConfig

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

the class IdentityProviderMgtServiceTestCase method testAddIdp.

@Test(priority = 2, groups = "wso2.is", description = "Test addIdp operation")
public void testAddIdp() throws Exception {
    String testIdpDescription = "This is test identity provider";
    String testIdpRealmId = "localhost";
    String testFedAuthDispName = "openid";
    String testFedAuthPropName = "OpenIdUrl";
    String testFedAuthPropValue = "https://testDomain:9853/openid";
    String testFedAuthPropName2 = "IsUserIdInClaims";
    String testFedAuthPropValue2 = "false";
    String testFedAuthPropName3 = "RealmId";
    String testFedAuthPropValue3 = "localhost";
    String testProvisionConfName = "scim";
    String testProvisionPropName = "scim-user-ep";
    String testProvisionPropDisplayName = "userEndPoint";
    String testProvisionPropValue = "https://localhost:9853/testProvisionLink";
    String testProvisionPropName2 = "scim-username";
    String testProvisionPropDisplayName2 = "userName";
    String testProvisionPropValue2 = "admin";
    String testProvisionPropName3 = "scim-password";
    String testProvisionPropDisplayName3 = "userPassword";
    String testProvisionPropValue3 = "admin";
    IdentityProvider idProvider = new IdentityProvider();
    FederatedAuthenticatorConfig[] fedAuthConfigs = new FederatedAuthenticatorConfig[1];
    // set idp information
    idProvider.setHomeRealmId(testIdpRealmId);
    idProvider.setEnable(true);
    idProvider.setIdentityProviderDescription(testIdpDescription);
    idProvider.setIdentityProviderName(testIdpName);
    idProvider.setCertificate(sampleCertificate);
    idProvider.setFederationHub(false);
    idProvider.setPrimary(false);
    // Add federated authentication configuration
    FederatedAuthenticatorConfig authConfig = new FederatedAuthenticatorConfig();
    authConfig.setDisplayName(testFedAuthDispName);
    authConfig.setEnabled(true);
    authConfig.setName(testFedAuthName);
    // set properties
    // property 1
    Property fedProp = new Property();
    fedProp.setName(testFedAuthPropName);
    fedProp.setValue(testFedAuthPropValue);
    // property 2
    Property fedProp2 = new Property();
    fedProp2.setName(testFedAuthPropName2);
    fedProp2.setValue(testFedAuthPropValue2);
    // property 3
    Property fedProp3 = new Property();
    fedProp3.setName(testFedAuthPropName3);
    fedProp3.setValue(testFedAuthPropValue3);
    Property[] props = new Property[3];
    props[0] = fedProp;
    props[1] = fedProp2;
    props[2] = fedProp3;
    authConfig.setProperties(props);
    fedAuthConfigs[0] = authConfig;
    idProvider.setFederatedAuthenticatorConfigs(fedAuthConfigs);
    // Set JIT config
    JustInTimeProvisioningConfig jitConfig = new JustInTimeProvisioningConfig();
    jitConfig.setProvisioningEnabled(true);
    idProvider.setJustInTimeProvisioningConfig(jitConfig);
    ProvisioningConnectorConfig provisioningConfig = new ProvisioningConnectorConfig();
    provisioningConfig.setName(testProvisionConfName);
    provisioningConfig.setValid(false);
    provisioningConfig.setBlocking(false);
    provisioningConfig.setEnabled(true);
    // set provisioning properties
    Property provisionProp = new Property();
    provisionProp.setName(testProvisionPropName);
    provisionProp.setDisplayName(testProvisionPropDisplayName);
    provisionProp.setValue(testProvisionPropValue);
    Property provisionProp2 = new Property();
    provisionProp2.setName(testProvisionPropName2);
    provisionProp2.setDisplayName(testProvisionPropDisplayName2);
    provisionProp2.setValue(testProvisionPropValue2);
    Property provisionProp3 = new Property();
    provisionProp3.setName(testProvisionPropName3);
    provisionProp3.setDisplayName(testProvisionPropDisplayName3);
    provisionProp3.setValue(testProvisionPropValue3);
    Property[] provisionProps = new Property[3];
    provisionProps[0] = provisionProp;
    provisionProps[1] = provisionProp2;
    provisionProps[2] = provisionProp3;
    provisioningConfig.setProvisioningProperties(provisionProps);
    ProvisioningConnectorConfig[] provisionConfigs = new ProvisioningConnectorConfig[1];
    provisionConfigs[0] = provisioningConfig;
    idProvider.setProvisioningConnectorConfigs(provisionConfigs);
    // add new identity provider
    idpMgtServiceClient.addIdP(idProvider);
    // check adding idp success
    IdentityProvider addedIdp = idpMgtServiceClient.getIdPByName(testIdpName);
    Assert.assertNotNull(addedIdp, "addIdP or getIdPByName failed");
    Assert.assertEquals(addedIdp.getHomeRealmId(), testIdpRealmId, "addIdP : setting home realm failed");
    Assert.assertEquals(addedIdp.getCertificate(), sampleCertificate, "addIdP : setting certificate failed");
    // idp auto enabled
    Assert.assertEquals(addedIdp.getEnable(), true, "addIdP : idp enable failed");
    Assert.assertEquals(addedIdp.getIdentityProviderDescription(), testIdpDescription, "addIdP : setting description failed");
    Assert.assertEquals(addedIdp.getFederationHub(), false, "addIdP : setting federation hub status failed");
    Assert.assertEquals(addedIdp.getPrimary(), false, "addIdP : setting primary status failed");
    // Check added federated authenticator configs
    FederatedAuthenticatorConfig[] addedFedAuth = addedIdp.getFederatedAuthenticatorConfigs();
    Assert.assertNotNull(addedFedAuth, "federated authenticator not found");
    Assert.assertEquals(addedFedAuth.length, 1, "addIdP : deviation from expected number of federated authenticators");
    Assert.assertEquals(addedFedAuth[0].getName(), testFedAuthName, "addIdP : federated authenticator name setting failed");
    Property[] fedAuthProps = addedFedAuth[0].getProperties();
    Assert.assertNotNull(fedAuthProps, "addIdP : federated authenticator properties not found");
    Assert.assertEquals(fedAuthProps.length, 3, "addIdP : Deviation of expected number of authenticator properties");
    Map<String, Property> propertyMap = new HashMap<String, Property>();
    for (Property fedAuthProp : fedAuthProps) {
        propertyMap.put(fedAuthProp.getName(), fedAuthProp);
    }
    Assert.assertEquals(propertyMap.containsKey(testFedAuthPropName), true, "addIdP : federated authenticator property not found");
    Assert.assertEquals(propertyMap.get(testFedAuthPropName).getValue(), testFedAuthPropValue, "Deviation of federated authenticator property value");
    Assert.assertEquals(propertyMap.containsKey(testFedAuthPropName2), true, "addIdP : federated authenticator property not found");
    Assert.assertEquals(propertyMap.get(testFedAuthPropName2).getValue(), testFedAuthPropValue2, "Deviation of federated authenticator property value");
    Assert.assertEquals(propertyMap.containsKey(testFedAuthPropName3), true, "addIdP : federated authenticator property not found");
    Assert.assertEquals(propertyMap.get(testFedAuthPropName3).getValue(), testFedAuthPropValue3, "Deviation of federated authenticator property value");
    propertyMap.clear();
    // check provisioning connector configs
    ProvisioningConnectorConfig[] provisioningConfigs = addedIdp.getProvisioningConnectorConfigs();
    Assert.assertNotNull(provisioningConfigs, "addIdP : provisioning connector not found");
    Assert.assertEquals(provisioningConfigs.length, 1, "addIdP : Provisioning configuration property adding failed");
    Assert.assertEquals(provisioningConfigs[0].getName(), testProvisionConfName, "addIdP : Provisioning configuration name setting failed");
    Property[] provisioningProps = provisioningConfigs[0].getProvisioningProperties();
    Assert.assertNotNull(provisioningProps, "addIdP : provisioning property not found");
    Assert.assertEquals(provisioningProps.length, 4, "addIdP :Provisioning configuration property setting failed");
    for (Property provisioningProp : provisioningProps) {
        propertyMap.put(provisioningProp.getName(), provisioningProp);
    }
    Assert.assertEquals(propertyMap.containsKey(testProvisionPropName), true, "addIdP : Provisioning configuration property not found : " + testProvisionPropName);
    Assert.assertEquals(propertyMap.get(testProvisionPropName).getValue(), testProvisionPropValue, "addIdP : Provisioning configuration property value failed : " + testProvisionPropName);
    Assert.assertEquals(propertyMap.containsKey(testProvisionPropName2), true, "addIdP : Provisioning configuration property not found : " + testProvisionPropName2);
    Assert.assertEquals(propertyMap.get(testProvisionPropName2).getValue(), testProvisionPropValue2, "addIdP : Provisioning configuration property value failed : " + testProvisionPropName2);
    Assert.assertEquals(propertyMap.containsKey(testProvisionPropName3), true, "addIdP : Provisioning configuration property not found : " + testProvisionPropName3);
    Assert.assertTrue(propertyMap.get(testProvisionPropName3).getValue().contains(RANDOM_PASSWORD_GENERATED), "addIdP : Provisioning configuration property value failed : " + testProvisionPropName3);
    // check jit
    Assert.assertEquals(addedIdp.getJustInTimeProvisioningConfig().getProvisioningEnabled(), true, "addIdP : JIT enabling failed");
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) HashMap(java.util.HashMap) JustInTimeProvisioningConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.JustInTimeProvisioningConfig) 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) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.ProvisioningConnectorConfig) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)39 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)19 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)19 Property (org.wso2.carbon.identity.application.common.model.Property)19 ArrayList (java.util.ArrayList)17 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)14 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)10 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)10 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.idp.xsd.ProvisioningConnectorConfig)10 PreparedStatement (java.sql.PreparedStatement)9 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)9 Test (org.testng.annotations.Test)8 Claim (org.wso2.carbon.identity.application.common.model.Claim)7 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)7 LocalRole (org.wso2.carbon.identity.application.common.model.LocalRole)7 PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)7 RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)7 ResultSet (java.sql.ResultSet)6 HashMap (java.util.HashMap)6 JustInTimeProvisioningConfig (org.wso2.carbon.identity.application.common.model.JustInTimeProvisioningConfig)6