|| (path.startsWith("/images/"))
|| (path.startsWith("/scripts/"))) {
chain.doNext(request, response);
return;
}
EnhancedResponse ehResponse = new EnhancedResponse(response);
ehResponse.sendRedirect("/admin/initial-configuration");
return;
}
}
try {
try {
httpLoginForced = request.getRequestURI().getParameterValues(
"forceHttpLogin")[0].equals("true");
} catch (Exception ex) {
}
CallbackHandler callbackHandler;
if (useCookieLogin && !httpLoginForced) {
callbackHandler = new CookieCallBackHandler(ehRequest, response);
} else {
callbackHandler = new WebCallBackHandler(request);
}
loginContext = new LoginContext(servletContextName, callbackHandler);
} catch (LoginException e) {
logger.error("Initializing LoginContext", e);
throw new RuntimeException(e.toString());
}
try {
loginContext.login();
} catch (LoginException e) {
}
try {
Subject subject = loginContext.getSubject();
Subject.doAsPrivileged(subject, new PrivilegedExceptionAction() {
public Object run() throws Exception {
// setting the policy only in the init method causes the
// current ProtectionDomain to
// be cached, i.E. all checks from classes within the
// current classpath entry to authorized
Policy.setPolicy(new RPolicy());
boolean isAdmin = false;
try {
AccessController.checkPermission(new RPermission(
AUTHORIZATION.admin));
isAdmin = true;
} catch (Exception e) {
}
if (!isAdmin) {
AccessControlFilter.checkPermssionOnResource(model
.createResource(ehRequest
.getRequestURLWithoutParams()
.toString()));
}
Request requestNoLoginParam = checkLoginRequested(request);
chain.doNext(requestNoLoginParam, response);
return null;
}
}, null);
} catch (AccessControlException e) {
// Authentication failed.
logger.debug("AccessControlException, will prompt for login", e);
if (useCookieLogin && !httpLoginForced
&& !ehRequest.getMethod().equals(Method.POST)
&& !ehRequest.getMethod().equals(Method.PUT)
&& !ehRequest.getMethod().equals(Method.MKCOL)
&& !ehRequest.getMethod().equals(Method.PROPFIND)) {
EnhancedResponse ehResponse = new EnhancedResponse(response);
try {
ehResponse.sendRedirect("/login?target="
+ URLEncoder.encode(ehRequest.getFullRequestURL()
.toString(), "utf-8"));
} catch (UnsupportedEncodingException e1) {
throw new RuntimeException(e1);
}