- java.lang.Object
-
- javax.security.auth.Policy
-
- com.sun.security.auth.PolicyFile
-
Deprecated, for removal: This API element is subject to removal in a future version.As of JDK 1.4, replaced bysun.security.provider.PolicyFile
. This class is entirely deprecated. This class is subject to removal in a future version of Java SE.
@Deprecated(since="1.4", forRemoval=true) public class PolicyFile extends Policy
This class represents a default implementation forjavax.security.auth.Policy
.This object stores the policy for entire Java runtime, and is the amalgamation of multiple static policy configurations that resides in files. The algorithm for locating the policy file(s) and reading their information into this
Policy
object is:-
Loop through the security properties,
auth.policy.url.1, auth.policy.url.2, ...,
auth.policy.url.X".
Each property value specifies a
URL
pointing to a policy file to be loaded. Read in and load each policy. -
The
java.lang.System
property java.security.auth.policy may also be set to aURL
pointing to another policy file (which is the case when a user uses the -D switch at runtime). If this property is defined, and its use is allowed by the security property file (the Security property, policy.allowSystemProperty is set to true), also load that policy. - If the java.security.auth.policy property is defined using "==" (rather than "="), then ignore all other specified policies and only load this policy.
grant signedBy "alias", codeBase "URL", principal principalClass "principalName", principal principalClass "principalName", ... { permission Type "name "action", signedBy "alias"; permission Type "name "action", signedBy "alias"; .... };
All non-bold items above must appear as is (although case doesn't matter and some are optional, as noted below). Italicized items represent variable values.A grant entry must begin with the word
grant
. ThesignedBy
andcodeBase
name/value pairs are optional. If they are not present, then any signer (including unsigned code) will match, and any codeBase will match. Note that theprincipal
name/value pair is not optional. ThisPolicy
implementation only permits Principal-based grant entries. Note that the principalClass may be set to the wildcard value, *, which allows it to match anyPrincipal
class. In addition, the principalName may also be set to the wildcard value, *, allowing it to match anyPrincipal
name. When setting the principalName to the *, do not surround the * with quotes.A permission entry must begin with the word
permission
. The wordType
in the template above is a specific permission type, such asjava.io.FilePermission
orjava.lang.RuntimePermission
.The "action" is required for many permission types, such as
java.io.FilePermission
(where it specifies what type of file access that is permitted). It is not required for categories such asjava.lang.RuntimePermission
where it is not necessary - you either have the permission specified by the "name
" value following the type name or you don't.The
signedBy
name/value pair for a permission entry is optional. If present, it indicates a signed permission. That is, the permission class itself must be signed by the given alias in order for it to be granted. For example, suppose you have the following grant entry:grant principal foo.com.Principal "Duke" { permission Foo "foobar", signedBy "FooSoft"; }
Then this permission of type Foo is granted if the
Foo.class
permission has been signed by the "FooSoft" alias, or ifFoo.class
is a system class (i.e., is found on the CLASSPATH).Items that appear in an entry must appear in the specified order (
permission
, Type, "name", and "action"). An entry is terminated with a semicolon.Case is unimportant for the identifiers (
permission
,signedBy
,codeBase
, etc.) but is significant for the Type or for any string that is passed in as a value.An example of two entries in a policy configuration file is
// if the code is comes from "foo.com" and is running as "Duke", // grant it read/write to all files in /tmp. grant codeBase "foo.com", principal foo.com.Principal "Duke" { permission java.io.FilePermission "/tmp/*", "read,write"; }; // grant any code running as "Duke" permission to read // the "java.vendor" Property. grant principal foo.com.Principal "Duke" { permission java.util.PropertyPermission "java.vendor";
This
Policy
implementation supports special handling for PrivateCredentialPermissions. If a grant entry is configured with aPrivateCredentialPermission
, and the "Principal Class/Principal Name" for thatPrivateCredentialPermission
is "self", then the entry grants the specifiedSubject
permission to access its own private Credential. For example, the following grants theSubject
"Duke" access to its own a.b.Credential.grant principal foo.com.Principal "Duke" { permission javax.security.auth.PrivateCredentialPermission "a.b.Credential self", "read"; };
The following grants theSubject
"Duke" access to all of its own private Credentials:grant principal foo.com.Principal "Duke" { permission javax.security.auth.PrivateCredentialPermission "* self", "read"; };
The following grants all Subjects authenticated as aSolarisPrincipal
(regardless of their respective names) permission to access their own private Credentials:grant principal com.sun.security.auth.SolarisPrincipal * { permission javax.security.auth.PrivateCredentialPermission "* self", "read"; };
The following grants all Subjects permission to access their own private Credentials:grant principal * * { permission javax.security.auth.PrivateCredentialPermission "* self", "read"; };
- See Also:
CodeSource
,Permissions
,ProtectionDomain
,security properties
-
Loop through the security properties,
auth.policy.url.1, auth.policy.url.2, ...,
auth.policy.url.X".
Each property value specifies a
-
-
Constructor Summary
Constructors Constructor Description PolicyFile()
Deprecated, for removal: This API element is subject to removal in a future version.Initializes the Policy object and reads the default policy configuration file(s) into the Policy object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PermissionCollection
getPermissions(Subject subject, CodeSource codesource)
Deprecated, for removal: This API element is subject to removal in a future version.Examines thisPolicy
and returns the Permissions granted to the specifiedSubject
andCodeSource
.void
refresh()
Deprecated, for removal: This API element is subject to removal in a future version.Refreshes the policy object by re-reading all the policy files.
-
-
-
Method Detail
-
refresh
public void refresh()
Deprecated, for removal: This API element is subject to removal in a future version.Refreshes the policy object by re-reading all the policy files.- Specified by:
refresh
in classPolicy
- Throws:
SecurityException
- if the caller doesn't have permission to refresh thePolicy
.
-
getPermissions
public PermissionCollection getPermissions(Subject subject, CodeSource codesource)
Deprecated, for removal: This API element is subject to removal in a future version.Examines thisPolicy
and returns the Permissions granted to the specifiedSubject
andCodeSource
.Permissions for a particular grant entry are returned if the
CodeSource
constructed using the codebase and signedby values specified in the entryimplies
theCodeSource
provided to this method, and if theSubject
provided to this method contains all of the Principals specified in the entry.The
Subject
provided to this method contains all of the Principals specified in the entry if, for eachPrincipal
, "P1", specified in the grant entry one of the following two conditions is met:- the
Subject
has aPrincipal
, "P2", whereP2.getClass().getName()
equals the P1's class name, and whereP2.getName()
equals the P1's name. - P1 implements
com.sun.security.auth.PrincipalComparator
, andP1.implies
the providedSubject
.
Note that this
Policy
implementation has special handling for PrivateCredentialPermissions. When this method encounters aPrivateCredentialPermission
which specifies "self" as thePrincipal
class and name, it does not add thatPermission
to the returnedPermissionCollection
. Instead, it builds a newPrivateCredentialPermission
for eachPrincipal
associated with the providedSubject
. Each newPrivateCredentialPermission
contains the same Credential class as specified in the originally granted permission, as well as the Class and name for the respectivePrincipal
.- Specified by:
getPermissions
in classPolicy
- Parameters:
subject
- the Permissions granted to thisSubject
and the additionally providedCodeSource
are returned.codesource
- the Permissions granted to thisCodeSource
and the additionally providedSubject
are returned.- Returns:
- the Permissions granted to the provided
Subject
CodeSource
.
- the
-
-