Advertisement

04.22.2008 at 08:27AM PDT, ID: 23343307 | Points: 250
[x]
Attachment Details

When to use JAAS

Asked by colr__ in Java Servlets, Apache Tomcat Application Server, Enterprise Java Beans (EJB)

I would like some input as to the best security model to use for my existing forum-based webapp. The alternatives I'm considering are using Tomcat's declarative security (DataSourceRealm) or going with a full JAAS implementation. The problem is that I'm not sure if JAAS is a bit overkill for what I need to do.

The webapp is a struts servlet webapp - no EJBs or other tiers (which is why I think JAAS might be overkill)

My webapp is similar to a forum - many of the methods require the userId of the logged in user, for example, to get a list of the posts this user has made to the forum, something like this:

     public List getThisUsersPosts(int userId){ ... }

With the declaritive security model, I was thinking of using a superclass Servlet/action that will obtain the userId and make it available to the servlets/actions that extend it. The first time the userId is required, the super class will have to get the userId from the database based on the username in the request (this is using declarative security). Something like this:

     private int userId = null;
     protected int getUserId(){
          if (userId == null){
               userId = getUserIdFromDatabase(request.getRemoteUser());
          }
          return userId;
     }

The other alternative is to use JAAS to do much of the same thing, but since Ive never worked with JAAS  before, I was hoping someone could tell me if this is overkill or not?

Ive only briefly read about JAAS - I wanted to check if

a) is JAAS overkill for my problem?
b) if I used JAAS could I code a Principle object that would natively hold the userId, so I wouldnt have to use a superclass as described above? i.e could I do something like:      
      ((MyPrinciple)request.getPrinciple()).getUserId();

Thanks for the input!
Start Free Trial
 
Loading Advertisement...
 
[+][-]04.22.2008 at 04:30PM PDT, ID: 21416535

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 02:10AM PDT, ID: 21418717

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 12:47AM PDT, ID: 21428452

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.28.2008 at 10:01AM PDT, ID: 22337104

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628