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: HttpConfigDeserializer.java 11985 2008-02-16 13:43:09Z jzhang $
023: */
024: package com.bostechcorp.cbesb.runtime.component.http.wsdl;
025:
026: import javax.wsdl.Definition;
027: import javax.wsdl.WSDLException;
028: import javax.wsdl.extensions.ExtensibilityElement;
029: import javax.wsdl.extensions.ExtensionDeserializer;
030: import javax.wsdl.extensions.ExtensionRegistry;
031: import javax.xml.namespace.QName;
032:
033: import org.w3c.dom.Element;
034:
035: import com.bostechcorp.cbesb.common.util.macro.MacroUtil;
036: import com.bostechcorp.cbesb.runtime.component.util.wsdl.BaseCommonAttributeDeserializer;
037: import com.ibm.wsdl.util.xml.DOMUtils;
038:
039: public class HttpConfigDeserializer extends
040: BaseCommonAttributeDeserializer implements
041: ExtensionDeserializer {
042:
043: /* (non-Javadoc)
044: * @see javax.wsdl.extensions.ExtensionDeserializer#unmarshall(java.lang.Class, javax.xml.namespace.QName, org.w3c.dom.Element, javax.wsdl.Definition, javax.wsdl.extensions.ExtensionRegistry)
045: */
046: public ExtensibilityElement unmarshall(Class parentType,
047: QName elementType, Element el, Definition def,
048: ExtensionRegistry extReg) throws WSDLException {
049: HttpConfig config = (HttpConfig) super .unmarshall(parentType,
050: elementType, el, def, extReg);
051:
052: String wsdlResource = DOMUtils.getAttribute(el,
053: HttpConfigExtension.WSDL_RESOURCE);
054: config.setWsdlResource(wsdlResource);
055:
056: if (DOMUtils.getAttribute(el, HttpConfigExtension.SSL_PROTOCOL) != null) {
057: config.setSslProtocol(DOMUtils.getAttribute(el,
058: HttpConfigExtension.SSL_PROTOCOL));
059: }
060: if (DOMUtils.getAttribute(el,
061: HttpConfigExtension.USE_PRIVATE_KEY) != null) {
062: config.setUsePrivateKey(Boolean.parseBoolean(DOMUtils
063: .getAttribute(el,
064: HttpConfigExtension.USE_PRIVATE_KEY)));
065: }
066: config.setKeyStoreFile(MacroUtil.resolveUserMacro(DOMUtils
067: .getAttribute(el, HttpConfigExtension.KEY_STORE_FILE)));
068: config.setKeyStorePassword(MacroUtil.resolveUserMacro(DOMUtils
069: .getAttribute(el,
070: HttpConfigExtension.KEY_STORE_PASSWORD)));
071: config.setUseDefaultTrustStore(Boolean.parseBoolean(DOMUtils
072: .getAttribute(el,
073: HttpConfigExtension.USE_DEFAULT_TRUST_STORE)));
074: config.setTrustStoreFile(MacroUtil
075: .resolveUserMacro(DOMUtils.getAttribute(el,
076: HttpConfigExtension.TRUST_STORE_FILE)));
077: config.setTrustStorePassword(MacroUtil
078: .resolveUserMacro(DOMUtils.getAttribute(el,
079: HttpConfigExtension.TRUST_STORE_PASSWORD)));
080: if (DOMUtils.getAttribute(el,
081: HttpConfigExtension.AUTHENTICATE_CLIENT) != null) {
082: config.setAuthenticateClient(Boolean.parseBoolean(DOMUtils
083: .getAttribute(el,
084: HttpConfigExtension.AUTHENTICATE_CLIENT)));
085: }
086: if (DOMUtils.getAttribute(el,
087: HttpConfigExtension.AUTHENTICATE_SERVER) != null) {
088: config.setAuthenticateServer(Boolean.parseBoolean(DOMUtils
089: .getAttribute(el,
090: HttpConfigExtension.AUTHENTICATE_SERVER)));
091: }
092: if (DOMUtils.getAttribute(el,
093: HttpConfigExtension.ALLOW_ANONYMOUS) != null) {
094: config.setAllowAnonymous(Boolean.parseBoolean(DOMUtils
095: .getAttribute(el,
096: HttpConfigExtension.ALLOW_ANONYMOUS)));
097: }
098:
099: config.setMarshaller(DOMUtils.getAttribute(el,
100: HttpConfigExtension.MARSHALLER));
101: if (DOMUtils.getAttribute(el, HttpConfigExtension.TIMEOUT) != null) {
102: config.setTimeout(Integer.parseInt(DOMUtils.getAttribute(
103: el, HttpConfigExtension.TIMEOUT)));
104: }
105: if (DOMUtils.getAttribute(el,
106: HttpConfigExtension.ATTACHMENT_MODE) != null) {
107: config.setAttachmentMode(DOMUtils.getAttribute(el,
108: HttpConfigExtension.ATTACHMENT_MODE));
109: }
110:
111: config.setAuthMode(DOMUtils.getAttribute(el,
112: HttpConfigExtension.AUTH_MODE));
113: config.setAuthUser(MacroUtil.resolveUserMacro(DOMUtils
114: .getAttribute(el, HttpConfigExtension.AUTH_USER)));
115: config.setAuthPassword(MacroUtil.resolveUserMacro(DOMUtils
116: .getAttribute(el, HttpConfigExtension.AUTH_PASSWORD)));
117:
118: config.setProxyHost(MacroUtil.resolveUserMacro(DOMUtils
119: .getAttribute(el, HttpConfigExtension.PROXY_HOST)));
120: config.setProxyPort(MacroUtil.resolveUserMacro(DOMUtils
121: .getAttribute(el, HttpConfigExtension.PROXY_PORT)));
122: config.setProxyUser(MacroUtil.resolveUserMacro(DOMUtils
123: .getAttribute(el, HttpConfigExtension.PROXY_USER)));
124: config.setProxyPassword(MacroUtil.resolveUserMacro(DOMUtils
125: .getAttribute(el, HttpConfigExtension.PROXY_PASSWORD)));
126:
127: config.setTargetService(DOMUtils.getAttribute(el,
128: HttpConfigExtension.TARGET_SERVICE));
129: config.setTargetPort(DOMUtils.getAttribute(el,
130: HttpConfigExtension.TARGET_PORT));
131: config.setTargetOperation(DOMUtils.getAttribute(el,
132: HttpConfigExtension.TARGET_OPERATION));
133:
134: return config;
135: }
136:
137: }
|