Revision 1485
Added by Jing Tao almost 22 years ago
src/edu/ucsb/nceas/metacat/PermissionController.java | ||
---|---|---|
29 | 29 |
package edu.ucsb.nceas.metacat; |
30 | 30 |
|
31 | 31 |
import java.sql.*; |
32 |
import java.util.Enumeration; |
|
32 | 33 |
import java.util.Hashtable; |
33 | 34 |
import java.util.Stack; |
34 | 35 |
import java.util.Vector; |
... | ... | |
52 | 53 |
hasSubTreeAccessControl = checkSubTreeAccessControl(); |
53 | 54 |
} |
54 | 55 |
|
56 |
/** |
|
57 |
* Return if a document has subtree access control |
|
58 |
*/ |
|
59 |
public boolean hasSubTreeAccessControl() |
|
60 |
{ |
|
61 |
return hasSubTreeAccessControl; |
|
62 |
} |
|
63 |
|
|
55 | 64 |
/* |
56 | 65 |
* Go through the access table and find if has subtree access control |
57 | 66 |
* if has, store the subtree into list and return true. Otherwise, |
... | ... | |
160 | 169 |
|
161 | 170 |
return hasPermission; |
162 | 171 |
} |
172 |
|
|
163 | 173 |
|
164 | 174 |
/** |
165 | 175 |
* Check from db connection if the users in String array @principals has |
... | ... | |
230 | 240 |
}//hasPermission |
231 | 241 |
|
232 | 242 |
/** |
243 |
* The method to determine of a node can be access by a user just by subtree |
|
244 |
* access control |
|
245 |
*/ |
|
246 |
public boolean hasPermissionForSubTreeNode(String user, String[] groups, |
|
247 |
String myPermission, long nodeId) |
|
248 |
throws McdbException |
|
249 |
{ |
|
250 |
boolean flag = false; |
|
251 |
// Get unaccessble subtree for this user |
|
252 |
Hashtable unaccessableSubTree = hasUnaccessableSubTree(user, groups, |
|
253 |
myPermission); |
|
254 |
Enumeration en = unaccessableSubTree.elements(); |
|
255 |
while (en.hasMoreElements()) |
|
256 |
{ |
|
257 |
SubTree tree = (SubTree)en.nextElement(); |
|
258 |
long start = tree.getStartNodeId(); |
|
259 |
long stop = tree.getEndNodeId(); |
|
260 |
if ( nodeId >= start && nodeId <= stop) |
|
261 |
{ |
|
262 |
flag = true; |
|
263 |
break; |
|
264 |
} |
|
265 |
} |
|
266 |
return flag; |
|
267 |
} |
|
268 |
/** |
|
233 | 269 |
* This method will return a hasTable of subtree which user doesn't has the |
234 | 270 |
* permssion to access |
235 | 271 |
* @param user the user name |
Also available in: Unified diff
Add code to handle check a node permission for subtree access control.