001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 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: TcpipConfigDeserializer.java 11990 2008-02-16 13:44:25Z jzhang $
023: */
024: package com.bostechcorp.cbesb.runtime.component.tcpip.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 TcpipConfigDeserializer extends
040: BaseCommonAttributeDeserializer implements
041: ExtensionDeserializer {
042:
043: public ExtensibilityElement unmarshall(Class parentType,
044: QName elementType, Element el, Definition def,
045: ExtensionRegistry extReg) throws WSDLException {
046:
047: TcpipConfig tcpipConfig = (TcpipConfig) super .unmarshall(
048: parentType, elementType, el, def, extReg);
049:
050: tcpipConfig.setProtocolHandler(DOMUtils.getAttribute(el,
051: TcpipExtension.PROTOCOL_HANDLER));
052:
053: String strConnectionMode = DOMUtils.getAttribute(el,
054: TcpipExtension.CONNECTION_MODE);
055: short connectionMode = -1;
056: if (strConnectionMode != null) {
057: if (strConnectionMode.equalsIgnoreCase("client"))
058: connectionMode = TcpipConfig.CONNECTION_MODE_CLIENT;
059: else if (strConnectionMode.equalsIgnoreCase("server"))
060: connectionMode = TcpipConfig.CONNECTION_MODE_SERVER;
061: }
062: tcpipConfig.setConnectionMode(connectionMode);
063:
064: tcpipConfig.setHost(MacroUtil.resolveUserMacro(DOMUtils
065: .getAttribute(el, TcpipExtension.HOST)));
066:
067: String portStr = MacroUtil.resolveUserMacro(DOMUtils
068: .getAttribute(el, TcpipExtension.PORT));
069: if (portStr != null)
070: tcpipConfig.setPort(Integer.parseInt(portStr));
071:
072: tcpipConfig.setLocalBindHost(MacroUtil
073: .resolveUserMacro(DOMUtils.getAttribute(el,
074: TcpipExtension.LOCAL_BIND_HOST)));
075: tcpipConfig.setUseSsl(Boolean.parseBoolean(DOMUtils
076: .getAttribute(el, TcpipExtension.USE_SSL)));
077: tcpipConfig.setSslProtocol(DOMUtils.getAttribute(el,
078: TcpipExtension.SSL_PROTOCOL));
079: tcpipConfig.setAllowAnonymous(Boolean.parseBoolean(DOMUtils
080: .getAttribute(el, TcpipExtension.ALLOW_ANONYMOUS)));
081: tcpipConfig.setUsePrivateKey(Boolean.parseBoolean(DOMUtils
082: .getAttribute(el, TcpipExtension.USE_PRIVATE_KEY)));
083: tcpipConfig.setKeyStoreFile(MacroUtil.resolveUserMacro(DOMUtils
084: .getAttribute(el, TcpipExtension.KEY_STORE_FILE)));
085: tcpipConfig.setKeyStorePassword(MacroUtil
086: .resolveUserMacro(DOMUtils.getAttribute(el,
087: TcpipExtension.KEY_STORE_PASSWORD)));
088: tcpipConfig.setAuthenticateServer(Boolean.parseBoolean(DOMUtils
089: .getAttribute(el, TcpipExtension.AUTHENTICATE_SERVER)));
090: tcpipConfig.setUseDefaultTrustStore(Boolean
091: .parseBoolean(DOMUtils.getAttribute(el,
092: TcpipExtension.USE_DEFAULT_TRUST_STORE)));
093: tcpipConfig.setTrustStoreFile(MacroUtil
094: .resolveUserMacro(DOMUtils.getAttribute(el,
095: TcpipExtension.TRUST_STORE_FILE)));
096:
097: String listenPortStr = MacroUtil.resolveUserMacro(DOMUtils
098: .getAttribute(el, TcpipExtension.LISTEN_PORT));
099: if (listenPortStr != null)
100: tcpipConfig.setListenPort(Integer.parseInt(listenPortStr));
101:
102: String maxClientStr = DOMUtils.getAttribute(el,
103: TcpipExtension.MAX_CLIENTS);
104: if (maxClientStr != null)
105: tcpipConfig.setMaxClients(Integer.parseInt(maxClientStr));
106:
107: tcpipConfig.setAuthenticateClient(Boolean.parseBoolean(DOMUtils
108: .getAttribute(el, TcpipExtension.AUTHENTICATE_CLIENT)));
109: tcpipConfig.setRecordType(DOMUtils.getAttribute(el,
110: TcpipExtension.RECORD_TYPE));
111: tcpipConfig.setCharset(DOMUtils.getAttribute(el,
112: TcpipExtension.CHARSET));
113: return tcpipConfig;
114: }
115: }
|