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;
19:
20: import org.w3c.dom.Document;
21: import org.w3c.dom.Element;
22:
23: /**
24: *
25: * @author mleidig
26: *
27: */
28: public class AuthConstraintImpl implements AuthConstraint {
29:
30: private Condition condition;
31: private String authPage;
32:
33: public AuthConstraintImpl() {
34: }
35:
36: public AuthConstraintImpl(Condition condition) {
37: this .condition = condition;
38: }
39:
40: public void setCondition(Condition condition) {
41: this .condition = condition;
42: }
43:
44: public Condition getCondition() {
45: return condition;
46: }
47:
48: public void setAuthPage(String authPage) {
49: this .authPage = authPage;
50: }
51:
52: public String getAuthPage() {
53: return authPage;
54: }
55:
56: public boolean isAuthorized(Authentication auth) {
57: if (condition != null) {
58: return condition.evaluate(auth);
59: }
60: return true;
61: }
62:
63: @Override
64: public String toString() {
65: StringBuilder sb = new StringBuilder();
66: sb.append(getClass().getName());
67: sb.append(" ");
68: sb.append("{");
69: sb.append("condition: ");
70: sb.append(condition);
71: sb.append("}");
72: return sb.toString();
73: }
74:
75: public Element toXML(Document doc) {
76: Element element = doc.createElement("authconstraint");
77: if (condition != null)
78: element.appendChild(condition.toXML(doc));
79: return element;
80: }
81:
82: }
|