You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by na...@apache.org on 2000/12/31 17:30:35 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm LocalStrings_es.properties JDBCRealm.java LocalStrings.properties MemoryRealm.java RealmBase.java

nacho       00/12/31 08:30:35

  Modified:    catalina/src/share/org/apache/catalina/realm JDBCRealm.java
                        LocalStrings.properties MemoryRealm.java
                        RealmBase.java
  Added:       catalina/src/share/org/apache/catalina/realm
                        LocalStrings_es.properties
  Log:
  Cleaned a bit :
  
  * Deleted duplicated PropertyChangeListerner
  support code between RealmBase and Realms.
  
  * log methods now in RealmBase, cleaned duplicate code.
  
  * JDBCRealm now need both connectionName
  and connectionPassword to use the 3 params getConnection
  
  Revision  Changes    Path
  1.8       +60 -224   jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/JDBCRealm.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JDBCRealm.java	2000/12/16 23:49:35	1.7
  +++ JDBCRealm.java	2000/12/31 16:30:35	1.8
  @@ -97,7 +97,7 @@
    * @author Carson McDonald
    */
   
  -public class JDBCRealm 
  +public class JDBCRealm
       extends RealmBase {
   
   
  @@ -111,24 +111,12 @@
   
   
       /**
  -     * The Container with which this Realm is associated.
  -     */
  -    private Container container = null;
  -
  -
  -    /**
        * The connection to the database.
        */
       private Connection dbConnection = null;
   
   
       /**
  -     * The debugging detail level for this component.
  -     */
  -    private int debug = 0;
  -
  -
  -    /**
        * The JDBC driver to use.
        */
       private String driverName = null;
  @@ -137,13 +125,14 @@
       /**
        * Descriptive information about this Realm implementation.
        */
  -    private static final String info = "org.apache.catalina.realm.JDBCRealm/1.0";
   
  +    protected static final String info = "org.apache.catalina.realm.JDBCRealm/1.0";
   
       /**
  -     * The lifecycle event support for this component.
  +     * Descriptive information about this Realm implementation.
        */
  -    private LifecycleSupport lifecycle = new LifecycleSupport(this);
  +
  +    private static final String name = "JDBCRealm";
   
   
       /**
  @@ -179,12 +168,6 @@
   
   
       /**
  -     * The property change support for this component.
  -     */
  -    private PropertyChangeSupport support = new PropertyChangeSupport(this);
  -
  -
  -    /**
        * The column in the user table that holds the user's credintials
        */
       private String userCredCol = null;
  @@ -241,44 +224,6 @@
   
   
       /**
  -     * Return the Container with which this Realm has been associated.
  -     */
  -    public Container getContainer() {
  -	return (container);
  -    }
  -
  -
  -    /**
  -     * Set the Container with which this Realm has been associated.
  -     *
  -     * @param container The associated Container
  -     */
  -    public void setContainer(Container container) {
  -	Container oldContainer = this.container;
  -	this.container = container;
  -	support.firePropertyChange("container", oldContainer, this.container);
  -    }
  -
  -
  -    /**
  -     * Return the debugging detail level for this component.
  -     */
  -    public int getDebug() {
  -	return (this.debug);
  -    }
  -
  -
  -    /**
  -     * Set the debugging detail level for this component.
  -     *
  -     * @param debug The new debugging detail level
  -     */
  -    public void setDebug(int debug) {
  -	this.debug = debug;
  -    }
  -
  -
  -    /**
        * Set the JDBC driver that will be used.
        *
        * @param driverName The driver name
  @@ -289,16 +234,6 @@
   
   
       /**
  -     * Return descriptive information about this Realm implementation and
  -     * the corresponding version number, in the format
  -     * <code>&lt;description&gt;/&lt;version&gt;</code>.
  -     */
  -    public String getInfo() {
  -	return (info);
  -    }
  -
  -
  -    /**
        * Set the column in the user role table that names a role
        *
        * @param userRoleNameCol The column name
  @@ -390,19 +325,29 @@
       }
   
   
  -    // --------------------------------------------------------- Public Methods
  +    /**
  +     * Return descriptive information about this Realm implementation and
  +     * the corresponding version number, in the format
  +     * <code>&lt;description&gt;/&lt;version&gt;</code>.
  +     */
  +    public String getInfo() {
  +
  +	return this.info;
   
  +    }
   
       /**
  -     * Add a property change listener to this component.
  -     *
  -     * @param listener The listener to add
  +     * Return short name of this Realm implementation
        */
  -    public void addPropertyChangeListener(PropertyChangeListener listener) {
  -	support.addPropertyChangeListener(listener);
  +    public String getName() {
  +
  +	return name;
  +
       }
   
  +    // --------------------------------------------------------- Public Methods
   
  +
       /**
        *
        * Return the Principal associated with the specified username and
  @@ -425,26 +370,8 @@
   					       String credentials) {
   
           try {
  -
  -	    // Establish the database connection if necessary
  -	    if ((dbConnection == null) || dbConnection.isClosed()) {
  -		log(sm.getString("jdbcRealm.authDBClosed"));
  -                if ((connectionName == null || connectionName.equals("")) &&
  -                    (connectionPassword == null || connectionPassword.equals(""))) {
  -                    dbConnection = DriverManager.getConnection(connectionURL);
  -                } else {
  -                    dbConnection = DriverManager.getConnection(connectionURL,
  -                                                               connectionName,
  -                                                               connectionPassword);
  -                }
  -		if( (dbConnection == null) || dbConnection.isClosed() ) {
  -		    log(sm.getString("jdbcRealm.authDBReOpenFail"));
  -		    return null;
  -		}
  -// XXX Commented it gives problems on Oracle 8i Drivers
  -//		dbConnection.setReadOnly(true);
  -	    }
   
  +            if (!checkConnection()) return null;
   	    // Create the authentication search prepared statement if necessary
   	    if (preparedAuthenticate == null) {
   		String sql = "SELECT " + userCredCol + " FROM " + userTable +
  @@ -543,31 +470,15 @@
   
       /**
        *
  -     * Return the Principal associated with the specified username and
  -     * credentials, if there is one; otherwise return <code>null</code>.
  -     *
  -     * See other authenticate for more details.
  -     * 
  -     * @param username Username of the Principal to look up
  -     * @param credentials Password or other credentials to use in
  -     *  authenticating this username
  -     */
  -    public Principal authenticate(String username, byte[] credentials) {
  -	return (authenticate(username, credentials.toString()));
  -    }
  -
  -
  -    /**
  -     *
        * Return <code>true</code> if the specified Principal has the specified
        * security role, within the context of this Realm; otherwise return
        * <code>false</code>.
        *
  -     * If there are any errors with the JDBC connection, executing 
  +     * If there are any errors with the JDBC connection, executing
        * the query or anything we return false (not in role set). This
  -     * event is also logged. 
  +     * event is also logged.
        *
  -     * If there is some SQL exception the connection is set to null. 
  +     * If there is some SQL exception the connection is set to null.
        * This will allow a retry on the next auth attempt. This might not
        * be the best thing to do but it will keep Catalina from needing a
        * restart if the database goes down.
  @@ -577,7 +488,7 @@
        */
       public boolean hasRole(Principal principal, String role) {
           String username = principal.getName();
  -     
  +
   	// Is the specified Principal one that we created?
   	if (!(principal instanceof JDBCRealmPrincipal))
   	    return (false);
  @@ -588,22 +499,11 @@
       }
   
   
  -    /**
  -     * Remove a property change listener from this component.
  -     *
  -     * @param listener The listener to remove
  -     */
  -    public void removePropertyChangeListener(PropertyChangeListener listener) {
  -	support.removePropertyChangeListener(listener);
  -    }
  -
  -
       // -------------------------------------------------------- Package Methods
   
   
       // ------------------------------------------------------ Protected Methods
   
  -
       /**
        * Return the password associated with the given principal's user name.
        */
  @@ -611,89 +511,11 @@
           return (null);
       }
   
  -
       /**
        * Return the Principal associated with the given user name.
        */
       protected Principal getPrincipal(String username) {
  -	return (null);
  -    }
  -
  -
  -    // -------------------------------------------------------- Private Methods
  -
  -
  -    /**
  -     * Log a message on the Logger associated with our Container (if any)
  -     *
  -     * @param message Message to be logged
  -     */
  -    private void log(String message) {
  -	Logger logger = null;
  -
  -	if (container != null) {
  -	    logger = container.getLogger();
  -        }
  -
  -	if (logger != null) {
  -	    logger.log("JDBCRealm[" + container.getName() + "]: " + message);
  -        } else {
  -	    String containerName = null;
  -	    if (container != null) {
  -		containerName = container.getName();
  -            }
  -	    System.out.println("JDBCRealm[" + containerName + "]: " + message);
  -	}
  -    }
  -
  -
  -    /**
  -     * Log a message on the Logger associated with our Container (if any)
  -     *
  -     * @param message Message to be logged
  -     * @param throwable Associated exception
  -     */
  -    private void log(String message, Throwable throwable) {
  -	Logger logger = null;
  -
  -	if (container != null) {
  -	    logger = container.getLogger();
  -        }
  -
  -	if (logger != null) {
  -	    logger.log("JDBCRealm[" + container.getName() + "] " + message, throwable);
  -        } else {
  -	    String containerName = null;
  -	    if (container != null) {
  -		containerName = container.getName();
  -            }
  -	    System.out.println("JDBCRealm[" + containerName + "]: " + message);
  -	    System.out.println("" + throwable);
  -	    throwable.printStackTrace(System.out);
  -	}
  -    }
  -
  -
  -    // ------------------------------------------------------ Lifecycle Methods
  -
  -
  -    /**
  -     * Add a lifecycle event listener to this component.
  -     *
  -     * @param listener The listener to add
  -     */
  -    public void addLifecycleListener(LifecycleListener listener) {
  -	lifecycle.addLifecycleListener(listener);
  -    }
  -
  -
  -    /**
  -     * Remove a lifecycle event listener from this component.
  -     *
  -     * @param listener The listener to remove
  -     */
  -    public void removeLifecycleListener(LifecycleListener listener) {
  -	lifecycle.removeLifecycleListener(listener);
  +        return (null);
       }
   
   
  @@ -714,27 +536,12 @@
   	if (started) {
   	    throw new LifecycleException (sm.getString("jdbcRealm.alreadyStarted"));
           }
  -
   	lifecycle.fireLifecycleEvent(START_EVENT, null);
   	started = true;
  -
  -        try {
  -            Class.forName(driverName);
  -            if ((connectionName == null || connectionName.equals("")) &&
  -                (connectionPassword == null || connectionPassword.equals(""))){
  -                        dbConnection = DriverManager.getConnection(connectionURL);
  -            } else {
  -                        dbConnection =DriverManager.getConnection(connectionURL,
  -                            connectionName,
  -                            connectionPassword);
  -            }
  -
  -        } catch( ClassNotFoundException ex ) {
  -	  throw new LifecycleException("JDBCRealm.start.readXml: " + ex, ex);
  +        if(!checkConnection()) {
  +            throw new LifecycleException (sm.getString("jdbcRealm.alreadyStarted"));
           }
  -        catch( SQLException ex ) {
  -	  throw new LifecycleException("JDBCRealm.start.readXml: " + ex, ex);
  -        }
  +
       }
   
   
  @@ -790,7 +597,6 @@
               // convert the byte array to hex string
               Base64 enc=new Base64();
               return new String(enc.encode(HexUtils.convert(dig).getBytes()));
  -//            return HexUtils.convert(dig);
   
           } catch( Exception ex ) {
                   ex.printStackTrace();
  @@ -798,6 +604,35 @@
           }
       }
   
  +    private boolean checkConnection(){
  +        try {
  +            if( (dbConnection == null) || dbConnection.isClosed() ) {
  +                Class.forName(driverName);
  +                log(sm.getString("jdbcRealm.checkConnectionDBClosed"));
  +                if ((connectionName == null || connectionName.equals("")) ||
  +                        (connectionPassword == null || connectionPassword.equals(""))) {
  +                        dbConnection = DriverManager.getConnection(connectionURL);
  +                } else {
  +                        dbConnection = DriverManager.getConnection(connectionURL,
  +                                                                   connectionName,
  +                                                                   connectionPassword);
  +                }
  +                if( dbConnection == null || dbConnection.isClosed() ) {
  +                  log(sm.getString("jdbcRealm.checkConnectionDBReOpenFail"));
  +                  return false;
  +                }
  +            }
  +            return true;
  +        }catch (SQLException ex){
  +            log(sm.getString("jdbcRealm.checkConnectionSQLException"),ex);
  +            return false;
  +        }
  +        catch( ClassNotFoundException ex ) {
  +            log(sm.getString("jdbcRealm.checkConnectionClassNotFoundException"),ex);
  +            return false;
  +        }
  +    }
  +
       public static void main(String args[] ) {
           if (args.length >= 2) {
               if( args[0].equalsIgnoreCase("-a")){
  @@ -809,6 +644,7 @@
           }
   
       }
  +
   }
   
   
  
  
  
  1.2       +10 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/LocalStrings.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalStrings.properties	2000/08/11 22:45:17	1.1
  +++ LocalStrings.properties	2000/12/31 16:30:35	1.2
  @@ -1,3 +1,10 @@
  +# $Id: LocalStrings.properties,v 1.2 2000/12/31 16:30:35 nacho Exp $
  +
  +# language 
  +
  +# package org.apache.catalina.realm
  +
  +
   memoryRealm.alreadyStarted=This Realm has already been started
   memoryRealm.authenticateFailure=Authentication unsuccessful for user {0}
   memoryRealm.authenticateSuccess=Authentication successful for user {0}
  @@ -16,8 +23,6 @@
   jdbcRealm.hasRoleSuccess=User {0} has role {1}
   jdbcRealm.hasRoleSQLException=There was an SQLException while in hasRole: {0}
   jdbcRealm.notStarted=This Realm has not yet been started
  -jdbcRealm.authDBClosed=The database connection is null or was found to be closed. Trying to re-open it.
  -jdbcRealm.authDBReOpenFail=The re-open on the database failed. The database could be down.
  -jdbcRealm.hasRoleDBClosed=The database connection is null or was found to be closed. Trying to re-open it.
  -jdbcRealm.hasRoleDBReOpenFail=The re-open on the database failed. The database could be down.
  -
  +jdbcRealm.checkConnectionDBClosed=The database connection is null or was found to be closed. Trying to re-open it.
  +jdbcRealm.checkConnectionDBReOpenFail=The re-open on the database failed. The database could be down.
  +jdbcRealm.checkConnectionClassNotFoundException=JDBC driver class not found {0}
  
  
  
  1.2       +16 -184   jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/MemoryRealm.java
  
  Index: MemoryRealm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/MemoryRealm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MemoryRealm.java	2000/08/11 22:45:17	1.1
  +++ MemoryRealm.java	2000/12/31 16:30:35	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/MemoryRealm.java,v 1.1 2000/08/11 22:45:17 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/11 22:45:17 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/MemoryRealm.java,v 1.2 2000/12/31 16:30:35 nacho Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/12/31 16:30:35 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    * synchronization is performed around accesses to the principals collection.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/08/11 22:45:17 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/31 16:30:35 $
    */
   
   public final class MemoryRealm
  @@ -113,22 +113,17 @@
   
   
       /**
  -     * The debugging detail level for this component.
  -     */
  -    private int debug = 0;
  -
  -
  -    /**
        * Descriptive information about this Realm implementation.
        */
  -    private static final String info =
  +    protected final String info =
   	"org.apache.catalina.realm.MemoryRealm/1.0";
   
   
       /**
  -     * The lifecycle event support for this component.
  +     * Descriptive information about this Realm implementation.
        */
  -    private LifecycleSupport lifecycle = new LifecycleSupport(this);
  +
  +    protected static final String name = "MemoryRealm";
   
   
       /**
  @@ -156,89 +151,34 @@
        */
       private boolean started = false;
   
  -
  -    /**
  -     * The property change support for this component.
  -     */
  -    private PropertyChangeSupport support = new PropertyChangeSupport(this);
  -
  -
       // ------------------------------------------------------------- Properties
   
   
       /**
  -     * Return the Container with which this Realm has been associated.
  -     */
  -    public Container getContainer() {
  -
  -	return (container);
  -
  -    }
  -
  -
  -    /**
  -     * Set the Container with which this Realm has been associated.
  -     *
  -     * @param container The associated Container
  -     */
  -    public void setContainer(Container container) {
  -
  -	Container oldContainer = this.container;
  -	this.container = container;
  -	support.firePropertyChange("container", oldContainer, this.container);
  -
  -    }
  -
  -
  -    /**
  -     * Return the debugging detail level for this component.
  -     */
  -    public int getDebug() {
  -
  -	return (this.debug);
  -
  -    }
  -
  -
  -    /**
  -     * Set the debugging detail level for this component.
  -     *
  -     * @param debug The new debugging detail level
  -     */
  -    public void setDebug(int debug) {
  -
  -	this.debug = debug;
  -
  -    }
  -
  -
  -    /**
        * Return descriptive information about this Realm implementation and
        * the corresponding version number, in the format
        * <code>&lt;description&gt;/&lt;version&gt;</code>.
        */
       public String getInfo() {
   
  -	return (info);
  +	return info;
   
       }
   
  -
  -    // --------------------------------------------------------- Public Methods
  -
  -
       /**
  -     * Add a property change listener to this component.
  -     *
  -     * @param listener The listener to add
  +     * Return short name of this Realm implementation
        */
  -    public void addPropertyChangeListener(PropertyChangeListener listener) {
  +    public String getName() {
   
  -	support.addPropertyChangeListener(listener);
  +	return name;
   
       }
   
   
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +
       /**
        * Return the Principal associated with the specified username and
        * credentials, if there is one; otherwise return <code>null</code>.
  @@ -266,21 +206,6 @@
   
   
       /**
  -     * Return the Principal associated with the specified username and
  -     * credentials, if there is one; otherwise return <code>null</code>.
  -     *
  -     * @param username Username of the Principal to look up
  -     * @param credentials Password or other credentials to use in
  -     *  authenticating this username
  -     */
  -    public Principal authenticate(String username, byte[] credentials) {
  -
  -	return (authenticate(username, credentials.toString()));
  -
  -    }
  -
  -
  -    /**
        * Return <code>true</code> if the specified Principal has the specified
        * security role, within the context of this Realm; otherwise return
        * <code>false</code>.
  @@ -307,18 +232,6 @@
       }
   
   
  -    /**
  -     * Remove a property change listener from this component.
  -     *
  -     * @param listener The listener to remove
  -     */
  -    public void removePropertyChangeListener(PropertyChangeListener listener) {
  -
  -	support.removePropertyChangeListener(listener);
  -
  -    }
  -
  -
       // -------------------------------------------------------- Package Methods
   
   
  @@ -373,88 +286,8 @@
       }
   
   
  -    // -------------------------------------------------------- Private Methods
  -
  -
  -    /**
  -     * Log a message on the Logger associated with our Container (if any)
  -     *
  -     * @param message Message to be logged
  -     */
  -    private void log(String message) {
  -
  -	Logger logger = null;
  -	if (container != null)
  -	    logger = container.getLogger();
  -	if (logger != null)
  -	    logger.log("MemoryRealm[" + container.getName() + "]: "
  -		       + message);
  -	else {
  -	    String containerName = null;
  -	    if (container != null)
  -		containerName = container.getName();
  -	    System.out.println("MemoryRealm[" + containerName
  -			       + "]: " + message);
  -	}
  -
  -    }
  -
   
       /**
  -     * Log a message on the Logger associated with our Container (if any)
  -     *
  -     * @param message Message to be logged
  -     * @param throwable Associated exception
  -     */
  -    private void log(String message, Throwable throwable) {
  -
  -	Logger logger = null;
  -	if (container != null)
  -	    logger = container.getLogger();
  -	if (logger != null)
  -	    logger.log("MemoryRealm[" + container.getName() + "] "
  -		       + message, throwable);
  -	else {
  -	    String containerName = null;
  -	    if (container != null)
  -		containerName = container.getName();
  -	    System.out.println("MemoryRealm[" + containerName
  -			       + "]: " + message);
  -	    System.out.println("" + throwable);
  -	    throwable.printStackTrace(System.out);
  -	}
  -
  -    }
  -
  -
  -    // ------------------------------------------------------ Lifecycle Methods
  -
  -
  -    /**
  -     * Add a lifecycle event listener to this component.
  -     *
  -     * @param listener The listener to add
  -     */
  -    public void addLifecycleListener(LifecycleListener listener) {
  -
  -	lifecycle.addLifecycleListener(listener);
  -
  -    }
  -
  -
  -    /**
  -     * Remove a lifecycle event listener from this component.
  -     *
  -     * @param listener The listener to remove
  -     */
  -    public void removeLifecycleListener(LifecycleListener listener) {
  -
  -	lifecycle.removeLifecycleListener(listener);
  -
  -    }
  -
  -
  -    /**
        * Prepare for active use of the public methods of this Component.
        *
        * @exception IllegalStateException if this component has already been
  @@ -646,5 +479,4 @@
   	realm.addUser(username, password, roles);
   
       }
  -
   }
  
  
  
  1.2       +69 -10    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/RealmBase.java
  
  Index: RealmBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RealmBase.java	2000/08/11 22:45:17	1.1
  +++ RealmBase.java	2000/12/31 16:30:35	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v 1.1 2000/08/11 22:45:17 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/11 22:45:17 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v 1.2 2000/12/31 16:30:35 nacho Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/12/31 16:30:35 $
    *
    * ====================================================================
    *
  @@ -93,7 +93,7 @@
    * location) are identical to those currently supported by Tomcat 3.X.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/08/11 22:45:17 $
  + * @version $Revision: 1.2 $ $Date: 2000/12/31 16:30:35 $
    */
   
   public abstract class RealmBase
  @@ -123,6 +123,11 @@
   
   
       /**
  +     * Short name for this Realm Implementation
  +     */
  +    protected static final String name = "RealmBase";
  +
  +    /**
        * The lifecycle event support for this component.
        */
       protected LifecycleSupport lifecycle = new LifecycleSupport(this);
  @@ -185,14 +190,11 @@
   
       }
   
  -
       /**
        * Return the debugging detail level for this component.
        */
       public int getDebug() {
  -
   	return (this.debug);
  -
       }
   
   
  @@ -202,9 +204,7 @@
        * @param debug The new debugging detail level
        */
       public void setDebug(int debug) {
  -
   	this.debug = debug;
  -
       }
   
   
  @@ -215,10 +215,18 @@
        */
       public String getInfo() {
   
  -	return (info);
  +	return info;
   
       }
   
  +    /**
  +     * Return short name of this Realm implementation
  +     */
  +    public String getName() {
  +
  +	return name;
  +
  +    }
   
       // --------------------------------------------------------- Public Methods
   
  @@ -451,6 +459,57 @@
        * Return the Principal associated with the given user name.
        */
       protected abstract Principal getPrincipal(String username);
  +
  +
  +    /**
  +     * Log a message on the Logger associated with our Container (if any)
  +     *
  +     * @param message Message to be logged
  +     */
  +    protected void log(String message) {
  +	Logger logger = null;
  +
  +	if (container != null) {
  +	    logger = container.getLogger();
  +        }
  +
  +	if (logger != null) {
  +	    logger.log(getName()+"[" + container.getName() + "]: " + message);
  +        } else {
  +	    String containerName = null;
  +	    if (container != null) {
  +		containerName = container.getName();
  +            }
  +	    System.out.println(getName()+"[" + containerName + "]: " + message);
  +	}
  +    }
  +
  +
  +    /**
  +     * Log a message on the Logger associated with our Container (if any)
  +     *
  +     * @param message Message to be logged
  +     * @param throwable Associated exception
  +     */
  +    protected void log(String message, Throwable throwable) {
  +	Logger logger = null;
  +
  +	if (container != null) {
  +	    logger = container.getLogger();
  +        }
  +
  +	if (logger != null) {
  +	    logger.log(getName()+"[" + container.getName() + "]: " + message, throwable);
  +        } else {
  +	    String containerName = null;
  +	    if (container != null) {
  +		containerName = container.getName();
  +            }
  +	    System.out.println(getName()+"[" + containerName + "]: " + message);
  +	    System.out.println("" + throwable);
  +	    throwable.printStackTrace(System.out);
  +	}
  +    }
   
   
   }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/realm/LocalStrings_es.properties
  
  Index: LocalStrings_es.properties
  ===================================================================
  # $Id: LocalStrings_es.properties,v 1.1 2000/12/31 16:30:35 nacho Exp $
  
  # language es
  
  # package org.apache.catalina.realm
  
  
  memoryRealm.alreadyStarted=Este Reino ya ha sido inicializado
  memoryRealm.authenticateFailure=Autentificacion fallida para el usuario {0}
  memoryRealm.authenticateSuccess=Autentificacion correcta para el usuario {0}
  memoryRealm.hasRoleFailure=El usuario {0} no tiene el rol {1}
  memoryRealm.hasRoleNone=Ningun usuario tiene el rol {0}
  memoryRealm.hasRoleSuccess=El usuario {0} tiene el rol {1}
  memoryRealm.hasRoleUser=El usuario {0} no existe en la base de datos de este reino
  memoryRealm.loadExist=El archivo {0} de usuarios no existe
  memoryRealm.loadPath=Caragando el archivo de usuarios {0}
  memoryRealm.notStarted=Este Reino ya no ha sido aun inicializado
  jdbcRealm.alreadyStarted=Este Reino ya ha sido inicializado
  jdbcRealm.authenticateFailure=Autentificacion fallida para el usuario {0}
  jdbcRealm.authenticateSuccess=Autentificacion correcta para el usuario {0}
  jdbcRealm.authenticateSQLException=Hubo una SQLException en authenticate: {0}
  jdbcRealm.hasRoleFailure=El usuario {0} no tiene el rol {1}
  jdbcRealm.hasRoleSuccess=El usuario {0} tiene el rol {1}
  jdbcRealm.hasRoleSQLException=Hubo una SQLException en hasRole: {0}
  jdbcRealm.notStarted=Este Reino ya no ha sido aun inicializado
  jdbcRealm.checkConnectionDBClosed=La conexion con la base de datos es nula o fue esta cerrada. Intentando reabrirla.
  jdbcRealm.checkConnectionDBReOpenFail=La reapertura de la base de datos fallo.La base de datos podria estar parada.
  jdbcRealm.checkConnectionClassNotFoundException=Clase del driver JDBC {0} no encontrada