tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Loyd Bacani <>
Subject RE: Problem implementing JAAS in Tomcat 4.1.2
Date Thu, 19 Jun 2003 14:33:36 GMT
I wish a was a bit more thorough in the first run, sorry about that. My question is more of
"How do I implement JAAS in Tomcat?" I know this is a broad question so lets break it down.

1. How do I configure Tomcat so that it uses JAAS?
2. What configuration files ( Java Secutiy & Tomcat ) do I need to accomplish question
3. Programmatically, I believe I have to extend org.apache.catalina.realm.JAASMemoryLoginModule
but how does Tomcat validates users using JAASRealm?
For #1 the following:
// server.xml
      <Realm  className="org.apache.catalina.realm.JAASRealm" debug="99"
For #2 the following:
// jaas.config
{ required debug=true;
// jaas.policy
grant codeBase "file:${catalina.home}/webapps/cdmanager/WEB-INF/classes/- { 
   permission java.util.PropertyPermission "", "read";
   permission java.util.PropertyPermission "", "read";
   permission "createLoginContext";
   permission "doAsPrivileged";
For #3 the following:
// JAASLoginModule
public class JAASLoginModule extends org.apache.catalina.realm.JAASMemoryLoginModule {
    // initial state
    private Subject subject;
    private CallbackHandler callbackHandler;
  public void initialize(Subject subject, CallbackHandler callbackHandler,
   Map sharedState, Map options) {
  this.subject = subject;
  this.callbackHandler = callbackHandler;
  this.sharedState = sharedState;
  this.options = options;

   handler = new;
            loginContext = new LoginContext("JAASPolicy", new;
            loginContext = new LoginContext("JAASPolicy", handler );
            loginContext.login();  // EXCEPTION HERE

"Shapira, Yoav" <> wrote:

Oh boy... See intermixed.

>I've used this code in Weblogic 6.X without any problem. If
>this could be done in Weblogic, then there is NO reason why we can't do

Of course there is. Tomcat's configuration is different than Weblogic's
configuration. Weblogic provides a superset of the servlet
specification, not to mention a complete J2EE container. Unless "this
code", "this", and "it" in the above sentence relate directly to the
servlet specification, v2.3, the above is false.

>Can anyone tell me what am I doing wrong? Or perhaps point me in the

Read the JAASRealm JavaDoc for starters:

Actually look at the example JAASRealm to see what attributes it takes.
Don't just assume it takes the same attribute names as the weblogic

> debug="99"
> loginContext="JAASPolicy"

This is meaningless as these are not the attributes expected by


This is irrelevant as the JAASRealm is not configured correctly.

Yoav Shapira

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged. This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender. Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message