?
Solved

JDBC Realm HTTP 403 problem

Posted on 2006-03-30
8
Medium Priority
?
1,129 Views
Last Modified: 2010-08-05
Hi,

I have successfully implemented JDBC Realm for authentication. I can add new users and passwords to the tables in the MySQL database and assign roles which i have populated in the database (from the tomcat-users.xml, i just populated those roles that were present in the tomcat-users.xml) .

I had earlier used tomcat-users.xml file for authentication which contains the roles and users. What i tried to do was add new roles in the database and create users and assign those roles to the users. It gives me HTTP 403 error.

In other words, creating new users and passwords and assigning existing roles works. But if i create a new role in the Database, and assign it to a new users, it fails to enter.

The error looks like this:
*********************
HTTP Status 403 - Access to the requested resource has been denied

--------------------------------------------------------------------------------

type Status report

message Access to the requested resource has been denied

description Access to the specified resource (Access to the requested resource has been denied) has been forbidden.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28

Please help!!!!!!!!!!!!!!!!!!!!!
0
Comment
Question by:geek4u
  • 4
  • 4
8 Comments
 
LVL 19

Accepted Solution

by:
actonwang earned 2000 total points
ID: 16333575
You also need to set up resources acess in your web.xml correctly after you set up JDBC realm.
especially looking for sth like this:

<security-constraint>
        <web-resource-collection>
                <web-resource-name>MyFirst</web-resource-name>
                <description> accessible by authenticated users of the tomcat role</description>
                <url-pattern>/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
                <http-method>PUT</http-method>
                <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
                <description>These roles are allowed access</description>
                <role-name>tomcat</role-name>
        </auth-constraint>
</security-constraint>
0
 

Author Comment

by:geek4u
ID: 16333649
I absolutely understood where the problem is!! Thanks for the help!!

Can i ask you some more help??

How can we set the web.xml in such a way that the <role-name> value is taken from the database??

In detail, I have an appication running on struts and performs JDBC Realm authentication (programmed by me). I need also to add new user roles on the fly i.e., i have created JSP from where admin can add new user role (into the database) and also assign controls (acl.xml). Everything is done, but just because i need to add the role-name in the web.xml this will not work. Do you know how i can do it???

I hope i am clear!!

Thanks
0
 

Author Comment

by:geek4u
ID: 16333657
The problem i am trying to avoid is "Every time i make an entry to web.xml, i need to restart the server" which we cannot afford when the system goes into production.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 19

Expert Comment

by:actonwang
ID: 16333755
>>How can we set the web.xml in such a way that the <role-name> value is taken from the database??
     web.xml is static so I am afraid you can not do it on the fly.
     But good news is that you can programtically do it if you want. Use: HttpServletRequest.isUserInRole(<role>)
0
 

Author Comment

by:geek4u
ID: 16333912
>>HttpServletRequest.isUserInRole(<role>)

I am using it to get authorization!!

But i need to put in the role-names in web.xml and not restart the server or any other way around!!
0
 
LVL 19

Expert Comment

by:actonwang
ID: 16334002
web.xml only reads during web app initiation. Sorry, no way around. Refer to specification, the only choice is using isUserInRole which should be sufficient.

0
 

Author Comment

by:geek4u
ID: 16334173
Can you explain it lil bit more clearly?? Thanks
0
 
LVL 19

Expert Comment

by:actonwang
ID: 16334223
what I mean is that programmtic authentication and authorizatio such as  isUserInRole is your only way.

You can not change web.xml on the fly. It is static.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question