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;
}
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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations