KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > PolicySpi


1 /*
2  * @(#)PolicySpi.java 1.2 05/11/17
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8
9 package java.security;
10
11 /**
12  * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
13  * for the <code>Policy</code> class.
14  * All the abstract methods in this class must be implemented by each
15  * service provider who wishes to supply a Policy implementation.
16  *
17  * <p> Subclass implementations of this abstract class must provide
18  * a public constructor that takes a <code>Policy.Parameters</code>
19  * object as an input parameter. This constructor also must throw
20  * an IllegalArgumentException if it does not understand the
21  * <code>Policy.Parameters</code> input.
22  *
23  * @version 1.2, 11/17/05
24  *
25  * @since 1.6
26  */

27
28 public abstract class PolicySpi {
29
30     /**
31      * Check whether the policy has granted a Permission to a ProtectionDomain.
32      *
33      * @param domain the ProtectionDomain to check.
34      *
35      * @param permission check whether this permission is granted to the
36      * specified domain.
37      *
38      * @return boolean true if the permission is granted to the domain.
39      */

40     protected abstract boolean engineImplies
41     (ProtectionDomain JavaDoc domain, Permission JavaDoc permission);
42
43     /**
44      * Refreshes/reloads the policy configuration. The behavior of this method
45      * depends on the implementation. For example, calling <code>refresh</code>
46      * on a file-based policy will cause the file to be re-read.
47      *
48      * <p> The default implementation of this method does nothing.
49      * This method should be overridden if a refresh operation is supported
50      * by the policy implementation.
51      */

52     protected void engineRefresh() { }
53
54     /**
55      * Return a PermissionCollection object containing the set of
56      * permissions granted to the specified CodeSource.
57      *
58      * <p> The default implementation of this method returns
59      * Policy.UNSUPPORTED_EMPTY_COLLECTION object. This method can be
60      * overridden if the policy implementation can return a set of
61      * permissions granted to a CodeSource.
62      *
63      * @param codesource the CodeSource to which the returned
64      * PermissionCollection has been granted.
65      *
66      * @return a set of permissions granted to the specified CodeSource.
67      * If this operation is supported, the returned
68      * set of permissions must be a new mutable instance
69      * and it must support heterogeneous Permission types.
70      * If this operation is not supported,
71      * Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.
72      */

73     protected PermissionCollection JavaDoc engineGetPermissions
74                     (CodeSource JavaDoc codesource) {
75     return Policy.UNSUPPORTED_EMPTY_COLLECTION;
76     }
77
78     /**
79      * Return a PermissionCollection object containing the set of
80      * permissions granted to the specified ProtectionDomain.
81      *
82      * <p> The default implementation of this method returns
83      * Policy.UNSUPPORTED_EMPTY_COLLECTION object. This method can be
84      * overridden if the policy implementation can return a set of
85      * permissions granted to a ProtectionDomain.
86      *
87      * @param domain the ProtectionDomain to which the returned
88      * PermissionCollection has been granted.
89      *
90      * @return a set of permissions granted to the specified ProtectionDomain.
91      * If this operation is supported, the returned
92      * set of permissions must be a new mutable instance
93      * and it must support heterogeneous Permission types.
94      * If this operation is not supported,
95      * Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.
96      */

97     protected PermissionCollection JavaDoc engineGetPermissions
98                     (ProtectionDomain JavaDoc domain) {
99     return Policy.UNSUPPORTED_EMPTY_COLLECTION;
100     }
101 }
102
Popular Tags