Search in sources :

Example 16 with ProvisioningConnectorConfig

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

the class IdPManagementDAOTest method testGetProvisioningConnectorConfigs.

@Test(dataProvider = "getProvisioningConnectorConfigsData")
public void testGetProvisioningConnectorConfigs(String idpName, int idpId, int tenantId, int resultCount) throws Exception {
    mockStatic(IdentityDatabaseUtil.class);
    try (Connection connection = getConnection(DB_NAME)) {
        when(IdentityDatabaseUtil.getDBConnection(anyBoolean())).thenReturn(connection);
        when(IdentityDatabaseUtil.getDBConnection()).thenReturn(connection);
        when(IdentityDatabaseUtil.getDataSource()).thenReturn(dataSourceMap.get(DB_NAME));
        addTestIdps();
        ProvisioningConnectorConfig[] pccResult = idPManagementDAO.getProvisioningConnectorConfigs(connection, idpName, idpId, tenantId);
        assertEquals(pccResult.length, resultCount);
    }
}
Also used : Connection(java.sql.Connection) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 17 with ProvisioningConnectorConfig

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

the class IdPManagementUtil method removeRandomPasswords.

/**
 * Use this method to replace random passwords with original passwords when original passwords are required
 * @param identityProvider
 * @param withCacheClear
 */
public static void removeRandomPasswords(IdentityProvider identityProvider, boolean withCacheClear) {
    if (identityProvider == null || identityProvider.getProvisioningConnectorConfigs() == null) {
        return;
    }
    for (ProvisioningConnectorConfig provisioningConnectorConfig : identityProvider.getProvisioningConnectorConfigs()) {
        Property[] properties = provisioningConnectorConfig.getProvisioningProperties();
        if (ArrayUtils.isEmpty(properties)) {
            continue;
        }
        properties = RandomPasswordProcessor.getInstance().removeRandomPasswords(properties, withCacheClear);
        provisioningConnectorConfig.setProvisioningProperties(properties);
    }
}
Also used : Property(org.wso2.carbon.identity.application.common.model.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)

Example 18 with ProvisioningConnectorConfig

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

the class IdPManagementUtil method removeOriginalPasswords.

/**
 * Use this method to replace original passwords with random passwords before sending to UI front-end
 * @param identityProvider
 * @return
 */
public static void removeOriginalPasswords(IdentityProvider identityProvider) {
    if (identityProvider == null || identityProvider.getProvisioningConnectorConfigs() == null) {
        return;
    }
    for (ProvisioningConnectorConfig provisioningConnectorConfig : identityProvider.getProvisioningConnectorConfigs()) {
        Property[] properties = provisioningConnectorConfig.getProvisioningProperties();
        if (ArrayUtils.isEmpty(properties)) {
            continue;
        }
        properties = RandomPasswordProcessor.getInstance().removeOriginalPasswords(properties);
        provisioningConnectorConfig.setProvisioningProperties(properties);
    }
}
Also used : Property(org.wso2.carbon.identity.application.common.model.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)

Example 19 with ProvisioningConnectorConfig

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

the class OutboundProvisioningManager method getOutboundProvisioningConnectors.

/**
 * TODO: Need to cache the output from this method.
 *
 * @return
 * @throws UserStoreException
 */
private Map<String, RuntimeProvisioningConfig> getOutboundProvisioningConnectors(ServiceProvider serviceProvider, String tenantDomain) throws IdentityProvisioningException {
    Map<String, RuntimeProvisioningConfig> connectors = new HashMap<>();
    ServiceProviderProvisioningConnectorCacheKey key;
    ServiceProviderProvisioningConnectorCacheEntry entry;
    // Reading from the cache.
    if (serviceProvider != null && tenantDomain != null) {
        key = new ServiceProviderProvisioningConnectorCacheKey(serviceProvider.getApplicationName());
        entry = ServiceProviderProvisioningConnectorCache.getInstance().getValueFromCache(key, tenantDomain);
        // cache hit
        if (entry != null) {
            if (log.isDebugEnabled()) {
                log.debug("Provisioning cache HIT for " + serviceProvider + " of " + tenantDomain);
            }
            return entry.getConnectors();
        }
    } else {
        throw new IdentityProvisioningException("Error reading service provider from cache.");
    }
    // NOW build the Map
    // a list of registered provisioning connector factories.
    Map<String, AbstractProvisioningConnectorFactory> registeredConnectorFactories = IdentityProvisionServiceComponent.getConnectorFactories();
    // get all registered list of out-bound provisioning connectors registered for the local
    // service provider.
    OutboundProvisioningConfig outboundProvisioningConfiguration = serviceProvider.getOutboundProvisioningConfig();
    if (outboundProvisioningConfiguration == null) {
        if (log.isDebugEnabled()) {
            log.debug("No outbound provisioning configuration defined for local service provider.");
        }
        // empty list.
        return new HashMap<String, RuntimeProvisioningConfig>();
    }
    // get the list of registered provisioning identity providers in out-bound provisioning
    // configuration.
    IdentityProvider[] provisionningIdPList = outboundProvisioningConfiguration.getProvisioningIdentityProviders();
    if (provisionningIdPList != null && provisionningIdPList.length > 0) {
        for (IdentityProvider fIdP : provisionningIdPList) {
            try {
                AbstractOutboundProvisioningConnector connector;
                ProvisioningConnectorConfig defaultConnector = fIdP.getDefaultProvisioningConnectorConfig();
                if (defaultConnector != null) {
                    // if no default provisioning connector defined for this identity provider,
                    // we can safely ignore it - need not to worry about provisioning.
                    String connectorType = fIdP.getDefaultProvisioningConnectorConfig().getName();
                    boolean enableJitProvisioning = false;
                    if (fIdP.getJustInTimeProvisioningConfig() != null && fIdP.getJustInTimeProvisioningConfig().isProvisioningEnabled()) {
                        enableJitProvisioning = true;
                    }
                    connector = getOutboundProvisioningConnector(fIdP, registeredConnectorFactories, tenantDomain, enableJitProvisioning);
                    // configuration of the local service provider.
                    if (connector != null) {
                        RuntimeProvisioningConfig proConfig = new RuntimeProvisioningConfig();
                        proConfig.setProvisioningConnectorEntry(new SimpleEntry<>(connectorType, connector));
                        proConfig.setBlocking(defaultConnector.isBlocking());
                        proConfig.setPolicyEnabled(defaultConnector.isRulesEnabled());
                        connectors.put(fIdP.getIdentityProviderName(), proConfig);
                    }
                }
            } catch (IdentityProviderManagementException e) {
                throw new IdentityProvisioningException("Error while retrieving idp configuration for " + fIdP.getIdentityProviderName(), e);
            }
        }
    }
    entry = new ServiceProviderProvisioningConnectorCacheEntry();
    entry.setConnectors(connectors);
    ServiceProviderProvisioningConnectorCache.getInstance().addToCache(key, entry, tenantDomain);
    if (log.isDebugEnabled()) {
        log.debug("Entry added successfully ");
    }
    return connectors;
}
Also used : HashMap(java.util.HashMap) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig) ServiceProviderProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheEntry) ServiceProviderProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheKey) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)

Example 20 with ProvisioningConnectorConfig

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

the class IdentityProvisionServiceComponent method setProvisioningConnectorFactory.

@Reference(name = "provisioning.connector.factory", service = org.wso2.carbon.identity.provisioning.AbstractProvisioningConnectorFactory.class, cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC, unbind = "unsetProvisioningConnectorFactory")
protected void setProvisioningConnectorFactory(AbstractProvisioningConnectorFactory connectorFactory) {
    ProvisioningServiceDataHolder.getInstance().getConnectorFactories().put(connectorFactory.getConnectorType(), connectorFactory);
    if (log.isDebugEnabled()) {
        log.debug("Added provisioning connector : " + connectorFactory.getConnectorType());
    }
    ProvisioningConnectorConfig provisioningConnectorConfig = new ProvisioningConnectorConfig();
    provisioningConnectorConfig.setName(connectorFactory.getConnectorType());
    Property[] property = new Property[connectorFactory.getConfigurationProperties().size()];
    provisioningConnectorConfig.setProvisioningProperties(connectorFactory.getConfigurationProperties().toArray(property));
    ProvisioningConnectorService.getInstance().addProvisioningConnectorConfigs(provisioningConnectorConfig);
}
Also used : Property(org.wso2.carbon.identity.application.common.model.Property) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) Reference(org.osgi.service.component.annotations.Reference)

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