KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > security > NoAuthorization


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.security;
11
12 import java.util.*;
13
14 /**
15  * This class is used when no authorization is configured. Everything is allowed.
16  *
17  * @author Eduard Witteveen
18  * @version $Id: NoAuthorization.java,v 1.11 2005/01/30 16:46:34 nico Exp $
19  */

20 final public class NoAuthorization extends Authorization {
21
22     // This defined the 'context' used everywhere where one is needed.
23
private static final String JavaDoc EVERYBODY = "everybody";
24     private static final Set possibleContexts = Collections.unmodifiableSet(new HashSet(Arrays.asList( new String JavaDoc[]{EVERYBODY, NoAuthentication.userContext.getOwnerField()})));
25
26     /**
27      * This method does nothing
28      */

29     protected void load() {
30     }
31
32     /**
33      * This method does nothing
34      */

35     public void create(UserContext user, int nodeid) {
36     }
37
38     /**
39      * This method does nothing
40      */

41     public void update(UserContext user, int nodeid) {
42     }
43
44     /**
45      * This method does nothing
46      */

47     public void remove(UserContext user, int nodeid) {
48     }
49
50     /**
51      * No authorization means that everyting is allowed
52      * @return true
53      */

54     public boolean check(UserContext user, int nodeid, Operation operation) {
55         return true;
56     }
57
58     /**
59      * This method does nothing
60      */

61     public void verify(UserContext user, int nodeid, Operation operation) throws org.mmbase.security.SecurityException {
62     }
63
64     /**
65      * No authorization means that everyting is allowed
66      * @return true
67      */

68     public boolean check(UserContext user, int nodeid, int srcNodeid, int dstNodeid, Operation operation) {
69         return true;
70     }
71
72     /**
73      * This method does nothing
74      */

75     public void verify(UserContext user, int nodeid, int srcNodeid, int dstNodeid, Operation operation) throws SecurityException JavaDoc {
76     }
77
78
79     /**
80      * This method does nothing, except from giving a specified string back
81      */

82     public String JavaDoc getContext(UserContext user, int nodeid) throws SecurityException JavaDoc {
83         return EVERYBODY;
84     }
85
86     /**
87      * Since this is not authorization, we simply allow every change of context.
88      */

89     public void setContext(UserContext user, int nodeid, String JavaDoc context) throws SecurityException JavaDoc {
90         //if(!EVERYBODY.equals(context)) throw new SecurityException("unknown context");
91
}
92
93     /**
94      * This method does nothing, except from returning a dummy value
95      */

96     public Set getPossibleContexts(UserContext user, int nodeid) throws SecurityException JavaDoc {
97         return possibleContexts;
98     }
99
100     public QueryCheck check(UserContext user, org.mmbase.bridge.Query query, Operation operation) {
101         return COMPLETE_CHECK;
102     }
103
104 }
105
Popular Tags