this.base = base;
}
@Override
public boolean process(final SimpleRequest request, final SimpleResponse response) {
RequestLine requestLine = request.getRequestLine();
HttpVersion ver = requestLine.getHttpVersion();
Header auth = request.getFirstHeader("Authorization");
Header cookie = request.getFirstHeader("Cookie");
if (!request.getFirstHeader("User-Agent").getValue().contains("Mozilla")) {
// 1st request - rejected by non-browser useragent
response.setStatusLine(ver, HttpStatus.SC_FORBIDDEN);
response.addHeader(new Header("X-Forms_Based_Auth_Required", base + customLogin));
response.setBodyString("403 UNAUTHORIZED");
return true;
} else {
if (requestLine.getUri().equals(customLogin)) {
// 2nd request - forward from custom login page to WIA login
response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
response.addHeader(new Header("Location", windowsLogin));
response.setBodyString(moved);
return true;
} else if (requestLine.getUri().equals(windowsLogin)) {
if (auth == null) {
// 3rd request - no authentication - offer NTLM
response.setStatusLine(ver, HttpStatus.SC_UNAUTHORIZED);
response.addHeader(new Header("WWW-Authenticate", "NTLM"));
return true;