MessageDigest md = MessageDigest.getInstance("SHA-1");
token = toHex(md.digest(token.getBytes()));
req.getSession().setAttribute(LAST_TOKEN, token);
resp.sendRedirect(req.getParameter("returl") + token);
tokenMap.put(token,
new TokenInfo(token,
(String)req.getSession().getAttribute(PermissionFilter.AUTHORIZED),
new Date(),
1));
} catch (NoSuchAlgorithmException e) {
throw new ServletException(e);
}
} else if (req.getParameter("token") != null && req.getParameter("returl") == null) {
resp.setContentType("text/plain");
TokenInfo ti = tokenMap.get(req.getParameter("token"));
if (ti != null && ti.getUserLogin() != null) {
resp.getWriter().print(ti.getUserLogin());
} else {
resp.setStatus(401);
resp.getWriter().print("Invalid token");
}
} else {