how to increase users in tomcat-users.xml file automatically not manually

Thread Solved

Join Date: Aug 2007
Posts: 63
Reputation: alsoumhi is an unknown quantity at this point 
Solved Threads: 0
alsoumhi alsoumhi is offline Offline
Junior Poster in Training

how to increase users in tomcat-users.xml file automatically not manually

 
0
  #1
20 Days Ago
Hi guys, I am trying to restrict users to access the sources of my application so I have used tomcat-users.xml file , but later I will be facing a problem which is how if I have a lot of authorized users , so I will add each one to that file manually , i think it is not efficient way . Furthermore , I am having an application that lets users used its resources based on the user account in database. if the user has an account in database he/she can login to the application and use the resources , so how can I use this idea with tomcat-users.xml just to avoid the increase number of authorized users in tomcat-users.xml
I hope you understand my question . I don't mind to repeat it again if you have any question
please help me guys because I want to prevent unathorized users to access directly using URL in my application
thank you very very very much
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,625
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 221
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso
 
0
  #2
20 Days Ago
Originally Posted by alsoumhi View Post
I want to prevent unathorized users to access directly using URL in my application
When the user logs in, do you put that user in the session?
  1. String username;
  2. String password;
  3.  
  4. // check the database to see if the user is valid.
  5. if (yes) {
  6. request.getSession().setAttribute("USER",username);
  7. }

When the user logs out do you do this:
  1. request.getSession().setAttribute("USER",null);

And my suggestion would be to put this check in all of your pages:
  1. String username = (String)request.getSession().getAttribute("USER");
  2. if (username==null) {
  3. // unauthorized user
  4. // redirect to log in page
  5. }
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC