You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Wade Little <wa...@sbcglobal.net> on 2007/02/27 21:37:21 UTC
j_security_check
I have tried all I can to setup Netbeans/Tomcat to use
postgre for my user auth via J_security_check by
talking with my Postgre DB....can anyone review the
following files and let me know if I have done
anything wrong. I verified I can connect via a JSP
and return a result. But I cant get the Auth to work.
Here is what I used that works to talk to the DB:
<%
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/landt";
Connection con = DriverManager.getConnection(url,
"postgres", "postgres");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet srs = stmt.executeQuery("SELECT username
FROM users");
while (srs.next()) {
String name = srs.getString("username");
out.println(name);
}
%>
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>TenantConstraint</display-name>
<web-resource-collection>
<web-resource-name>tenant</web-resource-name>
<description>Tenant</description>
<url-pattern>/secureTenant/*</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/>
<role-name>tenant</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>LandlordConstraint</display-name>
<web-resource-collection>
<web-resource-name>landlord</web-resource-name>
<description>Landlord</description>
<url-pattern>/secureLandlord/*</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/>
<role-name>landlord</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<Realm
className="org.apache.catalina.realm.JDBCRealm"
connectionName="postgres"
connectionPassword="postgres"
connectionURL="jdbc:postgresql://localhost:5432/landt"
debug="99" driverName="org.postgresql.Driver"
roleNameCol="rolename" userCredCol="password"
userNameCol="username" userRoleTable="user_roles"
userTable="users"/>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description>For Tenants</description>
<role-name>tenant</role-name>
</security-role>
<security-role>
<description>For Landlords</description>
<role-name>landlord</role-name>
</security-role>
</web-app>
---------------------------------------------------------------------
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