Search in sources :

Example 91 with Property

use of org.wso2.carbon.user.api.Property 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 92 with Property

use of org.wso2.carbon.user.api.Property 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 93 with Property

use of org.wso2.carbon.user.api.Property in project carbon-identity-framework by wso2.

the class RoleDAOImpl method getUserStoreProperty.

private String getUserStoreProperty(String property, int tenantId, String userStoreDomain) {
    RealmService realmService = RoleManagementServiceComponentHolder.getInstance().getRealmService();
    String propValue = null;
    if (realmService != null) {
        try {
            if (IdentityUtil.getPrimaryDomainName().equals(userStoreDomain)) {
                propValue = realmService.getTenantUserRealm(tenantId).getRealmConfiguration().getUserStoreProperty(property);
            } else {
                UserStoreManager userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
                if (userStoreManager instanceof AbstractUserStoreManager) {
                    propValue = ((AbstractUserStoreManager) userStoreManager).getSecondaryUserStoreManager(userStoreDomain).getRealmConfiguration().getUserStoreProperty(property);
                }
            }
        } catch (UserStoreException e) {
            log.error(String.format("Error while retrieving property %s for userstore %s in tenantId %s. " + "Returning null.", property, userStoreDomain, tenantId), e);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug(String.format("Userstore property %s is set to %s for userstore %s in tenantId %s", property, propValue, userStoreDomain, tenantId));
    }
    return propValue;
}
Also used : RealmService(org.wso2.carbon.user.core.service.RealmService) UserStoreException(org.wso2.carbon.user.api.UserStoreException) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager) AbstractUserStoreManager(org.wso2.carbon.user.core.common.AbstractUserStoreManager) UserStoreManager(org.wso2.carbon.user.api.UserStoreManager)

Example 94 with Property

use of org.wso2.carbon.user.api.Property in project carbon-identity-framework by wso2.

the class AbstractProvisioningConnectorFactory method getConnector.

/**
 * @param identityProviderName
 * @param provisoningProperties
 * @param tenantDomain
 * @return
 * @throws IdentityProvisioningException
 */
public AbstractOutboundProvisioningConnector getConnector(String identityProviderName, Property[] provisoningProperties, String tenantDomain) throws IdentityProvisioningException {
    ProvisioningConnectorCacheKey cacheKey = new ProvisioningConnectorCacheKey(identityProviderName);
    ProvisioningConnectorCacheEntry entry = ProvisioningConnectorCache.getInstance().getValueFromCache(cacheKey, tenantDomain);
    if (entry != null) {
        if (log.isDebugEnabled()) {
            log.debug("Provisioning cache HIT for " + identityProviderName + " of " + tenantDomain);
        }
        return entry.getProvisioningConnector();
    }
    AbstractOutboundProvisioningConnector connector;
    Property idpName = new Property();
    idpName.setName("identityProviderName");
    idpName.setValue(identityProviderName);
    List<Property> provisioningPropertiesList = new ArrayList<>(Arrays.asList(provisoningProperties));
    provisioningPropertiesList.add(idpName);
    Property[] provisioningProperties = new Property[provisioningPropertiesList.size()];
    provisioningProperties = provisioningPropertiesList.toArray(provisioningProperties);
    connector = buildConnector(provisioningProperties);
    entry = new ProvisioningConnectorCacheEntry();
    entry.setProvisioningConnector(connector);
    ProvisioningConnectorCache.getInstance().addToCache(cacheKey, entry, tenantDomain);
    return connector;
}
Also used : ProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry) ProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheKey) ArrayList(java.util.ArrayList) Property(org.wso2.carbon.identity.application.common.model.Property)

Example 95 with Property

use of org.wso2.carbon.user.api.Property 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

ArrayList (java.util.ArrayList)118 HashMap (java.util.HashMap)114 Property (org.wso2.carbon.identity.application.common.model.Property)105 Map (java.util.Map)62 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)50 Test (org.testng.annotations.Test)42 IOException (java.io.IOException)38 UserStoreException (org.wso2.carbon.user.api.UserStoreException)38 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)36 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)33 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)32 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)32 List (java.util.List)31 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)29 Resource (org.wso2.carbon.registry.core.Resource)29 OMElement (org.apache.axiom.om.OMElement)27 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)27 PreparedStatement (java.sql.PreparedStatement)23 QName (javax.xml.namespace.QName)23 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)23