cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa JDBCRealm.java

2001-10-05 Thread nacho

nacho   01/10/05 14:41:20

  Modified:src/share/org/apache/tomcat/modules/aaa JDBCRealm.java
  Log:
  Was not initting or stopping the JDBC connection at Tomcat init or shutdown
  
  Revision  ChangesPath
  1.8   +5 -5  
jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JDBCRealm.java2001/07/14 03:20:37 1.7
  +++ JDBCRealm.java2001/10/05 21:41:20 1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.7 
2001/07/14 03:20:37 nacho Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/07/14 03:20:37 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.8 
2001/10/05 21:41:20 nacho Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/10/05 21:41:20 $
*
* The Apache Software License, Version 1.1
*
  @@ -371,11 +371,11 @@
   }
   }
   
  -protected void ContextShutdown(Context ctx) throws TomcatException {
  +public void contextShutdown(Context ctx) throws TomcatException {
   if (started  JDBCStarted) close();
   }
   
  -protected void ContextInit(Context ctx) throws TomcatException {
  +public void contextInit(Context ctx) throws TomcatException {
   if (!started) {
   if (connectOnInit  !checkConnection()) {
   throw new RuntimeException(JDBCRealm cannot be started);
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa JDBCRealm.java

2001-04-10 Thread nacho

nacho   01/04/10 02:01:00

  Modified:src/share/org/apache/tomcat/modules/aaa JDBCRealm.java
  Log:
  The digest should be called on credentials, not on what's
  picked up from the database.
  
  Reported by Bojan Smojver
  
  Revision  ChangesPath
  1.6   +7 -6  
jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JDBCRealm.java2001/02/27 19:10:16 1.5
  +++ JDBCRealm.java2001/04/10 09:00:59 1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.5 
2001/02/27 19:10:16 costin Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/02/27 19:10:16 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.6 
2001/04/10 09:00:59 nacho Exp $
  + * $Revision: 1.6 $
  + * $Date: 2001/04/10 09:00:59 $
*
* The Apache Software License, Version 1.1
*
  @@ -277,14 +277,15 @@
   preparedAuthenticate.setString(1, username);
   ResultSet rs1 = preparedAuthenticate.executeQuery();
   if (rs1.next()) {
  -if (digest.equalsIgnoreCase("No")) {
  -if (credentials.equals(rs1.getString(1).trim())) {
  +String dbCredentials=rs1.getString(1).trim();
  +if( digest.equals("") || digest.equalsIgnoreCase("No")){
  +if (credentials.equals(dbCredentials)) {
   if (debug = 2)
   log(sm.getString("jdbcRealm.authenticateSuccess", 
username));
   return true;
   }
   } else {
  -if (credentials.equals(digest(rs1.getString(1), digest))) {
  +if (digest(credentials,digest).equals(dbCredentials)) {
   if (debug = 2)
   log(sm.getString("jdbcRealm.authenticateSuccess", 
username));
   return true;
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa JDBCRealm.java

2001-02-05 Thread nacho

nacho   01/02/05 18:05:46

  Modified:src/share/org/apache/tomcat/modules/aaa JDBCRealm.java
  Log:
  Bugzilla #307  #407
  
  Authentication failes using the JDBCRealm with Sybase ASE 11.9.2
  for Linux BugRat Report#560
  reported by: [EMAIL PROTECTED] (Allan Schweitz)
  
  JDBCRealm: Call trim() on names and roles read
  out of database BugRat Report#707
  reported by [EMAIL PROTECTED] (Adam Rabung)
  
  Revision  ChangesPath
  1.3   +44 -37
jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JDBCRealm.java2001/02/04 22:08:24 1.2
  +++ JDBCRealm.java2001/02/06 02:05:46 1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.2 
2001/02/04 22:08:24 nacho Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/02/04 22:08:24 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.3 
2001/02/06 02:05:46 nacho Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/02/06 02:05:46 $
*
* The Apache Software License, Version 1.1
*
  @@ -76,8 +76,13 @@
   
   /**
* Implmentation of bRealm/b that works with any JDBC supported database.
  - * See the JDBCRealm.howto for more details on how to set up the database and for 
configuration options. TODO:
  - * - Work on authentication with non-plaintext passwords
  + * See the JDBCRealm.howto for more details on how to set up the database and
  + * for configuration options.
  + *
  + *
  + * TODO: - Work on authentication with non-plaintext passwords
  + *
  + *
* @author Craig R. McClanahan
* @author Carson McDonald
* @author Ignacio J. Ortega
  @@ -210,44 +215,48 @@
   /**
* Set the column in the user role table that names a role
* @param roleNameCol The column name
  - */
  + */
   public void setRoleNameCol(String roleNameCol) {
   this.roleNameCol = roleNameCol;
   }
   
   /**
* Gets the digest algorithm  used for credentials in the database
  - * could be the same that MessageDigest accepts vor algorithm and "No" that is 
the Default
  - * @return 
  - */
  + * could be the same that MessageDigest accepts vor algorithm and "No" that
  + * is the Default
  + * @return
  + */
   public String getDigest() {
   return digest;
   }
   
   /**
* Sets the digest algorithm  used for credentials in the database
  - * could be the same that MessageDigest accepts vor algorithm and "No" that is 
the Default
  + * could be the same that MessageDigest accepts vor algorithm and "No"
  + * that is the Default
* @param algorithm the Encode type
  - */
  + */
   public void setDigest(String algorithm) {
   digest = algorithm;
   }
  -
  -/**
  - * When connectOnInit is setted to "true" the JDBC connection is started at tomcat 
init
  - * if false the connection is started in the first times is needed.
  - * @param s "true" or "false"
  - */
  -public void setConnectOnInit(String s) {
  -connectOnInit = Boolean.valueOf(s).booleanValue();
  +
  +/**
  + * When connectOnInit is true the JDBC connection is started at tomcat init
  + * if false the connection is started the first times it is needed.
  + * @param b
  + */
  +public void setConnectOnInit(boolean b) {
  +connectOnInit = b;
   }
   
   /**
* If there are any errors with the JDBC connection, executing
  - * the query or anything we return false (don't authenticate). This event is 
also logged.
  + * the query or anything we return false (don't authenticate). This event
  + * is also logged.
* 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 tomcat from needing a restart if 
the database goes down.
  + * be the best thing to do but it will keep tomcat from needing a restart
  + * if the database goes down.
*
* @param username Username of the Principal to look up
* @param credentials Password or other credentials to use in authenticating 
this username
  @@ -322,7 +331,8 @@
   (connectionPassword == null || connectionPassword.equals(""))) {
   dbConnection = DriverManager.getConnection(connectionURL);
   } else {
  -dbConnection = DriverManager.getConnection(connectionURL, 
connectionName, connectionPassword);
  +dbConnection = DriverManager.getConnection(connectionURL,
  +   

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa JDBCRealm.java

2001-02-04 Thread nacho

nacho   01/02/04 14:08:24

  Modified:src/share/org/apache/tomcat/modules/aaa JDBCRealm.java
  Log:
  Cosmetic changes and the ability to select
  when the JDBC connection is started at
  Tomcat init or in first realm access.
  
  Revision  ChangesPath
  1.2   +190 -268  
jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java
  
  Index: JDBCRealm.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JDBCRealm.java2001/01/01 02:01:29 1.1
  +++ JDBCRealm.java2001/02/04 22:08:24 1.2
  @@ -1,11 +1,11 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.1 
2001/01/01 02:01:29 costin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/01/01 02:01:29 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/aaa/JDBCRealm.java,v 1.2 
2001/02/04 22:08:24 nacho Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/02/04 22:08:24 $
*
* The Apache Software License, Version 1.1
*
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
  @@ -13,7 +13,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
  - *notice, this list of conditions and the following disclaimer. 
  + *notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
*notice, this list of conditions and the following disclaimer in
  @@ -21,7 +21,7 @@
*distribution.
*
* 3. The end-user documentation included with the redistribution, if
  - *any, must include the following acknowlegement:  
  + *any, must include the following acknowlegement:
*   "This product includes software developed by the
*Apache Software Foundation (http://www.apache.org/)."
*Alternately, this acknowlegement may appear in the software itself,
  @@ -64,152 +64,103 @@
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.util.*;
   import java.security.*;
  -import java.security.Principal;
  -import java.io.File;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  +//import java.security.Principal;
  +//import java.io.File;
  +//import java.util.Enumeration;
  +//import java.util.Hashtable;
   import java.util.Vector;
   import java.io.*;
   import java.net.*;
   import java.util.*;
   import java.sql.*;
   
  -
   /**
  - *
* Implmentation of bRealm/b that works with any JDBC supported database.
  - * See the JDBCRealm.howto for more details on how to set up the database and
  - * for configuration options.
  - *
  - * TODO:
  - *- Work on authentication with non-plaintext passwords
  - *
  + * See the JDBCRealm.howto for more details on how to set up the database and for 
configuration options. TODO:
  + * - Work on authentication with non-plaintext passwords
* @author Craig R. McClanahan
* @author Carson McDonald
* @author Ignacio J. Ortega
* @author Bip Thelin
  - *
*/
  -
   public final class JDBCRealm extends BaseInterceptor {
  -
  -
  -ContextManager cm;
   int reqRolesNote;
   int userNote;
   int passwordNote;
   // - Instance Variables
   
  -/**
  - * The connection to the database.
  - */
  +/** The connection to the database. */
   private Connection dbConnection = null;
   
  -/**
  - * The PreparedStatement to use for authenticating users.
  - */
  +/** The PreparedStatement to use for authenticating users. */
   private PreparedStatement preparedAuthenticate = null;
   
  -
  -/**
  - * The PreparedStatement to use for identifying the roles for
  - * a specified user.
  - */
  +/** The PreparedStatement to use for identifying the roles for a specified 
user. */
   private PreparedStatement preparedRoles = null;
  -
   
  -/**
  - * The connection URL to use when trying to connect to the databse
  - */
  +/** The connection URL to use when trying to connect to the databse */
   private String connectionURL = null;
   
  -/**
  - * The connection URL to use when trying to connect to the databse
  - */
  +/** The connection URL to use when trying to connect to the databse */
   private String connectionName = null;
   
  -/**
  - * The connection URL to use when trying to connect to the databse
  - */
  +/** The connection URL to use when trying to connect to the databse */
   private String connectionPassword = null;
   
  -/**
  - *