Search in sources :

Example 1 with AuthenticationScriptUsageType

use of org.xdi.model.AuthenticationScriptUsageType 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 : CustomScriptConfiguration(org.xdi.model.custom.script.conf.CustomScriptConfiguration) AuthenticationScriptUsageType(org.xdi.model.AuthenticationScriptUsageType)

Example 2 with AuthenticationScriptUsageType

use of org.xdi.model.AuthenticationScriptUsageType in project oxAuth by GluuFederation.

the class ExternalAuthenticationService method determineDefaultCustomScriptConfigurationsMap.

private Map<AuthenticationScriptUsageType, CustomScriptConfiguration> determineDefaultCustomScriptConfigurationsMap(Map<String, CustomScriptConfiguration> customScriptConfigurationsMap) {
    Map<AuthenticationScriptUsageType, CustomScriptConfiguration> newDefaultCustomScriptConfigurationsMap = new HashMap<AuthenticationScriptUsageType, CustomScriptConfiguration>();
    for (AuthenticationScriptUsageType usageType : AuthenticationScriptUsageType.values()) {
        CustomScriptConfiguration defaultExternalAuthenticator = null;
        for (CustomScriptConfiguration customScriptConfiguration : customScriptConfigurationsMapByUsageType.get(usageType)) {
            // Determine default authenticator
            if ((defaultExternalAuthenticator == null) || (defaultExternalAuthenticator.getLevel() < customScriptConfiguration.getLevel())) {
                defaultExternalAuthenticator = customScriptConfiguration;
            }
        }
        newDefaultCustomScriptConfigurationsMap.put(usageType, defaultExternalAuthenticator);
    }
    return newDefaultCustomScriptConfigurationsMap;
}
Also used : AuthenticationScriptUsageType(org.xdi.model.AuthenticationScriptUsageType) CustomScriptConfiguration(org.xdi.model.custom.script.conf.CustomScriptConfiguration)

Example 3 with AuthenticationScriptUsageType

use of org.xdi.model.AuthenticationScriptUsageType in project oxAuth by GluuFederation.

the class LdapCustomAuthenticationConfigurationService method mapCustomAuthentication.

private CustomAuthenticationConfiguration mapCustomAuthentication(oxIDPAuthConf oneConf) {
    CustomAuthenticationConfiguration customAuthenticationConfig = new CustomAuthenticationConfiguration();
    customAuthenticationConfig.setName(oneConf.getName());
    customAuthenticationConfig.setLevel(oneConf.getLevel());
    customAuthenticationConfig.setPriority(oneConf.getPriority());
    customAuthenticationConfig.setEnabled(oneConf.getEnabled());
    customAuthenticationConfig.setVersion(oneConf.getVersion());
    for (CustomProperty customProperty : oneConf.getFields()) {
        if ((customProperty.getValues() == null) || (customProperty.getValues().size() == 0)) {
            continue;
        }
        String attrName = StringHelper.toLowerCase(customProperty.getName());
        if (StringHelper.isEmpty(attrName)) {
            continue;
        }
        String value = customProperty.getValues().get(0);
        if (attrName.startsWith(CUSTOM_AUTHENTICATION_PROPERTY_PREFIX)) {
            String key = customProperty.getName().substring(CUSTOM_AUTHENTICATION_PROPERTY_PREFIX.length());
            SimpleCustomProperty property = new SimpleCustomProperty(key, value);
            customAuthenticationConfig.getCustomAuthenticationAttributes().add(property);
        } else if (StringHelper.equalsIgnoreCase(attrName, CUSTOM_AUTHENTICATION_SCRIPT_PROPERTY_NAME)) {
            customAuthenticationConfig.setCustomAuthenticationScript(value);
        } else if (StringHelper.equalsIgnoreCase(attrName, CUSTOM_AUTHENTICATION_SCRIPT_USAGE_TYPE)) {
            if (StringHelper.isNotEmpty(value)) {
                AuthenticationScriptUsageType authenticationScriptUsageType = AuthenticationScriptUsageType.getByValue(value);
                customAuthenticationConfig.setUsageType(authenticationScriptUsageType);
            }
        }
    }
    return customAuthenticationConfig;
}
Also used : CustomAuthenticationConfiguration(org.xdi.model.config.CustomAuthenticationConfiguration) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) CustomProperty(org.xdi.oxauth.model.config.CustomProperty) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) AuthenticationScriptUsageType(org.xdi.model.AuthenticationScriptUsageType)

Example 4 with AuthenticationScriptUsageType

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

Aggregations

AuthenticationScriptUsageType (org.xdi.model.AuthenticationScriptUsageType)4 SimpleCustomProperty (org.xdi.model.SimpleCustomProperty)2 CustomScriptConfiguration (org.xdi.model.custom.script.conf.CustomScriptConfiguration)2 CustomAuthenticationConfiguration (org.xdi.model.config.CustomAuthenticationConfiguration)1 CustomProperty (org.xdi.oxauth.model.config.CustomProperty)1