tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Muffett" <ma...@its-axiom.com>
Subject Re: JDBC Realm Questions Tomcat 3.2.2
Date Thu, 05 Jul 2001 13:27:13 GMT
I can't answer for 3.2, but I can confirm it works well with 3.3.  I've been
using JDBC realms for the last 2 or 3 weeks with Tomcat 3.3m3 and Postgresql
as the underlying RDB.

Mark



----- Original Message -----
From: "Alexa Petrean" <Alexa.Petrean@inthelrom.ro>
To: <tomcat-user@jakarta.apache.org>
Sent: Thursday, July 05, 2001 2:21 PM
Subject: Re: JDBC Realm Questions Tomcat 3.2.2


> Hi,
>
> I think I have a similar problem, but for Tomcat3.2.1 (NT platform). The
ideea
> is that I've configured the server.xml to access an Oracle DB, like this:
>
>         <RequestInterceptor
>             className="org.apache.tomcat.request.JDBCRealm"
>             debug="99"
>      driverName="oracle.jdbc.driver.OracleDriver"
>      connectionURL="jdbc:oracle:oci8:@oradb"
>      connectionName="myConn"
>      connectionPassword="oracle"
>      userTable="myUserTable"
>             userNameCol="Name"
>             userCredCol="Password"
>      userRoleTable="myUserRoles"
>             roleNameCol="RolName" />
>
> As I know, to give role based access to the users, we have to configure
web.xml
> for the application. Here is a sample, from my app:
>
> <web-app>
>     <security-role>
>       <role-name>Administrator</role-name>
>       <role-name>Operator</role-name>
>     </security-role>
>     <servlet>
>         <servlet-name>
>               myServlet
>    </servlet-name>
>         <servlet-class>
>               path.to.my.servlet.MyServletClass
>    </servlet-class>
>    <security-role-ref>
>       <role-name>ADMIN</role-name>
>       <role-link>Administrator</role-link>
>    </security-role-ref>
>    <security-role-ref>
>       <role-name>OPER</role-name>
>       <role-link>Operator</role-link>
>    </security-role-ref>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>
>             myServlet
>         </servlet-name>
>         <url-pattern>
>             /myServlet
>         </url-pattern>
>     </servlet-mapping>
>     <security-constraint>
>        <web-resource-collection>
>           <web-resource-name>
>                myServlet
>           </web-resource-name>
>           <url-pattern>
>                /myServlet
>           </url-pattern>
>           <http-method>GET</http-method>
>           <http-method>POST</http-method>
>        </web-resource-collection>
>        <auth-constraint>
>           <role-name>
>               Administrator
>           </role-name>
>        </auth-constraint>
>     </security-constraint>
> </web-app>
>
> Now, when somebody wants to access myServlet resource, he/she must have
the role
> of an Administrator or Operator. I think this should be checked into the
> database.  The problem is that, when I've tried to access myServlet for
the
> first time, the following message was generated in the tomcat console:
>
> 2001-07-05 04:11:49 - ContextManager: JDBCRealm: JDBCRealm.authenticate:
SELECT
> PASSWORD FROM MYUSERTABLE WHERE NAME = ?
> 2001-07-05 04:11:50 - ContextManager: JDBCRealm: Authentication
unsuccessful for
> user null
>
> In the same time, the login window has appeard on Netscape browser, but
after
> I'd entered a valid user name and password (from myUserTable) the message
was
> the same:
>
> 2001-07-05 04:14:19 - ContextManager: JDBCRealm: Authentication
unsuccessful for
> user null
>
> It seems for me that the user name is null every time, no matter if I
enter a
> valid (user, passwd) or not. Is that a Tomcat bug, or I've missed
something....?
>
> Any ideea would be highly appreciated
>
> Alex
>
> "Rajehswar V. Rao" wrote:
>
> > I am looking for same....
> >
> > -----Original Message-----
> > From: Jonathan_Pierce@seagram.com [mailto:Jonathan_Pierce@seagram.com]
> > Sent: Thursday, July 05, 2001 4:02 AM
> > To: TOMCAT-USER@jakarta.apache.org
> > Subject: Fwd:JDBC Realm Questions Tomcat 3.2.2
> >
> > Someone please respond to these questions so I know whether JDBC Realms
are
> > a
> > supported feature of Tomcat3.2.2. I posted the question a few days ago
and
> > have
> > gotten no responses.
> >
> > Has anyone been successful in referencing a jdbc datasource configured
in
> > the
> > server.xml of Tomcat 3.2.2? If so, how?
> >
> > Jonathan
> >
> > ____________________Forward Header_____________________
> > Subject:    JDBC Realm Questions Tomcat 3.2.2
> > Author: tomcat-dev@jakarta.apache.org
> > Date:       7/3/2001 8:21 PM
> >
> > This may be a stupid question but I've found hundreds of messages from
> > confused
> > users on the subject of JDBC Realms and Tomcat and no good explanation
or
> > example. There is a documentation file JDBCRealm.howto but it doesn't
> > describe
> > how to instantiate the datasource with a code example or what additional
> > property files need to be included to configure jndi properties.
> >
> > Like lots of other people, I'm trying to use the release Tomcat 3.2.2,
> > configure
> > multiple jdbc datasources in the server.xml file, and reference it in my
> > servlet. I am only interested in using a shared database ID to connect
to
> > the
> > database for all users of my servlet. The database connect info needs to
be
> > in
> > Tomcat conf files since the passwords need to be reconfigured at
deployment
> > time
> > outside my war file.
> >
> > 1. Is this behavior supported by Tomcat 3.2.2? How do I configure
multiple
> > database datasources and instantiate them in my code?
> >
> > 2. Assuming I setup the datasources like below, what properties do I use
to
> > assign a name to the datasource so I can reference it?
> >
> > <RequestInterceptor
> >     className="org.apache.tomcat.request.JDBCRealm"
> >     debug="99"
> >     driverName="oracle.jdbc.driver.OracleDriver"
> >     connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
> >     connectionName="scott"
> >     connectionPassword="tiger"
> > />
> >
> > <RequestInterceptor
> >     className="org.apache.tomcat.request.JDBCRealm"
> >     debug="99"
> >     driverName="oracle.jdbc.driver.OracleDriver"
> >     connectionURL="jdbc:oracle:thin:@ntserver2:1521:ORCL"
> >     connectionName="scott"
> >     connectionPassword="tiger"
> > />
> >
> > 3. What do I need to add to a config file in order to access the initial
> > context
> > so I can retrieve the datasource?
> >
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> > import javax.naming.*;
> > import javax.sql.*;
> >
> > String          theDataSourceName = "???";
> > String          theNamingProviderURL = "???";
> > String          theInitialContextNamingFactory = "???";
> > Properties theProperties = new Properties ();
> > theProperties.put("java.naming.provider.url", theNamingProviderURL);
> >
theProperties.put("java.naming.factory.initial",theInitialContextNamingFacto
> > ry);
> >
> > Context theInitialContext = new InitialContext(theProperties);
> > DataSource theDataSource = (DataSource) theInitialContext.lookup
> > (theDatasourceName);
>


Mime
View raw message