use of org.securityfilter.filter.URLPatternMatcher in project xwiki-platform by xwiki.
the class XWikiAuthServiceImpl method checkAuth.
@Override
public XWikiUser checkAuth(XWikiContext context) throws XWikiException {
// Debug time taken.
long time = System.currentTimeMillis();
HttpServletRequest request = null;
HttpServletResponse response = context.getResponse();
if (context.getRequest() != null) {
request = context.getRequest().getHttpServletRequest();
}
if (request == null) {
return null;
}
XWikiAuthenticator auth = getAuthenticator(context);
SecurityRequestWrapper wrappedRequest = new SecurityRequestWrapper(request, null, null, auth.getAuthMethod());
try {
if (auth.processLogin(wrappedRequest, response, context)) {
return null;
}
// Process logout (this only works with Forms)
if (auth.processLogout(wrappedRequest, response, new URLPatternMatcher())) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("User " + context.getUser() + " has been logged-out");
}
wrappedRequest.setUserPrincipal(null);
return null;
}
final String userName = getContextUserName(wrappedRequest.getUserPrincipal(), context);
if (LOGGER.isInfoEnabled()) {
if (userName != null) {
LOGGER.info("User " + userName + " is authentified");
}
}
if (userName == null) {
return null;
}
return new XWikiUser(userName);
} catch (Exception e) {
LOGGER.error("Failed to authenticate", e);
return null;
} finally {
LOGGER.debug("XWikiAuthServiceImpl.checkAuth(XWikiContext) took " + (System.currentTimeMillis() - time) + " milliseconds to run.");
}
}
Aggregations