Package org.springframework.security.web

Examples of org.springframework.security.web.AuthenticationEntryPoint


    public void setUp() throws Exception {
        AnonymousAuthenticationFilter aaf = new AnonymousAuthenticationFilter("anonymous");
        fsi = new FilterSecurityInterceptor();
        fsi.setAccessDecisionManager(accessDecisionManager);
        fsi.setSecurityMetadataSource(metadataSource);
        AuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint("/login");
        ExceptionTranslationFilter etf = new ExceptionTranslationFilter(authenticationEntryPoint);
        DefaultSecurityFilterChain securityChain = new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, aaf, etf, fsi);
        fcp = new FilterChainProxy(securityChain);
        validator = new DefaultFilterChainValidator();
        Whitebox.setInternalState(validator, "logger", logger);
View Full Code Here


        for (RequestMatcher requestMatcher : entryPoints.keySet()) {
            if(logger.isDebugEnabled()) {
                logger.debug("Trying to match using " + requestMatcher);
            }
            if (requestMatcher.matches(request)) {
               AuthenticationEntryPoint entryPoint = entryPoints.get(requestMatcher);
               if(logger.isDebugEnabled()) {
                   logger.debug("Match found! Executing " + entryPoint);
               }
               entryPoint.commence(request, response, authException);
               return;
            }
        }

        if(logger.isDebugEnabled()) {
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public void configure(H http) throws Exception {
        AuthenticationEntryPoint authenticationEntryPoint = null;
        ExceptionHandlingConfigurer<?> exceptionConf = http.getConfigurer(ExceptionHandlingConfigurer.class);
        if(exceptionConf != null) {
            authenticationEntryPoint = exceptionConf.getAuthenticationEntryPoint();
        }
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public void configure(H http) throws Exception {
        securityContextRequestFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
        ExceptionHandlingConfigurer<H> exceptionConf = http.getConfigurer(ExceptionHandlingConfigurer.class);
        AuthenticationEntryPoint authenticationEntryPoint = exceptionConf == null ? null : exceptionConf.getAuthenticationEntryPoint(http);
        securityContextRequestFilter.setAuthenticationEntryPoint(authenticationEntryPoint);
        LogoutConfigurer<H> logoutConf = http.getConfigurer(LogoutConfigurer.class);
        List<LogoutHandler> logoutHandlers = logoutConf == null ? null : logoutConf.getLogoutHandlers();
        securityContextRequestFilter.setLogoutHandlers(logoutHandlers);
        AuthenticationTrustResolver trustResolver = http.getSharedObject(AuthenticationTrustResolver.class);
View Full Code Here

        return this.accessDeniedHandler;
    }

    @Override
    public void configure(H http) throws Exception {
        AuthenticationEntryPoint entryPoint = getAuthenticationEntryPoint(http);
        ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(entryPoint, getRequestCache(http));
        if(accessDeniedHandler != null) {
            exceptionTranslationFilter.setAccessDeniedHandler(accessDeniedHandler);
        }
        exceptionTranslationFilter = postProcess(exceptionTranslationFilter);
View Full Code Here

     * Gets the {@link AuthenticationEntryPoint} according to the rules specified by {@link #authenticationEntryPoint(AuthenticationEntryPoint)}
     * @param http the {@link HttpSecurity} used to look up shared {@link AuthenticationEntryPoint}
     * @return the {@link AuthenticationEntryPoint} to use
     */
     AuthenticationEntryPoint getAuthenticationEntryPoint(H http) {
        AuthenticationEntryPoint entryPoint = this.authenticationEntryPoint;
        if(entryPoint == null) {
            entryPoint = createDefaultEntryPoint(http);
        }
        return entryPoint;
    }
View Full Code Here

            AsyncContext startAsync = super.startAsync(servletRequest, servletResponse);
            return new SecurityContextAsyncContext(startAsync);
        }

        public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {
            AuthenticationEntryPoint entryPoint = authenticationEntryPoint;
            if(entryPoint == null) {
                logger.debug("authenticationEntryPoint is null, so allowing original HttpServletRequest to handle authenticate");
                return super.authenticate(response);
            }
            if(isAuthenticated()) {
                return true;
            }
            entryPoint.commence(this, response, new AuthenticationCredentialsNotFoundException("User is not Authenticated"));
            return false;
        }
View Full Code Here

        daep.setDefaultEntryPoint(defaultEntryPoint);
    }

    @Test
    public void testDefaultEntryPoint() throws Exception {
        AuthenticationEntryPoint firstAEP = mock(AuthenticationEntryPoint.class);
        RequestMatcher firstRM = mock(RequestMatcher.class);
        when(firstRM.matches(request)).thenReturn(false);
        entryPoints.put(firstRM, firstAEP);

        daep.commence(request, null, null);
View Full Code Here

        verify(firstAEP, never()).commence(request, null, null);
    }

    @Test
    public void testFirstEntryPoint() throws Exception {
        AuthenticationEntryPoint firstAEP = mock(AuthenticationEntryPoint.class);
        RequestMatcher firstRM = mock(RequestMatcher.class);
        AuthenticationEntryPoint secondAEP = mock(AuthenticationEntryPoint.class);
        RequestMatcher secondRM = mock(RequestMatcher.class);
        when(firstRM.matches(request)).thenReturn(true);
        entryPoints.put(firstRM, firstAEP);
        entryPoints.put(secondRM, secondAEP);
View Full Code Here

        verify(secondRM, never()).matches(request);
    }

    @Test
    public void testSecondEntryPoint() throws Exception {
        AuthenticationEntryPoint firstAEP = mock(AuthenticationEntryPoint.class);
        RequestMatcher firstRM = mock(RequestMatcher.class);
        AuthenticationEntryPoint secondAEP = mock(AuthenticationEntryPoint.class);
        RequestMatcher secondRM = mock(RequestMatcher.class);
        when(firstRM.matches(request)).thenReturn(false);
        when(secondRM.matches(request)).thenReturn(true);
        entryPoints.put(firstRM, firstAEP);
        entryPoints.put(secondRM, secondAEP);
View Full Code Here

TOP

Related Classes of org.springframework.security.web.AuthenticationEntryPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.