RE: User authentication using Realms
Hey Frank, No the space seemed to make no difference. I tried it by replacing the space with an underscore and got the same result. Yes, I tested the DSN via my simple Java class and it works fine. The two "methods" I was talking about are as follows: Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); // Use next two statements to connect directly to Access DB. String dbName = "C:/Inetpub/wwwroot/SPID/db1.mdb"; String dbConnStr = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + dbName.trim () + ";DriverID=22;READONLY=true}"; // OR // Use next statement to connect to Access DB via DSN. String dbURL = "jdbc:odbc:Cost History"; // dbConnection = DriverManager.getConnection (dbConnStr, "", ""); dbConnection = DriverManager.getConnection (dbURL, "", ""); I simply have the first method commented out. Notice the space in the DSN name I use in the class. It works just fine. It works when I use the "Simple JSP" DSN too. I was hoping for more responses to these questions, but Frank, you seem to be the only one who takes the time to try to help someone out. I have gotten no further in this endeavor. I've read more of the Tomcat documentation, but have found no more insight into how to actually DO it. It does no good to provide a collection of documents if they don't provide the material necessary to help someone USE what they spend so much time describing. It doesn't give me great confidence in these mailing list/newsgroup/bulletin board type venues. I've tried to make use of resources such as this in the past and found them to be next to useless, because I either got no responses, or the few I would receive were of no help at all. What good is it, if it does not help those who use it? Thanks, Joe -Original Message- From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] Sent: Monday, June 20, 2005 9:58 AM To: Tomcat Users List Cc: Tomcat Users List Subject: Re: User authentication using Realms Glad to hear you got it working so far! :) Is your DSN name literally "Simple JSP"? If so, I suggest trying something without a space in it... I have a feeling it might not work with spaces in the name. Note that the exception you are getting is actually coming from Access, it is simply being "passed through" JDBC. So, as you try and Google for a solution, you can *almost* forget you are working in Java temporarily. Also, does your DSN actually work via the test function in the ODBC manager? I tend to assume you tried that already, but just making sure ;) Actually, it looks like your saying you have a test class that does connect via that DSN, is that correct? If so, ignore this suggestion! :) I notice you say your code can switch between two connection methods... is it possible that somehow it isn't switched to the DSN method and is trying to connect with the path you specified? That makes a little more sense with the exception you are seeing. Ok, that's all the shots in the dark I have right now :) -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Mon, June 20, 2005 9:34 am, Gagnon, Joseph M \(US SSA\) said: > I've finally (with lots of help) figured out how to do form-based user > authentication of a simple test JSP webapp. So far, so good ... it > seems to be working. > > However, the "database" is a list of roles and users currently defined > in conf/tomcat-users.xml. While this worked fine while I was learning > how to do this and finally get it up and running, this is definitely not > the method I want to use for the "real thing". > > So, I started looking around at some more of the Tomcat documentation > and stumbled upon realms. This seems to be the vehicle to allow Tomcat > to provide a better method of performing user authentication. The > question now is: how do I make use of this? The docs refer to the set > of built-in realm types that are available for use, but I don't > understand the subtle differences between many of them. There don't > seem to be any examples of how to use them. I don't know which ones > should be used for different situations. > > I'm running on a PC with MS Access installed. This is the database (at > least for now) that I intend to use. I have successfully accessed > information from an Access DB using a Java class to create the > connection and execute SQL statements. I've done only a very simple > case at this point, just to demonstrate that I can do it successfully. > > The class actually has two possible methods of connection to the DB, one > method defines the actual path to the DB file and a complex (and for the > most part, not understood) connection string, the other meth
Re: User authentication using Realms
Glad to hear you got it working so far! :) Is your DSN name literally "Simple JSP"? If so, I suggest trying something without a space in it... I have a feeling it might not work with spaces in the name. Note that the exception you are getting is actually coming from Access, it is simply being "passed through" JDBC. So, as you try and Google for a solution, you can *almost* forget you are working in Java temporarily. Also, does your DSN actually work via the test function in the ODBC manager? I tend to assume you tried that already, but just making sure ;) Actually, it looks like your saying you have a test class that does connect via that DSN, is that correct? If so, ignore this suggestion! :) I notice you say your code can switch between two connection methods... is it possible that somehow it isn't switched to the DSN method and is trying to connect with the path you specified? That makes a little more sense with the exception you are seeing. Ok, that's all the shots in the dark I have right now :) -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Mon, June 20, 2005 9:34 am, Gagnon, Joseph M \(US SSA\) said: > I've finally (with lots of help) figured out how to do form-based user > authentication of a simple test JSP webapp. So far, so good ... it > seems to be working. > > However, the "database" is a list of roles and users currently defined > in conf/tomcat-users.xml. While this worked fine while I was learning > how to do this and finally get it up and running, this is definitely not > the method I want to use for the "real thing". > > So, I started looking around at some more of the Tomcat documentation > and stumbled upon realms. This seems to be the vehicle to allow Tomcat > to provide a better method of performing user authentication. The > question now is: how do I make use of this? The docs refer to the set > of built-in realm types that are available for use, but I don't > understand the subtle differences between many of them. There don't > seem to be any examples of how to use them. I don't know which ones > should be used for different situations. > > I'm running on a PC with MS Access installed. This is the database (at > least for now) that I intend to use. I have successfully accessed > information from an Access DB using a Java class to create the > connection and execute SQL statements. I've done only a very simple > case at this point, just to demonstrate that I can do it successfully. > > The class actually has two possible methods of connection to the DB, one > method defines the actual path to the DB file and a complex (and for the > most part, not understood) connection string, the other method defines a > "URL" in the following format: "jdbc:odbc:". The DSN name was > set up in the Windows ODBC data source administrator utility. The > second method is the one I'm using at this point. > > I tried setting up a JDBCRealm realm to use an Access DB with two > tables, one for user names and passwords, the other for user names and > roles. I set up another ODBC DSN as described above and placed a > reference to that in the realm element. I *think* I followed the > directions correctly, but ran into a problem that I don't know how to > address. > > When I restart Tomcat, I'm getting the following error message in the > logs (stderr and catalina): > > Jun 20, 2005 9:06:57 AM org.apache.catalina.realm.JDBCRealm authenticate > SEVERE: Exception performing authentication > java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] > '(unknown)' is not a valid path. Make sure that the path name is > spelled correctly and that you are connected to the server on which the > file resides. > at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958) > at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115) > at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074) > at > sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323) > at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174) > at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:694) > at > org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:344) > at > org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut > henticator.java:256) > at > org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator > Base.java:391) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java > :126) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java > :105) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. > java:107) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1 > 48) > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:85 > 6) > at > org.apache.coyote.http
User authentication using Realms
I've finally (with lots of help) figured out how to do form-based user authentication of a simple test JSP webapp. So far, so good ... it seems to be working. However, the "database" is a list of roles and users currently defined in conf/tomcat-users.xml. While this worked fine while I was learning how to do this and finally get it up and running, this is definitely not the method I want to use for the "real thing". So, I started looking around at some more of the Tomcat documentation and stumbled upon realms. This seems to be the vehicle to allow Tomcat to provide a better method of performing user authentication. The question now is: how do I make use of this? The docs refer to the set of built-in realm types that are available for use, but I don't understand the subtle differences between many of them. There don't seem to be any examples of how to use them. I don't know which ones should be used for different situations. I'm running on a PC with MS Access installed. This is the database (at least for now) that I intend to use. I have successfully accessed information from an Access DB using a Java class to create the connection and execute SQL statements. I've done only a very simple case at this point, just to demonstrate that I can do it successfully. The class actually has two possible methods of connection to the DB, one method defines the actual path to the DB file and a complex (and for the most part, not understood) connection string, the other method defines a "URL" in the following format: "jdbc:odbc:". The DSN name was set up in the Windows ODBC data source administrator utility. The second method is the one I'm using at this point. I tried setting up a JDBCRealm realm to use an Access DB with two tables, one for user names and passwords, the other for user names and roles. I set up another ODBC DSN as described above and placed a reference to that in the realm element. I *think* I followed the directions correctly, but ran into a problem that I don't know how to address. When I restart Tomcat, I'm getting the following error message in the logs (stderr and catalina): Jun 20, 2005 9:06:57 AM org.apache.catalina.realm.JDBCRealm authenticate SEVERE: Exception performing authentication java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115) at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074) at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323) at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174) at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:694) at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:344) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut henticator.java:256) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:391) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1 48) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:85 6) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC onnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint .java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollow erWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:684) at java.lang.Thread.run(Thread.java:534) I don't know what the problem is. What am I not specifying such that it reports back with "unknown"? Am I using the wrong realm type? Does the method I'm trying to use not work with DSNs? The realm I've defined in my server.xml file is as follows: The connectionURL value (I think) should point to the ODBC DSN name I defined for my simple test DB. The table and field names are correct. By the way, I had previously commented out the following entry in server.xml: I figured I would be causing complications and confusion by leaving this entry "active". The reference to the UserDatabase resource was defined earlier in the file (within the GlobalNamingResources element) as: Any ideas or suggestions on what I'm doing wrong (or a better method altogether) would be appreciated. Thanks, Joe --