KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > common > SlideToken


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/SlideToken.java,v 1.19.2.1 2004/08/23 13:53:48 luetzkendorf Exp $
3  * $Revision: 1.19.2.1 $
4  * $Date: 2004/08/23 13:53:48 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.common;
25
26 import java.util.Enumeration JavaDoc;
27 import java.util.List JavaDoc;
28 import org.apache.slide.authenticate.CredentialsToken;
29 import org.apache.slide.store.ResourceId;
30 import org.apache.slide.structure.ActionNode;
31 import org.apache.slide.structure.ObjectNode;
32 import org.apache.slide.structure.SubjectNode;
33
34 /**
35  * The SlideToken interface identifies the current acting principal and its
36  * credentials, and maintains information about the state of the user
37  * transaction.
38  *
39  * <p>
40  * An object implementing this interface is required to use any of the
41  * methods provided by the helpers API. The default implementation of this
42  * interface is {@link SlideTokenImpl SlideTokenImpl}. In the context of a
43  * Java servlet, such an object should be instantiated like this:
44  * <pre>
45  * Principal principal = request.getUserPrincipal();
46  * CredentialsToken credentials;
47  * if (principal == null) {
48  * credentials = new CredentialsToken("");
49  * } else {
50  * credentials = new CredentialsToken(principal);
51  * }
52  * SlideToken token = new SlideTokenImpl(credentials);
53  * </pre>
54  * </p>
55  *
56  * @version $Revision: 1.19.2.1 $
57  */

58 public interface SlideToken {
59     
60     
61     
62     
63     // ------------------------------------------------------------- Properties
64

65     
66     /**
67      * Returns the credentials token.
68      *
69      * @return String
70      */

71     public CredentialsToken getCredentialsToken();
72     
73     
74     /**
75      * Credentials token mutator.
76      */

77     public void setCredentialsToken(CredentialsToken credentialsToken);
78     
79     
80     /**
81      * Returns the CacheInfo token.
82      *
83      * @return CacheInfoToken
84      */

85     public CacheInfoToken getCacheInfoToken() ;
86     
87     
88     /**
89      * CacheInfo token mutator.
90      */

91     public void setCacheInfoToken(CacheInfoToken cacheInfoToken) ;
92     
93     
94     /**
95      * Use lock tokens in lock resolution ?
96      *
97      * @return boolean
98      */

99     public boolean isEnforceLockTokens() ;
100     
101     
102     /**
103      * Enforce lock tokens flag mutator.
104      *
105      * @param enforceLockTokens New flag value
106      */

107     public void setEnforceLockTokens(boolean enforceLockTokens) ;
108     
109     
110     /**
111      * Force store enlistment flag accessor. If true, that will cause Slide to
112      * enlist the store in the current transaction for all operations,
113      * to be able to prevent dirty reads when doing complex updates.
114      *
115      * @return boolean
116      */

117     public boolean isForceStoreEnlistment() ;
118     
119     /**
120      * Force store enlistment flag mutator. If set to true, that will cause
121      * Slide to enlist the store in the current transaction for all
122      * operations, to be able to prevent dirty reads when doing complex
123      * updates. That value should be set to true only in some very specific
124      * critical sections of the code, as this would greatly decrease the
125      * ability of Slide to handle multiple concurrent requests.
126      *
127      * @param forceStoreEnlistment New flag value
128      */

129     public void setForceStoreEnlistment(boolean forceStoreEnlistment) ;
130     
131     
132     /**
133      * Add a new lock token to the lock token list.
134      *
135      * @param lockId Lock token to add
136      */

137     public void addLockToken(String JavaDoc lockId) ;
138     
139     
140     /**
141      * Removes a lock token from the lock token list.
142      *
143      * @param lockId Lock token to remove
144      */

145     public void removeLockToken(String JavaDoc lockId) ;
146     
147     
148     /**
149      * Clears the lock token list.
150      */

151     public void clearLockTokens() ;
152     
153     /**
154      * For debugging purposes ONLY
155      */

156     public List JavaDoc showLockTokens();
157     
158     /**
159      * Checks if the given lock token is present.
160      *
161      * @param lockToken Lock token to check
162      * @return boolean True if the given lock token is present
163      */

164     public boolean checkLockToken(String JavaDoc lockToken) ;
165     
166     
167     /**
168      * Add a new parameter to the parameter list.
169      *
170      * @param parameterName Parameter to add
171      * @param parameterValue Parameter value
172      */

173     public void addParameter(String JavaDoc parameterName, Object JavaDoc parameterValue) ;
174     
175     
176     /**
177      * Removes a parameter from the parameter list.
178      *
179      * @param parameterName Parameter to remove
180      */

181     public void removeParameter(String JavaDoc parameterName) ;
182     
183     
184     /**
185      * Clears the parameter list.
186      */

187     public void clearParameters() ;
188     
189     
190     /**
191      * Return parameter list.
192      */

193     public Enumeration JavaDoc getParameterNames() ;
194     
195     /**
196      * Returns a parameter given by name.
197      * @return the Object associated with <code>name</code> or
198      * <code>null</code> if no such parameter exists.
199      */

200     public Object JavaDoc getParameter(String JavaDoc name);
201     
202     /**
203      * allows to cache the result of a permission check
204      */

205     public void cachePermission(ObjectNode object, ActionNode action, boolean permission);
206     
207     /**
208      * checks if the permission cache contains an entry for the ObjectNode and
209      * ActionNode combination.
210      *
211      * @return true if granted, false if denied, null if nothing in the cache.
212      */

213     public Boolean JavaDoc checkPermissionCache(ObjectNode object, ActionNode action);
214     
215     
216     /**
217      * Force security check. If false, checkCredentials of SecurityImpl will
218      * return immediately.
219      *
220      * @return a boolean
221      */

222     public boolean isForceSecurity();
223     
224     public void setForceSecurity(boolean forceSecurity);
225     
226     /**
227      * allows to cache the result of a lock check
228      */

229     public void cacheLock(ObjectNode object, ActionNode action, boolean lock);
230     
231     /**
232      * checks if the lock cache contains an entry for the ObjectNode and
233      * ActionNode combination.
234      *
235      * @return true if locked, false otherwise
236      */

237     public Boolean JavaDoc checkLockCache(ObjectNode object, ActionNode action);
238     
239     /**
240      * Allows to cache the result of a resolve operation
241      */

242     public void cacheResolve(Uri uri, ResourceId resourceId);
243     
244     /**
245      * Allows to cache the result of a matchPrincipal operation
246      */

247     public void cacheMatchPrincipal(SubjectNode checkSubject, SubjectNode matchSubject, boolean match);
248     
249     /**
250      * Checks if the matchPrincipal cache
251      * @return the cached Boolean or null
252      */

253     public Boolean JavaDoc checkMatchPrincipalCache(SubjectNode checkSubject, SubjectNode matchSubject);
254     
255     /**
256      * Checks if the resolve cache contains an entry for the specified uri.
257      * @return the cached resourceId or null
258      */

259     public ResourceId checkResolveCache(Uri uri);
260         
261     /**
262      * Force lock check. If false, checkLock of LockImpl will
263      * return immediately.
264      *
265      * @return a boolean
266      */

267     public boolean isForceLock();
268     
269     public void setForceLock(boolean forceLock);
270     
271     /**
272      * Checks if this request is part of an externally controlled transaction.
273      */

274     public boolean isExternalTransaction();
275
276     /**
277      * Sets if this request is part of an externally controlled transaction.
278      */

279     public void setExternalTx();
280 }
281
282
Popular Tags