Tomcat 7.11 JDBCRealm和UserDatabaseRealm不能一起使用 [英] Tomcat 7.11 JDBCRealm and UserDatabaseRealm dont work together

查看:128
本文介绍了Tomcat 7.11 JDBCRealm和UserDatabaseRealm不能一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的Web应用程序(JSF 2.1 +休眠)设置一个容器管理的安全性领域.我注意到Tomcat 7一次只能使用一种类型的领域.

I'm trying to set a container managerd security a realm for my web app (JSF 2.1 + hibernate). I have noticed that Tomcat 7 can only use one type of realm at a time.

要在netbeans(7.0)中使用Tomcat,我必须创建一个经理脚本角色帐户.除了使用Tomcat Manager,我还需要另一个角色.这对我来说是个大问题,因为我用于JDBCRealm的表是来自存储用户和角色的实际表的视图,并且我不想将这两个角色都存储在程序使用的同一数据库中.

To use Tomcat in netbeans (7.0) i have to create an accout of manager-script role. In addition to work with Tomcat manager I also need another role. This is a big problem for me because the tables I'm using for JDBCRealm are viewes from actual tables that store users and roles and I would like not to store both of the roles in the same db that my program uses.

有没有一种方法可以使JDBCRealm和UserDBRealm一起工作?那将是一种解脱.

Is there a way to make JDBCRealm and UserDBRealm work together? That would be a relief.

这是来自server.config的代码:

here is the code from server.config:

<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

<Realm className="org.apache.catalina.realm.JDBCRealm"
    driverName="org.gjt.mm.mysql.Driver"
    connectionURL="jdbc:mysql://localhost:3306/realm?user=login&amp;password=pass" 
    userTable="users"
    userNameCol="user_name"
    userCredCol="user_pass"
    userRoleTable="user_roles" 
    roleNameCol="role_name" /> 

tomcat仅使用他在文件中找到的最后一个.他们分开工作很好

tomcat uses only the last one he finds in the file. They work fine separetly

推荐答案

使用CombinedRealm( javadoc ):

包含一个或多个领域的领域实现.验证 尝试按每个领域的配置顺序对其进行配置.如果有的话 域对用户进行身份验证,然后身份验证成功.什么时候 组合领域的用户名在所有组合中都应该是唯一的 领域.

Realm implementation that contains one or more realms. Authentication is attempted for each realm in the order they were configured. If any realm authenticates the user then the authentication succeeds. When combining realms usernames should be unique across all combined realms.

也许您已经在使用LockOutRealm( doc javadoc ),它是CombinedRealm的子类,它在Tomcat的默认配置中.

Maybe you are already using the LockOutRealm (doc, javadoc) which is a subclass of CombinedRealm and it's in the default config of Tomcat.

这篇关于Tomcat 7.11 JDBCRealm和UserDatabaseRealm不能一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆