use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManageCustomScriptAction method modify.
public String modify() {
if (this.initialized) {
return OxTrustConstants.RESULT_SUCCESS;
}
CustomScriptType[] allowedCustomScriptTypes = getScriptType();
this.customScriptsByTypes = new HashMap<CustomScriptType, List<CustomScript>>();
for (CustomScriptType customScriptType : allowedCustomScriptTypes) {
this.customScriptsByTypes.put(customScriptType, new ArrayList<CustomScript>());
}
try {
List<CustomScript> customScripts = customScriptService.findCustomScripts(Arrays.asList(allowedCustomScriptTypes));
for (CustomScript customScript : customScripts) {
CustomScriptType customScriptType = customScript.getScriptType();
List<CustomScript> customScriptsByType = this.customScriptsByTypes.get(customScriptType);
CustomScript typedCustomScript = customScript;
if (CustomScriptType.PERSON_AUTHENTICATION == customScriptType) {
typedCustomScript = new AuthenticationCustomScript(customScript);
}
if (typedCustomScript.getConfigurationProperties() == null) {
typedCustomScript.setConfigurationProperties(new ArrayList<SimpleExtendedCustomProperty>());
}
if (typedCustomScript.getModuleProperties() == null) {
typedCustomScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
}
customScriptsByType.add(typedCustomScript);
}
} catch (Exception ex) {
log.error("Failed to load custom scripts ", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to load custom scripts");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
this.initialized = true;
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManageCustomScriptAction method addCustomScript.
public void addCustomScript(CustomScriptType scriptType) {
List<CustomScript> customScriptsByType = this.customScriptsByTypes.get(scriptType);
CustomScript customScript;
if (CustomScriptType.PERSON_AUTHENTICATION == scriptType) {
AuthenticationCustomScript authenticationCustomScript = new AuthenticationCustomScript();
authenticationCustomScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
authenticationCustomScript.setUsageType(AuthenticationScriptUsageType.INTERACTIVE);
customScript = authenticationCustomScript;
} else {
customScript = new CustomScript();
customScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
}
customScript.setLocationType(ScriptLocationType.LDAP);
customScript.setScriptType(scriptType);
customScript.setProgrammingLanguage(ProgrammingLanguage.PYTHON);
customScript.setConfigurationProperties(new ArrayList<SimpleExtendedCustomProperty>());
customScriptsByType.add(customScript);
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManageCustomScriptAction method cleanAcrs.
private Set<String> cleanAcrs(String name) {
Set<String> result = new HashSet<>();
result.addAll(allAcrs);
List<CustomScript> scripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION));
for (CustomScript customScript : scripts) {
if (null == customScript.getAliases())
customScript.setAliases(new ArrayList<>());
if (customScript.getName() != null) {
if (!customScript.getName().equals(name)) {
List<String> existing = customScript.getAliases();
if (existing != null && existing.size() > 0) {
for (String value : existing) {
result.remove(value);
}
}
}
}
}
return result;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class ManagePersonAuthenticationAction method getPersonAuthenticationConfigurationNames.
public List<String> getPersonAuthenticationConfigurationNames() {
if (this.customAuthenticationConfigNames == null) {
this.customAuthenticationConfigNames = new ArrayList<String>();
for (CustomScript customScript : this.customScripts) {
if (customScript.isEnabled()) {
String name = customScript.getName();
if (StringHelper.isEmpty(name)) {
continue;
}
this.customAuthenticationConfigNames.add(customScript.getName());
}
}
boolean internalServerName = true;
for (GluuLdapConfiguration ldapConfig : this.sourceConfigs) {
if ((ldapConfig != null) && StringHelper.isNotEmpty(ldapConfig.getConfigId()) && ldapConfig.isEnabled()) {
this.customAuthenticationConfigNames.add(ldapConfig.getConfigId());
internalServerName = false;
}
}
if (internalServerName) {
this.customAuthenticationConfigNames.add(OxConstants.SCRIPT_TYPE_INTERNAL_RESERVED_NAME);
}
if (shouldEnableSimplePasswordAuth() && !this.customAuthenticationConfigNames.contains(SIMPLE_PASSWORD_AUTH)) {
this.customAuthenticationConfigNames.add(SIMPLE_PASSWORD_AUTH);
}
}
return this.customAuthenticationConfigNames;
}
use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.
the class UpdateClientAction method getInitialAcrs.
private List<CustomScript> getInitialAcrs() {
this.customScripts = new ArrayList<CustomScript>();
if (this.client.getDefaultAcrValues() != null && this.client.getDefaultAcrValues().length >= 1) {
for (String scriptName : this.client.getDefaultAcrValues()) {
CustomScript customScript = new CustomScript();
customScript.setName(scriptName);
this.customScripts.add(customScript);
}
}
return this.customScripts;
}
Aggregations