Search in sources :

Example 1 with ConnectorConfig

use of org.wso2.carbon.identity.core.ConnectorConfig in project carbon-identity-framework by wso2.

the class IdentityProviderManager method validateOutboundProvisioningConnectorProperties.

/**
 * Validate whether there are any duplicate properties in the ProvisioningConnectorConfig of an IdentityProvider.
 *
 * @param newIdentityProvider IdentityProvider object.
 * @throws IdentityProviderManagementException If duplicate properties found in ProvisioningConnectorConfig.
 */
private void validateOutboundProvisioningConnectorProperties(IdentityProvider newIdentityProvider) throws IdentityProviderManagementException {
    ProvisioningConnectorConfig[] provisioningConnectorConfigs = newIdentityProvider.getProvisioningConnectorConfigs();
    if (!ArrayUtils.isEmpty(provisioningConnectorConfigs)) {
        for (ProvisioningConnectorConfig connectorConfig : provisioningConnectorConfigs) {
            Property[] properties = connectorConfig.getProvisioningProperties();
            // If no properties have specified, validation needs to stop.
            if (ArrayUtils.isEmpty(properties) || properties.length < 2) {
                break;
            }
            Set<Property> connectorProperties = new HashSet<>();
            for (Property property : properties) {
                if (!connectorProperties.add(property)) {
                    throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.DUPLICATE_OUTBOUND_CONNECTOR_PROPERTIES, newIdentityProvider.getIdentityProviderName());
                }
            }
        }
    }
}
Also used : IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) Property(org.wso2.carbon.identity.application.common.model.Property) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) HashSet(java.util.HashSet)

Example 2 with ConnectorConfig

use of org.wso2.carbon.identity.core.ConnectorConfig in project carbon-identity-framework by wso2.

the class IdentityGovernanceAdminClient method getConnectorList.

public Map<String, Map<String, List<ConnectorConfig>>> getConnectorList() throws RemoteException, IdentityGovernanceAdminServiceIdentityGovernanceExceptionException {
    ConnectorConfig[] configs = stub.getConnectorList();
    Map<String, Map<String, List<ConnectorConfig>>> catMap = new HashMap<>();
    if (configs != null) {
        for (ConnectorConfig conf : configs) {
            String categoryName = StringUtils.isBlank(conf.getCategory()) ? DEFAULT : conf.getCategory();
            String subCategoryName = StringUtils.isBlank(conf.getSubCategory()) ? DEFAULT : conf.getSubCategory();
            if (catMap.containsKey(categoryName)) {
                Map<String, List<ConnectorConfig>> subCatMap = catMap.get(categoryName);
                if (subCatMap.containsKey(subCategoryName)) {
                    List<ConnectorConfig> confList = subCatMap.get(subCategoryName);
                    confList.add(conf);
                } else {
                    List<ConnectorConfig> confList = new ArrayList<ConnectorConfig>();
                    confList.add(conf);
                    subCatMap.put(subCategoryName, confList);
                }
            } else {
                Map<String, List<ConnectorConfig>> subCatMap = new HashMap<String, List<ConnectorConfig>>();
                catMap.put(categoryName, subCatMap);
                List<ConnectorConfig> confList = new ArrayList<ConnectorConfig>();
                confList.add(conf);
                subCatMap.put(subCategoryName, confList);
            }
        }
    }
    return catMap;
}
Also used : HashMap(java.util.HashMap) ConnectorConfig(org.wso2.carbon.identity.governance.stub.bean.ConnectorConfig) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ConnectorConfig

use of org.wso2.carbon.identity.core.ConnectorConfig in project carbon-identity-framework by wso2.

the class Util method isUserOnBoardingEnabled.

public static boolean isUserOnBoardingEnabled(ServletContext context, HttpSession session) {
    if (!isAskPasswordAdminUIEnabled) {
        return false;
    }
    String backendServerURL = CarbonUIUtil.getServerURL(context, session);
    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
    ConfigurationContext configContext = (ConfigurationContext) context.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    Map<String, Map<String, List<ConnectorConfig>>> connectorList;
    try {
        IdentityGovernanceAdminClient client = new IdentityGovernanceAdminClient(cookie, backendServerURL, configContext);
        connectorList = client.getConnectorList();
    } catch (Exception e) {
        log.error("Error while getting connector list from governance service, at URL :" + backendServerURL, e);
        return false;
    }
    if (connectorList != null) {
        for (Map.Entry<String, Map<String, List<ConnectorConfig>>> entry : connectorList.entrySet()) {
            Map<String, List<ConnectorConfig>> subCatList = entry.getValue();
            for (String subCatKey : subCatList.keySet()) {
                List<ConnectorConfig> connectorConfigs = subCatList.get(subCatKey);
                for (ConnectorConfig connectorConfig : connectorConfigs) {
                    Property[] properties = connectorConfig.getProperties();
                    for (Property property : properties) {
                        if (property != null) {
                            if (EMAIL_VERIFICATION_ENABLE_PROP_NAME.equals(property.getName())) {
                                String propValue = property.getValue();
                                boolean isEmailVerificationEnabled = false;
                                if (!StringUtils.isEmpty(propValue)) {
                                    isEmailVerificationEnabled = Boolean.parseBoolean(propValue);
                                }
                                return isEmailVerificationEnabled;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : IdentityGovernanceAdminClient(org.wso2.carbon.user.mgt.ui.client.IdentityGovernanceAdminClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ConnectorConfig(org.wso2.carbon.identity.governance.stub.bean.ConnectorConfig) CryptoException(org.wso2.carbon.core.util.CryptoException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) CarbonException(org.wso2.carbon.CarbonException) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Property(org.wso2.carbon.identity.governance.stub.bean.Property)

Example 4 with ConnectorConfig

use of org.wso2.carbon.identity.core.ConnectorConfig in project carbon-identity-framework by wso2.

the class Util method getAskPasswordTempPassGenerator.

public static RandomPasswordGenerator getAskPasswordTempPassGenerator(ServletContext context, HttpSession session) {
    if (!isAskPasswordAdminUIEnabled) {
        return new DefaultPasswordGenerator();
    }
    String randomPasswordGenerationClass = "org.wso2.carbon.user.mgt.common.DefaultPasswordGenerator";
    if (isUserOnBoardingEnabled(context, session)) {
        String backendServerURL = CarbonUIUtil.getServerURL(context, session);
        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
        ConfigurationContext configContext = (ConfigurationContext) context.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
        Map<String, Map<String, List<ConnectorConfig>>> connectorList;
        try {
            IdentityGovernanceAdminClient client = new IdentityGovernanceAdminClient(cookie, backendServerURL, configContext);
            connectorList = client.getConnectorList();
            if (connectorList != null) {
                for (Map.Entry<String, Map<String, List<ConnectorConfig>>> entry : connectorList.entrySet()) {
                    Map<String, List<ConnectorConfig>> subCatList = entry.getValue();
                    for (String subCatKey : subCatList.keySet()) {
                        List<ConnectorConfig> connectorConfigs = subCatList.get(subCatKey);
                        for (ConnectorConfig connectorConfig : connectorConfigs) {
                            Property[] properties = connectorConfig.getProperties();
                            for (Property property : properties) {
                                if (ASK_PASSWORD_TEMP_PASSWORD_GENERATOR.equals(property.getName())) {
                                    randomPasswordGenerationClass = property.getValue();
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("Error while getting connector list from governance service, at URL :" + backendServerURL, e);
        }
    } else {
        String randomPasswordGenerationClassFromFile = IdentityUtil.getProperty(ASK_PASSWORD_TEMP_PASSWORD_GENERATOR);
        if (StringUtils.isNotBlank(randomPasswordGenerationClassFromFile)) {
            randomPasswordGenerationClass = randomPasswordGenerationClassFromFile;
        }
    }
    try {
        Class clazz = Class.forName(randomPasswordGenerationClass);
        return (RandomPasswordGenerator) clazz.newInstance();
    } catch (Exception e) {
        log.error("Error while loading random password generator class. " + "Default random password generator would be used", e);
    }
    return new DefaultPasswordGenerator();
}
Also used : IdentityGovernanceAdminClient(org.wso2.carbon.user.mgt.ui.client.IdentityGovernanceAdminClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ConnectorConfig(org.wso2.carbon.identity.governance.stub.bean.ConnectorConfig) DefaultPasswordGenerator(org.wso2.carbon.user.mgt.common.DefaultPasswordGenerator) CryptoException(org.wso2.carbon.core.util.CryptoException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) CarbonException(org.wso2.carbon.CarbonException) RandomPasswordGenerator(org.wso2.carbon.user.mgt.common.RandomPasswordGenerator) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Property(org.wso2.carbon.identity.governance.stub.bean.Property)

Example 5 with ConnectorConfig

use of org.wso2.carbon.identity.core.ConnectorConfig in project carbon-identity-framework by wso2.

the class IdentityGovernanceAdminClient method getConnectorList.

public Map<String, Map<String, List<ConnectorConfig>>> getConnectorList() throws RemoteException, IdentityGovernanceAdminServiceIdentityGovernanceExceptionException {
    ConnectorConfig[] configs = stub.getConnectorList();
    Map<String, Map<String, List<ConnectorConfig>>> catMap = new HashMap<>();
    if (configs != null) {
        for (ConnectorConfig conf : configs) {
            String categoryName = StringUtils.isBlank(conf.getCategory()) ? DEFAULT : conf.getCategory();
            String subCategoryName = StringUtils.isBlank(conf.getSubCategory()) ? DEFAULT : conf.getSubCategory();
            Map<String, List<ConnectorConfig>> subCatMap = catMap.get(categoryName);
            if (subCatMap == null) {
                subCatMap = new HashMap<>();
                catMap.put(categoryName, subCatMap);
            }
            List confList = subCatMap.get(subCategoryName);
            if (confList == null) {
                confList = new ArrayList();
                subCatMap.put(subCategoryName, confList);
            }
            confList.add(conf);
        }
    }
    return catMap;
}
Also used : HashMap(java.util.HashMap) ConnectorConfig(org.wso2.carbon.identity.governance.stub.bean.ConnectorConfig) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Property (org.wso2.carbon.identity.application.common.model.Property)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)10 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)9 IdentityGovernanceException (org.wso2.carbon.identity.governance.IdentityGovernanceException)9 ConnectorConfig (org.wso2.carbon.identity.governance.bean.ConnectorConfig)8 List (java.util.List)7 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)7 IdentityGovernanceService (org.wso2.carbon.identity.governance.IdentityGovernanceService)7 ConnectorConfig (org.wso2.carbon.identity.governance.stub.bean.ConnectorConfig)6 Map (java.util.Map)5 CaptchaClientException (org.wso2.carbon.identity.captcha.exception.CaptchaClientException)5 CaptchaException (org.wso2.carbon.identity.captcha.exception.CaptchaException)5 IOException (java.io.IOException)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 MetaOutboundConnector (org.wso2.carbon.identity.api.server.idp.v1.model.MetaOutboundConnector)4 MetaProperty (org.wso2.carbon.identity.api.server.idp.v1.model.MetaProperty)4 SubProperty (org.wso2.carbon.identity.application.common.model.SubProperty)4 IdentityConnectorConfig (org.wso2.carbon.identity.governance.common.IdentityConnectorConfig)3 Property (org.wso2.carbon.identity.governance.stub.bean.Property)3