Author: markt Date: Fri Dec 19 13:56:30 2014 New Revision: 1646723 URL: http://svn.apache.org/r1646723 Log: Debug logging improvements
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/LocalStrings.properties tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java Modified: tomcat/trunk/java/org/apache/catalina/authenticator/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/LocalStrings.properties?rev=1646723&r1=1646722&r2=1646723&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/authenticator/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/authenticator/LocalStrings.properties Fri Dec 19 13:56:30 2014 @@ -31,6 +31,23 @@ formAuthenticator.forwardLoginFail=Unexp formAuthenticator.noErrorPage=No error page was defined for FORM authentication in context [{0}] formAuthenticator.noLoginPage=No login page was defined for FORM authentication in context [{0}] +singleSignOn.debug.associate=SSO associating application session [{1}] with SSO session [{0}] +singleSignOn.debug.associateFailed=SSO failed to associate application session [{0}] since SSO session [{1}] does not exist +singleSignOn.debug.cookieCheck=SSO checking for SSO cookie +singleSignOn.debug.cookieNotFound=SSO did not find an SSO cookie +singleSignOn.debug.deregister=SSO expiring application session [{0}] associated with SSO session [{1}] +singleSignOn.debug.deregisterFail=SSO failed to deregister the SSO session [{0}] because it was not in the cache +singleSignOn.debug.deregisterNone=SSO deregistered the SSO session [{0}] but found no associated application sessions +singleSignOn.debug.hasPrincipal=SSO found previously authenticated Principal [{0}] +singleSignOn.debug.invoke=SSO processing request for [{0}] +singleSignOn.debug.principalCheck=SSO looking for a cached Principal for SSO session [{0}] +singleSignOn.debug.principalFound=SSO found cached Principal [{0}] with authentication type [{1}] +singleSignOn.debug.principalNotFound=SSO did not find a cached Principal. Erasing SSO cookie for session [{0}] +singleSignOn.debug.register=SSO registering SSO session [{0}] for user [{1}] with authentication type [{2}] +singleSignOn.debug.removeSession=SSO removing application session [{0}] from SSO session [{1}] +singleSignOn.debug.sessionLogout=SSO processing a log out for SSO session [{0}] and application session [{1}] +singleSignOn.debug.sessionTimeout=SSO processing a time out for SSO session [{0}] and application session [{1}] +singleSignOn.debug.update=SSO updating SSO session [{0}] to authentication type [{1}] singleSignOn.sessionExpire.engineNull=SSO unable to expire session [{0}] because the Engine was null singleSignOn.sessionExpire.hostNotFound=SSO unable to expire session [{0}] because the Host could not be found singleSignOn.sessionExpire.contextNotFound=SSO unable to expire session [{0}] because the Context could not be found Modified: tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java?rev=1646723&r1=1646722&r2=1646723&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java (original) +++ tomcat/trunk/java/org/apache/catalina/authenticator/SingleSignOn.java Fri Dec 19 13:56:30 2014 @@ -19,6 +19,7 @@ package org.apache.catalina.authenticato import java.io.IOException; import java.security.Principal; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.servlet.ServletException; @@ -207,12 +208,12 @@ public class SingleSignOn extends ValveB // Has a valid user already been authenticated? if (containerLog.isDebugEnabled()) { - containerLog.debug("Process request for '" + request.getRequestURI() + "'"); + containerLog.debug(sm.getString("singleSignOn.debug.invoke", request.getRequestURI())); } if (request.getUserPrincipal() != null) { if (containerLog.isDebugEnabled()) { - containerLog.debug(" Principal '" + request.getUserPrincipal().getName() + - "' has already been authenticated"); + containerLog.debug(sm.getString("singleSignOn.debug.hasPrincipal", + request.getUserPrincipal().getName())); } getNext().invoke(request, response); return; @@ -220,7 +221,7 @@ public class SingleSignOn extends ValveB // Check for the single sign on cookie if (containerLog.isDebugEnabled()) { - containerLog.debug(" Checking for SSO cookie"); + containerLog.debug(sm.getString("singleSignOn.debug.cookieCheck")); } Cookie cookie = null; Cookie cookies[] = request.getCookies(); @@ -234,7 +235,7 @@ public class SingleSignOn extends ValveB } if (cookie == null) { if (containerLog.isDebugEnabled()) { - containerLog.debug(" SSO cookie is not present"); + containerLog.debug(sm.getString("singleSignOn.debug.cookieNotFound")); } getNext().invoke(request, response); return; @@ -242,14 +243,15 @@ public class SingleSignOn extends ValveB // Look up the cached Principal associated with this cookie value if (containerLog.isDebugEnabled()) { - containerLog.debug(" Checking for cached principal for " + cookie.getValue()); + containerLog.debug(sm.getString("singleSignOn.debug.principalCheck", + cookie.getValue())); } SingleSignOnEntry entry = cache.get(cookie.getValue()); if (entry != null) { if (containerLog.isDebugEnabled()) { - containerLog.debug(" Found cached principal '" + - (entry.getPrincipal() != null ? entry.getPrincipal().getName() : "") + "' with auth type '" + - entry.getAuthType() + "'"); + containerLog.debug(sm.getString("singleSignOn.debug.principalFound", + entry.getPrincipal() != null ? entry.getPrincipal().getName() : "", + entry.getAuthType())); } request.setNote(Constants.REQ_SSOID_NOTE, cookie.getValue()); // Only set security elements if reauthentication is not required @@ -259,7 +261,8 @@ public class SingleSignOn extends ValveB } } else { if (containerLog.isDebugEnabled()) { - containerLog.debug(" No cached principal found, erasing SSO cookie"); + containerLog.debug(sm.getString("singleSignOn.debug.principalNotFound", + cookie.getValue())); } // No need to return a valid SSO session ID cookie.setValue("REMOVE"); @@ -306,10 +309,6 @@ public class SingleSignOn extends ValveB return; } - if (containerLog.isDebugEnabled()) { - containerLog.debug("Process session destroyed on " + session); - } - // Was the session destroyed as the result of a timeout or context stop? // If so, we'll just remove the expired session from the SSO. If the // session was logged out, we'll log out of all session associated with @@ -318,11 +317,19 @@ public class SingleSignOn extends ValveB && (System.currentTimeMillis() - session.getThisAccessedTimeInternal() >= session.getMaxInactiveInterval() * 1000)) || (!session.getManager().getContext().getState().isAvailable())) { + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.sessionTimeout", + ssoId, session)); + } removeSession(ssoId, session); } else { // The session was logged out. // Deregister this single session id, invalidating // associated sessions + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.sessionLogout", + ssoId, session)); + } deregister(ssoId); } } @@ -339,15 +346,18 @@ public class SingleSignOn extends ValveB * session, otherwise <code>false</code> */ protected boolean associate(String ssoId, Session session) { - - if (containerLog.isDebugEnabled()) { - containerLog.debug("Associate sso id " + ssoId + " with session " + session); - } - SingleSignOnEntry sso = cache.get(ssoId); if (sso == null) { + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.associateFail", + ssoId, session)); + } return false; } else { + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.associate", + ssoId, session)); + } sso.addSession(this, ssoId, session); return true; } @@ -362,21 +372,26 @@ public class SingleSignOn extends ValveB */ protected void deregister(String ssoId) { - if (containerLog.isDebugEnabled()) { - containerLog.debug("Deregistering sso id '" + ssoId + "'"); - } - // Look up and remove the corresponding SingleSignOnEntry SingleSignOnEntry sso = cache.remove(ssoId); if (sso == null) { + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.deregisterFail", ssoId)); + } return; } // Expire any associated sessions - for (SingleSignOnSessionKey ssoKey : sso.findSessions()) { - if (containerLog.isTraceEnabled()) { - containerLog.trace(" Invalidating session " + ssoKey); + Set<SingleSignOnSessionKey> ssoKeys = sso.findSessions(); + if (ssoKeys.size() == 0) { + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.deregisterNone", ssoId)); + } + } + for (SingleSignOnSessionKey ssoKey : ssoKeys) { + if (containerLog.isDebugEnabled()) { + containerLog.debug(sm.getString("singleSignOn.debug.deregister", ssoKey, ssoId)); } // Invalidate this session expire(ssoKey); @@ -488,8 +503,8 @@ public class SingleSignOn extends ValveB String username, String password) { if (containerLog.isDebugEnabled()) { - containerLog.debug("Registering sso id '" + ssoId + "' for user '" + - (principal != null ? principal.getName() : "") + "' with auth type '" + authType + "'"); + containerLog.debug(sm.getString("singleSignOn.debug.register", ssoId, + principal != null ? principal.getName() : "", authType)); } cache.put(ssoId, new SingleSignOnEntry(principal, authType, username, password)); @@ -530,7 +545,7 @@ public class SingleSignOn extends ValveB SingleSignOnEntry sso = cache.get(ssoId); if (sso != null && !sso.getCanReauthenticate()) { if (containerLog.isDebugEnabled()) { - containerLog.debug("Update sso id " + ssoId + " to auth type " + authType); + containerLog.debug(sm.getString("singleSignOn.debug.update", ssoId, authType)); } sso.updateCredentials(principal, authType, username, password); @@ -550,8 +565,7 @@ public class SingleSignOn extends ValveB protected void removeSession(String ssoId, Session session) { if (containerLog.isDebugEnabled()) { - containerLog.debug("Removing session " + session.toString() + " from sso id " + - ssoId ); + containerLog.debug(sm.getString("singleSignOn.debug.removeSession", session, ssoId)); } // Get a reference to the SingleSignOn --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org