Search in sources :

Example 11 with SimpleCustomProperty

use of org.xdi.model.SimpleCustomProperty in project oxCore by GluuFederation.

the class CustomScriptManager method executeCustomScriptDestroy.

public boolean executeCustomScriptDestroy(CustomScriptConfiguration customScriptConfiguration) {
    try {
        log.debug("Executing python 'destroy' custom script method");
        BaseExternalType externalType = customScriptConfiguration.getExternalType();
        Map<String, SimpleCustomProperty> configurationAttributes = customScriptConfiguration.getConfigurationAttributes();
        return externalType.destroy(configurationAttributes);
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
    }
    return false;
}
Also used : BaseExternalType(org.xdi.model.custom.script.type.BaseExternalType) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) PythonException(org.xdi.exception.PythonException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 12 with SimpleCustomProperty

use of org.xdi.model.SimpleCustomProperty in project oxCore by GluuFederation.

the class CustomScript method getModuleProperty.

protected SimpleCustomProperty getModuleProperty(final String modulePropertyName) {
    SimpleCustomProperty result = null;
    List<SimpleCustomProperty> moduleProperties = getModuleProperties();
    if (moduleProperties == null) {
        return result;
    }
    for (SimpleCustomProperty moduleProperty : getModuleProperties()) {
        if (StringHelper.equalsIgnoreCase(moduleProperty.getValue1(), modulePropertyName)) {
            result = moduleProperty;
            break;
        }
    }
    return result;
}
Also used : SimpleCustomProperty(org.xdi.model.SimpleCustomProperty)

Example 13 with SimpleCustomProperty

use of org.xdi.model.SimpleCustomProperty in project oxCore by GluuFederation.

the class AuthenticationCustomScript method getUsageType.

public AuthenticationScriptUsageType getUsageType() {
    SimpleCustomProperty moduleProperty = getModuleProperty(USAGE_TYPE_MODEL_PROPERTY);
    AuthenticationScriptUsageType usageType = null;
    if (moduleProperty == null) {
        return usageType;
    }
    return AuthenticationScriptUsageType.getByValue(moduleProperty.getValue2());
}
Also used : SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) AuthenticationScriptUsageType(org.xdi.model.AuthenticationScriptUsageType)

Example 14 with SimpleCustomProperty

use of org.xdi.model.SimpleCustomProperty 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 15 with SimpleCustomProperty

use of org.xdi.model.SimpleCustomProperty 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)

Aggregations

SimpleCustomProperty (org.xdi.model.SimpleCustomProperty)41 PersonAuthenticationType (org.xdi.model.custom.script.type.auth.PersonAuthenticationType)10 InternalDefaultPersonAuthenticationType (org.xdi.oxauth.service.external.internal.InternalDefaultPersonAuthenticationType)10 ScimType (org.xdi.model.custom.script.type.scim.ScimType)6 CustomScript (org.xdi.model.custom.script.model.CustomScript)4 UpdateUserType (org.xdi.model.custom.script.type.user.UpdateUserType)4 UserRegistrationType (org.xdi.model.custom.script.type.user.UserRegistrationType)4 AuthenticationCustomScript (org.xdi.model.custom.script.model.auth.AuthenticationCustomScript)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AuthenticationScriptUsageType (org.xdi.model.AuthenticationScriptUsageType)2 CustomScriptConfiguration (org.xdi.model.custom.script.conf.CustomScriptConfiguration)2 BaseExternalType (org.xdi.model.custom.script.type.BaseExternalType)2 IdGeneratorType (org.xdi.model.custom.script.type.id.IdGeneratorType)2 File (java.io.File)1 FileFilter (java.io.FileFilter)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 List (java.util.List)1 Entry (java.util.Map.Entry)1