| java.lang.Object org.apache.harmony.security.fortress.PolicyUtils
PolicyUtils | public class PolicyUtils (Code) | | This class consist of a number of static methods, which provide a common functionality
for various policy and configuration providers.
|
Inner Class :public static class ExpansionFailedException extends Exception | |
Inner Class :public static interface GeneralExpansionHandler | |
Field Summary | |
final public static String | FALSE Negative value of switching properties. | final public static String | POLICY_ALLOW_DYNAMIC A key to security properties, deciding whether usage of
dynamic policy location via system properties is allowed. | final public static String | POLICY_EXPAND A key to security properties, deciding whether expansion of
system properties is allowed
(in security properties values, policy files, etc). | final public static String | TRUE Positive value of switching properties. |
Method Summary | |
public static boolean | canExpandProperties() Returns false if current security settings disable to perform
properties expansion, true otherwise. | public static String | expand(String str, Properties properties) Substitutes all entries like ${some.key}, found in specified string,
for specified values.
If some key is unknown, throws ExpansionFailedException. | public static String | expandGeneral(String str, GeneralExpansionHandler handler) Substitutes all entries like ${{protocol:data}}, found in specified string,
for values resolved by passed handler. | public static String | expandURL(String str, Properties properties) Handy shortcut for
expand(str, properties).replace(File.separatorChar, '/') . | public static URI | filePathToURI(String path) Converts a file path to URI without accessing file system
(like {File#toURI()} does).
Parameters: path - -file path. | public static URL[] | getPolicyURLs(Properties system, String systemUrlKey, String securityUrlPrefix) Obtains a list of locations for a policy or configuration provider.
The search algorithm is as follows:
- Look in security properties for keys of form
prefix + n ,
where n is an integer and prefix is a passed parameter. | public static Permission | instantiatePermission(Class> targetType, String targetName, String targetActions) Tries to find a suitable constructor and instantiate a new Permission
with specified parameters. | public static boolean | matchSubset(Object[] what, Object[] where) Checks whether the objects from what array are all
presented in where array. | public static URL | normalizeURL(URL codebase) Normalizes URLs to standard ones, eliminating pathname symbols.
Parameters: codebase - -the original URL. | public static PermissionCollection | toPermissionCollection(Collection<Permission> perms) Converts common-purpose collection of Permissions to PermissionCollection. |
FALSE | final public static String FALSE(Code) | | Negative value of switching properties.
|
POLICY_EXPAND | final public static String POLICY_EXPAND(Code) | | A key to security properties, deciding whether expansion of
system properties is allowed
(in security properties values, policy files, etc).
See Also: PolicyUtils.expand(String,Properties) See Also: |
TRUE | final public static String TRUE(Code) | | Positive value of switching properties.
|
canExpandProperties | public static boolean canExpandProperties()(Code) | | Returns false if current security settings disable to perform
properties expansion, true otherwise.
See Also: PolicyUtils.expand(String,Properties) See Also: |
expand | public static String expand(String str, Properties properties) throws ExpansionFailedException(Code) | | Substitutes all entries like ${some.key}, found in specified string,
for specified values.
If some key is unknown, throws ExpansionFailedException.
Parameters: str - the string to be expanded Parameters: properties - available key-value mappings expanded string throws: ExpansionFailedException - |
expandGeneral | public static String expandGeneral(String str, GeneralExpansionHandler handler) throws ExpansionFailedException(Code) | | Substitutes all entries like ${{protocol:data}}, found in specified string,
for values resolved by passed handler.
The data part may be empty, and in this case expression
may have simplified form, as ${{protocol}}.
If some entry cannot be resolved, throws ExpansionFailedException;
Parameters: str - the string to be expanded Parameters: handler - the handler to resolve data denoted by protocol expanded string throws: ExpansionFailedException - |
filePathToURI | public static URI filePathToURI(String path) throws URISyntaxException(Code) | | Converts a file path to URI without accessing file system
(like {File#toURI()} does).
Parameters: path - -file path. - the resulting URI. |
getPolicyURLs | public static URL[] getPolicyURLs(Properties system, String systemUrlKey, String securityUrlPrefix)(Code) | | Obtains a list of locations for a policy or configuration provider.
The search algorithm is as follows:
- Look in security properties for keys of form
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.
For each obtained key, try to construct an URL instance. On success,
add the URL to the list; otherwise ignore it.
-
If security settings do not prohibit (through
PolicyUtils.POLICY_ALLOW_DYNAMIC 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
-
If the additional location from the step above was specified to the
system via "==" (i.e. starts with '='), discard all URLs above
and use this only URL.
Note: all property values (both security and system) related to URLs are
subject to
PolicyUtils.expand(String,Properties) property expansion , regardless
of the "policy.expandProperties" security setting.
Parameters: system - system properties Parameters: systemUrlKey - key to additional policy location Parameters: securityUrlPrefix - prefix to numbered locations in security properties array of URLs to provider's configuration files, may be empty. |
instantiatePermission | public static Permission instantiatePermission(Class> targetType, String targetName, String targetActions) throws Exception(Code) | | Tries to find a suitable constructor and instantiate a new Permission
with specified parameters.
Parameters: targetType - class of expected Permission instance Parameters: targetName - name of expected Permission instance Parameters: targetActions - actions of expected Permission instance a new Permission instance throws: IllegalArgumentException - if no suitable constructor found throws: Exception - any exception thrown by Constructor.newInstance() |
matchSubset | public static boolean matchSubset(Object[] what, Object[] where)(Code) | | Checks whether the objects from what array are all
presented in where array.
Parameters: what - first array, may be null Parameters: 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 otherwise |
normalizeURL | public static URL normalizeURL(URL codebase)(Code) | | Normalizes URLs to standard ones, eliminating pathname symbols.
Parameters: codebase - -the original URL. - the normalized URL. |
toPermissionCollection | public static PermissionCollection toPermissionCollection(Collection<Permission> perms)(Code) | | Converts common-purpose collection of Permissions to PermissionCollection.
Parameters: perms - a collection containing arbitrary permissions, may be null mutable heterogeneous PermissionCollection containing all Permissions from the specified collection |
|
|