001: /*
002:
003: This software is OSI Certified Open Source Software.
004: OSI Certified is a certification mark of the Open Source Initiative.
005:
006: The license (Mozilla version 1.0) can be read at the MMBase site.
007: See http://www.MMBase.org/license
008:
009: */
010: package org.mmbase.security;
011:
012: import java.util.*;
013:
014: /**
015: * This class is used when no authorization is configured. Everything is allowed.
016: *
017: * @author Eduard Witteveen
018: * @version $Id: NoAuthorization.java,v 1.11 2005/01/30 16:46:34 nico Exp $
019: */
020: final public class NoAuthorization extends Authorization {
021:
022: // This defined the 'context' used everywhere where one is needed.
023: private static final String EVERYBODY = "everybody";
024: private static final Set possibleContexts = Collections
025: .unmodifiableSet(new HashSet(Arrays.asList(new String[] {
026: EVERYBODY,
027: NoAuthentication.userContext.getOwnerField() })));
028:
029: /**
030: * This method does nothing
031: */
032: protected void load() {
033: }
034:
035: /**
036: * This method does nothing
037: */
038: public void create(UserContext user, int nodeid) {
039: }
040:
041: /**
042: * This method does nothing
043: */
044: public void update(UserContext user, int nodeid) {
045: }
046:
047: /**
048: * This method does nothing
049: */
050: public void remove(UserContext user, int nodeid) {
051: }
052:
053: /**
054: * No authorization means that everyting is allowed
055: * @return true
056: */
057: public boolean check(UserContext user, int nodeid,
058: Operation operation) {
059: return true;
060: }
061:
062: /**
063: * This method does nothing
064: */
065: public void verify(UserContext user, int nodeid, Operation operation)
066: throws org.mmbase.security.SecurityException {
067: }
068:
069: /**
070: * No authorization means that everyting is allowed
071: * @return true
072: */
073: public boolean check(UserContext user, int nodeid, int srcNodeid,
074: int dstNodeid, Operation operation) {
075: return true;
076: }
077:
078: /**
079: * This method does nothing
080: */
081: public void verify(UserContext user, int nodeid, int srcNodeid,
082: int dstNodeid, Operation operation)
083: throws SecurityException {
084: }
085:
086: /**
087: * This method does nothing, except from giving a specified string back
088: */
089: public String getContext(UserContext user, int nodeid)
090: throws SecurityException {
091: return EVERYBODY;
092: }
093:
094: /**
095: * Since this is not authorization, we simply allow every change of context.
096: */
097: public void setContext(UserContext user, int nodeid, String context)
098: throws SecurityException {
099: //if(!EVERYBODY.equals(context)) throw new SecurityException("unknown context");
100: }
101:
102: /**
103: * This method does nothing, except from returning a dummy value
104: */
105: public Set getPossibleContexts(UserContext user, int nodeid)
106: throws SecurityException {
107: return possibleContexts;
108: }
109:
110: public QueryCheck check(UserContext user,
111: org.mmbase.bridge.Query query, Operation operation) {
112: return COMPLETE_CHECK;
113: }
114:
115: }
|