Search in sources :

Example 1 with BasicAuthenticationFilter

use of org.springframework.security.web.authentication.www.BasicAuthenticationFilter in project motech by motech.

the class SecurityRuleBuilder method addAuthenticationFilters.

private void addAuthenticationFilters(List<Filter> filters, MotechURLSecurityRule securityRule) {
    List<Scheme> supportedSchemes = securityRule.getSupportedSchemes();
    if (securityRule.isRest()) {
        if (supportedSchemes.contains(Scheme.BASIC)) {
            MotechRestBasicAuthenticationEntryPoint restAuthPoint = new MotechRestBasicAuthenticationEntryPoint(settingsFacade);
            BasicAuthenticationFilter basicAuthFilter = new BasicAuthenticationFilter(authenticationManager, restAuthPoint);
            filters.add(basicAuthFilter);
        }
    } else {
        if (supportedSchemes.contains(Scheme.USERNAME_PASSWORD)) {
            filters.add(usernamePasswordAuthenticationFilter);
        }
        if (supportedSchemes.contains(Scheme.OPEN_ID)) {
            filters.add(openIDAuthenticationFilter);
        }
    }
}
Also used : Scheme(org.motechproject.security.constants.Scheme) MotechRestBasicAuthenticationEntryPoint(org.motechproject.security.authentication.MotechRestBasicAuthenticationEntryPoint) BasicAuthenticationFilter(org.springframework.security.web.authentication.www.BasicAuthenticationFilter)

Example 2 with BasicAuthenticationFilter

use of org.springframework.security.web.authentication.www.BasicAuthenticationFilter in project spring-security by spring-projects.

the class HttpBasicConfigurer method configure.

@Override
public void configure(B http) {
    AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class);
    BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter(authenticationManager, this.authenticationEntryPoint);
    if (this.authenticationDetailsSource != null) {
        basicAuthenticationFilter.setAuthenticationDetailsSource(this.authenticationDetailsSource);
    }
    RememberMeServices rememberMeServices = http.getSharedObject(RememberMeServices.class);
    if (rememberMeServices != null) {
        basicAuthenticationFilter.setRememberMeServices(rememberMeServices);
    }
    basicAuthenticationFilter = postProcess(basicAuthenticationFilter);
    http.addFilter(basicAuthenticationFilter);
}
Also used : AuthenticationManager(org.springframework.security.authentication.AuthenticationManager) RememberMeServices(org.springframework.security.web.authentication.RememberMeServices) BasicAuthenticationFilter(org.springframework.security.web.authentication.www.BasicAuthenticationFilter)

Aggregations

BasicAuthenticationFilter (org.springframework.security.web.authentication.www.BasicAuthenticationFilter)2 MotechRestBasicAuthenticationEntryPoint (org.motechproject.security.authentication.MotechRestBasicAuthenticationEntryPoint)1 Scheme (org.motechproject.security.constants.Scheme)1 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)1 RememberMeServices (org.springframework.security.web.authentication.RememberMeServices)1