Java Doc for Policy.java in  » 6.0-JDK-Core » security » javax » security » auth » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » security » javax.security.auth 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.security.auth.Policy

Policy
abstract public class Policy (Code)

This is an abstract class for representing the system policy for Subject-based authorization. A subclass implementation of this class provides a means to specify a Subject-based access control Policy.

A Policy object can be queried for the set of Permissions granted to code running as a Principal in the following manner:

 policy = Policy.getPolicy();
 PermissionCollection perms = policy.getPermissions(subject,
 codeSource);
 
The Policy object consults the local policy and returns and appropriate Permissions object with the Permissions granted to the Principals associated with the provided subject, and granted to the code specified by the provided codeSource.

A Policy contains the following information. Note that this example only represents the syntax for the default Policy implementation. Subclass implementations of this class may implement alternative syntaxes and may retrieve the Policy from any source such as files, databases, or servers.

Each entry in the Policy is represented as a grant entry. Each grant entry specifies a codebase, code signers, and Principals triplet, as well as the Permissions granted to that triplet.

 grant CodeBase ["URL"], Signedby ["signers"],
 Principal [Principal_Class] "Principal_Name" {
 Permission Permission_Class ["Target_Name"]
 [, "Permission_Actions"]
 [, signedBy "SignerName"];
 };
 
The CodeBase and Signedby components of the triplet name/value pairs are optional. If they are not present, then any any codebase will match, and any signer (including unsigned code) will match. For Example,
 grant CodeBase "foo.com", Signedby "foo",
 Principal com.sun.security.auth.SolarisPrincipal "duke" {
 permission java.io.FilePermission "/home/duke", "read, write";
 };
 
This grant entry specifies that code from "foo.com", signed by "foo', and running as a SolarisPrincipal with the name, duke, has one Permission. This Permission permits the executing code to read and write files in the directory, "/home/duke".

To "run" as a particular Principal, code invokes the Subject.doAs(subject, ...) method. After invoking that method, the code runs as all the Principals associated with the specified Subject. Note that this Policy (and the Permissions granted in this Policy) only become effective after the call to Subject.doAs has occurred.

Multiple Principals may be listed within one grant entry. All the Principals in the grant entry must be associated with the Subject provided to Subject.doAs for that Subject to be granted the specified Permissions.

 grant Principal com.sun.security.auth.SolarisPrincipal "duke",
 Principal com.sun.security.auth.SolarisNumericUserPrincipal "0" {
 permission java.io.FilePermission "/home/duke", "read, write";
 permission java.net.SocketPermission "duke.com", "connect";
 };
 
This entry grants any code running as both "duke" and "0" permission to read and write files in duke's home directory, as well as permission to make socket connections to "duke.com".

Note that non Principal-based grant entries are not permitted in this Policy. Therefore, grant entries such as:

 grant CodeBase "foo.com", Signedby "foo" {
 permission java.io.FilePermission "/tmp/scratch", "read, write";
 };
 
are rejected. Such permission must be listed in the java.security.Policy.

The default Policy implementation can be changed by setting the value of the "auth.policy.provider" security property (in the Java security properties file) to the fully qualified name of the desired Policy implementation class. The Java security properties file is located in the file named <JAVA_HOME>/lib/security/java.security. <JAVA_HOME> refers to the value of the java.home system property, and specifies the directory where the JRE is installed.
version:
   1.59, 05/05/07




Constructor Summary
protected  Policy()
     Sole constructor.

Method Summary
abstract public  java.security.PermissionCollectiongetPermissions(Subject subject, java.security.CodeSource cs)
     Retrieve the Permissions granted to the Principals associated with the specified CodeSource.


Parameters:
  subject - the Subjectwhose associated Principals,in conjunction with the providedCodeSource, determines the Permissionsreturned by this method.

public static  PolicygetPolicy()
     Returns the installed Policy object. This method first calls SecurityManager.checkPermission with the AuthPermission("getPolicy") permission to ensure the caller has permission to get the Policy object.

the installed Policy.

static  PolicygetPolicyNoCheck()
     Returns the installed Policy object, skipping the security check.
abstract public  voidrefresh()
     Refresh and reload the Policy.

This method causes this object to refresh/reload its current Policy.

public static  voidsetPolicy(Policy policy)
     Sets the system-wide Policy object.


Constructor Detail
Policy
protected Policy()(Code)
Sole constructor. (For invocation by subclass constructors, typically implicit.)




Method Detail
getPermissions
abstract public java.security.PermissionCollection getPermissions(Subject subject, java.security.CodeSource cs)(Code)
Retrieve the Permissions granted to the Principals associated with the specified CodeSource.


Parameters:
  subject - the Subjectwhose associated Principals,in conjunction with the providedCodeSource, determines the Permissionsreturned by this method. This parametermay be null.


Parameters:
  cs - the code specified by its CodeSourcethat determines, in conjunction with the providedSubject, the Permissionsreturned by this method. This parameter may benull. the Collection of Permissions granted to all theSubject and code specified inthe provided subject and csparameters.




getPolicy
public static Policy getPolicy()(Code)
Returns the installed Policy object. This method first calls SecurityManager.checkPermission with the AuthPermission("getPolicy") permission to ensure the caller has permission to get the Policy object.

the installed Policy. The return value cannot benull.
exception:
  java.lang.SecurityException - if the current thread does nothave permission to get the Policy object.
See Also:   Policy.setPolicy




getPolicyNoCheck
static Policy getPolicyNoCheck()(Code)
Returns the installed Policy object, skipping the security check. the installed Policy.



refresh
abstract public void refresh()(Code)
Refresh and reload the Policy.

This method causes this object to refresh/reload its current Policy. This is implementation-dependent. For example, if the Policy object is stored in a file, calling refresh will cause the file to be re-read.


exception:
  SecurityException - if the caller does not have permissionto refresh the Policy.




setPolicy
public static void setPolicy(Policy policy)(Code)
Sets the system-wide Policy object. This method first calls SecurityManager.checkPermission with the AuthPermission("setPolicy") permission to ensure the caller has permission to set the Policy.


Parameters:
  policy - the new system Policy object.
exception:
  java.lang.SecurityException - if the current thread does nothave permission to set the Policy.
See Also:   Policy.getPolicy




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.