use of org.wso2.carbon.user.mgt.ui.client.IdentityGovernanceAdminClient 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;
}
use of org.wso2.carbon.user.mgt.ui.client.IdentityGovernanceAdminClient 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();
}
Aggregations