Tomcat 5.5.23 文档阅读Tips 5 Realms and Access Control

本文讲述的是在Tomcat中配置Realm(领域)。Realm就是一个username和password的集合,通过配置Realm,我们可以限制账户和web app等其他资源之间的access关系。对于EasyCluster而言,这个没什么意义,因为在EasyCluster的tomcat中,只会run一个web app。 

另一方面,通过配置Realm,用户可以把一些信息放到Realm中,并设定权限,从而方便web app的开发,比如将用户名和密码做成Realm。这个Realm来自Servlet Specification 2.4,这份specification中规定Servlet Container要实现叫做Container Managed Security的东西,反映在tomcat中就是这个Realm了。 

Realm有魅力的地方就在于他支持多种类型的Realm: 

(1) JDBCRealm - Accesses authentication information stored in a relational database, accessed via a JDBC driver. 
(2) DataSourceRealm - Accesses authentication information stored in a relational database, accessed via a named JNDI JDBC DataSource. 
(3) JNDIRealm - Accesses authentication information stored in an LDAP based directory server, accessed via a JNDI provider. 
(4) MemoryRealm - Accesses authentication information stored in an in-memory object collection, which is initialized from an XML document (conf/tomcat-users.xml). 
(5) JAASRealm - Accesses authentication information through the Java Authentication & Authorization Service (JAAS) framework. 

其实就是存放信息的类型不同,可以用数据库,LDAP,JNDI等等。刚才配置manager的账户的时候,我们修改tomcat-users.xml,其实这就是MemoryRealm。有关Realm的更多信息,请直接参考本文档,这里不详述了,因为对于我们,用处不大。
原文地址:https://www.cnblogs.com/super119/p/1933329.html