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