public abstract class PermissionGrantBuilder extends Object
PermissionGrant
Modifier and Type | Field and Description |
---|---|
static int |
CLASSLOADER
The PermissionGrant generated will apply to all classes loaded by
the ClassLoader
|
static int |
CODESOURCE_CERTS
The PermissionGrant generated will apply to all classes loaded from
CodeSource's that have at a minimum the defined array Certificate[]
provided the logged in Subject also has all Principals when defined.
|
static int |
PRINCIPAL
The PermissionGrant generated will apply to the Subject that has
all the principals provided.
|
static int |
PROTECTIONDOMAIN
The PermissionGrant generated will apply to all classes belonging to
the ProtectionDomain.
|
static int |
URI
The PermissionGrant generated will imply the ProtectionDomain run as
a Subject with all Principals (when applicable) and
CodeSource that has the Certificates and URI RFC3986 location as specified.
|
Constructor and Description |
---|
PermissionGrantBuilder() |
Modifier and Type | Method and Description |
---|---|
abstract PermissionGrant |
build()
Build the PermissionGrant using information supplied.
|
abstract PermissionGrantBuilder |
certificates(Certificate[] certs)
Sets the Certificate[] a CodeSource must have to receive the PermissionGrant.
|
abstract PermissionGrantBuilder |
certificates(Certificate[] certs,
String[] aliases)
Sets the Certificate[] a CodeSource must have to receive the PermissionGrant.
|
abstract PermissionGrantBuilder |
clazz(Class cl)
Extracts ProtectionDomain
from the Class for use in the PermissionGrantBuilder.
|
abstract PermissionGrantBuilder |
context(int context)
Sets the context of the PermissionGrant to on of the static final
fields in this class.
|
static PermissionGrantBuilder |
newBuilder() |
abstract PermissionGrantBuilder |
permissions(Permission[] perm)
Specifies Permission's to be granted.
|
abstract PermissionGrantBuilder |
principals(Principal[] pals)
Sets the Principal[] that a Subject must have to be entitled to receive
the PermissionGrant.
|
abstract PermissionGrantBuilder |
reset()
resets the state for reuse, identical to a newly created
PermissionGrantBuilder, this step must be performed to avoid unintentional
grants to previously added URI.
|
abstract PermissionGrantBuilder |
setDomain(WeakReference<ProtectionDomain> domain) |
abstract PermissionGrantBuilder |
uri(String path)
The URI will be added to the PermissionGrant, multiple may be specified by
calling multiple times.
|
public static final int CLASSLOADER
public static final int PROTECTIONDOMAIN
DNS is not consulted, the RFC3986 normalized URI and all Certificates contained by the CodeSources must be equal.
public static final int PRINCIPAL
Subject
,
Constant Field Valuespublic static final int CODESOURCE_CERTS
public static final int URI
The PermissionGrant generated will imply the ProtectionDomain run as a Subject with all Principals (when applicable) and CodeSource that has the Certificates and URI RFC3986 location as specified.
The outcome of URI comparison is similar to
CodeSource.implies(CodeSource)
.
DNS lookup is avoided for security and performance reasons, DNS is not authenticated and therefore cannot be trusted. Doing so, could allow an attacker to use DNS Cache poisoning to escalate Permission, by imitating a URL with privilege, such as AllPermission.
CodeSource URL are converted to URI and normalized according to RFC3986 before being compared as Strings.
A URI based PermissionGrant "implies" a specified ProtectionDomain
if:
ProtectionDomain
's CodeSource
is not null.
Principal
's, if defined in the PermissionGrant
are present in the
ProtectionDomain
, when run as a Subject
, in any order.
ProtectionDomain
or non null CodeSource
if:
Certificate
's included in a URI based
PermissionGrant are present in that ProtectionDomain
's
CodeSource
's certificates, in any order, or no Certificates
are defined by the PermissionGrant.
URI
in a PermissionGrant, checks are made in the
following order:
URI
implies any
ProtectionDomain
that contains a non null
CodeSource
, including a null URL
returned by
CodeSource.getLocation()
.
ProtectionDomain
's
CodeSource.getLocation()
's URL
after it is converted to a RFC3986 normalized URI
,
the PermissionGrant.implies(java.security.ProtectionDomain)
method will return true.
CodeSource.getLocation()
's URL
is checked
against each URI
contained in a PermissionGrant and
returns true if all the following conditions are met for at least
one URI
:
URI.getScheme()
scheme must be
equal to a CodeSource
's URL.getProtocol()
protocol, after normalization to RFC3986 rules.
URI.getHost()
is non null,
and URL.getHost()
is equal after RFC3986 compliant normalization
performed.
URI.getPort()
port is not
equal to -1 (that is, if a port is specified), it must equal the
CodeSource URL's port.
URI.getPath()
path doesn't equal
codesource's URL.getPath()
path, then the following checks are made:
If this URI's path ends with "/-",
then codesource's URL path must start with this URI's
path (exclusive the trailing "-").
If this URI's path ends with a "/*",
then codesource's URL path must start with this URI's
path and must not have any further "/" separators.
If this URI's path doesn't end with a "/",
then codesource's URL path must match this URI's
path with a '/' appended.
URI.getFragment()
fragment is
not null, it must equal codesource's
URL.getRef()
reference.
CodeSource.implies(java.security.CodeSource)
URI.getQuery()
query is not appended to the path because
normalization to specific platforms is undefined. It appears
that URL
was developed prior to RFC2396 and as such
the URL.getFile()
included the query component, later
in Java 1.3 the URL.getPath()
method was added, however
earlier developed classes like URLClassLoader
continued
to use URL.getFile()
and append this with path
separators and wild cards after the query, if it existed. In
any case, Certificate and Principal are more prudent identifiers for
privileges.
public static PermissionGrantBuilder newBuilder()
public abstract PermissionGrantBuilder reset()
public abstract PermissionGrantBuilder context(int context) throws IllegalStateException
context
- value of a static field defined in this builder.IllegalStateException
- if context out of range of static fields
defined in this builder.public abstract PermissionGrantBuilder uri(String path)
path
- - RFC3986 compliant URI or null.public abstract PermissionGrantBuilder clazz(Class cl)
cl
- Class used to determine the ProtectionDomain to be
used for PermissionGrant.public abstract PermissionGrantBuilder certificates(Certificate[] certs)
certs
- Certificatespublic abstract PermissionGrantBuilder certificates(Certificate[] certs, String[] aliases)
certs
- Certificatesaliases
- of certificates.public abstract PermissionGrantBuilder principals(Principal[] pals)
pals
- Principals.public abstract PermissionGrantBuilder permissions(Permission[] perm)
perm
- Permissions.public abstract PermissionGrant build()
public abstract PermissionGrantBuilder setDomain(WeakReference<ProtectionDomain> domain)
domain
- WeakReference containing ProtectionDomainCopyright © 2016–2018 The Apache Software Foundation. All rights reserved.