JAAS:使应用程序使用Tomcat身份验证设置

时间:2013-05-03 11:31:54

标签: authentication tomcat jaas

是否可以通过tomcats默认身份验证方法创建使用JAAS身份验证的Web应用程序。

举例说明:Tomcat使用tomcat_users.xml进行身份验证。 Web应用程序在jaas.cfg中定义了自己的方法。我们如何配置jaas.cfg,使其使用Tomcat的方法,以便在Tomcat中的配置更改时,应用程序的身份验证方法也会切换。

当前配置如下所示:

BonitaAuth {

  org.ow2.bonita.identity.auth.BonitaIdentityLoginModule required;

};



BonitaStore {

  org.ow2.bonita.identity.auth.LocalStorageLoginModule required;

};



BonitaAuth-default {

  org.ow2.bonita.identity.auth.BonitaIdentityLoginModule required domain="default";

  org.ow2.bonita.identity.auth.LocalStorageLoginModule required domain="default";

};



BonitaStore-default {

  org.ow2.bonita.identity.auth.LocalStorageLoginModule required domain="default";

};



/**

 * Used by the REST server

 */

BonitaRESTServer {

  org.ow2.bonita.identity.auth.BonitaRESTServerLoginModule required logins="restuser" passwords="restbpm" roles="restuser";

};

1 个答案:

答案 0 :(得分:0)

Tomcat用户存储库由Tomcat Realms定义。 tomcat_users.xml文件由MemoryRealm使用。 要使用JAAS配置(jaas.cfg),请配置JAASRealmhttp://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#JAASRealm

可以使用Java EE身份验证并实现您自己的领域。 您有3个选择:

  1. 实现Tomcat Realm接口 http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/Realm.html
  2. 延长RealmBase http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/realm/RealmBase.html
  3. 延长JAASRealm http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/realm/JAASRealm.html
  4. 在server.xml中配置您自己的领域

    <Realm className="org.myrealm"/>
    

    Tomcat将调用您的身份验证方法http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/realm/RealmBase.html#authenticate%28java.lang.String,%20java.lang.String%29

    在方法中,您可以调用JAAS身份验证。

相关问题