Search in sources :

Example 11 with CustomScriptConfiguration

use of org.gluu.model.custom.script.conf.CustomScriptConfiguration 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 12 with CustomScriptConfiguration

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

the class ExternalDynamicScopeService method executeExternalGetSupportedClaimsMethods.

public List<String> executeExternalGetSupportedClaimsMethods(List<Scope> dynamicScope) {
    DynamicScopeExternalContext context = new DynamicScopeExternalContext(dynamicScope, null, null);
    Set<String> result = new HashSet<String>();
    for (CustomScriptConfiguration customScriptConfiguration : getScriptsToExecute(context)) {
        List<String> scriptResult = executeExternalGetSupportedClaimsMethod(customScriptConfiguration);
        if (scriptResult != null) {
            result.addAll(scriptResult);
        }
    }
    return new ArrayList<String>(result);
}
Also used : ArrayList(java.util.ArrayList) DynamicScopeExternalContext(org.gluu.oxauth.service.external.context.DynamicScopeExternalContext) CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration) HashSet(java.util.HashSet)

Example 13 with CustomScriptConfiguration

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

the class ExternalPostAuthnService method externalForceReAuthentication.

public boolean externalForceReAuthentication(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 (!externalForceReAuthentication(script, context)) {
            return false;
        }
    }
    log.debug("Forcing re-authentication via post-authn script.");
    return true;
}
Also used : CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 14 with CustomScriptConfiguration

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

the class ExternalSpontaneousScopeService method executeExternalManipulateScope.

public void executeExternalManipulateScope(SpontaneousScopeExternalContext context) {
    for (CustomScriptConfiguration script : getScriptsToExecute(context.getClient())) {
        executeExternalManipulateScope(script, context);
        log.debug("GrantedScopes {} after execution of interception script {}.", context.getGrantedScopes(), script.getName());
    }
}
Also used : CustomScriptConfiguration(org.gluu.model.custom.script.conf.CustomScriptConfiguration)

Example 15 with CustomScriptConfiguration

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

the class ExternalUmaClaimsGatheringService method determineScript.

public CustomScriptConfiguration determineScript(String[] scriptNames) {
    log.trace("Trying to determine claims-gathering script, scriptNames: {} ...", Arrays.toString(scriptNames));
    List<CustomScriptConfiguration> scripts = new ArrayList<CustomScriptConfiguration>();
    for (String scriptName : scriptNames) {
        CustomScriptConfiguration script = getCustomScriptConfigurationByName(scriptName);
        if (script != null) {
            scripts.add(script);
        } else {
            log.error("Failed to load claims-gathering script with name: {}", scriptName);
        }
    }
    if (scripts.isEmpty()) {
        return null;
    }
    CustomScriptConfiguration highestPriority = Collections.max(scripts, new Comparator<CustomScriptConfiguration>() {

        @Override
        public int compare(CustomScriptConfiguration o1, CustomScriptConfiguration o2) {
            return Integer.compare(o1.getLevel(), o2.getLevel());
        }
    });
    log.trace("Determined claims-gathering script successfully. Name: {}, inum: {}", highestPriority.getName(), highestPriority.getInum());
    return highestPriority;
}
Also used : ArrayList(java.util.ArrayList) 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