Search in sources :

Example 11 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateScopeAction method fillAvailableDynScript.

private void fillAvailableDynScript() {
    List<CustomScript> availableScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.DYNAMIC_SCOPE));
    List<SelectableEntity<CustomScript>> tmpAvailableDynamicScripts = new ArrayList<SelectableEntity<CustomScript>>();
    for (CustomScript dynamicScript : availableScripts) {
        if (dynamicScript.isEnabled()) {
            tmpAvailableDynamicScripts.add(new SelectableEntity<CustomScript>(dynamicScript));
        }
    }
    availableDynamicScripts.addAll(tmpAvailableDynamicScripts);
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) SelectableEntity(org.gluu.model.SelectableEntity) ArrayList(java.util.ArrayList)

Example 12 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateScopeAction method getInitialDynamicScripts.

private List<CustomScript> getInitialDynamicScripts() {
    List<CustomScript> result = new ArrayList<CustomScript>();
    if ((this.scope.getDynamicScopeScripts() == null) || (this.scope.getDynamicScopeScripts().size() == 0)) {
        return result;
    }
    List<DisplayNameEntry> displayNameEntries = lookupService.getDisplayNameEntries(customScriptService.baseDn(), this.scope.getDynamicScopeScripts());
    if (displayNameEntries != null) {
        for (DisplayNameEntry displayNameEntry : displayNameEntries) {
            result.add(new CustomScript(displayNameEntry.getDn(), displayNameEntry.getInum(), displayNameEntry.getDisplayName()));
        }
    }
    return result;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) ArrayList(java.util.ArrayList) DisplayNameEntry(org.gluu.model.DisplayNameEntry)

Example 13 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateScopeAction method searchAvailableDynamicScripts.

public void searchAvailableDynamicScripts() {
    if (this.availableDynamicScripts != null) {
        selectAddedDynamicScripts();
        return;
    }
    try {
        List<CustomScript> availableScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.DYNAMIC_SCOPE), CUSTOM_SCRIPT_RETURN_ATTRIBUTES);
        List<SelectableEntity<CustomScript>> tmpAvailableDynamicScripts = new ArrayList<SelectableEntity<CustomScript>>();
        for (CustomScript dynamicScript : availableScripts) {
            if (dynamicScript.isEnabled()) {
                tmpAvailableDynamicScripts.add(new SelectableEntity<CustomScript>(dynamicScript));
            }
        }
        this.availableDynamicScripts = tmpAvailableDynamicScripts;
        selectAddedDynamicScripts();
    } catch (BasePersistenceException ex) {
        log.error("Failed to find available authorization policies", ex);
    }
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) SelectableEntity(org.gluu.model.SelectableEntity) ArrayList(java.util.ArrayList)

Example 14 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class UpdateGluuRadiusConfigAction method getRoPasswordScripts.

public List<String> getRoPasswordScripts() {
    List<String> ret = new ArrayList<String>();
    List<CustomScriptType> types = Arrays.asList(CustomScriptType.RESOURCE_OWNER_PASSWORD_CREDENTIALS);
    List<CustomScript> scripts = customScriptService.findCustomScripts(types);
    for (CustomScript script : scripts) {
        if (script.isEnabled())
            ret.add(script.getName());
    }
    return ret;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) CustomScriptType(org.gluu.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList)

Example 15 with CustomScript

use of org.gluu.model.custom.script.model.CustomScript in project oxTrust by GluuFederation.

the class ManageOtherCustomScriptAction 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)

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