Yes, here is some my code, I can send a complete though:
boolean checkCredentials() {
String credentials = req.getHeader(AUTHORIZATION);
if (credentials!=null) {
int p = credentials.indexOf(' ');
if (p > 0 && credentials.substring(0, p).equalsIgnoreCase("Basic")) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new sun.misc.BASE64Decoder().decodeBuffer(new StringBufferInputStream(credentials.substring(p+1)), baos);
credentials = baos.toString();
p = credentials.indexOf(':');
if (p > 0) {
String password = credentials.substring(p+1);
String user = credentials.substring(0, p);
if ("Administrator".equals(user) &&
dispatcher.getProperty(PROP_PASSWORD, "")
.equals(Crypt.crypt("", password)))
return true;
}
} catch(IOException e) {
dispatcher.log(e.getMessage());
}
} else {
try {
resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED , "Not supported authorization type.");
} catch(IOException e) {
dispatcher.log(e.getMessage());
}
return false;
}
}
resp.setHeader(WWW_AUTHENTICATE, "Basic realm=\"Payment Administrator\"");
try {
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Provide your credentials for the authorization.");
resp.flushBuffer();
} catch(IOException e) {
dispatcher.log(e.getMessage());
}
return false;
}