List of usage examples for org.springframework.security.core AuthenticationException toString
public String toString()
From source file:org.juiser.spring.security.web.authentication.HeaderAuthenticationFilter.java
/** * Clears the {@link SecurityContextHolder} and returns {@code true}. *///from w w w. ja va 2s .c om protected boolean unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, AuthenticationException failed) throws IOException, ServletException { SecurityContextHolder.clearContext(); if (log.isDebugEnabled()) { log.debug("Authentication request failed: " + failed.toString(), failed); log.debug("Updated SecurityContextHolder to contain null Authentication"); log.debug("Continuing filter chain with null Authentication"); } return true; }
From source file:org.springframework.security.ui.ntlm.NtlmAuthenticationFilter.java
/** * Authenticates the user credentials acquired from NTLM against the Spring * Security <code>AuthenticationManager</code>. * * @param request the <code>HttpServletRequest</code> object. * @param response the <code>HttpServletResponse</code> object. * @param session the <code>HttpSession</code> object. * @param auth the <code>NtlmPasswordAuthentication</code> object. * @throws IOException/* ww w . jav a2 s. co m*/ */ private void authenticate(final HttpServletRequest request, final HttpServletResponse response, final HttpSession session, final NtlmPasswordAuthentication auth) throws IOException { final Authentication authResult; final UsernamePasswordAuthenticationToken authRequest; final Authentication backupAuth; authRequest = new NtlmUsernamePasswordAuthenticationToken(auth, stripDomain); authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); // Place the last username attempted into HttpSession for views // session.setAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY, authRequest.getName()); // Replace in your code by : // SecurityContextHolder.getContext().getAuthentication().getPrincipal(); // Backup the current authentication in case of an AuthenticationException backupAuth = SecurityContextHolder.getContext().getAuthentication(); try { // Authenticate the user with the authentication manager authResult = authenticationManager.authenticate(authRequest); } catch (AuthenticationException failed) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Authentication request for user: " + authRequest.getName() + " failed: " + failed.toString()); } // Reset the backup Authentication object and rethrow the AuthenticationException SecurityContextHolder.getContext().setAuthentication(backupAuth); if (retryOnAuthFailure && (failed instanceof AuthenticationCredentialsNotFoundException || failed instanceof InsufficientAuthenticationException)) { LOGGER.debug("Restart NTLM authentication handshake due to AuthenticationException"); session.setAttribute(STATE_ATTR, BEGIN); throw new NtlmBeginHandshakeException(); } throw failed; } // Set the Authentication object with the valid authentication result SecurityContextHolder.getContext().setAuthentication(authResult); }
From source file:ro.nextreports.server.web.integration.IntegrationAuthenticationFilter.java
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) throws IOException, ServletException { SecurityContextHolder.clearContext(); if (logger.isDebugEnabled()) { logger.debug("Authentication request failed: " + failed.toString()); logger.debug("Updated SecurityContextHolder to contain null Authentication"); // logger.debug("Delegating to authentication failure handler" + failureHandler); }//from w w w. j av a2 s . c om // failureHandler.onAuthenticationFailure(request, response, failed); }
From source file:ubic.gemma.security.authentication.ManualAuthenticationServiceImpl.java
/** * @param failed//from ww w. j a v a 2 s. c om * @throws IOException */ protected void unsuccessfulAuthentication(AuthenticationException failed) { log.debug("Updated SecurityContextHolder to contain null Authentication"); log.debug("Authentication request failed: " + failed.toString()); }