Search in sources :

Example 6 with CustomScriptConfiguration

use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.

the class IdTokenFactory method setAmrClaim.

private void setAmrClaim(JsonWebResponse jwt, String acrValues) {
    List<String> amrList = Lists.newArrayList();
    CustomScriptConfiguration script = externalAuthenticationService.getCustomScriptConfigurationByName(acrValues);
    if (script != null) {
        amrList.add(Integer.toString(script.getLevel()));
        PersonAuthenticationType externalAuthenticator = (PersonAuthenticationType) script.getExternalType();
        int apiVersion = externalAuthenticator.getApiVersion();
        if (apiVersion > 3) {
            Map<String, String> authenticationMethodClaimsOrNull = externalAuthenticator.getAuthenticationMethodClaims(script.getConfigurationAttributes());
            if (authenticationMethodClaimsOrNull != null) {
                for (String key : authenticationMethodClaimsOrNull.keySet()) {
                    amrList.add(key + ":" + authenticationMethodClaimsOrNull.get(key));
                }
            }
        }
    }
    jwt.getClaims().setClaim(JwtClaimName.AUTHENTICATION_METHOD_REFERENCES, amrList);
}
Also used : PersonAuthenticationType(io.jans.model.custom.script.type.auth.PersonAuthenticationType) CustomScriptConfiguration(io.jans.model.custom.script.conf.CustomScriptConfiguration)

Example 7 with CustomScriptConfiguration

use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.

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 : AuthenticationScriptUsageType(io.jans.model.AuthenticationScriptUsageType) CustomScriptConfiguration(io.jans.model.custom.script.conf.CustomScriptConfiguration)

Example 8 with CustomScriptConfiguration

use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.

the class ExternalAuthenticationService method getInternalCustomScriptConfiguration.

private CustomScriptConfiguration getInternalCustomScriptConfiguration(GluuLdapConfiguration ldapAuthConfig) {
    CustomScriptConfiguration customScriptConfiguration = getInternalCustomScriptConfiguration();
    customScriptConfiguration.getCustomScript().setName(ldapAuthConfig.getConfigId());
    return customScriptConfiguration;
}
Also used : CustomScriptConfiguration(io.jans.model.custom.script.conf.CustomScriptConfiguration)

Example 9 with CustomScriptConfiguration

use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.

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(io.jans.model.custom.script.model.CustomScript) AuthenticationCustomScript(io.jans.model.custom.script.model.auth.AuthenticationCustomScript) CustomScriptType(io.jans.model.custom.script.CustomScriptType) BaseExternalType(io.jans.model.custom.script.type.BaseExternalType) CustomScriptConfiguration(io.jans.model.custom.script.conf.CustomScriptConfiguration)

Example 10 with CustomScriptConfiguration

use of io.jans.model.custom.script.conf.CustomScriptConfiguration in project jans by JanssenProject.

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);
        // Also publish alias configuration
        if (script.getCustomScript() != null && script.getCustomScript().getAliases() != null) {
            for (String alias : script.getCustomScript().getAliases()) {
                if (StringUtils.isNotBlank(alias)) {
                    acrs.add(alias);
                }
            }
        }
    }
    return map;
}
Also used : CustomScriptConfiguration(io.jans.model.custom.script.conf.CustomScriptConfiguration)

Aggregations

CustomScriptConfiguration (io.jans.model.custom.script.conf.CustomScriptConfiguration)58 SessionId (io.jans.as.server.model.common.SessionId)8 Test (org.testng.annotations.Test)8 WebApplicationException (jakarta.ws.rs.WebApplicationException)7 CustomScript (io.jans.model.custom.script.model.CustomScript)6 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)6 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)5 ArrayList (java.util.ArrayList)5 AuthenticationScriptUsageType (io.jans.model.AuthenticationScriptUsageType)4 Client (io.jans.as.common.model.registration.Client)3 ConsentGatheringContext (io.jans.as.server.service.external.context.ConsentGatheringContext)3 UmaGatherContext (io.jans.as.server.uma.authorization.UmaGatherContext)3 SimpleCustomProperty (io.jans.model.SimpleCustomProperty)3 AuthenticationCustomScript (io.jans.model.custom.script.model.auth.AuthenticationCustomScript)3 ClientRegistrationType (io.jans.model.custom.script.type.client.ClientRegistrationType)3 User (io.jans.as.common.model.common.User)2 Scope (io.jans.as.persistence.model.Scope)2 CustomScriptType (io.jans.model.custom.script.CustomScriptType)2 BaseExternalType (io.jans.model.custom.script.type.BaseExternalType)2 DiscoveryType (io.jans.model.custom.script.type.discovery.DiscoveryType)2