tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Configuring a DataSourceRealm
Date Thu, 24 May 2007 19:34:16 GMT
Hi Paulo.

We'll need to know what version of Tomcat you are working with.

--David

Paulo Vivacqua wrote:

> Hello there,
>
> I am having difficulty implementing a Datasource realm for my
> application. I followed some tutorials but could not make it to work.I
> already posted this issue on other forums but I got no answer.
>
> The application Instead of pulling out data from the MySQL database
> it´s getting the user information from the tomcat-users.xml
> (MemoryRealm)
>
> web.xml
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>   <session-config>
>       <session-timeout>
>           30
>       </session-timeout>
>   </session-config>
>   <welcome-file-list>
>       <welcome-file>
>           index.jsp
>       </welcome-file>
>   </welcome-file-list>
>   <security-constraint>
>       <display-name>Constraint1</display-name>
>       <web-resource-collection>
>           <web-resource-name>testeJdbc</web-resource-name>
>           <description/>
>           <url-pattern>/index.jsp</url-pattern>
>           <http-method>GET</http-method>
>           <http-method>POST</http-method>
>           <http-method>HEAD</http-method>
>           <http-method>PUT</http-method>
>           <http-method>OPTIONS</http-method>
>           <http-method>TRACE</http-method>
>           <http-method>DELETE</http-method>
>       </web-resource-collection>
>       <auth-constraint>
>           <description>admin</description>
>           <role-name>admin</role-name>
>           <role-name>tomcat</role-name>
>           <role-name>member</role-name>
>       </auth-constraint>
>       <user-data-constraint>
>           <description/>
>           <transport-guarantee>CONFIDENTIAL</transport-guarantee>
>       </user-data-constraint>
>   </security-constraint>
>
>   <security-constraint>
>       <display-name>Constraint2</display-name>
>       <web-resource-collection>
>           <web-resource-name>pagina1</web-resource-name>
>           <description/>
>           <url-pattern>/pagina1.jsp</url-pattern>
>           <http-method>GET</http-method>
>           <http-method>POST</http-method>
>       </web-resource-collection>
>       <auth-constraint>
>           <description/>
>           <role-name>admin</role-name>
>           <role-name>member</role-name>
>       </auth-constraint>
>       <user-data-constraint>
>           <description/>
>           <transport-guarantee>CONFIDENTIAL</transport-guarantee>
>       </user-data-constraint>
>   </security-constraint>
>
>   <login-config>
>       <auth-method>FORM</auth-method>
>       <realm-name/>
>       <form-login-config>
>           <form-login-page>/Login.jsp</form-login-page>
>           <form-error-page>/ErrorPage.jsp</form-error-page>
>       </form-login-config>
>   </login-config>
>   <security-role>
>       <description/>
>       <role-name>admin</role-name>
>   </security-role>
>   <security-role>
>       <description/>
>       <role-name>guest</role-name>
>   </security-role>
>   <security-role>
>       <description/>
>       <role-name>member</role-name>
>   </security-role>
>   <security-role>
>       <description/>
>       <role-name>tomcat</role-name>
>   </security-role>
>
>   <resource-ref>
>       <description>JdbcRealmTeste</description>
>       <res-ref-name>jdbc/oaso</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>   </resource-ref>
>
> </web-app>
>
> server.xml
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Server>
>   <Listener 
> className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
>   <Listener 
> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
>   <GlobalNamingResources>
>       <Environment name="simpleValue" type="java.lang.Integer" 
> value="30"/>
>       <Resource name="jdbc/oaso" type="javax.sql.DataSource"/>
>       <Resource auth="Container" description="User database that can
> be updated and saved" name="UserDatabase"
> type="org.apache.catalina.UserDatabase"/>
>       <ResourceParams name="jdbc/oaso">
>           <parameter>
>               <name>maxWait</name>
>               <value>5000</value>
>           </parameter>
>           <parameter>
>               <name>maxActive</name>
>               <value>4</value>
>           </parameter>
>           <parameter>
>               <name>password</name>
>               <value>shisqi3320</value>
>           </parameter>
>           <parameter>
>               <name>url</name>
>               <value>jdbc:mysql://localhost:3306/renatovivacqua</value>
>           </parameter>
>           <parameter>
>               <name>driverClassName</name>
>               <value>com.mysql.jdbc.Driver</value>
>           </parameter>
>           <parameter>
>               <name>maxIdle</name>
>               <value>2</value>
>           </parameter>
>           <parameter>
>               <name>username</name>
>               <value>root</value>
>           </parameter>
>       </ResourceParams>
>       <ResourceParams name="UserDatabase">
>           <parameter>
>               <name>factory</name>
>
> <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
>           </parameter>
>           <parameter>
>               <name>pathname</name>
>               <value>conf/tomcat-users.xml</value>
>           </parameter>
>       </ResourceParams>
>   </GlobalNamingResources>
>   <Service name="Catalina">
>       <Connector acceptCount="100" connectionTimeout="20000"
> disableUploadTimeout="true" maxSpareThreads="75" maxThreads="150"
> minSpareThreads="25" port="8080" redirectPort="8443">
>       </Connector>
>       <Connector port="8009" protocol="AJP/1.3"
> protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
> redirectPort="8443">
>       </Connector>
>       <Connector acceptCount="100"
> className="org.apache.coyote.tomcat5.CoyoteConnector"
> clientAuth="false" debug="0" disableUploadTimeout="true"
> enableLookups="true" maxProcessors="75" minProcessors="5" port="8443"
> scheme="https" secure="true" sslProtocol="TLS">
>       </Connector>
>       <Engine defaultHost="localhost" name="Catalina">
>           <Host appBase="webapps" name="localhost">
>               <Logger
> className="org.apache.catalina.logger.FileLogger"
> prefix="localhost_log." suffix=".txt" timestamp="true"/>
>
>               <Context path="/jdbc/oaso" docBase="jdbc/oaso"
>                        debug="5" reloadable="true" crossContext="true">
>
>                   <Logger 
> className="org.apache.catalina.logger.FileLogger"
>                           prefix="localhost_RealmJdbcTeste_log." 
> suffix=".txt"
>                           timestamp="true"/>
>
>                   <Resource name="jdbc/oaso"
>                             auth="Container"
>                             type="javax.sql.DataSource"/>
>
>                   <Realm
> className="org.apache.catalina.realm.DataSourceRealm" debug="99"
>                          dataSourceName="jdbc/oaso"
>                          localDataSource="true"
>                          userTable="users"
>                          userNameCol="user_name"
>                          userCredCol="user_pass"
>                          userRoleTable="user_roles"
>                          roleNameCol="role_name"/>
>
>                   <ResourceParams name="jdbc/oaso">
>                       <parameter>
>                           <name>factory</name>
>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>                       </parameter>
>                       <parameter>
>                           <name>maxActive</name>
>                           <value>4</value>
>                       </parameter>
>                       <parameter>
>                           <name>maxIdle</name>
>                           <value>2</value>
>                       </parameter>
>                       <parameter>
>                           <name>maxWait</name>
>                           <value>5000</value>
>                       </parameter>
>                       <parameter>
>                           <name>username</name>
>                           <value>root</value>
>                       </parameter>
>                       <parameter>
>                           <name>password</name>
>                           <value>shisqi3320</value>
>                       </parameter>
>                       <parameter>
>                           <name>driverClassName</name>
>                           <value>com.mysql.jdbc.Driver</value>
>                       </parameter>
>                       <parameter>
>                           <name>url</name>
>
> <value>jdbc:mysql://localhost:3306/renatovivacqua?autoReconnect=true</value>

>
>                       </parameter>
>                   </ResourceParams>
>               </Context>
>           </Host>
>           <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="catalina_log." suffix=".txt" timestamp="true"/>
>           <Realm 
> className="org.apache.catalina.realm.UserDatabaseRealm"/>
>       </Engine>
>   </Service>
> </Server>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message