Java Doc for DefaultPolicy.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » security » fortress » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.security.fortress 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.security.Policy
      org.apache.harmony.security.fortress.DefaultPolicy

DefaultPolicy
public class DefaultPolicy extends Policy (Code)
Default Policy implementation based on policy configuration files. This implementation recognizes text files, consisting of clauses with the following syntax:
 keystore "some_keystore_url" [, "keystore_type"];
 
 grant [SignedBy "signer_names"] [, CodeBase "URL"]
 [, Principal [principal_class_name] "principal_name"]
 [, Principal [principal_class_name] "principal_name"] ... {
 permission permission_class_name [ "target_name" ] [, "action"] 
 [, SignedBy "signer_names"];
 permission ...
 };
 
The keystore clause specifies reference to a keystore, which is a database of private keys and their associated digital certificates. The keystore is used to look up the certificates of signers specified in the grant entries of the file. The policy file can contain any number of keystore entries which can appear at any ordinal position. However, only the first successfully loaded keystore is used, others are ignored. The keystore must be specified if some grant clause refers to a certificate's alias.
The grant clause associates a CodeSource (consisting of an URL and a set of certificates) of some executable code with a set of Permissions which should be granted to the code. So, the CodeSource is defined by values of CodeBase and SignedBy fields. The CodeBase value must be in URL format, while SignedBy value is a (comma-separated list of) alias(es) to keystore certificates. These fields can be omitted to denote any codebase and any signers (including case of unsigned code), respectively.
Also, the code may be required to be executed on behalf of some Principals (in other words, code's ProtectionDomain must have the array of Principals associated) in order to possess the Permissions. This fact is indicated by specifying one or more Principal fields in the grant clause. Each Principal is specified as class/name pair; name and class can be either concrete value or wildcard * . As a special case, the class value may be omitted and then the name is treated as an alias to X.509 Certificate, and the Principal is assumed to be javax.security.auth.x500.X500Principal with a name of subject's distinguished name from the certificate.
The order between the CodeBase , SignedBy , and Principal fields does not matter. The policy file can contain any number of grant clauses.
Each grant clause must contain one or more permission entry. The permission entry consist of a fully qualified class name along with optional name , actions and signedby values. Name and actions are arguments to the corresponding constructor of the permission class. SignedBy value represents the keystore alias(es) to certificate(s) used to sign the permission class. That is, this permission entry is effective (i.e., access control permission will be granted based on this entry) only if the bytecode implementation of permission class is verified to be correctly signed by the said alias(es).

The policy content may be parameterized via property expansion. Namely, expressions like ${key} are replaced by values of corresponding system properties. Also, the special slash key (i.e. ${/}) is supported, it is a shortcut to "file.separator" key. Property expansion is performed anywhere a double quoted string is allowed in the policy file. However, this feature is controlled by security properties and should be turned on by setting "policy.expandProperties" property to true .
If property expansion fails (due to a missing key), a corresponding entry is ignored. For fields of keystore and grant clauses, the whole clause is ignored, and for permission entry, only that entry is ignored.

The policy also supports generalized expansion in permissions names, of expressions like ${{protocol:data}} . Currently the following protocols supported:
self
Denotes substitution to a principal information of the parental Grant entry. Replaced by a space-separated list of resolved Principals (including wildcarded), each formatted as class "name" . If parental Grant entry has no Principals, the permission is ignored.
alias: name
Denotes substitution of a KeyStore alias. Namely, if a KeyStore has an X.509 certificate associated with the specified name, then replaced by javax.security.auth.x500.X500Principal " DN " string, where DN is a certificate's subject distinguished name.


This implementation is thread-safe. The policy caches sets of calculated permissions for the requested objects (ProtectionDomains and CodeSources) via WeakHashMap; the cache is cleaned either explicitly during refresh() invocation, or naturally by garbage-collecting the corresponding objects.
See Also:   org.apache.harmony.security.PolicyUtils.getPolicyURLs(PropertiesStringString)


Field Summary
final public static  StringJAVA_SECURITY_POLICY
     System property for dynamically added policy location.
final public static  StringPOLICY_URL_PREFIX
     Prefix for numbered Policy locations specified in security.properties.

Constructor Summary
public  DefaultPolicy()
     Default constructor, equivalent to DefaultPolicy(new DefaultPolicyParser()).
public  DefaultPolicy(DefaultPolicyParser dpr)
     Extension constructor for plugging-in a custom parser.

Method Summary
public  PermissionCollectiongetPermissions(ProtectionDomain pd)
     Returns collection of permissions allowed for the domain according to the policy.
public  PermissionCollectiongetPermissions(CodeSource cs)
     Returns collection of permissions allowed for the codesource according to the policy.
public synchronized  voidrefresh()
     Gets fresh list of locations and tries to load all of them in sequence; failed loads are ignored.

Field Detail
JAVA_SECURITY_POLICY
final public static String JAVA_SECURITY_POLICY(Code)
System property for dynamically added policy location.



POLICY_URL_PREFIX
final public static String POLICY_URL_PREFIX(Code)
Prefix for numbered Policy locations specified in security.properties.




Constructor Detail
DefaultPolicy
public DefaultPolicy()(Code)
Default constructor, equivalent to DefaultPolicy(new DefaultPolicyParser()).



DefaultPolicy
public DefaultPolicy(DefaultPolicyParser dpr)(Code)
Extension constructor for plugging-in a custom parser. Defers policy data initialization before the first getPermissions() call (though policy may be refreshed explicitly, as well).




Method Detail
getPermissions
public PermissionCollection getPermissions(ProtectionDomain pd)(Code)
Returns collection of permissions allowed for the domain according to the policy. The evaluated characteristics of the domain are it's codesource and principals; they are assumed to be null if the domain is null.



getPermissions
public PermissionCollection getPermissions(CodeSource cs)(Code)
Returns collection of permissions allowed for the codesource according to the policy. The evaluation assumes that current principals are undefined.



refresh
public synchronized void refresh()(Code)
Gets fresh list of locations and tries to load all of them in sequence; failed loads are ignored. After processing all locations, old policy settings are discarded and new ones come into force.
This method is declared synchronized to avoid concurrent reloading.
See Also:   PolicyUtils.getPolicyURLs(PropertiesStringString)



Fields inherited from java.security.Policy
final public static PermissionCollection UNSUPPORTED_EMPTY_COLLECTION(Code)(Java Doc)

Methods inherited from java.security.Policy
public static Policy getInstance(String type, Policy.Parameters params) throws NoSuchAlgorithmException(Code)(Java Doc)
public static Policy getInstance(String type, Policy.Parameters params, String provider) throws NoSuchProviderException, NoSuchAlgorithmException(Code)(Java Doc)
public static Policy getInstance(String type, Policy.Parameters params, Provider provider) throws NoSuchAlgorithmException(Code)(Java Doc)
public Policy.Parameters getParameters()(Code)(Java Doc)
public PermissionCollection getPermissions(CodeSource codesource)(Code)(Java Doc)
public PermissionCollection getPermissions(ProtectionDomain domain)(Code)(Java Doc)
public static Policy getPolicy()(Code)(Java Doc)
public Provider getProvider()(Code)(Java Doc)
public String getType()(Code)(Java Doc)
public boolean implies(ProtectionDomain domain, Permission permission)(Code)(Java Doc)
public void refresh()(Code)(Java Doc)
public static void setPolicy(Policy p)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.