Search in sources :

Example 6 with CustomScript

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;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) SimpleExtendedCustomProperty(org.gluu.model.SimpleExtendedCustomProperty) CustomScriptType(org.gluu.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList) List(java.util.List) SimpleCustomProperty(org.gluu.model.SimpleCustomProperty)

Example 7 with CustomScript

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);
}
Also used : SimpleExtendedCustomProperty(org.gluu.model.SimpleExtendedCustomProperty) CustomScript(org.gluu.model.custom.script.model.CustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) SimpleCustomProperty(org.gluu.model.SimpleCustomProperty)

Example 8 with 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;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 9 with CustomScript

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;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 10 with CustomScript

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;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript)

Aggregations

CustomScript (org.gluu.model.custom.script.model.CustomScript)42 ArrayList (java.util.ArrayList)20 AuthenticationCustomScript (org.gluu.model.custom.script.model.auth.AuthenticationCustomScript)11 CustomScriptType (org.gluu.model.custom.script.CustomScriptType)8 IOException (java.io.IOException)7 SimpleCustomProperty (org.gluu.model.SimpleCustomProperty)6 HttpEntity (org.apache.http.HttpEntity)5 HttpResponse (org.apache.http.HttpResponse)5 ParseException (org.apache.http.ParseException)5 SimpleExtendedCustomProperty (org.gluu.model.SimpleExtendedCustomProperty)5 Test (org.junit.Test)5 List (java.util.List)4 CustomScriptConfiguration (org.gluu.model.custom.script.conf.CustomScriptConfiguration)4 HttpGet (org.apache.http.client.methods.HttpGet)3 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)3 SelectableEntity (org.gluu.model.SelectableEntity)3 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)3 Filter (org.gluu.search.filter.Filter)3 Operation (io.swagger.v3.oas.annotations.Operation)2 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)2