Search in sources :

Example 1 with CustomScript

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

the class IdGenServiceTest method removeCustomScript.

@Test(dependsOnMethods = "testCustomIdGenerationByPythonScript")
public void removeCustomScript() {
    CustomScript customScript = new CustomScript();
    customScript.setDn(this.idCustomScriptDn);
    ldapEntryManager.remove(customScript);
}
Also used : CustomScript(org.xdi.model.custom.script.model.CustomScript) BaseComponentTest(org.xdi.oxauth.BaseComponentTest) Test(org.testng.annotations.Test)

Example 2 with CustomScript

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

the class IdGenServiceTest method buildIdCustomScriptEntry.

private CustomScript buildIdCustomScriptEntry(String idScript) {
    String basedInum = configurationFactory.getAppConfiguration().getOrganizationInum();
    String customScriptId = basedInum + "!" + INumGenerator.generate(2);
    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.xdi.model.custom.script.model.CustomScript)

Example 3 with CustomScript

use of org.xdi.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 = this.applianceService.getCustomScriptTypes();
    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<SimpleCustomProperty>());
            }
            if (typedCustomScript.getModuleProperties() == null) {
                typedCustomScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
            }
            customScriptsByType.add(typedCustomScript);
        }
    } catch (Exception ex) {
        log.error("Failed to load custom scripts ", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.initialized = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : AuthenticationCustomScript(org.xdi.model.custom.script.model.auth.AuthenticationCustomScript) CustomScript(org.xdi.model.custom.script.model.CustomScript) CustomScriptType(org.xdi.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList) List(java.util.List) AuthenticationCustomScript(org.xdi.model.custom.script.model.auth.AuthenticationCustomScript) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 4 with CustomScript

use of org.xdi.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<SimpleCustomProperty>());
    customScriptsByType.add(customScript);
}
Also used : AuthenticationCustomScript(org.xdi.model.custom.script.model.auth.AuthenticationCustomScript) CustomScript(org.xdi.model.custom.script.model.CustomScript) AuthenticationCustomScript(org.xdi.model.custom.script.model.auth.AuthenticationCustomScript) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty)

Example 5 with CustomScript

use of org.xdi.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.xdi.model.custom.script.model.CustomScript) ArrayList(java.util.ArrayList) DisplayNameEntry(org.xdi.model.DisplayNameEntry)

Aggregations

CustomScript (org.xdi.model.custom.script.model.CustomScript)16 ArrayList (java.util.ArrayList)10 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)4 SimpleCustomProperty (org.xdi.model.SimpleCustomProperty)4 AuthenticationCustomScript (org.xdi.model.custom.script.model.auth.AuthenticationCustomScript)4 CustomScriptType (org.xdi.model.custom.script.CustomScriptType)3 List (java.util.List)2 Test (org.testng.annotations.Test)2 DisplayNameEntry (org.xdi.model.DisplayNameEntry)2 SelectableEntity (org.xdi.model.SelectableEntity)2 CustomScriptConfiguration (org.xdi.model.custom.script.conf.CustomScriptConfiguration)2 BaseComponentTest (org.xdi.oxauth.BaseComponentTest)2 Filter (com.unboundid.ldap.sdk.Filter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 BaseExternalType (org.xdi.model.custom.script.type.BaseExternalType)1