You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2005/02/18 20:17:57 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

luehe       2005/02/18 11:17:57

  Modified:    catalina/src/share/org/apache/catalina/realm
                        DataSourceRealm.java JAASCallbackHandler.java
                        JAASMemoryLoginModule.java JDBCRealm.java
                        JNDIRealm.java RealmBase.java
                        UserDatabaseRealm.java
  Log:
  More logging cleanup
  
  Revision  Changes    Path
  1.13      +23 -24    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/DataSourceRealm.java
  
  Index: DataSourceRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/DataSourceRealm.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DataSourceRealm.java	3 Feb 2005 15:14:34 -0000	1.12
  +++ DataSourceRealm.java	18 Feb 2005 19:17:57 -0000	1.13
  @@ -33,6 +33,9 @@
   import org.apache.catalina.ServerFactory;
   import org.apache.catalina.core.StandardServer;
   import org.apache.catalina.util.StringManager;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   
   /**
   *
  @@ -50,6 +53,7 @@
   public class DataSourceRealm
       extends RealmBase {
   
  +    private static Log log = LogFactory.getLog(DataSourceRealm.class);
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -290,7 +294,7 @@
               
           } catch (SQLException e) {
               // Log the problem for posterity
  -            container.getLogger().error(sm.getString("dataSourceRealm.exception"), e);
  +            log.error(sm.getString("dataSourceRealm.exception"), e);
   
               // Return "not authenticated" for this request
               return (null);
  @@ -318,8 +322,8 @@
        *  authenticating this username
        */
       protected Principal authenticate(Connection dbConnection,
  -                                               String username,
  -                                               String credentials) throws SQLException{
  +                                     String username,
  +                                     String credentials) throws SQLException{
   
           String dbCredentials = getPassword(dbConnection, username);
   
  @@ -332,13 +336,13 @@
               validated = (digest(credentials).equals(dbCredentials));
   
           if (validated) {
  -            if (container.getLogger().isTraceEnabled())
  -                container.getLogger().trace(sm.getString("dataSourceRealm.authenticateSuccess",
  -                                 username));
  +            if (log.isTraceEnabled())
  +                log.trace(sm.getString("dataSourceRealm.authenticateSuccess",
  +                                       username));
           } else {
  -            if (container.getLogger().isTraceEnabled())
  -                container.getLogger().trace(sm.getString("dataSourceRealm.authenticateFailure",
  -                                 username));
  +            if (log.isTraceEnabled())
  +                log.trace(sm.getString("dataSourceRealm.authenticateFailure",
  +                                       username));
               return (null);
           }
   
  @@ -368,7 +372,7 @@
           	}
               dbConnection.close();
           } catch (SQLException e) {
  -            container.getLogger().error(sm.getString("dataSourceRealm.close"), e); // Just log it here
  +            log.error(sm.getString("dataSourceRealm.close"), e); // Just log it here
           }
   
       }
  @@ -394,7 +398,7 @@
   	    return dataSource.getConnection();
           } catch (Exception e) {
               // Log the problem for posterity
  -            container.getLogger().error(sm.getString("dataSourceRealm.exception"), e);
  +            log.error(sm.getString("dataSourceRealm.exception"), e);
           }  
           return null;
       }
  @@ -450,9 +454,8 @@
               return (dbCredentials != null) ? dbCredentials.trim() : null;
               
           } catch(SQLException e) {
  -        	container.getLogger().error(sm
  -	                .getString("dataSourceRealm.getPassword.exception",
  -	        		           username));
  +        	log.error(sm.getString("dataSourceRealm.getPassword.exception",
  +	        		       username));
           } finally {
           	try {
   	            if (rs != null) {
  @@ -462,10 +465,8 @@
   	                stmt.close();
   	            }
           	} catch (SQLException e) {
  -            	container.getLogger().error(sm
  -                        .getString("dataSourceRealm.getPassword.exception",
  +                    log.error(sm.getString("dataSourceRealm.getPassword.exception",
           		                   username));
  -        		
           	}
           }
           
  @@ -538,9 +539,8 @@
       		}
       		return list;
       	} catch(SQLException e) {
  -        	container.getLogger().error(sm
  -	                .getString("dataSourceRealm.getRoles.exception",
  -	        		           username));
  +        	log.error(sm.getString("dataSourceRealm.getRoles.exception",
  +	        		       username));
           }
       	finally {
           	try {
  @@ -551,9 +551,8 @@
   	                stmt.close();
   	            }
           	} catch (SQLException e) {
  -            	container.getLogger().error(sm
  -                        .getString("dataSourceRealm.getRoles.exception",
  -        		                   username));
  +                    log.error(sm.getString("dataSourceRealm.getRoles.exception",
  +                                           username));
           		
           	}
           }
  
  
  
  1.7       +3 -3      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JAASCallbackHandler.java
  
  Index: JAASCallbackHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JAASCallbackHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JAASCallbackHandler.java	21 Jan 2005 08:41:17 -0000	1.6
  +++ JAASCallbackHandler.java	18 Feb 2005 19:17:57 -0000	1.7
  @@ -124,8 +124,8 @@
           for (int i = 0; i < callbacks.length; i++) {
   
               if (callbacks[i] instanceof NameCallback) {
  -                if (realm.getContainer().getLogger().isTraceEnabled())
  -                    realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username));
  +                if (log.isTraceEnabled())
  +                    log.trace(sm.getString("jaasCallback.username", username));
                   ((NameCallback) callbacks[i]).setName(username);
               } else if (callbacks[i] instanceof PasswordCallback) {
                   final char[] passwordcontents;
  
  
  
  1.13      +24 -13    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JAASMemoryLoginModule.java
  
  Index: JAASMemoryLoginModule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JAASMemoryLoginModule.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JAASMemoryLoginModule.java	24 Sep 2004 07:25:07 -0000	1.12
  +++ JAASMemoryLoginModule.java	18 Feb 2005 19:17:57 -0000	1.13
  @@ -141,7 +141,9 @@
       // --------------------------------------------------------- Public Methods
   
       public JAASMemoryLoginModule() {
  -        log.debug("MEMORY LOGIN MODULE");
  +        if (log.isDebugEnabled()) {
  +            log.debug("MEMORY LOGIN MODULE");
  +        }
       }
   
       /**
  @@ -168,7 +170,9 @@
               committed = false;
               principal = null;
           }
  -        log.debug("Abort");
  +        if (log.isDebugEnabled()) {
  +            log.debug("Abort");
  +        }
           return (true);
   
       }
  @@ -186,7 +190,9 @@
        * @exception LoginException if the commit fails
        */
       public boolean commit() throws LoginException {
  -        log.debug("commit " + principal);
  +        if (log.isDebugEnabled()) {
  +            log.debug("commit " + principal);
  +        }
   
           // If authentication was not successful, just return false
           if (principal == null)
  @@ -215,8 +221,8 @@
           // Are there any defined security constraints?
           SecurityConstraint constraints[] = context.findConstraints();
           if ((constraints == null) || (constraints.length == 0)) {
  -            if (context.getLogger().isDebugEnabled())
  -                context.getLogger().debug("  No applicable constraints defined");
  +            if (log.isDebugEnabled())
  +                log.debug("  No applicable constraints defined");
               return (null);
           }
   
  @@ -228,8 +234,8 @@
           uri = RequestUtil.URLDecode(uri); // Before checking constraints
           String method = request.getMethod();
           for (int i = 0; i < constraints.length; i++) {
  -            if (context.getLogger().isDebugEnabled())
  -                context.getLogger().debug("  Checking constraint '" + constraints[i] +
  +            if (log.isDebugEnabled())
  +                log.debug("  Checking constraint '" + constraints[i] +
                       "' against " + method + " " + uri + " --> " +
                       constraints[i].included(uri, method));
               if (constraints[i].included(uri, method)) {
  @@ -241,8 +247,8 @@
           }
   
           // No applicable security constraint was found
  -        if (context.getLogger().isDebugEnabled())
  -            context.getLogger().debug("  No applicable constraint located");
  +        if (log.isDebugEnabled())
  +            log.debug("  No applicable constraint located");
           if(results == null)
               return null;
           SecurityConstraint [] array = new SecurityConstraint[results.size()];
  @@ -265,7 +271,10 @@
        */
       public void initialize(Subject subject, CallbackHandler callbackHandler,
                              Map sharedState, Map options) {
  -        log.debug("Init");
  +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Init");
  +        }
   
           // Save configuration values
           this.subject = subject;
  @@ -318,7 +327,9 @@
           // Validate the username and password we have received
           principal = super.authenticate(username, password);
   
  -        log.debug("login " + username + " " + principal);
  +        if (log.isDebugEnabled()) {
  +            log.debug("login " + username + " " + principal);
  +        }
   
           // Report results based on success or failure
           if (principal != null) {
  @@ -376,7 +387,7 @@
               digester.parse(file);
           } catch (Exception e) {
               log.warn("Error processing configuration file " +
  -                file.getAbsolutePath(), e);
  +                     file.getAbsolutePath(), e);
               return;
           } finally {
               digester.reset();
  
  
  
  1.11      +23 -24    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JDBCRealm.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JDBCRealm.java	6 Jan 2005 11:33:22 -0000	1.10
  +++ JDBCRealm.java	18 Feb 2005 19:17:57 -0000	1.11
  @@ -29,6 +29,8 @@
   
   import org.apache.catalina.LifecycleException;
   import org.apache.catalina.util.StringManager;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   
   /**
  @@ -50,6 +52,7 @@
   public class JDBCRealm
       extends RealmBase {
   
  +    private static Log log = LogFactory.getLog(JDBCRealm.class);
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -354,7 +357,7 @@
               } catch (SQLException e) {
   
                   // Log the problem for posterity
  -                container.getLogger().error(sm.getString("jdbcRealm.exception"), e);
  +                log.error(sm.getString("jdbcRealm.exception"), e);
   
                   // Close the connection so that it gets reopened next time
                   if (dbConnection != null)
  @@ -408,13 +411,13 @@
           }
   
           if (validated) {
  -            if (container.getLogger().isTraceEnabled())
  -                container.getLogger().trace(sm.getString("jdbcRealm.authenticateSuccess",
  -                                 username));
  +            if (log.isTraceEnabled())
  +                log.trace(sm.getString("jdbcRealm.authenticateSuccess",
  +                                       username));
           } else {
  -            if (container.getLogger().isTraceEnabled())
  -                container.getLogger().trace(sm.getString("jdbcRealm.authenticateFailure",
  -                                 username));
  +            if (log.isTraceEnabled())
  +                log.trace(sm.getString("jdbcRealm.authenticateFailure",
  +                                       username));
               return (null);
           }
   
  @@ -458,7 +461,7 @@
           try {
               dbConnection.close();
           } catch (SQLException e) {
  -            container.getLogger().warn(sm.getString("jdbcRealm.close"), e); // Just log it here
  +            log.warn(sm.getString("jdbcRealm.close"), e); // Just log it here
           } finally {
              this.dbConnection = null;
           }
  @@ -538,23 +541,21 @@
               return dbCredentials;
               
           } catch(SQLException e){
  -            container.getLogger().
  -                    error(sm.getString("jdbcRealm.getPassword.exception",
  -                                       username), e);
  +            log.error(sm.getString("jdbcRealm.getPassword.exception",
  +                                   username), e);
           } finally {
               if (rs!=null) {
                   try {
                       rs.close();
                   } catch(SQLException e) {
  -                    container.getLogger().warn(sm.getString("jdbcRealm.abnormalCloseResultSet"));
  +                    log.warn(sm.getString("jdbcRealm.abnormalCloseResultSet"));
                   }
               }
               try {
                   dbConnection.commit();
               } catch (SQLException e) {
  -                container.getLogger().
  -                        warn(sm.getString("jdbcRealm.getPassword.exception",
  -                                          username));
  +                log.warn(sm.getString("jdbcRealm.getPassword.exception",
  +                                      username));
               }
           }
           
  @@ -600,23 +601,21 @@
               return (roleList);
               
           } catch(SQLException e){
  -            container.getLogger().
  -                    error(sm.getString("jdbcRealm.getRoles.exception",
  -                                       username));
  +            log.error(sm.getString("jdbcRealm.getRoles.exception",
  +                                   username));
           } finally {
               if (rs!=null) {
                   try {
                       rs.close();
                   } catch(SQLException e) {
  -                    container.getLogger().warn(sm.getString("jdbcRealm.abnormalCloseResultSet"));
  +                    log.warn(sm.getString("jdbcRealm.abnormalCloseResultSet"));
                   }
               }
               try {
                   dbConnection.commit();
               } catch (SQLException e) {
  -                container.getLogger().
  -                        warn(sm.getString("jdbcRealm.getRoles.exception",
  -                                          username));
  +                log.warn(sm.getString("jdbcRealm.getRoles.exception",
  +                                      username));
               }
           }
   
  @@ -719,7 +718,7 @@
           try {
               open();
           } catch (SQLException e) {
  -            container.getLogger().error(sm.getString("jdbcRealm.open"), e);
  +            log.error(sm.getString("jdbcRealm.open"), e);
           }
   
           // Perform normal superclass initialization
  
  
  
  1.18      +43 -38    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JNDIRealm.java
  
  Index: JNDIRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JNDIRealm.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JNDIRealm.java	1 Jan 2005 11:08:15 -0000	1.17
  +++ JNDIRealm.java	18 Feb 2005 19:17:57 -0000	1.18
  @@ -44,6 +44,8 @@
   import javax.naming.directory.SearchResult;
   import org.apache.catalina.LifecycleException;
   import org.apache.catalina.util.Base64;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   
   /**
  @@ -156,6 +158,9 @@
   public class JNDIRealm extends RealmBase {
   
   
  +    private static Log log = LogFactory.getLog(JNDIRealm.class);
  +
  +
       // ----------------------------------------------------- Instance Variables
   
       /**
  @@ -819,7 +824,7 @@
                       throw(e);
   
                   // log the exception so we know it's there.
  -                container.getLogger().error(sm.getString("jndiRealm.exception"), e);
  +                log.error(sm.getString("jndiRealm.exception"), e);
   
                   // close the connection so we know it will be reopened.
                   if (context != null)
  @@ -843,7 +848,7 @@
           } catch (NamingException e) {
   
               // Log the problem for posterity
  -            container.getLogger().error(sm.getString("jndiRealm.exception"), e);
  +            log.error(sm.getString("jndiRealm.exception"), e);
   
               // Close the connection so that it gets reopened next time
               if (context != null)
  @@ -902,7 +907,7 @@
                           }
                       } catch (InvalidNameException ine) {
                           // Log the problem for posterity
  -                        container.getLogger().warn(sm.getString("jndiRealm.exception"), ine);
  +                        log.warn(sm.getString("jndiRealm.exception"), ine);
                           // ignore; this is probably due to a name not fitting
                           // the search path format exactly, as in a fully-
                           // qualified name being munged into a search path
  @@ -1074,7 +1079,7 @@
   
           // Check no further entries were found
           if (results.hasMore()) {
  -            container.getLogger().info("username " + username + " has multiple entries");
  +            log.info("username " + username + " has multiple entries");
               return (null);
           }
   
  @@ -1090,8 +1095,8 @@
           name = name.addAll(entryName);
           String dn = name.toString();
   
  -        if (container.getLogger().isTraceEnabled())
  -            container.getLogger().trace("  entry found for " + username + " with dn " + dn);
  +        if (log.isTraceEnabled())
  +            log.trace("  entry found for " + username + " with dn " + dn);
   
           // Get the entry's attributes
           Attributes attrs = result.getAttributes();
  @@ -1140,13 +1145,13 @@
                validated = compareCredentials(context, user, credentials);
            }
   
  -         if (container.getLogger().isTraceEnabled()) {
  +         if (log.isTraceEnabled()) {
                if (validated) {
  -                 container.getLogger().trace(sm.getString("jndiRealm.authenticateSuccess",
  -                                  user.username));
  +                 log.trace(sm.getString("jndiRealm.authenticateSuccess",
  +                                        user.username));
                } else {
  -                 container.getLogger().trace(sm.getString("jndiRealm.authenticateFailure",
  -                                  user.username));
  +                 log.trace(sm.getString("jndiRealm.authenticateFailure",
  +                                        user.username));
                }
            }
            return (validated);
  @@ -1177,8 +1182,8 @@
               return (false);
   
           // Validate the credentials specified by the user
  -        if (container.getLogger().isTraceEnabled())
  -            container.getLogger().trace("  validating credentials");
  +        if (log.isTraceEnabled())
  +            log.trace("  validating credentials");
   
           boolean validated = false;
           if (hasMessageDigest()) {
  @@ -1230,8 +1235,8 @@
                return (false);
   
            // Validate the credentials specified by the user
  -         if (container.getLogger().isTraceEnabled()) {
  -             container.getLogger().trace("  validating credentials by binding as the user");
  +         if (log.isTraceEnabled()) {
  +             log.trace("  validating credentials by binding as the user");
           }
   
           // Set up security environment to bind as the user
  @@ -1241,15 +1246,15 @@
           // Elicit an LDAP bind operation
           boolean validated = false;
           try {
  -            if (container.getLogger().isTraceEnabled()) {
  -                container.getLogger().trace("  binding as "  + dn);
  +            if (log.isTraceEnabled()) {
  +                log.trace("  binding as "  + dn);
               }
               attr = context.getAttributes("", null);
               validated = true;
           }
           catch (AuthenticationException e) {
  -            if (container.getLogger().isTraceEnabled()) {
  -                container.getLogger().trace("  bind attempt failed");
  +            if (log.isTraceEnabled()) {
  +                log.trace("  bind attempt failed");
               }
           }
   
  @@ -1296,8 +1301,8 @@
           if (dn == null || username == null)
               return (null);
   
  -        if (container.getLogger().isTraceEnabled())
  -            container.getLogger().trace("  getRoles(" + dn + ")");
  +        if (log.isTraceEnabled())
  +            log.trace("  getRoles(" + dn + ")");
   
           // Start with roles retrieved from the user entry
           ArrayList list = user.roles;
  @@ -1332,13 +1337,13 @@
           }
   
   
  -        if (container.getLogger().isTraceEnabled()) {
  +        if (log.isTraceEnabled()) {
               if (list != null) {
  -                container.getLogger().trace("  Returning " + list.size() + " roles");
  +                log.trace("  Returning " + list.size() + " roles");
                   for (int i=0; i<list.size(); i++)
  -                    container.getLogger().trace(  "  Found role " + list.get(i));
  +                    log.trace(  "  Found role " + list.get(i));
               } else {
  -                container.getLogger().trace("  getRoles about to return null ");
  +                log.trace("  getRoles about to return null ");
               }
           }
   
  @@ -1357,8 +1362,8 @@
       private String getAttributeValue(String attrId, Attributes attrs)
           throws NamingException {
   
  -        if (container.getLogger().isTraceEnabled())
  -            container.getLogger().trace("  retrieving attribute " + attrId);
  +        if (log.isTraceEnabled())
  +            log.trace("  retrieving attribute " + attrId);
   
           if (attrId == null || attrs == null)
               return null;
  @@ -1394,8 +1399,8 @@
                                            ArrayList values)
           throws NamingException{
   
  -        if (container.getLogger().isTraceEnabled())
  -            container.getLogger().trace("  retrieving values for attribute " + attrId);
  +        if (log.isTraceEnabled())
  +            log.trace("  retrieving values for attribute " + attrId);
           if (attrId == null || attrs == null)
               return values;
           if (values == null)
  @@ -1425,11 +1430,11 @@
   
           // Close our opened connection
           try {
  -            if (container.getLogger().isDebugEnabled())
  -                container.getLogger().debug("Closing directory context");
  +            if (log.isDebugEnabled())
  +                log.debug("Closing directory context");
               context.close();
           } catch (NamingException e) {
  -            container.getLogger().error(sm.getString("jndiRealm.close"), e);
  +            log.error(sm.getString("jndiRealm.close"), e);
           }
           this.context = null;
   
  @@ -1489,7 +1494,7 @@
               connectionAttempt = 1;
   
               // log the first exception.
  -            container.getLogger().warn(sm.getString("jndiRealm.exception"), e);
  +            log.warn(sm.getString("jndiRealm.exception"), e);
   
               // Try connecting to the alternate url.
               context = new InitialDirContext(getDirectoryContextEnvironment());
  @@ -1516,10 +1521,10 @@
           Hashtable env = new Hashtable();
   
           // Configure our directory context environment.
  -        if (container.getLogger().isDebugEnabled() && connectionAttempt == 0)
  -            container.getLogger().debug("Connecting to URL " + connectionURL);
  -        else if (container.getLogger().isDebugEnabled() && connectionAttempt > 0)
  -            container.getLogger().debug("Connecting to URL " + alternateURL);
  +        if (log.isDebugEnabled() && connectionAttempt == 0)
  +            log.debug("Connecting to URL " + connectionURL);
  +        else if (log.isDebugEnabled() && connectionAttempt > 0)
  +            log.debug("Connecting to URL " + alternateURL);
           env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
           if (connectionName != null)
               env.put(Context.SECURITY_PRINCIPAL, connectionName);
  
  
  
  1.46      +7 -9      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java
  
  Index: RealmBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- RealmBase.java	7 Jan 2005 10:06:38 -0000	1.45
  +++ RealmBase.java	18 Feb 2005 19:17:57 -0000	1.46
  @@ -283,17 +283,15 @@
               validated = serverCredentials.equals(credentials);
           }
           if(! validated ) {
  -            if (container.getLogger().isTraceEnabled()) {
  -                container.getLogger().
  -                    trace(sm.getString("realmBase.authenticateFailure",
  -                                 username));
  +            if (log.isTraceEnabled()) {
  +                log.trace(sm.getString("realmBase.authenticateFailure",
  +                                       username));
               }
               return null;
           }
  -        if (container.getLogger().isTraceEnabled()) {
  -            container.getLogger().
  -                trace(sm.getString("realmBase.authenticateSuccess",
  -                             username));
  +        if (log.isTraceEnabled()) {
  +            log.trace(sm.getString("realmBase.authenticateSuccess",
  +                                   username));
           }
   
           return getPrincipal(username);
  
  
  
  1.10      +6 -2      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/UserDatabaseRealm.java
  
  Index: UserDatabaseRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/UserDatabaseRealm.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- UserDatabaseRealm.java	29 Aug 2004 16:46:12 -0000	1.9
  +++ UserDatabaseRealm.java	18 Feb 2005 19:17:57 -0000	1.10
  @@ -31,6 +31,8 @@
   import org.apache.catalina.UserDatabase;
   import org.apache.catalina.core.StandardServer;
   import org.apache.catalina.util.StringManager;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   
   /**
  @@ -48,6 +50,7 @@
   public class UserDatabaseRealm
       extends RealmBase {
   
  +    private static Log log = LogFactory.getLog(UserDatabaseRealm.class);
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -221,7 +224,8 @@
               Context context = server.getGlobalNamingContext();
               database = (UserDatabase) context.lookup(resourceName);
           } catch (Throwable e) {
  -            container.getLogger().error(sm.getString("userDatabaseRealm.lookup", resourceName), e);
  +            log.error(sm.getString("userDatabaseRealm.lookup", resourceName),
  +                      e);
               database = null;
           }
           if (database == null) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Logging

Posted by Remy Maucherat <re...@apache.org>.
Bill Barker wrote:
>> Jan Luehe wrote:
>>
>>> Remy,
>>>
>>> Remy Maucherat wrote:
>>>
>>>> Jan Luehe wrote:
>>>>
>>>> It's a little risky. We should use the container logger only while 
>>>> the classloader is initialized.
>>>>
>>>> It's probably far from perfect ;)
>>>
>>> Then how about RealmBase.authenticate()?
>>>
>>> RealmBase.authenticate(String username, String credentials)
>>> uses Container.getLogger(), whereas the other RealmBase.authenticate()
>>> methods use LogFactory.getLog(). Shouldn't this be consistent?
>>> This is where my confusion has stemmed from.
>>
>> Well, yes, it's a problem. It's simple: as soon as the container is 
>> started, all the container logging should go to container.getLogger(), 
>> as it used to in Tomcat 4.x.
>>
>> That was my idea.
> 
> Another option is to use something like:
>  log = LogFactory.getLog(container.logName()+".RealmBase");
> 
> The output will usually go to the container log, but it allows you to 
> only set the Realm to log as debug.

That seems like a good idea.

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Logging (was: Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java)

Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message ----- 
From: "Remy Maucherat" <re...@apache.org>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Saturday, February 19, 2005 2:55 AM
Subject: Logging (was: Re: cvs commit: 
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm 
DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java 
JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java)


> Jan Luehe wrote:
>> Remy,
>>
>> Remy Maucherat wrote:
>>
>>>Jan Luehe wrote:
>>>
>>>It's a little risky. We should use the container logger only while the 
>>>classloader is initialized.
>>>
>>>It's probably far from perfect ;)
>>
>> Then how about RealmBase.authenticate()?
>>
>> RealmBase.authenticate(String username, String credentials)
>> uses Container.getLogger(), whereas the other RealmBase.authenticate()
>> methods use LogFactory.getLog(). Shouldn't this be consistent?
>> This is where my confusion has stemmed from.
>
>Well, yes, it's a problem. It's simple: as soon as the container is 
>started, all the container logging should go to container.getLogger(), as 
>it used to in Tomcat 4.x.
>
>That was my idea.

Another option is to use something like:
  log = LogFactory.getLog(container.logName()+".RealmBase");

The output will usually go to the container log, but it allows you to only 
set the Realm to log as debug.

>
>> If you agree, I can help make the inconsistent cases consistent.
>
>Sure.
>
>>>In parallel, I want to start a commons component about a j.u.logging 
>>>implementation keyed per classloader (as seen in bug 33143; it may be 
>>>expanded a little later to allow per classloader configuration).
>>>
>>>I'm looking for committers for the proposal :)
>>
>> Sounds interesting!
>
>Actually, it's not a very interesting project ;)
>
>The support for j.u.logging is bad at the moment, as there is no (to my 
>knowledge) implementation of j.u.logging which can realistically be used in 
>a server like Tomcat. I hope the core (log manager + rotatable logger) can 
>fit inside a JAR smaller than c-l-api.
>
>Before moving to commons (svn is scaring me ;) ), I think I should start 
>putting the code together in j-t-c/juli (as mentioned, juli means Java Util 
>Logging Implementation). Is that ok ? (and is the name ok ?)

Welcome to j-t-c, Juli.

>
>Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org





This message is intended only for the use of the person(s) listed above as the intended recipient(s), and may contain information that is PRIVILEGED and CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or distribute this message or any attachment. If you received this communication in error, please notify us immediately by e-mail and then delete all copies of this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through the Internet is not secure. Do not send confidential or sensitive information, such as social security numbers, account numbers, personal identification numbers and passwords, to us via ordinary (unencrypted) e-mail.



Logging (was: Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java)

Posted by Remy Maucherat <re...@apache.org>.
Jan Luehe wrote:
> Remy,
> 
> Remy Maucherat wrote:
> 
>>Jan Luehe wrote:
>>
>>It's a little risky. We should use the container logger only while the 
>>classloader is initialized.
>>
>>It's probably far from perfect ;)
> 
> Then how about RealmBase.authenticate()?
> 
> RealmBase.authenticate(String username, String credentials)
> uses Container.getLogger(), whereas the other RealmBase.authenticate()
> methods use LogFactory.getLog(). Shouldn't this be consistent?
> This is where my confusion has stemmed from.

Well, yes, it's a problem. It's simple: as soon as the container is 
started, all the container logging should go to container.getLogger(), 
as it used to in Tomcat 4.x.

That was my idea.

> If you agree, I can help make the inconsistent cases consistent.

Sure.

>>In parallel, I want to start a commons component about a j.u.logging 
>>implementation keyed per classloader (as seen in bug 33143; it may be 
>>expanded a little later to allow per classloader configuration).
>>
>>I'm looking for committers for the proposal :)
> 
> Sounds interesting!

Actually, it's not a very interesting project ;)

The support for j.u.logging is bad at the moment, as there is no (to my 
knowledge) implementation of j.u.logging which can realistically be used 
in a server like Tomcat. I hope the core (log manager + rotatable 
logger) can fit inside a JAR smaller than c-l-api.

Before moving to commons (svn is scaring me ;) ), I think I should start 
putting the code together in j-t-c/juli (as mentioned, juli means Java 
Util Logging Implementation). Is that ok ? (and is the name ok ?)

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

Posted by Jan Luehe <Ja...@Sun.COM>.
Remy,

Remy Maucherat wrote:
> Jan Luehe wrote:
> 
>>Remy Maucherat wrote:
>>
>>I'm still confused. ;-)
>>Which log messages are supposed to go to LogFactory.getLog(), and which
>>ones to Container.getLogger()?
>>For example, in StandardContext.java, we're using LogFactory.getLog()
>>exclusively. Shouldn't most of them also be considered app specific
>>and therefore be directed to Container.getLogger()?
> 
> 
> It's a little risky. We should use the container logger only while the 
> classloader is initialized.
> 
> It's probably far from perfect ;)

Then how about RealmBase.authenticate()?

RealmBase.authenticate(String username, String credentials)
uses Container.getLogger(), whereas the other RealmBase.authenticate()
methods use LogFactory.getLog(). Shouldn't this be consistent?
This is where my confusion has stemmed from.

If you agree, I can help make the inconsistent cases consistent.

> In parallel, I want to start a commons component about a j.u.logging 
> implementation keyed per classloader (as seen in bug 33143; it may be 
> expanded a little later to allow per classloader configuration).
> 
> I'm looking for committers for the proposal :)

Sounds interesting!

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

Posted by Remy Maucherat <re...@apache.org>.
Jan Luehe wrote:
> Remy Maucherat wrote:
> 
> I'm still confused. ;-)
> Which log messages are supposed to go to LogFactory.getLog(), and which
> ones to Container.getLogger()?
> For example, in StandardContext.java, we're using LogFactory.getLog()
> exclusively. Shouldn't most of them also be considered app specific
> and therefore be directed to Container.getLogger()?

It's a little risky. We should use the container logger only while the 
classloader is initialized.

It's probably far from perfect ;)

> I understand the difference between the 2 "Log" types is that one
> carries the app name and the container nesting levels in its name,
> whereas the other carries the fully qualified class name of the
> container class that issued the log message.
> 
> Therefore, while the former allows log messages to be differentiated
> by app name in the server log, the latter allows to pinpoint the
> container component that printed the log message. I think a combination
> of the two would be most useful.
> 
> I also think it would make sense to be able to distinguish the log
> messages issued by ServletContext.log() from those log messages
> that originate from the container.

Yes, but from what I understand nobody uses these stupid ServletContext 
log methods anymore (they're right, it's a good idea :) ). So the log 
would be empty quite often, and the per container categories are useless.

I think the per container Logger from Tomcat 4.x was decent, that's what 
I'm trying to replicate.

> I'll undo my 2 previous commits until I have a better understanding
> of the issue.

In parallel, I want to start a commons component about a j.u.logging 
implementation keyed per classloader (as seen in bug 33143; it may be 
expanded a little later to allow per classloader configuration).

I'm looking for committers for the proposal :)

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

Posted by Jan Luehe <Ja...@Sun.COM>.

Remy Maucherat wrote:
> Jan Luehe wrote:
> 
>>Remy Maucherat wrote:
>>
>>
>>>luehe@apache.org wrote:
>>>
>>>
>>>
>>>>luehe       2005/02/18 11:17:57
>>>>
>>>>Modified:    catalina/src/share/org/apache/catalina/realm
>>>>                      DataSourceRealm.java JAASCallbackHandler.java
>>>>                      JAASMemoryLoginModule.java JDBCRealm.java
>>>>                      JNDIRealm.java RealmBase.java
>>>>                      UserDatabaseRealm.java
>>>>Log:
>>>>More logging cleanup
>>>
>>>
>>>I disagree with these changes: all these logs are application specific, 
>>>which is why I direct them to the application category.
>>>
>>>Can you explain why it is bad ?
>>
>>
>>I think the boundaries between container and application specific logs
>>has been pretty blurred, and we've been using the two inconsistently in
>>the past.
>>
>>In my interpretation, any log messages issued by ServletContext.log()
>>should be directed to container.getLogger(), but any container
>>generated log messages should be directed to LogFactory.getLog().
>>
>>Where do you see the line? This has been something that has confused
>>me in the past.
> 
> 
> The thing has been blurred in 5.0. In 4.1, loggers were associated with 
> containers (ex: a context). All logging for the container (including all 
> subcomponents such as realm, manager, etc) would go to it. I liked that 
> better.
> 
> I reintroduced that in 5.5 by adding a per container category (with 
> nesting).

I'm still confused. ;-)
Which log messages are supposed to go to LogFactory.getLog(), and which
ones to Container.getLogger()?
For example, in StandardContext.java, we're using LogFactory.getLog()
exclusively. Shouldn't most of them also be considered app specific
and therefore be directed to Container.getLogger()?

I understand the difference between the 2 "Log" types is that one
carries the app name and the container nesting levels in its name,
whereas the other carries the fully qualified class name of the
container class that issued the log message.

Therefore, while the former allows log messages to be differentiated
by app name in the server log, the latter allows to pinpoint the
container component that printed the log message. I think a combination
of the two would be most useful.

I also think it would make sense to be able to distinguish the log
messages issued by ServletContext.log() from those log messages
that originate from the container.

I'll undo my 2 previous commits until I have a better understanding
of the issue.

Thanks,


Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

Posted by Remy Maucherat <re...@apache.org>.
Jan Luehe wrote:
> 
> Remy Maucherat wrote:
> 
>>luehe@apache.org wrote:
>>
>>
>>>luehe       2005/02/18 11:17:57
>>>
>>> Modified:    catalina/src/share/org/apache/catalina/realm
>>>                       DataSourceRealm.java JAASCallbackHandler.java
>>>                       JAASMemoryLoginModule.java JDBCRealm.java
>>>                       JNDIRealm.java RealmBase.java
>>>                       UserDatabaseRealm.java
>>> Log:
>>> More logging cleanup
>>
>>
>>I disagree with these changes: all these logs are application specific, 
>>which is why I direct them to the application category.
>>
>>Can you explain why it is bad ?
> 
> 
> I think the boundaries between container and application specific logs
> has been pretty blurred, and we've been using the two inconsistently in
> the past.
> 
> In my interpretation, any log messages issued by ServletContext.log()
> should be directed to container.getLogger(), but any container
> generated log messages should be directed to LogFactory.getLog().
> 
> Where do you see the line? This has been something that has confused
> me in the past.

The thing has been blurred in 5.0. In 4.1, loggers were associated with 
containers (ex: a context). All logging for the container (including all 
subcomponents such as realm, manager, etc) would go to it. I liked that 
better.

I reintroduced that in 5.5 by adding a per container category (with 
nesting).

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

Posted by Jan Luehe <Ja...@Sun.COM>.

Remy Maucherat wrote:
> luehe@apache.org wrote:
> 
>>luehe       2005/02/18 11:17:57
>>
>>  Modified:    catalina/src/share/org/apache/catalina/realm
>>                        DataSourceRealm.java JAASCallbackHandler.java
>>                        JAASMemoryLoginModule.java JDBCRealm.java
>>                        JNDIRealm.java RealmBase.java
>>                        UserDatabaseRealm.java
>>  Log:
>>  More logging cleanup
> 
> 
> I disagree with these changes: all these logs are application specific, 
> which is why I direct them to the application category.
> 
> Can you explain why it is bad ?

I think the boundaries between container and application specific logs
has been pretty blurred, and we've been using the two inconsistently in
the past.

In my interpretation, any log messages issued by ServletContext.log()
should be directed to container.getLogger(), but any container
generated log messages should be directed to LogFactory.getLog().

Where do you see the line? This has been something that has confused
me in the past.


Jan


> Rémy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm DataSourceRealm.java JAASCallbackHandler.java JAASMemoryLoginModule.java JDBCRealm.java JNDIRealm.java RealmBase.java UserDatabaseRealm.java

Posted by Remy Maucherat <re...@apache.org>.
luehe@apache.org wrote:
> luehe       2005/02/18 11:17:57
> 
>   Modified:    catalina/src/share/org/apache/catalina/realm
>                         DataSourceRealm.java JAASCallbackHandler.java
>                         JAASMemoryLoginModule.java JDBCRealm.java
>                         JNDIRealm.java RealmBase.java
>                         UserDatabaseRealm.java
>   Log:
>   More logging cleanup

I disagree with these changes: all these logs are application specific, 
which is why I direct them to the application category.

Can you explain why it is bad ?

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org