class PolicyUtils extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
PolicyUtils.ExpansionFailedException
Specific exception to signal that property expansion failed
due to unknown key.
|
(package private) static interface |
PolicyUtils.GeneralExpansionHandler
Instances of this interface are intended for resolving
generalized expansion expressions, of the form ${{protocol:data}}.
|
(package private) static class |
PolicyUtils.SecurityPropertyAccessor
Auxiliary action for accessing specific security property.
|
(package private) static class |
PolicyUtils.URLLoader
Auxiliary action for opening InputStream from specified location.
|
Modifier and Type | Field and Description |
---|---|
(package private) static String |
FALSE
Negative value of switching properties.
|
private static Class[] |
NO_ARGS |
private static Class[] |
ONE_ARGS |
(package private) static String |
POLICY_ALLOW_DYNAMIC
A key to security properties, deciding whether usage of
dynamic policy location via system properties is allowed.
|
(package private) static String |
POLICY_EXPAND
A key to security properties, deciding whether expansion of
system properties is allowed
(in security properties values, policy files, etc).
|
(package private) static String |
TRUE
Positive value of switching properties.
|
private static Class[] |
TWO_ARGS |
Modifier | Constructor and Description |
---|---|
private |
PolicyUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static boolean |
canExpandProperties()
Returns false if current security settings disable to perform
properties expansion, true otherwise.
|
static String |
expand(String str,
Properties properties)
Substitutes all entries like ${some.key}, found in specified string,
for specified values.
|
(package private) static String |
expandGeneral(String str,
PolicyUtils.GeneralExpansionHandler handler)
Substitutes all entries like ${{protocol:data}}, found in specified string,
for values resolved by passed handler.
|
(package private) static String |
expandURL(String str,
Properties properties)
Handy shortcut for
expand(str, properties).replace(File.separatorChar, '/') . |
(package private) static URI |
filePathToURI(String path)
Converts a file path to URI without accessing file system
(like {File#toURI()} does).
|
(package private) static URL[] |
getPolicyURLs(Properties system,
String systemUrlKey,
String securityUrlPrefix)
Obtains a list of locations for a policy or configuration provider.
|
(package private) static Permission |
instantiatePermission(Class<?> targetType,
String targetName,
String targetActions)
Tries to find a suitable constructor and instantiate a new Permission
with specified parameters.
|
static boolean |
matchSubset(Object[] what,
Object[] where)
Checks whether the objects from
what array are all
presented in where array. |
(package private) static URI |
normalizeURL(URL codebase)
Normalizes URLs to standard ones, eliminating pathname symbols.
|
(package private) static PermissionCollection |
toPermissionCollection(Collection<Permission> perms)
Converts common-purpose collection of Permissions to PermissionCollection.
|
static final String POLICY_ALLOW_DYNAMIC
static final String POLICY_EXPAND
expand(String, Properties)
,
Constant Field Valuesstatic final String TRUE
static final String FALSE
private static final Class[] NO_ARGS
private static final Class[] ONE_ARGS
private static final Class[] TWO_ARGS
public static String expand(String str, Properties properties) throws PolicyUtils.ExpansionFailedException
str
- the string to be expandedproperties
- available key-value mappingsPolicyUtils.ExpansionFailedException
static String expandURL(String str, Properties properties) throws PolicyUtils.ExpansionFailedException
expand(str, properties).replace(File.separatorChar, '/')
.PolicyUtils.ExpansionFailedException
expand(String, Properties)
static URI normalizeURL(URL codebase) throws URISyntaxException
codebase
- -
the original URL.URISyntaxException
static URI filePathToURI(String path) throws URISyntaxException
path
- -
file path.URISyntaxException
static String expandGeneral(String str, PolicyUtils.GeneralExpansionHandler handler) throws PolicyUtils.ExpansionFailedException
str
- the string to be expandedhandler
- the handler to resolve data denoted by protocolPolicyUtils.ExpansionFailedException
static boolean canExpandProperties()
expand(String, Properties)
static URL[] getPolicyURLs(Properties system, String systemUrlKey, String securityUrlPrefix)
prefix + n
,
where n is an integer and prefix is a passed parameter.
Sequence starts with n=1
, and keeps incrementing n
until next key is not found. the "policy.allowSystemProperty" property
)
to use additional policy location, read the system property under the
passed key parameter. If property exists, it may designate a file or
an absolute URL. Thus, first check if there is a file with that name,
and if so, convert the pathname to URL. Otherwise, try to instantiate
an URL directly. If succeeded, append the URL to the list
property expansion
, regardless
of the "policy.expandProperties" security setting.system
- system propertiessystemUrlKey
- key to additional policy locationsecurityUrlPrefix
- prefix to numbered locations in security propertiesstatic PermissionCollection toPermissionCollection(Collection<Permission> perms)
perms
- a collection containing arbitrary permissions, may be nullstatic Permission instantiatePermission(Class<?> targetType, String targetName, String targetActions) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
targetType
- class of expected Permission instancetargetName
- name of expected Permission instancetargetActions
- actions of expected Permission instanceIllegalArgumentException
- if no suitable constructor foundException
- any exception thrown by Constructor.newInstance()InstantiationException
IllegalAccessException
InvocationTargetException
public static boolean matchSubset(Object[] what, Object[] where)
what
array are all
presented in where
array.what
- first array, may be null
where
- second array, may be null
true
if the first array is null
or if each and every object (ignoring null values)
from the first array has a twin in the second array; false
otherwiseCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.