@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { HttpSession session = request.getSession(); // check to see if we've got a target String target = getStoredSessionString(session, TARGET_SESSION_VARIABLE); if (!Strings.isNullOrEmpty(target)) { session.removeAttribute(TARGET_SESSION_VARIABLE); if (deepLinkFilter != null) { target = deepLinkFilter.filter(target); } response.sendRedirect(target); } else { // if the target was blank, use the default behavior here passthrough.onAuthenticationSuccess(request, response, authentication); } }
public void happy_day_password_reset(String redirectUri) throws Exception { filter.doFilterInternal(request, response, chain); //do our assertion verify(service, times(1)).resetPassword(any(ExpiringCode.class), eq(password)); verify(authenticationSuccessHandler, times(0)).onAuthenticationSuccess(same(request), same(response), any(Authentication.class)); assertNull(SecurityContextHolder.getContext().getAuthentication()); if (!StringUtils.hasText(redirectUri) || redirectUri.equals("home")) { verify(response, times(1)).sendRedirect(request.getContextPath() + "/login?success=password_reset"); } else { verify(response, times(1)).sendRedirect(request.getContextPath() + "/login?success=password_reset&form_redirect_uri="+ redirectUri); } verify(chain, times(0)).doFilter(any(), any()); }
public AuthenticationException error_during_password_reset(Class<? extends Exception> failure) throws Exception { ArgumentCaptor<AuthenticationException> authenticationException = ArgumentCaptor.forClass(AuthenticationException.class); filter.doFilterInternal(request, response, chain); //do our assertion verify(authenticationSuccessHandler, times(0)).onAuthenticationSuccess(same(request), same(response), any(Authentication.class)); verify(entryPoint, times(1)).commence(same(request), same(response), authenticationException.capture()); assertNull(SecurityContextHolder.getContext().getAuthentication()); AuthenticationException exception = authenticationException.getValue(); assertSame(failure, exception.getCause().getClass()); return exception; }
filter.doFilter(request, response, chain); verifyNoMoreInteractions(chain); verify(successHandler).onAuthenticationSuccess(request, response, authentication);
@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { successHandler.onAuthenticationSuccess(request, response, authResult); }
@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { successHandler.onAuthenticationSuccess(request, response, authResult); }
@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { successHandler.onAuthenticationSuccess(request, response, authResult); }
@Override protected void onSuccessfulAuthentication( HttpServletRequest request, HttpServletResponse response, Authentication authResult) { if (successHandler == null) { return; } try { successHandler.onAuthenticationSuccess(request, response, authResult); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } }
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { HttpSession session = request.getSession(); // check to see if we've got a target String target = getStoredSessionString(session, TARGET_SESSION_VARIABLE); if (!Strings.isNullOrEmpty(target)) { session.removeAttribute(TARGET_SESSION_VARIABLE); target = deepLinkFilter.filter(target); response.sendRedirect(target); } else { // if the target was blank, use the default behavior here passthrough.onAuthenticationSuccess(request, response, authentication); } }
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { HttpSession session = request.getSession(); // check to see if we've got a target String target = getStoredSessionString(session, TARGET_SESSION_VARIABLE); if (!Strings.isNullOrEmpty(target)) { session.removeAttribute(TARGET_SESSION_VARIABLE); if (deepLinkFilter != null) { target = deepLinkFilter.filter(target); } response.sendRedirect(target); } else { // if the target was blank, use the default behavior here passthrough.onAuthenticationSuccess(request, response, authentication); } }
/** * Puts the <code>Authentication</code> instance returned by the authentication * manager into the secure context. */ protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("Authentication success: " + authResult); } SecurityContextHolder.getContext().setAuthentication(authResult); // Fire event if (this.eventPublisher != null) { eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent( authResult, this.getClass())); } if (authenticationSuccessHandler != null) { authenticationSuccessHandler.onAuthenticationSuccess(request, response, authResult); } }
@Autowired AuthenticationSuccessHandler successHandler; @Autowired AuthenticationManager authenticationManager; @Autowired AuthenticationFailureHandler failureHandler; public void login(HttpServletRequest request, HttpServletResponse response, String username, String password) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password); token.setDetails(new WebAuthenticationDetails(request));//if request is needed during authentication Authentication auth; try { auth = authenticationManager.authenticate(token); } catch (AuthenticationException e) { //if failureHandler exists try { failureHandler.onAuthenticationFailure(request, response, e); } catch (IOException | ServletException se) { //ignore } throw e; } SecurityContextHolder.getContext().setAuthentication(auth); successHandler.onAuthenticationSuccess(request, response, auth);//if successHandler exists //if user has a http session you need to save context in session for subsequent requests HttpSession session = request.getSession(true); session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext); }
this.authenticationSuccessHandler.onAuthenticationSuccess(request, response, authentication); } catch (final IOException | ServletException e) { DelegatingNegotiateSecurityFilter.LOGGER.warn("Error calling authenticationSuccessHandler: {}",
this.authenticationSuccessHandler.onAuthenticationSuccess(request, response, authentication); } catch (final IOException | ServletException e) { DelegatingNegotiateSecurityFilter.LOGGER.warn("Error calling authenticationSuccessHandler: {}",
this.authenticationSuccessHandler.onAuthenticationSuccess(request, response, authentication); } catch (final IOException | ServletException e) { DelegatingNegotiateSecurityFilter.LOGGER.warn("Error calling authenticationSuccessHandler: {}",
successHandler.onAuthenticationSuccess(request, response, authResult);
this.authenticationSuccessHandler.onAuthenticationSuccess(request, response, authentication); } catch (final IOException | ServletException e) { DelegatingNegotiateSecurityFilter.LOGGER.warn("Error calling authenticationSuccessHandler: {}",
this.successHandler.onAuthenticationSuccess(request, response, targetUser); this.successHandler.onAuthenticationSuccess(request, response, originalUser);
successHandler.onAuthenticationSuccess(request, response, rememberMeAuth);
SecurityContextHolder.getContext().setAuthentication(authentication); if (successHandler != null) { successHandler.onAuthenticationSuccess(request, response, authentication);