All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.rules.webstudio.security.OpenLAuthenticationProviderWrapper Maven / Gradle / Ivy

There is a newer version: 5.27.9
Show newest version
package org.openl.rules.webstudio.security;

import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;

public class OpenLAuthenticationProviderWrapper implements AuthenticationProvider {
    private final AuthenticationProvider delegate;

    public OpenLAuthenticationProviderWrapper(AuthenticationProvider delegate) {
        this.delegate = delegate;
    }

    @Override
    public Authentication authenticate(Authentication authentication) {
        if (!delegate.supports(authentication.getClass())) {
            return null;
        }

        try {
            AuthenticationHolder.setAuthentication(authentication);

            return delegate.authenticate(authentication);
        } finally {
            AuthenticationHolder.clear();
        }
    }

    @Override
    public boolean supports(Class authentication) {
        return authentication != null && Authentication.class.isAssignableFrom(authentication);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy