001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2007 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id: HttpPropertiesEnumeration.java 9219 2007-09-21 17:38:17Z mpreston $
023: */
024: package com.bostechcorp.cbesb.runtime.component.http;
025:
026: public enum HttpPropertiesEnumeration {
027:
028: ALLOW_ANONYMOUS {
029: String getValue(HttpEndpoint endpoint) {
030: return (endpoint.isAllowAnonymous()) ? " Y " : " N ";
031: }
032:
033: void setValue(HttpEndpoint endpoint, Object value) {
034: if (isSetable()) {
035: String val = ((String) value).trim();
036: if ("Y".equalsIgnoreCase(val))
037: endpoint.setAllowAnonymous(true);
038: else
039: endpoint.setAllowAnonymous(false);
040: }
041: }
042:
043: boolean isSetable() {
044: return true;
045: }
046: },
047: ATTACHMENT_MODE {
048: String getValue(HttpEndpoint endpoint) {
049: if (endpoint.isUsingMTOM())
050: return "MTOM";
051: else if (endpoint.isUsingSwA())
052: return "SwA";
053: else
054: return "none";
055: }
056:
057: void setValue(HttpEndpoint endpoint, Object value) {
058: if (isSetable()) {
059: String val = (String) value;
060: if (val.equalsIgnoreCase("MTOM"))
061: endpoint.setAttachmentMode("MTOM");
062: else if (val.equalsIgnoreCase("SwA"))
063: endpoint.setAttachmentMode("SwA");
064: else
065: endpoint.setAttachmentMode("none");
066: }
067: }
068:
069: boolean isSetable() {
070: return true;
071: }
072: },
073: AUTHENTICATE_CLIENT {
074: String getValue(HttpEndpoint endpoint) {
075: return (endpoint.isAuthenticateClient()) ? " Y " : " N ";
076: }
077:
078: void setValue(HttpEndpoint endpoint, Object value) {
079: if (isSetable()) {
080: String val = ((String) value).trim();
081: if ("Y".equalsIgnoreCase(val))
082: endpoint.setAuthenticateClient(true);
083: else
084: endpoint.setAuthenticateClient(false);
085: }
086: }
087:
088: boolean isSetable() {
089: return true;
090: }
091: },
092: AUTHENTICATE_SERVER {
093: String getValue(HttpEndpoint endpoint) {
094: return (endpoint.isAuthenticateServer()) ? " Y " : " N ";
095: }
096:
097: void setValue(HttpEndpoint endpoint, Object value) {
098: if (isSetable()) {
099: String val = ((String) value).trim();
100: if ("Y".equalsIgnoreCase(val))
101: endpoint.setAuthenticateServer(true);
102: else
103: endpoint.setAuthenticateServer(false);
104: }
105: }
106:
107: boolean isSetable() {
108: return true;
109: }
110: },
111: AUTH_MODE {
112: String getValue(HttpEndpoint endpoint) {
113: return (endpoint.getAuthMode() == null) ? "none" : endpoint
114: .getAuthMode();
115: }
116:
117: void setValue(HttpEndpoint endpoint, Object value) {
118: if (isSetable()) {
119: String val = (String) value;
120: if (val.equalsIgnoreCase("Basic")) {
121: endpoint.setAuthMode("Basic");
122: } else {
123: endpoint.setAuthMode(null);
124: }
125: endpoint.setAuthenticateServer(Boolean
126: .parseBoolean((String) value));
127: }
128: }
129:
130: boolean isSetable() {
131: return true;
132: }
133: },
134: AUTH_PASSWORD {
135: String getValue(HttpEndpoint endpoint) {
136: return (endpoint.getAuthPassword() == null) ? "" : endpoint
137: .getAuthPassword();
138: }
139:
140: void setValue(HttpEndpoint endpoint, Object value) {
141: if (isSetable())
142: endpoint.setAuthPassword((String) value);
143: }
144:
145: boolean isSetable() {
146: return true;
147: }
148: },
149: AUTH_USER {
150: String getValue(HttpEndpoint endpoint) {
151: return (endpoint.getAuthUser() == null) ? "" : endpoint
152: .getAuthUser();
153: }
154:
155: void setValue(HttpEndpoint endpoint, Object value) {
156: if (isSetable())
157: endpoint.setAuthUser((String) value);
158: }
159:
160: boolean isSetable() {
161: return true;
162: }
163: },
164: KEYSTORE_FILE {
165: String getValue(HttpEndpoint endpoint) {
166: return (endpoint.getKeyStoreFile() == null) ? "" : endpoint
167: .getKeyStoreFile();
168: }
169:
170: void setValue(HttpEndpoint endpoint, Object value) {
171: if (isSetable())
172: endpoint.setKeyStoreFile((String) value);
173: }
174:
175: boolean isSetable() {
176: return true;
177: }
178: },
179: KEYSTORE_PASSWORD {
180: String getValue(HttpEndpoint endpoint) {
181: return (endpoint.getKeyStorePassword() == null) ? ""
182: : endpoint.getKeyStorePassword();
183: }
184:
185: void setValue(HttpEndpoint endpoint, Object value) {
186: if (isSetable())
187: endpoint.setKeyStorePassword((String) value);
188: }
189:
190: boolean isSetable() {
191: return true;
192: }
193: },
194: LOCATION_URI {
195: String getValue(HttpEndpoint endpoint) {
196: return (endpoint.getLocationURI() == null) ? "" : endpoint
197: .getLocationURI();
198: }
199:
200: void setValue(HttpEndpoint endpoint, Object value) {
201: if (isSetable())
202: endpoint.setLocationURI((String) value);
203: }
204:
205: boolean isSetable() {
206: return true;
207: }
208: },
209: PROXY_HOST {
210: String getValue(HttpEndpoint endpoint) {
211: return (endpoint.getProxyHost() == null) ? "" : endpoint
212: .getProxyHost();
213: }
214:
215: void setValue(HttpEndpoint endpoint, Object value) {
216: if (isSetable())
217: endpoint.setProxyHost((String) value);
218: }
219:
220: boolean isSetable() {
221: return true;
222: }
223: },
224: PROXY_PASSWORD {
225: String getValue(HttpEndpoint endpoint) {
226: return (endpoint.getProxyPassword() == null) ? ""
227: : endpoint.getProxyPassword();
228: }
229:
230: void setValue(HttpEndpoint endpoint, Object value) {
231: if (isSetable())
232: endpoint.setProxyPassword((String) value);
233: }
234:
235: boolean isSetable() {
236: return true;
237: }
238: },
239: PROXY_PORT {
240: String getValue(HttpEndpoint endpoint) {
241: return (endpoint.getProxyPort() == null) ? "" : endpoint
242: .getProxyPort();
243: }
244:
245: void setValue(HttpEndpoint endpoint, Object value) {
246: if (isSetable())
247: endpoint.setProxyPort((String) value);
248: }
249:
250: boolean isSetable() {
251: return true;
252: }
253: },
254: PROXY_USER {
255: String getValue(HttpEndpoint endpoint) {
256: return (endpoint.getProxyUser() == null) ? "" : endpoint
257: .getProxyUser();
258: }
259:
260: void setValue(HttpEndpoint endpoint, Object value) {
261: if (isSetable())
262: endpoint.setProxyUser((String) value);
263: }
264:
265: boolean isSetable() {
266: return true;
267: }
268: },
269: SOAP {
270: String getValue(HttpEndpoint endpoint) {
271: return (endpoint.isSoap()) ? " Y " : " N ";
272: }
273:
274: void setValue(HttpEndpoint endpoint, Object value) {
275: if (isSetable()) {
276: String val = ((String) value).trim();
277: if ("Y".equalsIgnoreCase(val))
278: endpoint.setSoap(true);
279: else
280: endpoint.setSoap(false);
281: }
282: }
283:
284: boolean isSetable() {
285: return true;
286: }
287: },
288: SOAP_VERSION {
289: String getValue(HttpEndpoint endpoint) {
290: return (endpoint.getSoapVersion() == null) ? "" : endpoint
291: .getSoapVersion();
292: }
293:
294: void setValue(HttpEndpoint endpoint, Object value) {
295: if (isSetable()) {
296: if (value.equals("1.2")) {
297: endpoint.setSoapVersion("1.2");
298: } else {
299: endpoint.setSoapVersion("1.1");
300: }
301: }
302: }
303:
304: boolean isSetable() {
305: return true;
306: }
307: },
308: SSL_PROTOCOL {
309: String getValue(HttpEndpoint endpoint) {
310: return (endpoint.getSslProtocol() == null) ? "" : endpoint
311: .getSslProtocol();
312: }
313:
314: void setValue(HttpEndpoint endpoint, Object value) {
315: if (isSetable()) {
316: String val = (String) value;
317: if (val.equalsIgnoreCase("SSL")) {
318: endpoint.setSslProtocol("SSL");
319: } else if (val.equalsIgnoreCase("SSLv3")) {
320: endpoint.setSslProtocol("SSLv3");
321: } else {
322: endpoint.setSslProtocol("TLS");
323: }
324: }
325: }
326:
327: boolean isSetable() {
328: return true;
329: }
330: },
331: TIMEOUT {
332: String getValue(HttpEndpoint endpoint) {
333: return Integer.toString(endpoint.getTimeout());
334: }
335:
336: void setValue(HttpEndpoint endpoint, Object value) {
337: if (isSetable()) {
338: endpoint.setTimeout(Integer.parseInt((String) value));
339: }
340: }
341:
342: boolean isSetable() {
343: return true;
344: }
345: },
346: TRUSTSTORE_FILE {
347: String getValue(HttpEndpoint endpoint) {
348: return (endpoint.getTrustStoreFile() == null) ? ""
349: : endpoint.getTrustStoreFile();
350: }
351:
352: void setValue(HttpEndpoint endpoint, Object value) {
353: if (isSetable())
354: endpoint.setTrustStoreFile((String) value);
355: }
356:
357: boolean isSetable() {
358: return true;
359: }
360: },
361: TRUSTSTORE_PASSWORD {
362: String getValue(HttpEndpoint endpoint) {
363: return (endpoint.getTrustStorePassword() == null) ? ""
364: : endpoint.getTrustStorePassword();
365: }
366:
367: void setValue(HttpEndpoint endpoint, Object value) {
368: if (isSetable())
369: endpoint.setTrustStorePassword((String) value);
370: }
371:
372: boolean isSetable() {
373: return true;
374: }
375: },
376: USE_DEFAULT_TRUSTSTORE {
377: String getValue(HttpEndpoint endpoint) {
378: return (endpoint.isUseDefaultTrustStore()) ? " Y " : " N ";
379: }
380:
381: void setValue(HttpEndpoint endpoint, Object value) {
382: if (isSetable()) {
383: String val = ((String) value).trim();
384: if ("Y".equalsIgnoreCase(val))
385: endpoint.setUseDefaultTrustStore(true);
386: else
387: endpoint.setUseDefaultTrustStore(false);
388: }
389: }
390:
391: boolean isSetable() {
392: return true;
393: }
394: },
395: USE_PRIVATE_KEY {
396: String getValue(HttpEndpoint endpoint) {
397: return (endpoint.isUsePrivateKey()) ? " Y " : " N ";
398: }
399:
400: void setValue(HttpEndpoint endpoint, Object value) {
401: if (isSetable()) {
402: String val = ((String) value).trim();
403: if ("Y".equalsIgnoreCase(val))
404: endpoint.setUsePrivateKey(true);
405: else
406: endpoint.setUsePrivateKey(false);
407: }
408: }
409:
410: boolean isSetable() {
411: return true;
412: }
413: };
414: /**
415: *
416: * @param endpoint --
417: * endpoint in use
418: * @return - attribute value according to enumeration item
419: */
420: abstract String getValue(HttpEndpoint endpoint);
421:
422: /**
423: *
424: * @param endpoint--
425: * endpoint in use
426: * @param value -
427: * sets attribute value according to enumeration item
428: */
429: abstract void setValue(HttpEndpoint endpoint, Object value);
430:
431: /**
432: * tells either is possible or not to set the value false if the attribute
433: * is read only
434: *
435: * @return
436: */
437: abstract boolean isSetable();
438: }
|