You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Josh Gooding <jo...@gmail.com> on 2011/02/27 13:21:50 UTC
Login page not showing up with configured realm.
ok, I swore I wasn't going to bother you guys again on the weekend, but I am
running into a little quirk here. I'm running 6.0.29. Here is my webapp's
context.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource
name="jdbc/RealmDB" auth="Container" type="javax.sql.DataSource"
username="root" password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/gamedatabase"
maxActive="-1" maxIdle="5" maxWait="5000"
removeAbandoned="true" removeAbandonedTimeout="60"
testWhileIdle="true" timeBetweenEvictionRunsMillis="180000"/>
<Realm
className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/RealmDB" localDataSource="true"
digest="MD5"
userTable="users" userNameCol="users_name" userCredCol="password"
userRoleTable="tcrole" roleNameCol="role_name" />
</Context>
My Database credentials are fine. When I do a select * from users where
user_name="JGooding" I get the proper things back
Here is my web.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<display-name>MMO</display-name>
<description>MMO Testing</description>
<resource-ref>
<res-type>javax.sql.DataSource</res-type>
<res-ref-name>jdbc/RealmDB</res-ref-name>
<res-auth>Container</res-auth>
</resource-ref>
<error-page>
<error-code>403</error-code>
<location>/error/403.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/error/404.jsp</location>
</error-page>
<session-config>
<session-timeout>480</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>Main.jsp</welcome-file>
</welcome-file-list>
<!--Constraints to control access to an entire namespace of urls-->
<security-constraint><!--/admin/* limits access to those in admin
role.-->
<web-resource-collection>
<web-resource-name>MMO</web-resource-name>
<url-pattern>/admin/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint><!--/Private/* completely blocks access except
by the webserver itself.-->
<web-resource-collection>
<web-resource-name>MMO</web-resource-name>
<url-pattern>/private/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name></role-name>
</auth-constraint>
</security-constraint>
<!--Constraints to limit access to individual urls which are not limited
by any namespace in their url-->
<security-constraint><!--/Main.jsp requires login, but then is available
to everybody who can login.-->
<web-resource-collection>
<web-resource-name>MMO</web-resource-name>
<url-pattern>/Main.jsp</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
<role-name>player</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>MMO</realm-name>
<form-login-config>
<form-login-page>/private/Login.jsp</form-login-page>
<form-error-page>/private/Login.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
My Main.jsp is in the root directory of the webapps/[my proj] folder and the
Login.jsp is in /webapps/[my proj]/private. So now for the issues. When I
login with j_security_check, I get no errors, so as much as I hate making
assumptions, I'm going to assume that nothing is wrong with the realm.
However what's happening is that when I login, it's just reverting back to
the login page. I checked the catalina.out and localhost.[current day] logs
and I'm not getting an errors. Any ideas on what could cause this? It's
been forever and a day since I set up my last realm.
Warmest regards,
- Josh
Re: Login page not showing up with configured realm.
Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/2/27 Josh Gooding <jo...@gmail.com>:
> My Main.jsp is in the root directory of the webapps/[my proj] folder and the
> Login.jsp is in /webapps/[my proj]/private. So now for the issues. When I
> login with j_security_check, I get no errors, so as much as I hate making
> assumptions, I'm going to assume that nothing is wrong with the realm.
> However what's happening is that when I login, it's just reverting back to
> the login page. I checked the catalina.out and localhost.[current day] logs
> and I'm not getting an errors. Any ideas on what could cause this? It's
> been forever and a day since I set up my last realm.
>
How are you are triggering your login?
Usually that is
1. GET some protected resource
2. Tomcat returns the login form instead of the resource
3. User fills the form and POSTs it to j_security_check
4. The resource requested in (1) is displayed.
I do not remember whether the resource is displayed as response for
(3) or whether a redirect to the original URL is being sent to the
browser. It does not matter.
The essence is that in (4) you are seeing what you were requesting in
(1). So, if you requested your Login.jsp, you will see your Login.jsp
after successfully typing in the password.
BTW, if you want to run Tomcat with a debugger,
http://wiki.apache.org/tomcat/FAQ/Developing
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org