Search in sources :

Example 26 with CustomScriptConfiguration

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

the class ExternalAuthenticationService method groupCustomScriptConfigurationsMapByUsageType.

private Map<AuthenticationScriptUsageType, List<CustomScriptConfiguration>> groupCustomScriptConfigurationsMapByUsageType(Map<String, CustomScriptConfiguration> customScriptConfigurationsMap) {
    Map<AuthenticationScriptUsageType, List<CustomScriptConfiguration>> newCustomScriptConfigurationsMapByUsageType = new HashMap<AuthenticationScriptUsageType, List<CustomScriptConfiguration>>();
    for (AuthenticationScriptUsageType usageType : AuthenticationScriptUsageType.values()) {
        List<CustomScriptConfiguration> currCustomScriptConfigurationsMapByUsageType = new ArrayList<CustomScriptConfiguration>();
        for (CustomScriptConfiguration customScriptConfiguration : customScriptConfigurationsMap.values()) {
            if (!isValidateUsageType(usageType, customScriptConfiguration)) {
                continue;
            }
            currCustomScriptConfigurationsMapByUsageType.add(customScriptConfiguration);
        }
        newCustomScriptConfigurationsMapByUsageType.put(usageType, currCustomScriptConfigurationsMapByUsageType);
    }
    return newCustomScriptConfigurationsMapByUsageType;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AuthenticationScriptUsageType(org.gluu.model.AuthenticationScriptUsageType) CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 27 with CustomScriptConfiguration

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

the class ExternalAuthenticationService method levelToAcrMapping.

public Map<Integer, Set<String>> levelToAcrMapping() {
    Map<Integer, Set<String>> map = Maps.newHashMap();
    for (CustomScriptConfiguration script : getCustomScriptConfigurationsMap()) {
        int level = script.getLevel();
        String acr = script.getName();
        Set<String> acrs = map.get(level);
        if (acrs == null) {
            acrs = Sets.newHashSet();
            map.put(level, acrs);
        }
        acrs.add(acr);
    }
    return map;
}
Also used : Set(java.util.Set) CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 28 with CustomScriptConfiguration

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

the class ExternalAuthenticationService method getAuthModesByAcrValues.

public List<String> getAuthModesByAcrValues(List<String> acrValues) {
    List<String> authModes = new ArrayList<String>();
    for (String acrValue : acrValues) {
        if (StringHelper.isNotEmpty(acrValue)) {
            String customScriptName = StringHelper.toLowerCase(scriptName(acrValue));
            if (customScriptConfigurationsNameMap.containsKey(customScriptName)) {
                CustomScriptConfiguration customScriptConfiguration = customScriptConfigurationsNameMap.get(customScriptName);
                CustomScript customScript = customScriptConfiguration.getCustomScript();
                // Handle internal authentication method
                if (customScript.isInternal()) {
                    authModes.add(scriptName(acrValue));
                    continue;
                }
                CustomScriptType customScriptType = customScriptConfiguration.getCustomScript().getScriptType();
                BaseExternalType defaultImplementation = customScriptType.getDefaultImplementation();
                BaseExternalType pythonImplementation = customScriptConfiguration.getExternalType();
                if ((pythonImplementation != null) && (defaultImplementation != pythonImplementation)) {
                    authModes.add(scriptName(acrValue));
                }
            }
        }
    }
    return authModes;
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) AuthenticationCustomScript(org.gluu.model.custom.script.model.auth.AuthenticationCustomScript) CustomScriptType(org.gluu.model.custom.script.CustomScriptType) BaseExternalType(org.gluu.model.custom.script.type.BaseExternalType) ArrayList(java.util.ArrayList) CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 29 with CustomScriptConfiguration

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

the class ExternalDynamicScopeService method getScriptsToExecute.

private Set<CustomScriptConfiguration> getScriptsToExecute(DynamicScopeExternalContext context) {
    Set<String> allowedScripts = Sets.newHashSet();
    for (org.oxauth.persistence.model.Scope scope : context.getScopes()) {
        List<String> scopeScripts = scope.getDynamicScopeScripts();
        if (scopeScripts != null) {
            allowedScripts.addAll(scopeScripts);
        }
    }
    Set<CustomScriptConfiguration> result = Sets.newHashSet();
    if (this.customScriptConfigurations != null) {
        for (CustomScriptConfiguration script : this.customScriptConfigurations) {
            if (allowedScripts.contains(script.getCustomScript().getDn())) {
                result.add(script);
            }
        }
    }
    return result;
}
Also used : CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration) Scope(org.oxauth.persistence.model.Scope)

Example 30 with CustomScriptConfiguration

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

the class ExternalPostAuthnService method externalForceAuthorization.

public boolean externalForceAuthorization(Client client, ExternalPostAuthnContext context) {
    final List<CustomScriptConfiguration> scripts = getCustomScriptConfigurationsByDns(client.getAttributes().getPostAuthnScripts());
    if (scripts.isEmpty()) {
        return false;
    }
    log.trace("Found {} post-authn scripts.", scripts.size());
    for (CustomScriptConfiguration script : scripts) {
        if (!externalForceAuthorization(script, context)) {
            return false;
        }
    }
    log.debug("Forcing authorization via post-authn script.");
    return true;
}
Also used : CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Aggregations

CustomScriptConfiguration (org.gluu.model.custom.script.conf.CustomScriptConfiguration)35 SessionId (org.gluu.oxauth.model.common.SessionId)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 CustomScript (org.gluu.model.custom.script.model.CustomScript)3 AuthenticationCustomScript (org.gluu.model.custom.script.model.auth.AuthenticationCustomScript)3 ConsentGatheringContext (org.gluu.oxauth.service.external.context.ConsentGatheringContext)3 UmaGatherContext (org.gluu.oxauth.uma.authorization.UmaGatherContext)3 AuthenticationScriptUsageType (org.gluu.model.AuthenticationScriptUsageType)2 User (org.gluu.oxauth.model.common.User)2 Client (org.gluu.oxauth.model.registration.Client)2 Scope (org.oxauth.persistence.model.Scope)2 IOException (java.io.IOException)1 URI (java.net.URI)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1