01: package org.drools.repository;
02:
03: import javax.jcr.AccessDeniedException;
04: import javax.jcr.ItemNotFoundException;
05: import javax.jcr.NoSuchWorkspaceException;
06: import javax.jcr.Node;
07: import javax.jcr.RepositoryException;
08:
09: import org.apache.jackrabbit.core.ItemId;
10: import org.apache.jackrabbit.core.NodeId;
11: import org.apache.jackrabbit.core.security.AMContext;
12: import org.apache.jackrabbit.core.security.AccessManager;
13:
14: /**
15: * This is just an experimental access manager for proof of concept. Don't
16: * actually use it or you are insane !
17: */
18: public class MyAccessManager implements AccessManager {
19:
20: private AMContext amContext;
21:
22: public boolean canAccess(String arg0)
23: throws NoSuchWorkspaceException, RepositoryException {
24: System.out.println("can access " + arg0);
25: return true;
26: }
27:
28: public void checkPermission(ItemId arg0, int arg1)
29: throws AccessDeniedException, ItemNotFoundException,
30: RepositoryException {
31: System.out.println("check permission: " + arg0);
32:
33: }
34:
35: public void close() throws Exception {
36: // TODO Auto-generated method stub
37:
38: }
39:
40: public void init(AMContext arg0) throws AccessDeniedException,
41: Exception {
42:
43: this .amContext = arg0;
44:
45: }
46:
47: public boolean isGranted(ItemId arg0, int arg1)
48: throws ItemNotFoundException, RepositoryException {
49: if (arg0.denotesNode()) {
50: NodeId id = (NodeId) arg0;
51: System.out.println(arg0);
52:
53: // try {
54: // Node n = RepositorySession.getRepository().getSession().getNodeByUUID( id.getUUID().toString() );
55: // System.out.println(n.getName());
56: // } catch (Exception e) {
57: // System.out.println(e);
58: // }
59: }
60: //System.out.println("is granted: " + arg0);
61: return true;
62: }
63:
64: }
|