|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.security.jacc Class WebResourcePermission
java.lang.Object java.security.Permission javax.security.jacc.WebResourcePermission
- All Implemented Interfaces:
- Serializable, Guard
public final class WebResourcePermission
- extends Permission
- implements Serializable
Servlet Web 资源权限的类。WebResourcePermission 是一种指定权限,它包含各种操作。
WebResourcePermission 的名称(也称为目标名称)标识应用权限的 Web 资源。
此类的实现可以实现 newPermissionCollection,也可以从超类继承其实现。
version | %I% %E% |
See also | java.security.Permission |
Class for Servlet web resource permissions. A WebResourcePermission is a named permission and has actions.
The name of a WebResourcePermission (also referred to as the target name) identifies the Web resources to which the permission pertains.
Implementations of this class MAY implement newPermissionCollection or inherit its implementation from the super class.
- Version:
- %I% %E%
- Author:
- Ron Monzillo, Gary Ellison
- See Also:
Permission
, Serialized Form
Constructor Summary | |
---|---|
WebResourcePermission(HttpServletRequest request)
Creates a new WebResourcePermission from the HttpServletRequest object. |
|
WebResourcePermission(String name,
String actions)
Creates a new WebResourcePermission with the specified name and actions. |
|
WebResourcePermission(String urlPatternSpec,
String[] HTTPMethods)
Creates a new WebResourcePermission with name corresponding to the URLPatternSpec, and actions composed from the array of HTTP methods. |
Method Summary | |
---|---|
boolean |
equals(Object o)
Checks two WebResourcePermission objects for equality. |
String |
getActions()
Returns a canonical String representation of the actions of this WebResourcePermission. |
int |
hashCode()
Returns the hash code value for this WebResourcePermission. |
boolean |
implies(Permission permission)
Determines if the argument Permission is "implied by" this WebResourcePermission. |
Methods inherited from class java.security.Permission |
---|
checkGuard, getName, newPermissionCollection, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public
WebResourcePermission(String name, String actions)
创建具有指定名称和操作的新 WebResourcePermission。
名称包含可以标识要应用权限的 Web 资源的 URLPatternSpec。URLPatternSpec 的语法如下:
URLPatternList ::= URLPattern | URLPatternList colon URLPattern URLPatternSpec ::= null | URLPattern | URLPattern colon URLPatternList
null URLPatternSpec 可以通过权限构造方法转换为默认的 URLPattern ("/")。空字符串是一个 exact URLPattern,在 URLPatternSpec 中,只要是 exact URLPattern 可能出现的地方,它都有可能出现。URLPatternSpec 的第一个 URLPattern 可以是任何模式类型:exact、path-prefix、extension 或者默认类型(在 Java Servlet 规范中定义)。如果 URLPatternSpec 包含 URLPatternList,则 URLPatternList 的模式标识未应用权限的资源,并依赖第一个模式的模式类型和值,如下所示:
- 匹配第一个模式的 URLPatternList 中不存在任何模式。
- 如果第一个模式是 path-prefix 模式,则 URLPatternList 中只存在匹配第一个模式的 exact 模式和匹配第一个模式(但不同)的 path-prefix 模式。
- 如果第一个模式是 extension 模式,则 URLPatternList 中只存在匹配第一个模式的 exact 模式和 path-prefix 模式。
- 如果第一个模式是默认模式 "/",则除默认模式以外的模式都可以出现在 URLPatternList 中。
- 如果第一个模式是 exact 模式,则 URLPatternList 不得在 URLPatternSpec 中显示。
actions 参数包含以逗号分隔的 HTTP 方法列表。actions 参数的语法定义如下:
ExtensionMethod ::= any token as defined by RFC 2616 (即 1*[除了 CTL 或分隔符以外的任何字符]) HTTPMethod ::= "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "TRACE" | ExtensionMethod HTTPMethodList ::= HTTPMethod | HTTPMethodList comma HTTPMethod HTTPMethodExceptionList ::= exclaimationPoint HTTPMethodList HTTPMethodSpec ::= null | HTTPMethodExceptionList | HTTPMethodList
如果 HTTPMethodSpec 中出现重复,则必须使用权限构造方法删除。
null 或空字符串 HTTPMethodSpec 表示将权限应用于 URL 模式所标识资源的所有 HTTP 方法。
如果 HTTPMethodSpec 包含 HTTPMethodExceptionList(即它以 exclaimationPoint 开始),则权限将应用于未出现在异常列表中的所有方法。
name | 标识应用权限的特定于应用程序的 Web 资源的 URLPatternSpec。URLPatternSpec 中的所有 URLPattern 都相对于部署了 Web 应用程序模块的上下文路径,URLPatternSpec 中不得多次出现相同的 URLPattern。null URLPatternSpec 可以通过权限构造方法转换为默认的 URLPattern ("/")。 |
actions | 标识应用权限的 HTTP 方法。如果通过此参数传递的值为 null 或空字符串,则权限将应用于所有可能的 HTTP 方法。 |
WebResourcePermission
public WebResourcePermission(String name, String actions)
- Creates a new WebResourcePermission with the specified name and actions.
The name contains a URLPatternSpec that identifies the web resources to which the permissions applies. The syntax of a URLPatternSpec is as follows:
URLPatternList ::= URLPattern | URLPatternList colon URLPattern URLPatternSpec ::= null | URLPattern | URLPattern colon URLPatternList
A null URLPatternSpec is translated to the default URLPattern, "/", by the permission constructor. The empty string is an exact URLPattern, and may occur anywhere in a URLPatternSpec that an exact URLPattern may occur. The first URLPattern in a URLPatternSpec may be any of the pattern types, exact, path-prefix, extension, or default as defined in the Java Servlet Specification). When a URLPatternSpec includes a URLPatternList, the patterns of the URLPatternList identify the resources to which the permission does NOT apply and depend on the pattern type and value of the first pattern as follows:
- No pattern may exist in the URLPatternList that matches the first pattern.
- If the first pattern is a path-prefix pattern, only exact patterns matched by the first pattern and path-prefix patterns matched by, but different from, the first pattern may occur in the URLPatternList.
- If the first pattern is an extension pattern, only exact patterns that are matched by the first pattern and path-prefix patterns may occur in the URLPatternList.
- If the first pattern is the default pattern, "/", any pattern except the default pattern may occur in the URLPatternList.
- If the first pattern is an exact pattern a URLPatternList must not be present in the URLPatternSpec.
The actions parameter contains a comma seperated list of HTTP methods. The syntax of the actions parameter is defined as follows:
ExtensionMethod ::= any token as defined by RFC 2616 (that is, 1*[any CHAR except CTLs or separators]) HTTPMethod ::= "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS" | "TRACE" | ExtensionMethod HTTPMethodList ::= HTTPMethod | HTTPMethodList comma HTTPMethod HTTPMethodExceptionList ::= exclaimationPoint HTTPMethodList HTTPMethodSpec ::= null | HTTPMethodExceptionList | HTTPMethodList
If duplicates occur in the HTTPMethodSpec they must be eliminated by the permission constructor.
A null or empty string HTTPMethodSpec indicates that the permission applies to all HTTP methods at the resources identified by the URL pattern.
If the HTTPMethodSpec contains an HTTPMethodExceptionList (i.e., it begins with an exclaimationPoint), the permission pertains to all methods except those occuring in the exception list.
- Parameters:
name
- the URLPatternSpec that identifies the application specific web resources to which the permission pertains. All URLPatterns in the URLPatternSpec are relative to the context path of the deployed web application module, and the same URLPattern must not occur more than once in a URLPatternSpec. A null URLPatternSpec is translated to the default URLPattern, "/", by the permission constructor.actions
- identifies the HTTP methods to which the permission pertains. If the value passed through this parameter is null or the empty string, then the permission pertains to all the possible HTTP methods.
public
WebResourcePermission(String urlPatternSpec, String[] HTTPMethods)
创建新 WebResourcePermission,其名称对应于 URLPatternSpec,其操作由 HTTP 方法数组组成。
urlPatternSpec | 标识应用权限的特定于应用程序的 Web 资源的 URLPatternSpec。URLPatternSpec 中的所有 URLPattern 都相对于部署了 Web 应用程序模块的上下文路径,URLPatternSpec 中不得多次出现相同的 URLPattern。null URLPatternSpec 可以通过权限构造方法转换为默认的 URLPattern ("/")。 |
HTTPMethods | 一个字符串数组,其中每个元素都包含一个 HTTP 方法的值。如果通过此参数传递的值为 null,或者是不包含任何元素的数组,则权限将应用于所有可能的 HTTP 方法。 |
WebResourcePermission
public WebResourcePermission(String urlPatternSpec, String[] HTTPMethods)
- Creates a new WebResourcePermission with name corresponding
to the URLPatternSpec, and actions composed from the array of HTTP
methods.
- Parameters:
urlPatternSpec
- the URLPatternSpec that identifies the application specific web resources to which the permission pertains. All URLPatterns in the URLPatternSpec are relative to the context path of the deployed web application module, and the same URLPattern must not occur more than once in a URLPatternSpec. A null URLPatternSpec is translated to the default URLPattern, "/", by the permission constructor.HTTPMethods
- an array of strings each element of which contains the value of an HTTP method. If the value passed through this parameter is null or is an array with no elements, then the permission pertains to all the possible HTTP methods.
public
WebResourcePermission(HttpServletRequest request)
根据 HttpServletRequest 对象创建新的 WebResourcePermission。
request | 对应于应用权限的 Servlet 操作的 HttpServletRequest 对象。权限名称是 contextPath (HttpServletRequest.getContextPath()) 之后 requestURI (HttpServletRequest.getRequestURI()) 所得结果的子字符串。当子字符串操作超过字符串 "/" 时,构造权限过程中将使用空字符串作为其名称。从 HttpServletRequest.getMethod() 中获取权限的操作字段。 |
WebResourcePermission
public WebResourcePermission(HttpServletRequest request)
- Creates a new WebResourcePermission from the HttpServletRequest
object.
- Parameters:
request
- the HttpServletRequest object corresponding to the Servlet operation to which the permission pertains. The permission name is the substring of the requestURI (HttpServletRequest.getRequestURI()) that begins after the contextPath (HttpServletRequest.getContextPath()). When the substring operation yields the string "/", the permission is constructed with the empty string as its name. The permission's actions field is obtained from HttpServletRequest.getMethod().
Method Detail |
---|
public boolean
equals(Object o)
检查两个 WebResourcePermission 对象是否相等。如果 WebResourcePermission 对象的 URLPatternSpec 和(规范)操作值相等,则它们相等。如果引用权限 URLPatternSpec 的第一个模式等于参数权限 URLPatternSpec 的第一个模式,并且引用权限整个 URLPatternList 中的模式与参数权限 URLPatternList 中的模式匹配完全相同的模式集合,则这两个权限相等。
当且仅当 P1.implies(P2) && P2.implies(P1) 时,这两个 Permission 对象(P1 和 P2)才是相等的。
o | 要测试是否与此 WebResourcePermission 相等的 WebResourcePermission 对象 |
return | 如果参数 WebResourcePermission 对象与此 WebResourcePermission 相等,则返回 true。 |
equals
public boolean equals(Object o)
- Checks two WebResourcePermission objects for equality.
WebResourcePermission objects are equivalent if their
URLPatternSpec and (canonicalized) actions values are equivalent.
The URLPatternSpec of a reference permission is equivalent to that
of an argument permission if their first patterns are
equivalent, and the patterns of the URLPatternList of the reference
permission collectively match exactly the same set of patterns
as are matched by the patterns of the URLPatternList of the
argument permission.
Two Permission objects, P1 and P2, are equivalent if and only if P1.implies(P2) && P2.implies(P1).
- Specified by:
equals
in classPermission
- Parameters:
o
- the WebResourcePermission object being tested for equality with this WebResourcePermission.- Returns:
- true if the argument WebResourcePermission object is equivalent to this WebResourcePermission.
public String
getActions()
返回此 WebResourcePermission 的操作的规范字符串表示形式。在规范形式中,预定义的方法位于扩展方法之前,并且在每个方法类别中,相应的方法按词汇升序排列。在规范形式中可能不存在重复的 HTTP 方法,所有 HTTP 方法集合的规范形式为 null 值。
return | 包含此 WebResourcePermission 的规范化操作的字符串(或 null 值)。 |
getActions
public String getActions()
- Returns a canonical String representation of the actions of this
WebResourcePermission. In the canonical form, predefined methods
preceed extension methods, and within each method classification the
corresponding methods occur in ascending lexical order. There may be
no duplicate HTTP methods in the canonical form, and the canonical
form of the set of all HTTP methods is the value null.
- Specified by:
getActions
in classPermission
- Returns:
- a String containing the canonicalized actions of this WebResourcePermission (or the null value).
public int
hashCode()
返回此 WebResourcePermission 的哈希码值。所返回哈希码的属性必须如下所示:
- 在 Java 应用程序的生命周期中,每次对 WebResourcePermission 对象调用 hashCode 方法时,该方法都必须返回相同的整数值。应用程序每次对特定 WebResourcePermission 执行 hashCode 所返回的值不必总是相同。
- 如果根据 equals 方法,两个 WebResourcePermission 对象相等,那么对这两个 Permission 对象调用 hashCode 方法必须生成相同的整数结果(在应用程序内)。
return | 此对象的整数哈希码值。 |
hashCode
public int hashCode()
- Returns the hash code value for this WebResourcePermission. The
properties of the returned hash code must be as follows:
- During the lifetime of a Java application, the hashCode method must return the same integer value, every time it is called on a WebResourcePermission object. The value returned by hashCode for a particular WebResourcePermission need not remain consistent from one execution of an application to another.
- If two WebResourcePermission objects are equal according to the equals method, then calling the hashCode method on each of the two Permission objects must produce the same integer result (within an application).
- Specified by:
hashCode
in classPermission
- Returns:
- the integer hash code value for this object.
public boolean
implies(java.security.Permission permission)
确定此 WebResourcePermission 是否“隐含”参数 Permission。如果是这样,则所有下列各项都必须为 true:
- 参数是 WebResourcePermission 的实例
- 参数 permission 名称的第一个 URLPattern 匹配此权限名称的第一个 URLPattern。
- 参数 permission 名称的第一个 URLPattern 不匹配此权限 URLPatternSpec URLPatternList 中的任何 URLPattern。
- 如果参数 permission 名称的第一个 URLPattern 匹配此权限 URLPatternSpec 中的第一个 URLPattern,那么此权限 URLPatternSpec URLPatternList 中的每个 URLPattern 都匹配参数 permission URLPatternList 中的 URLPattern。
- 参数 permission 操作所表示的 HTTP 方法是此权限操作所表示的 HTTP 方法的子集。
URLPattern 匹配根据 Servlet 匹配规则 执行,模式匹配的两个 URL 的关系应该满足以下条件:
- 其模式值为等效的 String;
- 此模式为 path-prefix 模式 "/*";
- 此模式为 path-prefix 模式(即以 "/" 开头以 "/*" 结尾),并且参数模式以此模式的子字符串(减去最后 2 个字符)开头,且参数模式的下一个字符为 "/"(如果有);
- 此模式是 extension 模式(即以 "*." 开头),并且参数模式以此模式结尾;
- 引用模式是特殊的默认模式 "/",它匹配所有参数模式。
上述所有比较都是区分大小写的。
permission | 检查是否隐含参数权限的 "this" WebResourcePermission。 |
return | 如果对象隐含指定的权限,则返回 true;否则返回 false。 |
implies
public boolean implies(Permission permission)
- Determines if the argument Permission is "implied by" this
WebResourcePermission. For this to be the case, all of the following
must be true:
- The argument is an instanceof WebResourcePermission
- The first URLPattern in the name of the argument permission is matched by the first URLPattern in the name of this permission.
- The first URLPattern in the name of the argument permission is NOT matched by any URLPattern in the URLPatternList of the URLPatternSpec of this permission.
- If the first URLPattern in the name of the argument permission matches the first URLPattern in the URLPatternSpec of this permission, then every URLPattern in the URLPatternList of the URLPatternSpec of this permission is matched by a URLPattern in the URLPatternList of the argument permission.
- The HTTP methods represented by the actions of the argument permission are a subset of the HTTP methods represented by the actions of this permission.
URLPattern matching is performed using the Servlet matching rules where two URL patterns match if they are related as follows:
- their pattern values are String equivalent, or
- this pattern is the path-prefix pattern "/*", or
- this pattern is a path-prefix pattern (that is, it starts with "/" and ends with "/*") and the argument pattern starts with the substring of this pattern, minus its last 2 characters, and the next character of the argument pattern, if there is one, is "/", or
- this pattern is an extension pattern (that is, it starts with "*.") and the argument pattern ends with this pattern, or
- the reference pattern is the special default pattern, "/", which matches all argument patterns.
All of the comparisons described above are case sensitive.
- Specified by:
implies
in classPermission
- Parameters:
permission
- "this" WebResourcePermission is checked to see if it implies the argument permission.- Returns:
- true if the specified permission is implied by this object, false if not.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!