@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.setContentType("text/html; charset=UTF-8");
Credentials credentials = getWCIController().getCredentials(req, resp);
//
if (credentials == null)
{
//
String token = getRememberMeTokenCookie(req);
if (token != null)
{
AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
credentials = tokenService.validateToken(token, false);
if (credentials == null)
{
log.debug("Login initiated with no credentials in session but found token an invalid " + token + " " +
"that will be cleared in next response");
// We clear the cookie in the next response as it was not valid
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
cookie.setPath(req.getContextPath());
cookie.setMaxAge(0);
resp.addCookie(cookie);
// This allows the customer to define another login page without
// changing the portal
getWCIController().showLoginForm(req, resp);
}
else
{
// Send authentication request
log.debug("Login initiated with no credentials in session but found token " + token + " with existing credentials, " +
"performing authentication");
getWCIController().sendAuth(req, resp, credentials.getUsername(), token);
}
}
else
{
// This allows the customer to define another login page without