1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.internet2.middleware.shibboleth.wayf;
18
19 import java.util.HashSet;
20
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23 import org.w3c.dom.Element;
24 import org.w3c.dom.NodeList;
25
26 import edu.internet2.middleware.shibboleth.common.ShibbolethConfigurationException;
27
28
29
30
31
32 public class HandlerConfig {
33
34
35
36
37 private static final Logger LOG = LoggerFactory.getLogger(HandlerConfig.class.getName());
38
39
40 private final HashSet <String> ignoredForMatch;
41
42
43 private final String jspFile;
44
45
46 private final String errorJspFile;
47
48
49 private final boolean provideListOfLists;
50
51
52 private final boolean provideList;
53
54
55 private final boolean lookupSp;
56
57
58 private final boolean warnOnBadBinding;
59
60
61 public HandlerConfig() {
62
63
64
65 jspFile = "/wayf.jsp";
66 errorJspFile = "/wayfError.jsp";
67 provideList = true;
68 provideListOfLists = false;
69 lookupSp = true;
70 ignoredForMatch = new HashSet <String>();
71 warnOnBadBinding = false;
72 }
73
74
75
76
77
78
79
80
81
82 public HandlerConfig(Element config, HandlerConfig defaultValue) throws ShibbolethConfigurationException {
83
84 String attribute;
85 LOG.debug("Loading global configuration properties.");
86
87 NodeList list = config.getElementsByTagName("SearchIgnore");
88
89 if (list.getLength() == 0) {
90
91 ignoredForMatch = defaultValue.ignoredForMatch;
92
93 } else {
94
95 ignoredForMatch = new HashSet<String>();
96
97 for (int i = 0; i < list.getLength(); i++ ) {
98
99 NodeList inner = ((Element) list.item(i)).getElementsByTagName("IgnoreText");
100
101 for(int j = 0; j < inner.getLength(); j++) {
102
103 addIgnoredForMatch(inner.item(j).getTextContent());
104 }
105 }
106 }
107
108 attribute = config.getAttribute("jspFile");
109 if (attribute != null && !attribute.equals("")) {
110 jspFile = attribute;
111 } else {
112 jspFile = defaultValue.jspFile;
113 }
114
115 attribute = config.getAttribute("errorJspFile");
116 if (attribute != null && !attribute.equals("")) {
117 errorJspFile = attribute;
118 } else {
119 errorJspFile = defaultValue.errorJspFile;
120 }
121
122 attribute = config.getAttribute("provideList");
123 if (attribute != null && !attribute.equals("")) {
124 provideList = Boolean.valueOf(attribute).booleanValue();
125 } else {
126 provideList = defaultValue.provideList;
127 }
128
129 attribute = config.getAttribute("provideListOfList");
130 if (attribute != null && !attribute.equals("")) {
131 provideListOfLists = Boolean.valueOf(attribute).booleanValue();
132 } else {
133 provideListOfLists = defaultValue.provideListOfLists;
134 }
135
136 attribute = config.getAttribute("showUnusableIdPs");
137 if (attribute != null && !attribute.equals("")) {
138 lookupSp = !Boolean.valueOf(attribute).booleanValue();
139 } else {
140 lookupSp = defaultValue.lookupSp;
141 }
142
143 attribute = config.getAttribute("warnOnBadBinding");
144 if (null != attribute && !attribute.equals("")) {
145 warnOnBadBinding = Boolean.valueOf(attribute).booleanValue();
146 } else {
147 warnOnBadBinding = false;
148 }
149 }
150
151
152
153
154
155
156
157
158 public boolean isIgnoredForMatch(String str) {
159
160 return ignoredForMatch.contains(str.toLowerCase());
161 }
162
163
164
165
166
167
168
169 private void addIgnoredForMatch(String s) {
170
171 ignoredForMatch.add(s.toLowerCase());
172 }
173
174
175
176
177
178 public String getJspFile() {
179 return jspFile;
180 }
181
182
183
184
185
186 public String getErrorJspFile() {
187 return errorJspFile;
188 }
189
190
191
192
193
194 public boolean getProvideListOfLists() {
195 return provideListOfLists;
196 }
197
198
199
200
201
202 public boolean getProvideList() {
203 return provideList;
204 }
205
206
207
208
209
210 public boolean getLookupSp() {
211 return lookupSp;
212 }
213
214
215
216
217
218 public boolean getWarnOnBadBinding() {
219 return warnOnBadBinding;
220 }
221
222 }