public User authenticate(HttpServletRequest request, HttpServletResponse response) throws IOException {
public User authenticate(HttpServletRequest request, HttpServletResponse response) throws IOException {  HttpSession session = request.getSession(); User user = null; if(session != null) { user = (User)session.getAttribute(XQueryContext.HTTP_SESSIONVAR_XMLDB_USER); if (user != null) { return user; } }
	public User authenticate(HttpServletRequest request,			HttpServletResponse response) throws IOException {		String credentials = request.getHeader("Authorization");		if(credentials == null) {                       //LOG.debug("Sending BASIC auth challenge.");			sendChallenge(request, response);			return null;		}		Base64Decoder dec = new Base64Decoder();		dec.translate(credentials.substring("Basic ".length()));		byte[] c = dec.getByteArray();		String s = new String(c);                //LOG.debug("BASIC auth credentials: "+s);		int p = s.indexOf(':');		String username = p<0 ? s : s.substring(0, p);		String password = p<0 ? null : s.substring(p + 1);				SecurityManager secman = pool.getSecurityManager();		User user = secman.getUser(username);		if(user == null) {			response.sendError(HttpServletResponse.SC_UNAUTHORIZED);			return null;		}		if (!user.validate(password)) {			response.sendError(HttpServletResponse.SC_UNAUTHORIZED);			return null;		}		return user;	}