Search in sources :

Example 1 with Http403ForbiddenEntryPoint

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

the class JeeConfigurer method init.

/**
 * Populates a {@link PreAuthenticatedAuthenticationProvider} into
 * {@link HttpSecurity#authenticationProvider(org.springframework.security.authentication.AuthenticationProvider)}
 * and a {@link Http403ForbiddenEntryPoint} into
 * {@link HttpSecurityBuilder#setSharedObject(Class, Object)}
 *
 * @see org.springframework.security.config.annotation.SecurityConfigurerAdapter#init(org.springframework.security.config.annotation.SecurityBuilder)
 */
@Override
public void init(H http) {
    PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
    authenticationProvider.setPreAuthenticatedUserDetailsService(getUserDetailsService());
    authenticationProvider = postProcess(authenticationProvider);
    http.authenticationProvider(authenticationProvider).setSharedObject(AuthenticationEntryPoint.class, new Http403ForbiddenEntryPoint());
}
Also used : PreAuthenticatedAuthenticationProvider(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider) Http403ForbiddenEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)

Example 2 with Http403ForbiddenEntryPoint

use of org.springframework.security.web.authentication.Http403ForbiddenEntryPoint in project midpoint by Evolveum.

the class MidpointExceptionHandlingConfigurer method createDefaultEntryPoint.

private AuthenticationEntryPoint createDefaultEntryPoint() {
    if (this.defaultEntryPointMappings.isEmpty()) {
        return new Http403ForbiddenEntryPoint();
    }
    if (this.defaultEntryPointMappings.size() == 1) {
        return this.defaultEntryPointMappings.values().iterator().next();
    }
    DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(this.defaultEntryPointMappings);
    entryPoint.setDefaultEntryPoint(this.defaultEntryPointMappings.values().iterator().next());
    return entryPoint;
}
Also used : DelegatingAuthenticationEntryPoint(org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint) Http403ForbiddenEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)

Example 3 with Http403ForbiddenEntryPoint

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

the class X509Configurer method init.

@Override
public void init(H http) {
    PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
    authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));
    http.authenticationProvider(authenticationProvider).setSharedObject(AuthenticationEntryPoint.class, new Http403ForbiddenEntryPoint());
}
Also used : PreAuthenticatedAuthenticationProvider(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider) Http403ForbiddenEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)

Example 4 with Http403ForbiddenEntryPoint

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

the class ExceptionHandlingConfigurer method createDefaultEntryPoint.

private AuthenticationEntryPoint createDefaultEntryPoint(H http) {
    if (this.defaultEntryPointMappings.isEmpty()) {
        return new Http403ForbiddenEntryPoint();
    }
    if (this.defaultEntryPointMappings.size() == 1) {
        return this.defaultEntryPointMappings.values().iterator().next();
    }
    DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(this.defaultEntryPointMappings);
    entryPoint.setDefaultEntryPoint(this.defaultEntryPointMappings.values().iterator().next());
    return entryPoint;
}
Also used : DelegatingAuthenticationEntryPoint(org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint) Http403ForbiddenEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)

Example 5 with Http403ForbiddenEntryPoint

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

the class Http403ForbiddenEntryPointTests method testCommence.

public void testCommence() throws IOException {
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse resp = new MockHttpServletResponse();
    Http403ForbiddenEntryPoint fep = new Http403ForbiddenEntryPoint();
    fep.commence(req, resp, new AuthenticationCredentialsNotFoundException("test"));
    assertThat(resp.getStatus()).withFailMessage("Incorrect status").isEqualTo(HttpServletResponse.SC_FORBIDDEN);
}
Also used : AuthenticationCredentialsNotFoundException(org.springframework.security.authentication.AuthenticationCredentialsNotFoundException) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Http403ForbiddenEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

Http403ForbiddenEntryPoint (org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)5 DelegatingAuthenticationEntryPoint (org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint)2 PreAuthenticatedAuthenticationProvider (org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 AuthenticationCredentialsNotFoundException (org.springframework.security.authentication.AuthenticationCredentialsNotFoundException)1