Source:
public WebSession authenticate(SessionManagementMethod sessionManagementMethod, AuthenticationCredentials credentials, User user) throws AuthenticationMethod.UnsupportedAuthenticationCredentialsException { if (!(credentials instanceof UsernamePasswordAuthenticationCredentials)) { throw new UnsupportedAuthenticationCredentialsException( "Post based authentication method only supports " + UsernamePasswordAuthenticationCredentials.class.getSimpleName() + ". Received: " + credentials.getClass()); } UsernamePasswordAuthenticationCredentials cred = (UsernamePasswordAuthenticationCredentials) credentials; if (!cred.isConfigured()) { LOGGER.warn("No credentials to authenticate user: " + user.getName()); return null; } HttpMessage msg; try { msg = prepareRequestMessage(cred); } catch (Exception e) { LOGGER.error("Unable to prepare authentication message: " + e.getMessage(), e); return null; } if (user.getAuthenticatedSession() == null) user.setAuthenticatedSession(sessionManagementMethod.createEmptyWebSession()); msg.setRequestingUser(user); if(!this.requireAnitCsrfTokenWhenLogin) { msg.getRequestHeader().setHeader(HttpRequestHeader.COOKIE, null); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Authentication request header: \n" + msg.getRequestHeader()); if (!msg.getRequestHeader().getMethod().equals(HttpRequestHeader.GET)) LOGGER.debug("Authentication request body: \n" + msg.getRequestBody()); } try { if(this.requireAnitCsrfTokenWhenLogin) { getHttpSender().sendAndReceive(msg, true); } else { getHttpSender().sendAndReceive(msg); } } catch (IOException e) { LOGGER.error("Unable to send authentication message: " + e.getMessage()); return null; } if (this.isAuthenticated(msg)) { AuthenticationHelper.notifyOutputAuthSuccessful(msg); } else { AuthenticationHelper.notifyOutputAuthFailure(msg); } AuthenticationHelper.addAuthMessageToHistory(msg); return sessionManagementMethod.extractWebSession(msg); }

Target:
public WebSession authenticate(SessionManagementMethod sessionManagementMethod, AuthenticationCredentials credentials, User user) throws AuthenticationMethod.UnsupportedAuthenticationCredentialsException { if (!(credentials instanceof UsernamePasswordAuthenticationCredentials)) { throw new UnsupportedAuthenticationCredentialsException( "Post based authentication method only supports " + UsernamePasswordAuthenticationCredentials.class.getSimpleName() + ". Received: " + credentials.getClass()); } UsernamePasswordAuthenticationCredentials cred = (UsernamePasswordAuthenticationCredentials) credentials; if (!cred.isConfigured()) { LOGGER.warn("No credentials to authenticate user: " + user.getName()); return null; } HttpMessage msg; try { msg = prepareRequestMessage(cred); if (user.getAuthenticatedSession() == null) user.setAuthenticatedSession(sessionManagementMethod.createEmptyWebSession()); msg.setRequestingUser(user); replaceAntiCsrfTokenValueIfRequired(msg, user); } catch (Exception e) { LOGGER.error("Unable to prepare authentication message: " + e.getMessage(), e); return null; } msg.getRequestHeader().setHeader(HttpRequestHeader.COOKIE, null); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Authentication request header: \n" + msg.getRequestHeader()); if (!msg.getRequestHeader().getMethod().equals(HttpRequestHeader.GET)) LOGGER.debug("Authentication request body: \n" + msg.getRequestBody()); } try { getHttpSender().sendAndReceive(msg); } catch (IOException e) { LOGGER.error("Unable to send authentication message: " + e.getMessage()); return null; } if (this.isAuthenticated(msg)) { AuthenticationHelper.notifyOutputAuthSuccessful(msg); } else { AuthenticationHelper.notifyOutputAuthFailure(msg); } AuthenticationHelper.addAuthMessageToHistory(msg); return sessionManagementMethod.extractWebSession(msg); }