I've answered my own question. I swear I read the Servlet 2.3 spec a few times, but it 
didn't really click until now...I was looking at the problem from the wrong angle...

Basically, I had to realize that role mapping is accomplished differently for 
declarative vs. programmatic authorization. In other words, the mapping from an 
organizational role to a logical security role used by your application needs to be 
treated differently for declarative vs. programmatic authorization.

For declarative authorization, you simply change the name of the role in the 
<auth-constraint> child element of the <security-constraint> element in the web.xml 
file to the organizational role name used in the LDAP directory server. Hence the term 
"declarative" ;-)

For example, in the example I gave in my previous posting, I have a role name in the 
LDAP server: QA Managers. Since my Servlet code uses programmatic authorization using 
the role name qamgr, I thought that I needed to be consistent between declarative and 
programmatic authorization. That is, I thought I had to use qamgr in the <role-name> 
element for declarative authorization in the web.xml file. However, what I really 
needed to do was very simple:


  | <auth-constraint>
  |   <description>People who can manage QA entries</description>
  |   <role-name>QA Managers</role-name>
  | </auth-constraint>
  | 

See how the <role-name> element uses QA Managers instead of qamgr. This works because 
the Subject holds "QA Managers" as a role from the LDAP query.

So the lesson is that with declarative authorization, one shouldn't get confused by 
what your programmatic authorization code is doing and just use the organizational 
role names from your security provider, in my case LDAP.

On the other hand, programmatic authorization is where a Servlet calls:

request.isUserInRole("qamgr");

In this case, the container needs to know that qamgr is really QA Managers. This is 
done using a <security-role-ref> element in the web.xml. Specifically, each Servlet 
that issues calls like isUserInRole("qamgr") needs to include a "link" to tell the 
container that qamgr is the same as the role name QA Managers held in the Subject.

Here's an example:


  | <security-role-ref>
  |   <role-name>qamgr</role-name>
  |   <role-link>QA Managers</manager>
  | </security-role-ref> 
  | 

Great product by the way!!! Cheers, Tim

<a 
href="http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3827674#3827674";>View 
the original post</a>

<a 
href="http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3827674>Reply 
to the post</a>


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to