| Unlike most Catalina components, there are several standard Realm implementations available. As a result, the className attribute MUST be used to select the implementation you wish to use. JDBC Database Realm (org.apache.catalina.realm.JDBCRealm) The JDBC Database Realm connects Catalina to a relational database, accessed through an appropriate JDBC driver, to perform lookups of usernames, passwords, and their associated roles. Because the lookup is done each time that it is required, changes to the database will be immediately reflected in the information used to authenticate new logins. A rich set of additional attributes lets you configure the required connection to the underlying database, as well as the table and column names used to retrieve the required information: AttributeDescription | connectionName | The database username to use when establishing the JDBC connection. | | connectionPassword | The database password to use when establishing the JDBC connection. | | connectionURL | The connection URL to be passed to the JDBC driver when establishing a database connection. | | driverName | Fully qualified Java class name of the JDBC driver to be used to connect to the authentication database. Consult the documentation for your JDBC driver for the appropriate value. | | roleNameCol | Name of the column, in the "user roles" table, which contains a role name assigned to the corresponding user. | | userCredCol | Name of the column, in the "users" table, which contains the user's credentials (i.e. password). If a value for the digest attribute is specified, this component will assume that the passwords have been encoded with the specified algorithm. Otherwise, they will be assumed to be in clear text. | | userNameCol | Name of the column, in the "users" and "user roles" table, that contains the user's username. | | userRoleTable | 表名,它的每一行包含指派給某一特定用戶名稱的一個角色。這個表格必須至少包括那些由userNameCol和roleNameCol屬性定名的列。 | | userTable | 表名,它的每一行包含一個可被Tomcat識別的用戶名稱。這個表格必須至少包括那些由userNameCol 和 userCredCol 屬性定名的列。 | See the Container-Managed Security Guide for more information on setting up container managed security using the JDBC Database Realm component. DataSource Database Realm (org.apache.catalina.realm.DataSourceRealm) The DataSource Database Realm connects Catalina to a relational database, accessed through a JNDI named JDBC DataSource to perform lookups of usernames, passwords, and their associated roles. Because the lookup is done each time that it is required, changes to the database will be immediately reflected in the information used to authenticate new logins. The JDBC Realm uses a single db connection. This requires that realm based authentication be synchronized, i.e. only one authentication can be done at a time. This could be a bottleneck for applications with high volumes of realm based authentications. The DataSource Database Realm supports simultaneous realm based authentications and allows the underlying JDBC DataSource to handle optimizations like database connection pooling. A rich set of additional attributes lets you configure the name of the JNDI JDBC DataSource, as well as the table and column names used to retrieve the required information: AttributeDescription | dataSourceName | 你的數據庫需要的一個叫做JDBC DataSource的JNDI。如果這個DataSource對于上下文來說是局部的話,這個名字與java:/comp/env相關,否則這個名字應該和定義全球性DataSource的名字相映射。 | | localDataSource | 當這個realm被套嵌在一個Context元素里邊,就允許這個realm使用為這個Context定義的DataSource,而不是全球性DataSource 。如果沒有指定,默認值是false:使用全球性DataSource 。 | | roleNameCol | Name of the column, in the "user roles" table, which contains a role name assigned to the corresponding user. | | userCredCol | Name of the column, in the "users" table, which contains the user's credentials (i.e. password). If a value for the digest attribute is specified, this component will assume that the passwords have been encoded with the specified algorithm. Otherwise, they will be assumed to be in clear text. | | userNameCol | Name of the column, in the "users" and "user roles" table, that contains the user's username. | | userRoleTable | 表名,它的每一行包含指派給某一特定用戶名稱的一個角色。這個表格必須至少包括那些由userNameCol和roleNameCol屬性定名的列。 | | userTable | 表名,它的每一行包含一個可被Tomcat識別的用戶名稱。這個表格必須至少包括那些由userNameCol 和 userCredCol 屬性定名的列。 | See the DataSource Realm HOW-TO for more information on setting up container managed security using the DataSource Database Realm component. JNDI Directory Realm (org.apache.catalina.realm.JNDIRealm) The JNDI Directory Realm connects Catalina to an LDAP Directory, accessed through an appropriate JNDI driver, that stores usernames, passwords, and their associated roles. Changes to the directory are immediately reflected in the information used to authenticate new logins. The directory realm supports a variety of approaches to using LDAP for authentication: - The realm can either use a pattern to determine the distinguished name (DN) of the user's directory entry, or search the directory to locate that entry.
- The realm can authenticate the user either by binding to the directory with the DN of the user's entry and the password presented by the user, or by retrieving the password from the user's entry and performing a comparison locally.
- Roles may be represented in the directory as explicit entries found by a directory search (e.g. group entries of which the user is a member), as the values of an attribute in the user's entry, or both.
A rich set of additional attributes lets you configure the required behaviour as well as the connection to the underlying directory and the element and attribute names used to retrieve information from the directory: AttributeDescription | alternateURL | If a socket connection can not be made to the provider at the connectionURL an attempt will be made to use the alternateURL. | | authentication | A string specifying the type of authentication to use. "none", "simple", "strong" or a provider specific definition can be used. If no value is given the providers default is used. | | connectionName | 建立與LDAP search操作目錄的連接時使用的目錄用戶名。如果沒有指定,就使用無名的連接,除非你指定了userPassword屬性,通常這就足夠了。 | | connectionPassword | 建立與LDAP search操作目錄的連接時使用的目錄密碼。如果沒有指定,就使用無名的連接,除非你指定了userPassword屬性,通常這就足夠了。 | | connectionURL | 在建立與目錄的連接時傳遞給JNDI驅動的連接URL。 | | contextFactory | Fully qualified Java class name of the factory class used to acquire our JNDI InitialContext. By default, assumes that the standard JNDI LDAP provider will be utilized (com.sun.jndi.ldap.LdapCtxFactory). | | derefAliases | A string specifying how aliases are to be dereferenced during search operations. The allowed values are "always", "never", "finding" and "searching". If not specified, "always" is used. | | protocol | A string specifying the security protocol to use. If not given the providers default is used. | | roleBase | The base directory entry for performing role searches. If not specified the top-level element in the directory context will be used. | | roleName | 屬性的名字,它包含被角色搜尋查找到的目錄輸入里的角色名字。另外,你可以在包含有額外的角色名字的用戶輸入里使用userRoleName property來指定一個attribute的名字。如果roleName沒有被指定,角色搜尋就不會發生,只能從用戶的輸入里得到角色。 | | roleSearch | 用來執行角色搜尋的LDAP過濾器表達式,后面緊跟著由java.text.MessageFormat類支持的語法。使用{0}來代替用戶的獨特名字(distinguished name (DN)),并且/或者用{1}來代替用戶名(username)。如果沒有被指定,角色搜尋就不發生,角色就由userRoleName property指定的用戶輸入里的屬性來決定。 | | roleSubtree | 在查找與用戶相關的角色輸入時,如果你想搜尋roleBase property指定的元素的整個subtree,設值為true。默認值為false,它僅僅使得頂層元素被搜尋。 | | userBase | 通過使用userSearch表達式來執行的用戶搜尋基本元素。如果沒有指定,目錄context里的頂層元素將被使用。如果你在使用userPattern表達式,就不用使用它。 | | userPassword | Name of the attribute in the user's entry containing the user's password. If you specify this value, JNDIRealm will bind to the directory using the values specified by connectionName and connectionPassword properties, and retrieve the corresponding attribute for comparison to the value specified by the user being authenticated. If the digest attribute is set, the specified digest algorithm is applied to the password offered by the user before comparing it with the value retrieved from the directory. If you do not specify this value, JNDIRealm will attempt a simple bind to the directory using the DN of the user's entry and the password presented by the user, with a successful bind being interpreted as an authenticated user. | | userPattern | Pattern for the distinguished name (DN) of the user's directory entry, following the syntax supported by the java.text.MessageFormat class. with {0} marking where the actual username should be inserted. You can use this property instead of userSearch, userSubtree and userBase when the distinguished name contains the username and is otherwise the same for all users. | | userRoleName | 用戶目錄輸入中的一個屬性名,該屬性包含了零個或多個指定給用戶的角色名稱的值。另外,可以使用roleName屬性來指定屬性名,這個屬性可以通過搜索目錄在單獨的角色輸入里得到。如果不指定userRoleName,用戶的所有角色通過角色搜索得到。 | | userSearch | 搜索用戶目錄輸入時,使用的LDAP過濾器表達式,{0}代表實際用戶名應該在什么地方被插入。使用這個userSearch屬性(和userBase以及userSubtree屬性一起),而不是userPattern,來搜索目錄尋找用戶的輸入。 | | userSubtree | 如果想要搜索由userBase屬性指定的元素的整個subtree,設為true,缺省值為false,即僅僅是頂級元素被搜索。如果使用userPattern表達式,則不使用這個屬性。 | See the Container-Managed Security Guide for more information on setting up container managed security using the JNDI Directory Realm component. Memory Based Realm (org.apache.catalina.realm.MemoryRealm) The Memory Based Realm is a simple Realm implementation that reads user information from an XML format, and represents it as a collection of Java objects in memory. This implementation is intended solely to get up and running with container managed security - it is NOT intended for production use. As such, there are no mechanisms for updating the in-memory collection of users when the content of the underlying data file is changed. The Memory Based Realm implementation supports the following additional attributes: AttributeDescription | pathname | Absolute or relative (to $CATALINA_HOME) pathname to the XML file containing our user information. See below for details on the XML element format required. If no pathname is specified, the default value is conf/tomcat-users.xml. | The XML document referenced by the pathname attribute must conform to the following requirements: - The root (outer) element must be <tomcat-users>.
- Each authorized user must be represented by a single XML element <user>, nested inside the root element.
- Each <user> element must have the following attributes:
- name - Username of this user (must be unique within this file).
- password - Password of this user (in clear text).
- roles - Comma-delimited list of the role names assigned to this user.
See the Container-Managed Security Guide for more information on setting up container managed security using the Memory Based Realm component. User Database Realm (org.apache.catalina.realm.UserDatabaseRealm) The User Database Realm is Realm implementation that is based on an implementation of the UserDatabase interface that is made available through the global JNDI resources configured for this Tomcat instance. The User Database Realm implementation supports the following additional attributes: AttributeDescription | resourceName | The global JNDI name of the UserDatabase resource used by this Realm. | See the Container-Managed Security Guide for more information on setting up container managed security using the UserDatabase Realm component. JAAS Realm (org.apache.catalina.realm.JAASRealm) The JAAS Realm implementation supports the following additional attributes: AttributeDescription | appName | 你在login配置文件中( JAAS LoginConfig)配置的應用程序名。 | | userClassNames | 由逗號分隔開的,你為你的用戶Principals制作的類名列單。 | | roleClassNames | 由逗號分隔開的,你為你的角色Principals制作的類名列單。 | | useContextClassLoader | Instructs JAASRealm to use the context class loader for loading the user-specified LoginModule class and associated Principal classes. The default value is true, which is backwards-compatible with the way Tomcat 4 works. To load classes using the container's classloader, specify false. | See the Container-Managed Security Guide for more information on setting up container managed security using the JASS Realm component. |