Search in sources :

Example 1 with BasicAuthorizationProvider

use of org.apache.logging.log4j.core.util.BasicAuthorizationProvider in project logging-log4j2 by apache.

the class ConfigurationFactory method authorizationProvider.

public static AuthorizationProvider authorizationProvider(final PropertiesUtil props) {
    final String authClass = props.getStringProperty(PREFIXES, AUTHORIZATION_PROVIDER, null);
    AuthorizationProvider provider = null;
    if (authClass != null) {
        try {
            final Object obj = LoaderUtil.newInstanceOf(authClass);
            if (obj instanceof AuthorizationProvider) {
                provider = (AuthorizationProvider) obj;
            } else {
                LOGGER.warn("{} is not an AuthorizationProvider, using default", obj.getClass().getName());
            }
        } catch (final Exception ex) {
            LOGGER.warn("Unable to create {}, using default: {}", authClass, ex.getMessage());
        }
    }
    if (provider == null) {
        provider = new BasicAuthorizationProvider(props);
    }
    return provider;
}
Also used : BasicAuthorizationProvider(org.apache.logging.log4j.core.util.BasicAuthorizationProvider) BasicAuthorizationProvider(org.apache.logging.log4j.core.util.BasicAuthorizationProvider) AuthorizationProvider(org.apache.logging.log4j.core.util.AuthorizationProvider) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 URISyntaxException (java.net.URISyntaxException)1 AuthorizationProvider (org.apache.logging.log4j.core.util.AuthorizationProvider)1 BasicAuthorizationProvider (org.apache.logging.log4j.core.util.BasicAuthorizationProvider)1