Search in sources :

Example 1 with IdentityConnectorConfig

use of org.wso2.carbon.identity.governance.common.IdentityConnectorConfig in project identity-governance by wso2-extensions.

the class IdentityGovernanceServiceImpl method getConnectorListWithConfigs.

public List<ConnectorConfig> getConnectorListWithConfigs(String tenantDomain) throws IdentityGovernanceException {
    List<IdentityConnectorConfig> list = IdentityMgtServiceDataHolder.getInstance().getIdentityGovernanceConnectorList();
    Property[] properties = this.getConfiguration(tenantDomain);
    List<ConnectorConfig> configs = new ArrayList<>(list.size());
    String[] connectorProperties;
    for (int i = 0; i < list.size(); i++) {
        ConnectorConfig config = new ConnectorConfig();
        Map<String, String> propertyFriendlyNames = list.get(i).getPropertyNameMapping();
        Map<String, String> propertyDescriptions = list.get(i).getPropertyDescriptionMapping();
        Map<String, Property> metaData = list.get(i).getMetaData();
        List<String> confidentialProperties = list.get(i).getConfidentialPropertyValues(tenantDomain);
        config.setFriendlyName(list.get(i).getFriendlyName());
        config.setName(list.get(i).getName());
        config.setCategory(list.get(i).getCategory());
        config.setSubCategory(list.get(i).getSubCategory());
        config.setOrder(list.get(i).getOrder());
        connectorProperties = list.get(i).getPropertyNames();
        Property[] configProperties = new Property[connectorProperties.length];
        for (int j = 0; j < connectorProperties.length; j++) {
            for (Property property : properties) {
                if (connectorProperties[j].equals(property.getName())) {
                    configProperties[j] = property;
                    String resourceName = configProperties[j].getName();
                    configProperties[j].setDisplayName(propertyFriendlyNames.get(resourceName));
                    configProperties[j].setDescription(propertyDescriptions.get(resourceName));
                    if (metaData != null && metaData.containsKey(resourceName)) {
                        configProperties[j].setType(metaData.get(resourceName).getType());
                        configProperties[j].setRegex(metaData.get(resourceName).getRegex());
                        configProperties[j].setGroupId(metaData.get(resourceName).getGroupId());
                    }
                    if (confidentialProperties != null && confidentialProperties.contains(configProperties[j].getName())) {
                        configProperties[j].setConfidential(true);
                    }
                    break;
                }
            }
        }
        config.setProperties(configProperties);
        configs.add(i, config);
    }
    return configs;
}
Also used : IdentityConnectorConfig(org.wso2.carbon.identity.governance.common.IdentityConnectorConfig) ConnectorConfig(org.wso2.carbon.identity.governance.bean.ConnectorConfig) ArrayList(java.util.ArrayList) IdentityConnectorConfig(org.wso2.carbon.identity.governance.common.IdentityConnectorConfig) Property(org.wso2.carbon.identity.application.common.model.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)

Example 2 with IdentityConnectorConfig

use of org.wso2.carbon.identity.governance.common.IdentityConnectorConfig in project identity-governance by wso2-extensions.

the class MultiAttributeLoginServiceComponent method activate.

@Activate
protected void activate(ComponentContext context) {
    BundleContext bundleContext = context.getBundleContext();
    try {
        IdentityConnectorConfig multiAttributeLoginHandler = new MultiAttributeLoginHandler();
        bundleContext.registerService(IdentityConnectorConfig.class.getName(), multiAttributeLoginHandler, null);
        if (log.isDebugEnabled()) {
            log.debug("MultiAttributeLoginHandler is registered.");
        }
    } catch (Throwable e) {
        log.error("Error while activating MultiAttributeLoginHandler.", e);
    }
    try {
        MultiAttributeLoginService multiAttributeLoginService = new MultiAttributeLoginServiceServiceImpl();
        bundleContext.registerService(MultiAttributeLoginService.class.getName(), multiAttributeLoginService, null);
        if (log.isDebugEnabled()) {
            log.debug("MultiAttributeLoginService is registered.");
        }
    } catch (Throwable e) {
        log.error("Error while activating multi attribute login bundle.", e);
    }
}
Also used : IdentityConnectorConfig(org.wso2.carbon.identity.governance.common.IdentityConnectorConfig) MultiAttributeLoginServiceServiceImpl(org.wso2.carbon.identity.multi.attribute.login.service.MultiAttributeLoginServiceServiceImpl) MultiAttributeLoginHandler(org.wso2.carbon.identity.multi.attribute.login.handler.MultiAttributeLoginHandler) BundleContext(org.osgi.framework.BundleContext) MultiAttributeLoginService(org.wso2.carbon.identity.multi.attribute.login.mgt.MultiAttributeLoginService) Activate(org.osgi.service.component.annotations.Activate)

Example 3 with IdentityConnectorConfig

use of org.wso2.carbon.identity.governance.common.IdentityConnectorConfig in project identity-governance by wso2-extensions.

the class IdentityGovernanceUtil method saveConnectorDefaultProperties.

@Deprecated
public static void saveConnectorDefaultProperties(IdentityConnectorConfig identityConnectorConfig, String tenantDomain) throws ConnectorException {
    IdpManager identityProviderManager = IdentityMgtServiceDataHolder.getInstance().getIdpManager();
    try {
        IdentityProvider residentIdp = identityProviderManager.getResidentIdP(tenantDomain);
        IdentityProviderProperty[] idpProperties = residentIdp.getIdpProperties();
        String[] connectorPropertiesNames = identityConnectorConfig.getPropertyNames();
        List<IdentityProviderProperty> propertiesToAdd = new ArrayList<>();
        for (String connectorPropertyName : connectorPropertiesNames) {
            boolean propertyExists = false;
            for (IdentityProviderProperty property : idpProperties) {
                if (connectorPropertyName.equals(property.getName())) {
                    propertyExists = true;
                    break;
                }
            }
            if (!propertyExists) {
                IdentityProviderProperty newProperty = new IdentityProviderProperty();
                newProperty.setName(connectorPropertyName);
                newProperty.setDisplayName(identityConnectorConfig.getPropertyNameMapping().get(connectorPropertyName));
                Properties defaultPropertyValues = identityConnectorConfig.getDefaultPropertyValues(tenantDomain);
                newProperty.setValue(String.valueOf(defaultPropertyValues.get(connectorPropertyName)));
                propertiesToAdd.add(newProperty);
            }
        }
        // If the property list size is greater than 0, add the new properties to the database.
        if (propertiesToAdd.size() > 0) {
            String alreadyWrittenPropertyName = identityConnectorConfig.getName() + "." + IdentityEventConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_KEY;
            boolean alreadyWrittenPropertyExists = false;
            for (IdentityProviderProperty property : idpProperties) {
                if (alreadyWrittenPropertyName.equals(property.getName())) {
                    alreadyWrittenPropertyExists = true;
                    break;
                }
            }
            if (!alreadyWrittenPropertyExists) {
                IdentityProviderProperty property = new IdentityProviderProperty();
                property.setName(alreadyWrittenPropertyName);
                property.setValue(IdentityEventConstants.PropertyConfig.ALREADY_WRITTEN_PROPERTY_VALUE);
                propertiesToAdd.add(property);
            }
            propertiesToAdd.addAll(Arrays.asList(idpProperties));
            residentIdp.setIdpProperties(propertiesToAdd.toArray(new IdentityProviderProperty[0]));
            FederatedAuthenticatorConfig[] authenticatorConfigs = residentIdp.getFederatedAuthenticatorConfigs();
            List<FederatedAuthenticatorConfig> configsToSave = new ArrayList<>();
            for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
                if (IdentityApplicationConstants.Authenticator.PassiveSTS.NAME.equals(authenticatorConfig.getName()) || IdentityApplicationConstants.Authenticator.SAML2SSO.NAME.equals(authenticatorConfig.getName())) {
                    configsToSave.add(authenticatorConfig);
                }
            }
            residentIdp.setFederatedAuthenticatorConfigs(configsToSave.toArray(new FederatedAuthenticatorConfig[0]));
            identityProviderManager.updateResidentIdP(residentIdp, tenantDomain);
            if (log.isDebugEnabled()) {
                log.debug("New resident IDP properties for tenant : " + tenantDomain + " written to database");
            }
        }
    } catch (IdentityProviderManagementException e) {
        log.error("Error while adding identity management properties to resident Idp.", e);
    }
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) ArrayList(java.util.ArrayList) IdpManager(org.wso2.carbon.idp.mgt.IdpManager) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) Properties(java.util.Properties) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 4 with IdentityConnectorConfig

use of org.wso2.carbon.identity.governance.common.IdentityConnectorConfig in project carbon-identity-framework by wso2.

the class IdpMgtServiceComponentHolder method addConnectorConfig.

public void addConnectorConfig(ConnectorConfig identityConnectorConfig) throws IdentityProviderManagementException {
    CacheBackedIdPMgtDAO dao = new CacheBackedIdPMgtDAO(new IdPManagementDAO());
    dao.clearIdpCache(IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME, IdentityTenantUtil.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    this.identityConnectorConfigList.add(identityConnectorConfig);
}
Also used : CacheBackedIdPMgtDAO(org.wso2.carbon.idp.mgt.dao.CacheBackedIdPMgtDAO) IdPManagementDAO(org.wso2.carbon.idp.mgt.dao.IdPManagementDAO)

Example 5 with IdentityConnectorConfig

use of org.wso2.carbon.identity.governance.common.IdentityConnectorConfig in project identity-governance by wso2-extensions.

the class CaptchaComponent method activate.

@Activate
protected void activate(ComponentContext context) {
    try {
        // Initialize reCaptcha.
        CaptchaUtil.buildReCaptchaFilterProperties();
        // Initialize and register SSOLoginReCaptchaConfig.
        IdentityConnectorConfig connector = new SSOLoginReCaptchaConfig();
        ((SSOLoginReCaptchaConfig) connector).init(CaptchaDataHolder.getInstance().getIdentityGovernanceService());
        context.getBundleContext().registerService(IdentityConnectorConfig.class, connector, null);
        CaptchaDataHolder.getInstance().addCaptchaConnector((SSOLoginReCaptchaConfig) connector);
        // Initialize and register PathBasedReCaptchaConnector.
        CaptchaConnector captchaConnector = new SelfSignUpReCaptchaConnector();
        captchaConnector.init(CaptchaDataHolder.getInstance().getIdentityGovernanceService());
        CaptchaDataHolder.getInstance().addCaptchaConnector(captchaConnector);
        // Initialize and register UsernameRecoveryReCaptchaConnector.
        captchaConnector = new UsernameRecoveryReCaptchaConnector();
        captchaConnector.init(CaptchaDataHolder.getInstance().getIdentityGovernanceService());
        CaptchaDataHolder.getInstance().addCaptchaConnector(captchaConnector);
        // Initialize and register PasswordRecoveryReCaptchaConnector.
        captchaConnector = new PasswordRecoveryReCaptchaConnector();
        captchaConnector.init(CaptchaDataHolder.getInstance().getIdentityGovernanceService());
        CaptchaDataHolder.getInstance().addCaptchaConnector(captchaConnector);
        // Initialize and register ResendConfirmationReCaptchaConnector.
        captchaConnector = new ResendConfirmationReCaptchaConnector();
        captchaConnector.init(CaptchaDataHolder.getInstance().getIdentityGovernanceService());
        CaptchaDataHolder.getInstance().addCaptchaConnector(captchaConnector);
        AuthenticationDataPublisher failedLoginAttemptValidator = new FailLoginAttemptValidator();
        context.getBundleContext().registerService(AuthenticationDataPublisher.class, failedLoginAttemptValidator, null);
        context.getBundleContext().registerService(AbstractEventHandler.class.getName(), new FailLoginAttemptValidationHandler(), null);
        if (log.isDebugEnabled()) {
            log.debug("Captcha Component is activated");
        }
    } catch (Throwable e) {
        log.error("Failed to start CaptchaComponent", e);
    }
}
Also used : FailLoginAttemptValidationHandler(org.wso2.carbon.identity.captcha.validator.FailLoginAttemptValidationHandler) SelfSignUpReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.SelfSignUpReCaptchaConnector) PasswordRecoveryReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.PasswordRecoveryReCaptchaConnector) CaptchaConnector(org.wso2.carbon.identity.captcha.connector.CaptchaConnector) ResendConfirmationReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.ResendConfirmationReCaptchaConnector) UsernameRecoveryReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.UsernameRecoveryReCaptchaConnector) IdentityConnectorConfig(org.wso2.carbon.identity.governance.common.IdentityConnectorConfig) SelfSignUpReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.SelfSignUpReCaptchaConnector) ResendConfirmationReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.ResendConfirmationReCaptchaConnector) AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) PasswordRecoveryReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.PasswordRecoveryReCaptchaConnector) SSOLoginReCaptchaConfig(org.wso2.carbon.identity.captcha.connector.recaptcha.SSOLoginReCaptchaConfig) UsernameRecoveryReCaptchaConnector(org.wso2.carbon.identity.captcha.connector.recaptcha.UsernameRecoveryReCaptchaConnector) AuthenticationDataPublisher(org.wso2.carbon.identity.application.authentication.framework.AuthenticationDataPublisher) FailLoginAttemptValidator(org.wso2.carbon.identity.captcha.validator.FailLoginAttemptValidator) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

IdentityConnectorConfig (org.wso2.carbon.identity.governance.common.IdentityConnectorConfig)4 ArrayList (java.util.ArrayList)2 BundleContext (org.osgi.framework.BundleContext)2 Activate (org.osgi.service.component.annotations.Activate)2 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)2 Properties (java.util.Properties)1 Reference (org.osgi.service.component.annotations.Reference)1 AuthenticationDataPublisher (org.wso2.carbon.identity.application.authentication.framework.AuthenticationDataPublisher)1 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)1 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)1 Property (org.wso2.carbon.identity.application.common.model.Property)1 CaptchaConnector (org.wso2.carbon.identity.captcha.connector.CaptchaConnector)1 PasswordRecoveryReCaptchaConnector (org.wso2.carbon.identity.captcha.connector.recaptcha.PasswordRecoveryReCaptchaConnector)1 ResendConfirmationReCaptchaConnector (org.wso2.carbon.identity.captcha.connector.recaptcha.ResendConfirmationReCaptchaConnector)1 SSOLoginReCaptchaConfig (org.wso2.carbon.identity.captcha.connector.recaptcha.SSOLoginReCaptchaConfig)1 SelfSignUpReCaptchaConnector (org.wso2.carbon.identity.captcha.connector.recaptcha.SelfSignUpReCaptchaConnector)1 UsernameRecoveryReCaptchaConnector (org.wso2.carbon.identity.captcha.connector.recaptcha.UsernameRecoveryReCaptchaConnector)1 FailLoginAttemptValidationHandler (org.wso2.carbon.identity.captcha.validator.FailLoginAttemptValidationHandler)1 FailLoginAttemptValidator (org.wso2.carbon.identity.captcha.validator.FailLoginAttemptValidator)1 ConnectorConfig (org.wso2.carbon.identity.core.ConnectorConfig)1