Search in sources :

Example 1 with CustomScript

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

the class IdGenServiceTest method buildIdCustomScriptEntry.

private CustomScript buildIdCustomScriptEntry(String idScript) {
    String customScriptId = UUID.randomUUID().toString();
    String dn = customScriptService.buildDn(customScriptId);
    CustomScript customScript = new CustomScript();
    customScript.setDn(dn);
    customScript.setInum(customScriptId);
    customScript.setProgrammingLanguage(ProgrammingLanguage.PYTHON);
    customScript.setScriptType(CustomScriptType.ID_GENERATOR);
    customScript.setScript(idScript);
    customScript.setName("test_id");
    customScript.setLevel(0);
    customScript.setEnabled(true);
    customScript.setRevision(1);
    return customScript;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript)

Example 2 with CustomScript

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

the class ExternalAuthenticationService method buildScriptAliases.

private HashMap<String, String> buildScriptAliases() {
    HashMap<String, String> newScriptAliases = new HashMap<String, String>();
    for (Entry<String, CustomScriptConfiguration> script : customScriptConfigurationsNameMap.entrySet()) {
        String name = script.getKey();
        CustomScript customScript = script.getValue().getCustomScript();
        newScriptAliases.put(name, name);
        List<String> aliases = customScript.getAliases();
        if (aliases != null) {
            for (String alias : aliases) {
                if (StringUtils.isNotBlank(alias)) {
                    newScriptAliases.put(alias, name);
                }
            }
        }
    }
    return newScriptAliases;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) HashMap(java.util.HashMap) CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 3 with CustomScript

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

the class ExternalAuthenticationService method getInternalCustomScriptConfiguration.

private CustomScriptConfiguration getInternalCustomScriptConfiguration() {
    CustomScript customScript = new AuthenticationCustomScript() {

        @Override
        public AuthenticationScriptUsageType getUsageType() {
            return AuthenticationScriptUsageType.INTERACTIVE;
        }
    };
    customScript.setName(OxConstants.SCRIPT_TYPE_INTERNAL_RESERVED_NAME);
    customScript.setLevel(-1);
    customScript.setInternal(true);
    CustomScriptConfiguration customScriptConfiguration = new CustomScriptConfiguration(customScript, internalDefaultPersonAuthenticationType, new HashMap<String, SimpleCustomProperty>(0));
    return customScriptConfiguration;
}
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) SimpleCustomProperty(org.gluu.model.SimpleCustomProperty) CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 4 with CustomScript

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

the class AbstractCustomScriptService method findCustomScripts.

public List<CustomScript> findCustomScripts(List<CustomScriptType> customScriptTypes, String... returnAttributes) {
    String baseDn = baseDn();
    if ((customScriptTypes == null) || (customScriptTypes.size() == 0)) {
        return findAllCustomScripts(returnAttributes);
    }
    List<Filter> customScriptTypeFilters = new ArrayList<Filter>();
    for (CustomScriptType customScriptType : customScriptTypes) {
        Filter customScriptTypeFilter = Filter.createEqualityFilter("oxScriptType", customScriptType.getValue());
        customScriptTypeFilters.add(customScriptTypeFilter);
    }
    Filter filter = Filter.createORFilter(customScriptTypeFilters);
    List<CustomScript> result = persistenceEntryManager.findEntries(baseDn, CustomScript.class, filter, returnAttributes);
    return result;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) Filter(org.gluu.search.filter.Filter) CustomScriptType(org.gluu.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList)

Example 5 with CustomScript

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

the class AbstractCustomScriptService method getScriptByDisplayName.

public CustomScript getScriptByDisplayName(String name) {
    Filter searchFilter = Filter.createEqualityFilter("displayName", name);
    List<CustomScript> result = persistenceEntryManager.findEntries(baseDn(), CustomScript.class, searchFilter, 1);
    if (result != null && !result.isEmpty()) {
        return result.get(0);
    }
    return null;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) Filter(org.gluu.search.filter.Filter)

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