Source code: com/sun/xacml/finder/ResourceFinderModule.java
1
2 /*
3 * @(#)ResourceFinderModule.java
4 *
5 * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistribution of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * 2. Redistribution in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * Neither the name of Sun Microsystems, Inc. or the names of contributors may
18 * be used to endorse or promote products derived from this software without
19 * specific prior written permission.
20 *
21 * This software is provided "AS IS," without a warranty of any kind. ALL
22 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
23 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
24 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
25 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
26 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
27 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
28 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
29 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
30 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
31 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use in
34 * the design, construction, operation or maintenance of any nuclear facility.
35 */
36
37 package com.sun.xacml.finder;
38
39 import com.sun.xacml.EvaluationCtx;
40
41 import com.sun.xacml.attr.AttributeValue;
42
43
44 /**
45 * This is the abstract class that all <code>ResourceFinder</code> modules
46 * extend. All methods have default values to represent that the given
47 * feature isn't supported by this module, so module writers needs only
48 * implement the methods for the features they're supporting.
49 *
50 * @since 1.0
51 * @author Seth Proctor
52 */
53 public abstract class ResourceFinderModule
54 {
55
56 /**
57 * Returns this module's identifier. A module does not need to provide
58 * a unique identifier, but it is a good idea, especially in support of
59 * management software. Common identifiers would be the full package
60 * and class name (the default if this method isn't overridden), just the
61 * class name, or some other well-known string that identifies this class.
62 *
63 * @return this module's identifier
64 */
65 public String getIdentifier() {
66 return getClass().getName();
67 }
68
69 /**
70 * Returns true if this module supports finding resources with the
71 * "Children" scope. By default this method returns false.
72 *
73 * @return true if the module supports the Children scope
74 */
75 public boolean isChildSupported() {
76 return false;
77 }
78
79 /**
80 * Returns true if this module supports finding resources with the
81 * "Descendants" scope. By default this method returns false.
82 *
83 * @return true if the module supports the Descendants scope
84 */
85 public boolean isDescendantSupported() {
86 return false;
87 }
88
89 /**
90 * This is an experimental method that asks the module to invalidate any
91 * cache values it may contain. This is not used by any of the core
92 * processing code, but it may be used by management software that wants
93 * to have some control over these modules. Since a module is free to
94 * decide how or if it caches values, and whether it is capable of
95 * updating values once in a cache, a module is free to intrepret this
96 * message in any way it sees fit (including igoring the message). It
97 * is preferable, however, for a module to make every effort to clear
98 * any dynamically cached values it contains.
99 * <p>
100 * This method has been introduced to see what people think of this
101 * functionality, and how they would like to use it. It may be removed
102 * in future versions, or it may be changed to a more general
103 * message-passing system (if other useful messages are identified).
104 *
105 * @since 1.2
106 */
107 public void invalidateCache() {
108
109 }
110
111 /**
112 * Tries to find the child Resource Ids associated with the parent. If
113 * this module cannot handle the given identifier, then an empty result is
114 * returned, otherwise the result will always contain at least the
115 * parent Resource Id, either as a successfully resolved Resource Id or an
116 * error case, but never both.
117 *
118 * @param parentResourceId the parent resource identifier
119 * @param context the representation of the request data
120 *
121 * @return the result of finding child resources
122 */
123 public ResourceFinderResult findChildResources(AttributeValue
124 parentResourceId,
125 EvaluationCtx context) {
126 return new ResourceFinderResult();
127 }
128
129 /**
130 * Tries to find the child Resource Ids associated with the parent. If
131 * this module cannot handle the given identifier, then an empty result is
132 * returned, otherwise the result will always contain at least the
133 * parent Resource Id, either as a successfully resolved Resource Id or an
134 * error case, but never both.
135 *
136 * @deprecated As of version 1.2, replaced by
137 * {@link #findChildResources(AttributeValue,EvaluationCtx)}.
138 * This version does not provide the evaluation context,
139 * and will be removed in a future release. Also, not that
140 * this will never get called when using the default PDP.
141 *
142 * @param parentResourceId the parent resource identifier
143 *
144 * @return the result of finding child resources
145 */
146 public ResourceFinderResult findChildResources(AttributeValue
147 parentResourceId) {
148 return new ResourceFinderResult();
149 }
150
151 /**
152 * Tries to find the descendant Resource Ids associated with the parent. If
153 * this module cannot handle the given identifier, then an empty result is
154 * returned, otherwise the result will always contain at least the
155 * parent Resource Id, either as a successfuly resolved Resource Id or an
156 * error case, but never both.
157 *
158 * @param parentResourceId the parent resource identifier
159 * @param context the representation of the request data
160 *
161 * @return the result of finding descendant resources
162 */
163 public ResourceFinderResult findDescendantResources(AttributeValue
164 parentResourceId,
165 EvaluationCtx
166 context) {
167 return new ResourceFinderResult();
168 }
169
170 /**
171 * Tries to find the descendant Resource Ids associated with the parent. If
172 * this module cannot handle the given identifier, then an empty result is
173 * returned, otherwise the result will always contain at least the
174 * parent Resource Id, either as a successfuly resolved Resource Id or an
175 * error case, but never both.
176 *
177 * @deprecated As of version 1.2, replaced by
178 * {@link #findDescendantResources(AttributeValue,EvaluationCtx)}.
179 * This version does not provide the evaluation context,
180 * and will be removed in a future release. Also, not that
181 * this will never get called when using the default PDP.
182 *
183 * @param parentResourceId the parent resource identifier
184 *
185 * @return the result of finding descendant resources
186 */
187 public ResourceFinderResult findDescendantResources(AttributeValue
188 parentResourceId) {
189 return new ResourceFinderResult();
190 }
191
192 }