improved logging

This commit is contained in:
2018-10-29 12:35:35 +01:00
parent 4eb6bb77e2
commit f07467fd3e
2 changed files with 120 additions and 105 deletions

View File

@ -10,6 +10,7 @@ import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped; import javax.faces.view.ViewScoped;
import javax.inject.Named; import javax.inject.Named;
import javax.naming.NamingException;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
@ -68,8 +69,17 @@ public class LoginView implements Serializable {
String hint = "Error while authenticating user " + username; String hint = "Error while authenticating user " + username;
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug(hint, ex); LOGGER.debug(hint, ex);
}
if (ex.getMessage() != null) {
hint += "Reason: " + ex.getMessage();
} else { } else {
LOGGER.error(hint + " Reason: " + ex.toString()); hint += "Reason: " + ex.toString();
}
if ((ex.getCause() != null) && (ex.getCause().getMessage() != null)) {
hint += "Rootcause: " + ex.getMessage();
LOGGER.error(hint);
} }
FacesUtil.addGlobalErrorMessage("Login failed", hint); FacesUtil.addGlobalErrorMessage("Login failed", hint);

View File

@ -39,15 +39,20 @@ public class UserNameActiveDirectoryRealm extends ActiveDirectoryRealm {
} }
// Binds using the username and password provided by the user. // Binds using the username and password provided by the user.
LOGGER.debug("start creating context"); if (LOGGER.isDebugEnabled()) {
LOGGER.debug("start creating context");
}
ctx = ldapContextFactory.getLdapContext(userName, upToken.getCredentials()); ctx = ldapContextFactory.getLdapContext(userName, upToken.getCredentials());
LOGGER.debug("context created"); if (LOGGER.isDebugEnabled()) {
LOGGER.debug("User {} LDAP authenticated", userName);
}
} finally { } finally {
LdapUtils.closeContext(ctx); LdapUtils.closeContext(ctx);
} }
LOGGER.debug("building authentication info"); LOGGER.debug("building authentication info");
AuthenticationInfo authInfo = buildAuthenticationInfo(userName, upToken.getPassword()); AuthenticationInfo authInfo = buildAuthenticationInfo(userName, upToken.getPassword());
LOGGER.debug("authentifaction info created"); LOGGER.debug("authentifaction info created");
return authInfo; return authInfo;
} }