Java Doc for DefaultPolicyParser.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
   org.apache.harmony.security.fortress.DefaultPolicyParser

DefaultPolicyParser
public class DefaultPolicyParser (Code)
This is a basic loader of policy files. It delegates lexical analysis to a pluggable scanner and converts received tokens to a set of org.apache.harmony.security.PolicyEntry PolicyEntries . For details of policy format, see the org.apache.harmony.security.DefaultPolicy default policy description .
For ordinary uses, this class has just one public method parse(), which performs the main task. Extensions of this parser may redefine specific operations separately, by overriding corresponding protected methods.
This implementation is effectively thread-safe, as it has no field references to data being processed (that is, passes all the data as method parameters).
See Also:   org.apache.harmony.security.DefaultPolicy
See Also:   org.apache.harmony.security.DefaultPolicyScanner
See Also:   org.apache.harmony.security.PolicyEntry

Inner Class :class PermissionExpander implements PolicyUtils.GeneralExpansionHandler


Constructor Summary
public  DefaultPolicyParser()
     Default constructor, org.apache.harmony.security.DefaultPolicyScanner DefaultPolicyScanner is used.
public  DefaultPolicyParser(DefaultPolicyScanner s)
     Extension constructor for plugging-in custom scanner.

Method Summary
protected  PrincipalgetPrincipalByAlias(KeyStore ks, String alias)
     Returns a subject's X500Principal of an X509Certificate, which is associated with the specified keystore alias.
protected  KeyStoreinitKeyStore(List<KeystoreEntry> keystores, URL base, Properties system, boolean resolve)
     Returns the first successfully loaded KeyStore, from the specified list of possible locations.
public  Collection<PolicyEntry>parse(URL location, Properties system)
     This is the main business method.
protected  PolicyEntryresolveGrant(DefaultPolicyScanner.GrantEntry ge, KeyStore ks, Properties system, boolean resolve)
     Translates GrantEntry token to PolicyEntry object.
protected  PermissionresolvePermission(DefaultPolicyScanner.PermissionEntry pe, DefaultPolicyScanner.GrantEntry ge, KeyStore ks, Properties system, boolean resolve)
     Translates PermissionEntry token to Permission object.
protected  Certificate[]resolveSigners(KeyStore ks, String signers)
     Takes a comma-separated list of aliases and obtains corresponding certificates.


Constructor Detail
DefaultPolicyParser
public DefaultPolicyParser()(Code)
Default constructor, org.apache.harmony.security.DefaultPolicyScanner DefaultPolicyScanner is used.



DefaultPolicyParser
public DefaultPolicyParser(DefaultPolicyScanner s)(Code)
Extension constructor for plugging-in custom scanner.




Method Detail
getPrincipalByAlias
protected Principal getPrincipalByAlias(KeyStore ks, String alias) throws KeyStoreException, CertificateException(Code)
Returns a subject's X500Principal of an X509Certificate, which is associated with the specified keystore alias.
Parameters:
  ks - KeyStore for resolving Certificate, may be null
Parameters:
  alias - alias to a certificate X500Principal with a subject distinguished name
throws:
  KeyStoreException - if KeyStore is null or if it failed to provide a certificate
throws:
  CertificateException - if found certificate is not an X509Certificate



initKeyStore
protected KeyStore initKeyStore(List<KeystoreEntry> keystores, URL base, Properties system, boolean resolve)(Code)
Returns the first successfully loaded KeyStore, from the specified list of possible locations. This method iterates over the list of KeystoreEntries; for each entry expands url and type, tries to construct instances of specified URL and KeyStore and to load the keystore. If it is loaded, returns the keystore, otherwise proceeds to the next KeystoreEntry.
Note: an url may be relative to the policy file location or absolute.
Parameters:
  keystores - list of available KeystoreEntries
Parameters:
  base - the policy file location
Parameters:
  system - system properties, used for property expansion
Parameters:
  resolve - flag enabling/disabling property expansion the first successfully loaded KeyStore or null



parse
public Collection<PolicyEntry> parse(URL location, Properties system) throws Exception(Code)
This is the main business method. It manages loading process as follows: the associated scanner is used to parse the stream to a set of org.apache.harmony.security.DefaultPolicyScanner.GrantEntry composite tokens , then this set is iterated and each token is translated to a PolicyEntry. Semantically invalid tokens are ignored, the same as void PolicyEntries.
A policy file may refer to some KeyStore(s), and in this case the first valid reference is initialized and used in processing tokens.
Parameters:
  location - an URL of a policy file to be loaded
Parameters:
  system - system properties, used for property expansion a collection of PolicyEntry objects, may be empty
throws:
  Exception - IO error while reading location or file syntax error



resolveGrant
protected PolicyEntry resolveGrant(DefaultPolicyScanner.GrantEntry ge, KeyStore ks, Properties system, boolean resolve) throws Exception(Code)
Translates GrantEntry token to PolicyEntry object. It goes step by step, trying to resolve each component of the GrantEntry:
  • If codebase is specified, expand it and construct an URL.
  • If signers is specified, expand it and obtain corresponding Certificates.
  • If principals collection is specified, iterate over it. For each PrincipalEntry, expand name and if no class specified, resolve actual X500Principal from a KeyStore certificate; otherwise keep it as UnresolvedPrincipal.
  • Iterate over permissions collection. For each PermissionEntry, try to resolve (see method DefaultPolicyParser.resolvePermission(DefaultPolicyScanner.PermissionEntry,DefaultPolicyScanner.GrantEntry,KeyStore,Properties,boolean) resolvePermission() ) a corresponding permission. If resolution failed, ignore the PermissionEntry.
In fact, property expansion in the steps above is conditional and is ruled by the parameter resolve.
Finally a new PolicyEntry is created, which associates the trinity of resolved URL, Certificates and Principals to a set of granted Permissions.
Parameters:
  ge - GrantEntry token to be resolved
Parameters:
  ks - KeyStore for resolving Certificates, may be null
Parameters:
  system - system properties, used for property expansion
Parameters:
  resolve - flag enabling/disabling property expansion resolved PolicyEntry
throws:
  Exception - if unable to resolve codebase, signers or principals of the GrantEntry
See Also:   DefaultPolicyScanner.PrincipalEntry
See Also:   DefaultPolicyScanner.PermissionEntry
See Also:   org.apache.harmony.security.PolicyUtils



resolvePermission
protected Permission resolvePermission(DefaultPolicyScanner.PermissionEntry pe, DefaultPolicyScanner.GrantEntry ge, KeyStore ks, Properties system, boolean resolve) throws Exception(Code)
Translates PermissionEntry token to Permission object. First, it performs general expansion for non-null name and properties expansion for non-null name, action and signers. Then, it obtains signing Certificates(if any), tries to find a class specified by klass name and instantiate a corresponding permission object. If class is not found or it is signed improperly, returns UnresolvedPermission.
Parameters:
  pe - PermissionEntry token to be resolved
Parameters:
  ge - parental GrantEntry of the PermissionEntry
Parameters:
  ks - KeyStore for resolving Certificates, may be null
Parameters:
  system - system properties, used for property expansion
Parameters:
  resolve - flag enabling/disabling property expansion resolved Permission object, either of concrete class or UnresolvedPermission
throws:
  Exception - if failed to expand properties, or to get a Certificate, or to create an instance of a successfully found class



resolveSigners
protected Certificate[] resolveSigners(KeyStore ks, String signers) throws Exception(Code)
Takes a comma-separated list of aliases and obtains corresponding certificates.
Parameters:
  ks - KeyStore for resolving Certificates, may be null
Parameters:
  signers - comma-separated list of certificate aliases, must be not null an array of signing Certificates
throws:
  Exception - if KeyStore is null or if it failed to provide a certificate



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.