he 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 of any permission that contains the string, "
${{self}}", as part of its target name. When such a permission is evaluated (such as during a security check),
${{self}} is replaced with one or more Principal class/name pairs. The exact replacement performed depends upon the contents of the grant clause to which the permission belongs.
If the grant clause does not contain any principal information, the permission will be ignored (permissions containing ${{self}} in their target names are only valid in the context of a principal-based grant clause). For example, BarPermission will always be ignored in the following grant clause:
grant codebase "www.foo.com", signedby "duke" { permission BarPermission "... ${{self}} ..."; };
If the grant clause contains principal information,
${{self}} will be replaced with that same principal information. For example,
${{self}} in BarPermission will be replaced by
javax.security.auth.x500.X500Principal "cn=Duke" in the following grant clause:
grant principal javax.security.auth.x500.X500Principal "cn=Duke" { permission BarPermission "... ${{self}} ..."; };
If there is a comma-separated list of principals in the grant clause, then
${{self}} will be replaced by the same comma-separated list or principals. In the case where both the principal class and name are wildcarded in the grant clause,
${{self}} is replaced with all the principals associated with the
Subject
in the current
AccessControlContext
.
For PrivateCredentialPermissions, you can also use "self" instead of "${{self}}". However the use of "self" is deprecated in favour of "${{self}}".
@see java.security.CodeSource
@see java.security.Permissions
@see java.security.ProtectionDomain