Spec-Zone .ru
спецификации, руководства, описания, API
|
public final class HttpURLPermission extends Permission
The url
The url string is also used to instantiate a URI
object which is
used for comparison with other HttpURLPermission instances. Therefore, any
references in this specification to url, mean this URI object.
The path component of the url comprises a sequence of path segments, separated
by '/' characters. The path is specified in a similar way to the path
in FilePermission
. There are three different ways
as the following examples show:
Example url | Description |
---|---|
http://www.oracle.com/a/b/c.html | A url which identifies a specific (single) resource |
http://www.oracle.com/a/b/* | The '*' character refers to all resources in the same "directory" - in other words all resources with the same number of path components, and which only differ in the final path component, represented by the '*'. |
http://www.oracle.com/a/b/- | The '-' character refers to all resources recursively below the preceding path (eg. http://www.oracle.com/a/b/c/d/e.html matches this example). |
The '*' and '-' may only be specified in the final segment of a path and must be the only character in that segment. Any query or fragment components of the url are ignored when constructing HttpURLPermissions.
As a special case, urls of the form, "http:*" or "https:*" are accepted to mean any url of the given scheme.
The actions string
The actions string of a HttpURLPermission is a concatenation of the method list and the request headers list. These are lists of the permitted HTTP request methods and permitted request headers of the permission (respectively). The two lists are separated by a colon ':' character and elements of each list are comma separated. Some examples are:
"POST,GET,DELETE" "GET:X-Foo-Request,X-Bar-Request" "POST,GET:Header1,Header2"The first example specifies the methods: POST, GET and DELETE, but no request headers. The second example specifies one request method and two headers. The third example specifies two request methods, and two headers.
The colon separator need not be present if the request headers list is empty. No white-space is permitted in the actions string. The action strings supplied to the HttpURLPermission constructors are case-insensitive and are normalized by converting method names to upper-case and header names to the form defines in RFC2616 (lower case with initial letter of each word capitalized). Either list can contain a wild-card '*' character which signifies all request methods or headers respectively.
Note. Depending on the context of use, some request methods and headers may be permitted at all times, and others may not be permitted at any time. For example, the HTTP protocol handler might disallow certain headers such as Content-Length from being set by application code, regardless of whether the security policy in force, permits it.
Constructor and Description |
---|
HttpURLPermission(String url)
Creates a HttpURLPermission with the given url string and unrestricted
methods and request headers by invoking the two argument
constructor as follows: HttpURLPermission(url, "*:*")
|
HttpURLPermission(String url,
String actions)
Creates a new HttpURLPermission from a url string and which permits the given
request methods and user-settable request headers.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object p)
Returns true if, this.getActions().equals(p.getActions())
and p's url equals this's url.
|
String |
getActions()
Returns the normalized method list and request
header list, in the form:
|
int |
hashCode()
Returns a hashcode calculated from the hashcode of the
actions String and the url
|
boolean |
implies(Permission p)
Checks if this HttpURLPermission implies the given permission.
|
checkGuard, getName, newPermissionCollection, toString
public HttpURLPermission(String url, String actions)
url
- the url stringactions
- the actions stringIllegalArgumentException
- if url does not result in a valid URI
,
its scheme is not http or https, or if actions contains white-space.public HttpURLPermission(String url)
IllegalArgumentException
- if url does not result in a valid URI
public String getActions()
"method-names : header-names"
where method-names is the list of methods separated by commas and header-names is the list of permitted headers separated by commas. There is no white space in the returned String. If header-names is empty then the colon separator will not be present.
getActions
in class Permission
public boolean implies(Permission p)
Some examples of how paths are matched are shown below:
this's path | p's path | match |
---|---|---|
/a/b | /a/b | yes |
/a/b/* | /a/b/c | yes |
/a/b/* | /a/b/c/d | no |
/a/b/- | /a/b/c/d | yes |
/a/b/- | /a/b/c/d/e | yes |
/a/b/- | /a/b/c/* | yes |
/a/b/* | /a/b/c/- | no |
implies
in class Permission
p
- the permission to check against.public boolean equals(Object p)
equals
in class Permission
p
- the object we are testing for equality with this object.Object.hashCode()
,
HashMap
public int hashCode()
hashCode
in class Permission
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.
DRAFT ea-b92