01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package de.schlund.pfixcore.auth.conditions;
19:
20: import org.w3c.dom.Document;
21: import org.w3c.dom.Element;
22:
23: import de.schlund.pfixcore.auth.Authentication;
24: import de.schlund.pfixcore.auth.Condition;
25:
26: /**
27: *
28: * @author mleidig@schlund.de
29: *
30: */
31: public class Not implements Condition {
32:
33: private Condition condition;
34:
35: public Not() {
36: }
37:
38: public Not(Condition condition) {
39: this .condition = condition;
40: }
41:
42: public void set(Condition condition) {
43: this .condition = condition;
44: }
45:
46: public boolean evaluate(Authentication auth) {
47: return !condition.evaluate(auth);
48: }
49:
50: @Override
51: public String toString() {
52: StringBuilder sb = new StringBuilder();
53: sb.append("! ");
54: sb.append(condition);
55: return sb.toString();
56: }
57:
58: public Element toXML(Document doc) {
59: Element element = doc.createElement("not");
60: if (condition != null)
61: element.appendChild(condition.toXML(doc));
62: return element;
63: }
64:
65: }
|