01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.security;
11:
12: import org.mmbase.util.functions.Parameters;
13:
14: /**
15: * A piece of 'action check' functionality. Provided by actions themselves, but security
16: * implementations can perhaps also use this interface to administer their implementation of {@link
17: * Authorization#check(UserContext, Action)}.
18: *
19: * @author Michiel Meeuwissen
20: * @version $Id: ActionChecker.java,v 1.5 2008/02/03 17:33:57 nklasens Exp $
21: * @since MMBase-1.9
22: */
23: public interface ActionChecker extends java.io.Serializable {
24:
25: boolean check(UserContext user, Action ac, Parameters parameters);
26:
27: /**
28: * This basic implementation of ActionChecker checks the action only based on rank. A minimal
29: * rank is to be supplied in the constructor.
30: */
31:
32: public static class Rank implements ActionChecker {
33: final org.mmbase.security.Rank rank;
34:
35: public Rank(org.mmbase.security.Rank r) {
36: rank = r;
37: }
38:
39: public boolean check(UserContext user, Action ac,
40: Parameters parameters) {
41: return user.getRank().getInt() >= rank.getInt();
42: }
43:
44: public String toString() {
45: return "at least " + rank;
46: }
47: }
48: }
|