//
int status;
if (req.getRemoteUser() == null) {
if (username != null && password != null) {
Credentials credentials = new Credentials(username, password);
ServletContainer container = ServletContainerFactory.getServletContainer();
// This will login or send an AuthenticationException
try {
container.login(req, resp, credentials);
} catch (AuthenticationException e) {
log.debug("User authentication failed");
if (log.isTraceEnabled()) {
log.trace(e.getMessage(), e);
}