Search in sources :

Example 1 with InboundProvisioningConfig

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

the class ApplicationDAOImpl method updateInboundProvisioningConfiguration.

/**
 * @param applicationId
 * @param inBoundProvisioningConfig
 * @param connection
 * @throws SQLException
 */
private void updateInboundProvisioningConfiguration(int applicationId, InboundProvisioningConfig inBoundProvisioningConfig, Connection connection) throws SQLException {
    if (inBoundProvisioningConfig == null) {
        return;
    }
    int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    PreparedStatement inboundProConfigPrepStmt = null;
    try {
        inboundProConfigPrepStmt = connection.prepareStatement(UPDATE_BASIC_APPINFO_WITH_PRO_PROPERTIES);
        // PROVISIONING_USERSTORE_DOMAIN=?
        inboundProConfigPrepStmt.setString(1, inBoundProvisioningConfig.getProvisioningUserStore());
        inboundProConfigPrepStmt.setString(2, inBoundProvisioningConfig.isDumbMode() ? "1" : "0");
        inboundProConfigPrepStmt.setInt(3, tenantID);
        inboundProConfigPrepStmt.setInt(4, applicationId);
        inboundProConfigPrepStmt.execute();
    } finally {
        IdentityApplicationManagementUtil.closeStatement(inboundProConfigPrepStmt);
    }
}
Also used : PreparedStatement(java.sql.PreparedStatement) NamedPreparedStatement(org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)

Example 2 with InboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.InboundProvisioningConfig 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 3 with InboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.InboundProvisioningConfig 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 4 with InboundProvisioningConfig

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

the class ApplicationManagementTestCase method testUpdateInboundProvisioningData.

@Test(alwaysRun = true, description = "Testing update Inbound Provisioning Data")
public void testUpdateInboundProvisioningData() {
    String applicationName = "TestServiceProvider";
    try {
        ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
        String provisioningUserStore = "scim-inbound-userstore";
        InboundProvisioningConfig inBoundProConfig = new InboundProvisioningConfig();
        inBoundProConfig.setProvisioningUserStore(provisioningUserStore);
        serviceProvider.setInboundProvisioningConfig(inBoundProConfig);
        applicationManagementServiceClient.updateApplicationData(serviceProvider);
        ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
        Assert.assertEquals(updatedServiceProvider.getInboundProvisioningConfig().getProvisioningUserStore(), "scim-inbound-userstore", "Failed update provisioning user store");
    } catch (Exception e) {
        Assert.fail("Error while trying to update inbound provisioning data", e);
    }
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 5 with InboundProvisioningConfig

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

the class ProvisioningTestCase method addSP.

private void addSP(int portOffset) throws Exception {
    ServiceProvider serviceProvider = applicationManagementServiceClients.get(portOffset).getApplication("wso2carbon-local-sp");
    if (serviceProvider == null) {
        serviceProvider = new ServiceProvider();
        serviceProvider.setApplicationName("wso2carbon-local-sp");
        try {
            applicationManagementServiceClients.get(portOffset).createApplication(serviceProvider);
            serviceProvider = applicationManagementServiceClients.get(portOffset).getApplication("wso2carbon-local-sp");
        } catch (Exception ex) {
            // log.error("Error occurred during obtaining applicationManagementServiceClients", ex);
            throw new Exception("Error occurred during obtaining applicationManagementServiceClients", ex);
        }
    }
    InboundProvisioningConfig inBoundProConfig = new InboundProvisioningConfig();
    inBoundProConfig.setProvisioningUserStore("");
    serviceProvider.setInboundProvisioningConfig(inBoundProConfig);
    String proProvider = SAMPLE_IDENTITY_PROVIDER_NAME + "_" + Integer.toString(portOffset);
    String connector = "scim";
    JustInTimeProvisioningConfig jitpro = new JustInTimeProvisioningConfig();
    jitpro.setProvisioningEnabled(false);
    org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider proIdp = new org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider();
    proIdp.setIdentityProviderName(proProvider);
    org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig proCon = new org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig();
    proCon.setBlocking(true);
    proCon.setName(connector);
    proIdp.setJustInTimeProvisioningConfig(jitpro);
    proIdp.setDefaultProvisioningConnectorConfig(proCon);
    List<org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider> provisioningIdps = new ArrayList<org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider>();
    provisioningIdps.add(proIdp);
    if (provisioningIdps.size() > 0) {
        OutboundProvisioningConfig outboundProConfig = new OutboundProvisioningConfig();
        outboundProConfig.setProvisioningIdentityProviders(provisioningIdps.toArray(new org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider[provisioningIdps.size()]));
        serviceProvider.setOutboundProvisioningConfig(outboundProConfig);
    }
    applicationManagementServiceClients.get(portOffset).updateApplicationData(serviceProvider);
}
Also used : InboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundProvisioningConfig) ArrayList(java.util.ArrayList) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) CharonException(org.wso2.charon.core.exceptions.CharonException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig) JustInTimeProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.JustInTimeProvisioningConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.ProvisioningConnectorConfig)

Aggregations

InboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.InboundProvisioningConfig)6 ArrayList (java.util.ArrayList)4 InboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundProvisioningConfig)4 Test (org.testng.annotations.Test)3 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)3 JustInTimeProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.JustInTimeProvisioningConfig)3 OutboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig)3 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)3 PreparedStatement (java.sql.PreparedStatement)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)2 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)2 OutboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig)2 IdentityProvider (org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider)2 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig)2 AbstractUserStoreManager (org.wso2.carbon.user.core.common.AbstractUserStoreManager)2 User (org.wso2.charon3.core.objects.User)2 ResultSet (java.sql.ResultSet)1 HashMap (java.util.HashMap)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1