axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r549585 - in /webservices/axis2/trunk/java/modules: kernel/ kernel/src/org/apache/axis2/transport/nhttp/ parent/
Date Thu, 21 Jun 2007 18:50:23 GMT
Author: dims
Date: Thu Jun 21 11:50:22 2007
New Revision: 549585

URL: http://svn.apache.org/viewvc?view=rev&rev=549585
Log:
Enable NIO SSL classes to build only on maven2 under jdk1.5/1.6

Modified:
    webservices/axis2/trunk/java/modules/kernel/pom.xml
    webservices/axis2/trunk/java/modules/kernel/project.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLListener.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java
    webservices/axis2/trunk/java/modules/parent/pom.xml

Modified: webservices/axis2/trunk/java/modules/kernel/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/pom.xml?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/pom.xml Thu Jun 21 11:50:22 2007
@@ -47,10 +47,6 @@
                         <groupId>org.apache.httpcomponents</groupId>
                         <artifactId>jakarta-httpcore-nio</artifactId>
                 </dependency>
-                <!--<dependency>
-                        <groupId>org.apache.httpcomponents</groupId>
-                        <artifactId>jakarta-httpcore-niossl</artifactId>
-                </dependency>-->
 		<dependency>
 			<groupId>wsdl4j</groupId>
 			<artifactId>wsdl4j</artifactId>
@@ -100,6 +96,53 @@
 			<artifactId>commons-logging</artifactId>
 		</dependency>
 	</dependencies>
+	<profiles>
+		<profile>
+			<id>java14</id>
+			<activation>
+				<jdk>1.4</jdk>
+			</activation>
+            <build>
+                <plugins>
+					<plugin>
+						<artifactId>maven-compiler-plugin</artifactId>
+						<inherited>true</inherited>
+						<configuration>
+                            <excludes>
+                                <exclude>**/*NIOSSL*.java</exclude>
+                                <exclude>**/SSLServerIOEventDispatch.java</exclude>
+                                <exclude>**/SSLClientIOEventDispatch.java</exclude>
+                            </excludes>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+		</profile>
+		<profile>
+			<id>java15</id>
+			<activation>
+				<jdk>1.5</jdk>
+			</activation>
+			<dependencies>
+                <dependency>
+                        <groupId>org.apache.httpcomponents</groupId>
+                        <artifactId>jakarta-httpcore-niossl</artifactId>
+                </dependency>
+			</dependencies>
+		</profile>
+		<profile>
+			<id>java16</id>
+			<activation>
+				<jdk>1.6</jdk>
+			</activation>
+			<dependencies>
+                <dependency>
+                        <groupId>org.apache.httpcomponents</groupId>
+                        <artifactId>jakarta-httpcore-niossl</artifactId>
+                </dependency>
+			</dependencies>
+		</profile>
+	</profiles>
 	<build>
 		<sourceDirectory>src</sourceDirectory>
 		<testSourceDirectory>test</testSourceDirectory>

Modified: webservices/axis2/trunk/java/modules/kernel/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/project.xml?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/project.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/project.xml Thu Jun 21 11:50:22 2007
@@ -197,6 +197,17 @@
         </dependency>
     </dependencies>
     <build>
+       <sourceModifications>
+           <sourceModification>
+               <className>Ignore.NIO.SSL</className>
+               <excludes>
+                   <exclude>**/*NIOSSL*.java</exclude>
+                   <exclude>**/SSLServerIOEventDispatch.java</exclude>
+				   <exclude>**/SSLClientIOEventDispatch.java</exclude>
+               </excludes>
+           </sourceModification>
+       </sourceModifications>
+    
 		<resources>
 			<resource>
 				<directory>conf</directory>

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLListener.java?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLListener.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLListener.java Thu Jun 21 11:50:22 2007
@@ -1,179 +1,179 @@
-///*
-// *  Licensed to the Apache Software Foundation (ASF) under one
-// *  or more contributor license agreements.  See the NOTICE file
-// *  distributed with this work for additional information
-// *  regarding copyright ownership.  The ASF licenses this file
-// *  to you under the Apache License, Version 2.0 (the
-// *  "License"); you may not use this file except in compliance
-// *  with the License.  You may obtain a copy of the License at
-// *
-// *   http://www.apache.org/licenses/LICENSE-2.0
-// *
-// *  Unless required by applicable law or agreed to in writing,
-// *  software distributed under the License is distributed on an
-// *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// *  KIND, either express or implied.  See the License for the
-// *  specific language governing permissions and limitations
-// *  under the License.
-// */
-//
-//package org.apache.axis2.transport.nhttp;
-//
-//import java.io.IOException;
-//import java.net.SocketAddress;
-//import java.net.URL;
-//import java.security.GeneralSecurityException;
-//import java.security.KeyStore;
-//
-//import javax.net.ssl.KeyManager;
-//import javax.net.ssl.KeyManagerFactory;
-//import javax.net.ssl.SSLContext;
-//import javax.net.ssl.SSLEngine;
-//import javax.net.ssl.SSLException;
-//import javax.net.ssl.SSLSession;
-//import javax.net.ssl.TrustManager;
-//import javax.net.ssl.TrustManagerFactory;
-//import javax.xml.namespace.QName;
-//
-//import org.apache.axiom.om.OMElement;
-//import org.apache.axis2.AxisFault;
-//import org.apache.axis2.context.ConfigurationContext;
-//import org.apache.axis2.description.Parameter;
-//import org.apache.axis2.description.TransportInDescription;
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
-//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
-//import org.apache.http.nio.NHttpServiceHandler;
-//import org.apache.http.nio.reactor.IOEventDispatch;
-//import org.apache.http.params.HttpParams;
-//
-//public class HttpCoreNIOSSLListener extends HttpCoreNIOListener {
-//
-//    private static final Log log = LogFactory.getLog(HttpCoreNIOSSLListener.class);
-//
-//    protected IOEventDispatch getEventDispatch(
-//        NHttpServiceHandler handler, SSLContext sslContext,
-//        SSLIOSessionHandler sslIOSessionHandler, HttpParams params) {
-//        return new SSLServerIOEventDispatch(handler, sslContext, sslIOSessionHandler, params);
-//    }
-//
-//    /**
-//     * Return the EPR prefix for services made available over this transport
-//     * @return
-//     */
-//    protected String getServiceEPRPrefix(ConfigurationContext cfgCtx, String host, int port) {
-//        return "https://" + host + (port == 443 ? "" : ":" + port) +
-//            (!cfgCtx.getServiceContextPath().startsWith("/") ? "/" : "") +
-//            cfgCtx.getServiceContextPath() +
-//            (!cfgCtx.getServiceContextPath().endsWith("/") ? "/" : "");
-//    }
-//
-//
-//    /**
-//     * Create the SSLContext to be used by this listener
-//     * @param transportIn the Axis2 transport description
-//     * @return the SSLContext to be used
-//     */
-//    protected SSLContext getSSLContext(TransportInDescription transportIn) throws AxisFault {
-//
-//        KeyManager[] keymanagers  = null;
-//        TrustManager[] trustManagers = null;
-//
-//        Parameter keyParam    = transportIn.getParameter("keystore");
-//        Parameter trustParam  = transportIn.getParameter("truststore");
-//
-//        if (keyParam != null) {
-//            OMElement ksEle      = keyParam.getParameterElement().getFirstElement();
-//            String location      = ksEle.getFirstChildWithName(new QName("Location")).getText();
-//            String type          = ksEle.getFirstChildWithName(new QName("Type")).getText();
-//            String storePassword = ksEle.getFirstChildWithName(new QName("Password")).getText();
-//            String keyPassword   = ksEle.getFirstChildWithName(new QName("KeyPassword")).getText();
-//
-//            try {
-//                KeyStore keyStore = KeyStore.getInstance(type);
-//                URL url = getClass().getClassLoader().getResource(location);
-//                log.debug("Loading Key Store from URL : " + url);
-//
-//                keyStore.load(url.openStream(), storePassword.toCharArray());
-//                KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
-//                    KeyManagerFactory.getDefaultAlgorithm());
-//                kmfactory.init(keyStore, keyPassword.toCharArray());
-//                keymanagers = kmfactory.getKeyManagers();
-//
-//            } catch (GeneralSecurityException gse) {
-//                log.error("Error loading Key store : " + location, gse);
-//                throw new AxisFault("Error loading Key store : " + location, gse);
-//            } catch (IOException ioe) {
-//                log.error("Error opening Key store : " + location, ioe);
-//                throw new AxisFault("Error opening Key store : " + location, ioe);
-//            }
-//        }
-//
-//        if (trustParam != null) {
-//            OMElement tsEle      = trustParam.getParameterElement().getFirstElement();
-//            String location      = tsEle.getFirstChildWithName(new QName("Location")).getText();
-//            String type          = tsEle.getFirstChildWithName(new QName("Type")).getText();
-//            String storePassword = tsEle.getFirstChildWithName(new QName("Password")).getText();
-//
-//            try {
-//                KeyStore trustStore = KeyStore.getInstance(type);
-//                URL url = getClass().getClassLoader().getResource(location);
-//                log.debug("Loading Trust Key Store from URL : " + url);
-//
-//                trustStore.load(url.openStream(), storePassword.toCharArray());
-//                TrustManagerFactory trustManagerfactory = TrustManagerFactory.getInstance(
-//                    TrustManagerFactory.getDefaultAlgorithm());
-//                trustManagerfactory.init(trustStore);
-//                trustManagers = trustManagerfactory.getTrustManagers();
-//
-//            } catch (GeneralSecurityException gse) {
-//                log.error("Error loading Key store : " + location, gse);
-//                throw new AxisFault("Error loading Key store : " + location, gse);
-//            } catch (IOException ioe) {
-//                log.error("Error opening Key store : " + location, ioe);
-//                throw new AxisFault("Error opening Key store : " + location, ioe);
-//            }
-//        }
-//
-//        try {
-//            SSLContext sslcontext = SSLContext.getInstance("TLS");
-//            sslcontext.init(keymanagers, trustManagers, null);
-//            return sslcontext;
-//
-//        } catch (GeneralSecurityException gse) {
-//            log.error("Unable to create SSL context with the given configuration", gse);
-//            throw new AxisFault("Unable to create SSL context with the given configuration", gse);
-//        }
-//    }
-//
-//    /**
-//     * Create the SSLIOSessionHandler to initialize the SSL session / engine, and request for
-//     * client authentication at the following levels, through an Axis2 transport configuration
-//     * parameter as follows:
-//     * SSLVerifyClient - none, optional, require
-//     *
-//     * @param transportIn the Axis2 transport configuration
-//     * @return the SSLIOSessionHandler to be used
-//     * @throws AxisFault if a configuration error occurs
-//     */
-//    protected SSLIOSessionHandler getSSLIOSessionHandler(TransportInDescription transportIn) throws AxisFault {
-//
-//        final Parameter clientAuth = transportIn.getParameter("SSLVerifyClient");
-//
-//        return new SSLIOSessionHandler() {
-//
-//            public void initalize(SSLEngine sslengine, HttpParams params) {
-//                if (clientAuth != null) {
-//                    if ("optional".equals(clientAuth.getValue())) {
-//                        sslengine.setWantClientAuth(true);
-//                    } else if ("require".equals(clientAuth.getValue())) {
-//                        sslengine.setNeedClientAuth(true);
-//                    }
-//                }
-//            }
-//
-//            public void verify(SocketAddress removeAddress, SSLSession session)
-//                throws SSLException {}
-//        };
-//    }
-//}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.axis2.transport.nhttp;
+
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.params.HttpParams;
+
+public class HttpCoreNIOSSLListener extends HttpCoreNIOListener {
+
+    private static final Log log = LogFactory.getLog(HttpCoreNIOSSLListener.class);
+
+    protected IOEventDispatch getEventDispatch(
+        NHttpServiceHandler handler, SSLContext sslContext,
+        SSLIOSessionHandler sslIOSessionHandler, HttpParams params) {
+        return new SSLServerIOEventDispatch(handler, sslContext, sslIOSessionHandler, params);
+    }
+
+    /**
+     * Return the EPR prefix for services made available over this transport
+     * @return
+     */
+    protected String getServiceEPRPrefix(ConfigurationContext cfgCtx, String host, int port) {
+        return "https://" + host + (port == 443 ? "" : ":" + port) +
+            (!cfgCtx.getServiceContextPath().startsWith("/") ? "/" : "") +
+            cfgCtx.getServiceContextPath() +
+            (!cfgCtx.getServiceContextPath().endsWith("/") ? "/" : "");
+    }
+
+
+    /**
+     * Create the SSLContext to be used by this listener
+     * @param transportIn the Axis2 transport description
+     * @return the SSLContext to be used
+     */
+    protected SSLContext getSSLContext(TransportInDescription transportIn) throws AxisFault {
+
+        KeyManager[] keymanagers  = null;
+        TrustManager[] trustManagers = null;
+
+        Parameter keyParam    = transportIn.getParameter("keystore");
+        Parameter trustParam  = transportIn.getParameter("truststore");
+
+        if (keyParam != null) {
+            OMElement ksEle      = keyParam.getParameterElement().getFirstElement();
+            String location      = ksEle.getFirstChildWithName(new QName("Location")).getText();
+            String type          = ksEle.getFirstChildWithName(new QName("Type")).getText();
+            String storePassword = ksEle.getFirstChildWithName(new QName("Password")).getText();
+            String keyPassword   = ksEle.getFirstChildWithName(new QName("KeyPassword")).getText();
+
+            try {
+                KeyStore keyStore = KeyStore.getInstance(type);
+                URL url = getClass().getClassLoader().getResource(location);
+                log.debug("Loading Key Store from URL : " + url);
+
+                keyStore.load(url.openStream(), storePassword.toCharArray());
+                KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
+                    KeyManagerFactory.getDefaultAlgorithm());
+                kmfactory.init(keyStore, keyPassword.toCharArray());
+                keymanagers = kmfactory.getKeyManagers();
+
+            } catch (GeneralSecurityException gse) {
+                log.error("Error loading Key store : " + location, gse);
+                throw new AxisFault("Error loading Key store : " + location, gse);
+            } catch (IOException ioe) {
+                log.error("Error opening Key store : " + location, ioe);
+                throw new AxisFault("Error opening Key store : " + location, ioe);
+            }
+        }
+
+        if (trustParam != null) {
+            OMElement tsEle      = trustParam.getParameterElement().getFirstElement();
+            String location      = tsEle.getFirstChildWithName(new QName("Location")).getText();
+            String type          = tsEle.getFirstChildWithName(new QName("Type")).getText();
+            String storePassword = tsEle.getFirstChildWithName(new QName("Password")).getText();
+
+            try {
+                KeyStore trustStore = KeyStore.getInstance(type);
+                URL url = getClass().getClassLoader().getResource(location);
+                log.debug("Loading Trust Key Store from URL : " + url);
+
+                trustStore.load(url.openStream(), storePassword.toCharArray());
+                TrustManagerFactory trustManagerfactory = TrustManagerFactory.getInstance(
+                    TrustManagerFactory.getDefaultAlgorithm());
+                trustManagerfactory.init(trustStore);
+                trustManagers = trustManagerfactory.getTrustManagers();
+
+            } catch (GeneralSecurityException gse) {
+                log.error("Error loading Key store : " + location, gse);
+                throw new AxisFault("Error loading Key store : " + location, gse);
+            } catch (IOException ioe) {
+                log.error("Error opening Key store : " + location, ioe);
+                throw new AxisFault("Error opening Key store : " + location, ioe);
+            }
+        }
+
+        try {
+            SSLContext sslcontext = SSLContext.getInstance("TLS");
+            sslcontext.init(keymanagers, trustManagers, null);
+            return sslcontext;
+
+        } catch (GeneralSecurityException gse) {
+            log.error("Unable to create SSL context with the given configuration", gse);
+            throw new AxisFault("Unable to create SSL context with the given configuration", gse);
+        }
+    }
+
+    /**
+     * Create the SSLIOSessionHandler to initialize the SSL session / engine, and request for
+     * client authentication at the following levels, through an Axis2 transport configuration
+     * parameter as follows:
+     * SSLVerifyClient - none, optional, require
+     *
+     * @param transportIn the Axis2 transport configuration
+     * @return the SSLIOSessionHandler to be used
+     * @throws AxisFault if a configuration error occurs
+     */
+    protected SSLIOSessionHandler getSSLIOSessionHandler(TransportInDescription transportIn) throws AxisFault {
+
+        final Parameter clientAuth = transportIn.getParameter("SSLVerifyClient");
+
+        return new SSLIOSessionHandler() {
+
+            public void initalize(SSLEngine sslengine, HttpParams params) {
+                if (clientAuth != null) {
+                    if ("optional".equals(clientAuth.getValue())) {
+                        sslengine.setWantClientAuth(true);
+                    } else if ("require".equals(clientAuth.getValue())) {
+                        sslengine.setNeedClientAuth(true);
+                    }
+                }
+            }
+
+            public void verify(SocketAddress removeAddress, SSLSession session)
+                throws SSLException {}
+        };
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/HttpCoreNIOSSLSender.java Thu Jun 21 11:50:22 2007
@@ -1,176 +1,183 @@
-///*
-// *  Licensed to the Apache Software Foundation (ASF) under one
-// *  or more contributor license agreements.  See the NOTICE file
-// *  distributed with this work for additional information
-// *  regarding copyright ownership.  The ASF licenses this file
-// *  to you under the Apache License, Version 2.0 (the
-// *  "License"); you may not use this file except in compliance
-// *  with the License.  You may obtain a copy of the License at
-// *
-// *   http://www.apache.org/licenses/LICENSE-2.0
-// *
-// *  Unless required by applicable law or agreed to in writing,
-// *  software distributed under the License is distributed on an
-// *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// *  KIND, either express or implied.  See the License for the
-// *  specific language governing permissions and limitations
-// *  under the License.
-// */
-//
-//package org.apache.axis2.transport.nhttp;
-//
-//import org.apache.commons.logging.LogFactory;
-//import org.apache.commons.logging.Log;
-//import org.apache.http.nio.reactor.IOEventDispatch;
-//import org.apache.http.nio.NHttpClientHandler;
-//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
-//import org.apache.http.params.HttpParams;
-//import org.apache.axis2.AxisFault;
-//import org.apache.axis2.description.Parameter;
-//import org.apache.axis2.description.TransportOutDescription;
-//import org.apache.axiom.om.OMElement;
-//
-//import javax.net.ssl.*;
-//import javax.xml.namespace.QName;
-//import java.security.GeneralSecurityException;
-//import java.security.KeyStore;
-//import java.net.URL;
-//import java.net.SocketAddress;
-//import java.net.InetSocketAddress;
-//import java.io.IOException;
-//
-//public class HttpCoreNIOSSLSender extends HttpCoreNIOSender{
-//
-//    private static final Log log = LogFactory.getLog(HttpCoreNIOSSLSender.class);
-//
-//    protected IOEventDispatch getEventDispatch(
-//        NHttpClientHandler handler, SSLContext sslContext,
-//        SSLIOSessionHandler sslIOSessionHandler, HttpParams params) {
-//        return new SSLClientIOEventDispatch(handler, sslContext, sslIOSessionHandler, params);
-//    }
-//
-//    /**
-//     * Create the SSLContext to be used by this listener
-//     * @param transportOut the Axis2 transport configuration
-//     * @return the SSLContext to be used
-//     */
-//    protected SSLContext getSSLContext(TransportOutDescription transportOut) throws AxisFault {
-//
-//        KeyManager[] keymanagers  = null;
-//        TrustManager[] trustManagers = null;
-//
-//        Parameter keyParam    = transportOut.getParameter("keystore");
-//        Parameter trustParam  = transportOut.getParameter("truststore");
-//
-//        if (keyParam != null) {
-//            OMElement ksEle      = keyParam.getParameterElement().getFirstElement();
-//            String location      = ksEle.getFirstChildWithName(new QName("Location")).getText();
-//            String type          = ksEle.getFirstChildWithName(new QName("Type")).getText();
-//            String storePassword = ksEle.getFirstChildWithName(new QName("Password")).getText();
-//            String keyPassword   = ksEle.getFirstChildWithName(new QName("KeyPassword")).getText();
-//
-//            try {
-//                KeyStore keyStore = KeyStore.getInstance(type);
-//                URL url = getClass().getClassLoader().getResource(location);
-//                log.debug("Loading Key Store from URL : " + url);
-//
-//                keyStore.load(url.openStream(), storePassword.toCharArray());
-//                KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
-//                    KeyManagerFactory.getDefaultAlgorithm());
-//                kmfactory.init(keyStore, keyPassword.toCharArray());
-//                keymanagers = kmfactory.getKeyManagers();
-//
-//            } catch (GeneralSecurityException gse) {
-//                log.error("Error loading Key store : " + location, gse);
-//                throw new AxisFault("Error loading Key store : " + location, gse);
-//            } catch (IOException ioe) {
-//                log.error("Error opening Key store : " + location, ioe);
-//                throw new AxisFault("Error opening Key store : " + location, ioe);
-//            }
-//        }
-//
-//        if (trustParam != null) {
-//            OMElement tsEle      = trustParam.getParameterElement().getFirstElement();
-//            String location      = tsEle.getFirstChildWithName(new QName("Location")).getText();
-//            String type          = tsEle.getFirstChildWithName(new QName("Type")).getText();
-//            String storePassword = tsEle.getFirstChildWithName(new QName("Password")).getText();
-//
-//            try {
-//                KeyStore trustStore = KeyStore.getInstance(type);
-//                URL url = getClass().getClassLoader().getResource(location);
-//                log.debug("Loading Trust Key Store from URL : " + url);
-//
-//                trustStore.load(url.openStream(), storePassword.toCharArray());
-//                TrustManagerFactory trustManagerfactory = TrustManagerFactory.getInstance(
-//                    TrustManagerFactory.getDefaultAlgorithm());
-//                trustManagerfactory.init(trustStore);
-//                trustManagers = trustManagerfactory.getTrustManagers();
-//
-//            } catch (GeneralSecurityException gse) {
-//                log.error("Error loading Key store : " + location, gse);
-//                throw new AxisFault("Error loading Key store : " + location, gse);
-//            } catch (IOException ioe) {
-//                log.error("Error opening Key store : " + location, ioe);
-//                throw new AxisFault("Error opening Key store : " + location, ioe);
-//            }
-//        }
-//
-//        try {
-//            SSLContext sslcontext = SSLContext.getInstance("TLS");
-//            sslcontext.init(keymanagers, trustManagers, null);
-//            return sslcontext;
-//
-//        } catch (GeneralSecurityException gse) {
-//            log.error("Unable to create SSL context with the given configuration", gse);
-//            throw new AxisFault("Unable to create SSL context with the given configuration", gse);
-//        }
-//    }
-//
-//    /**
-//     * Create the SSLIOSessionHandler to initialize the host name verification at the following
-//     * levels, through an Axis2 transport configuration parameter as follows:
-//     * HostnameVerifier - Default, DefaultAndLocalhost, Strict, AllowAll
-//     *
-//     * @param transportOut the Axis2 transport configuration
-//     * @return the SSLIOSessionHandler to be used
-//     * @throws AxisFault if a configuration error occurs
-//     */
-//    protected SSLIOSessionHandler getSSLIOSessionHandler(TransportOutDescription transportOut) throws AxisFault {
-//
-//        final Parameter hostnameVerifier = transportOut.getParameter("HostnameVerifier");
-//
-//        return new SSLIOSessionHandler() {
-//
-//            public void initalize(SSLEngine sslengine, HttpParams params) {
-//            }
-//
-//            public void verify(SocketAddress remoteAddress, SSLSession session)
-//                throws SSLException {
-//
-//                String address = null;
-//                if (remoteAddress instanceof InetSocketAddress) {
-//                    address = ((InetSocketAddress) remoteAddress).getHostName();
-//                } else {
-//                    address = remoteAddress.toString();
-//                }
-//
-//                boolean valid = false;
-//                if (hostnameVerifier != null) {
-//                    if ("Strict".equals(hostnameVerifier.getValue())) {
-//                        valid = HostnameVerifier.STRICT.verify(address, session);
-//                    } else if ("AllowAll".equals(hostnameVerifier.getValue())) {
-//                        valid = HostnameVerifier.ALLOW_ALL.verify(address, session);
-//                    } else if ("DefaultAndLocalhost".equals(hostnameVerifier.getValue())) {
-//                        valid = HostnameVerifier.DEFAULT_AND_LOCALHOST.verify(address, session);
-//                    }
-//                } else {
-//                    valid = HostnameVerifier.DEFAULT.verify(address, session);
-//                }
-//
-//                if (!valid) {
-//                    throw new SSLException("Host name verification failed for host : " + address);
-//                }
-//            }
-//        };
-//    }
-//}
+
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.axis2.transport.nhttp;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+import org.apache.http.params.HttpParams;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axiom.om.OMElement;
+
+import javax.net.ssl.*;
+import javax.xml.namespace.QName;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.net.URL;
+import java.net.SocketAddress;
+import java.net.InetSocketAddress;
+import java.io.IOException;
+
+public class HttpCoreNIOSSLSender extends HttpCoreNIOSender{
+
+    private static final Log log = LogFactory.getLog(HttpCoreNIOSSLSender.class);
+
+    protected IOEventDispatch getEventDispatch(
+        NHttpClientHandler handler, SSLContext sslContext,
+        SSLIOSessionHandler sslIOSessionHandler, HttpParams params) {
+        return new SSLClientIOEventDispatch(handler, sslContext, sslIOSessionHandler, params);
+    }
+
+    /*
+     *
+     * Create the SSLContext to be used by this listener
+     * @param transportOut the Axis2 transport configuration
+     * @return the SSLContext to be used
+     */
+
+    protected SSLContext getSSLContext(TransportOutDescription transportOut) throws AxisFault {
+
+        KeyManager[] keymanagers  = null;
+        TrustManager[] trustManagers = null;
+
+        Parameter keyParam    = transportOut.getParameter("keystore");
+        Parameter trustParam  = transportOut.getParameter("truststore");
+
+        if (keyParam != null) {
+            OMElement ksEle      = keyParam.getParameterElement().getFirstElement();
+            String location      = ksEle.getFirstChildWithName(new QName("Location")).getText();
+            String type          = ksEle.getFirstChildWithName(new QName("Type")).getText();
+            String storePassword = ksEle.getFirstChildWithName(new QName("Password")).getText();
+            String keyPassword   = ksEle.getFirstChildWithName(new QName("KeyPassword")).getText();
+
+            try {
+                KeyStore keyStore = KeyStore.getInstance(type);
+                URL url = getClass().getClassLoader().getResource(location);
+                log.debug("Loading Key Store from URL : " + url);
+
+                keyStore.load(url.openStream(), storePassword.toCharArray());
+                KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
+                    KeyManagerFactory.getDefaultAlgorithm());
+                kmfactory.init(keyStore, keyPassword.toCharArray());
+                keymanagers = kmfactory.getKeyManagers();
+
+            } catch (GeneralSecurityException gse) {
+                log.error("Error loading Key store : " + location, gse);
+                throw new AxisFault("Error loading Key store : " + location, gse);
+            } catch (IOException ioe) {
+                log.error("Error opening Key store : " + location, ioe);
+                throw new AxisFault("Error opening Key store : " + location, ioe);
+            }
+        }
+
+        if (trustParam != null) {
+            OMElement tsEle      = trustParam.getParameterElement().getFirstElement();
+            String location      = tsEle.getFirstChildWithName(new QName("Location")).getText();
+            String type          = tsEle.getFirstChildWithName(new QName("Type")).getText();
+            String storePassword = tsEle.getFirstChildWithName(new QName("Password")).getText();
+
+            try {
+                KeyStore trustStore = KeyStore.getInstance(type);
+                URL url = getClass().getClassLoader().getResource(location);
+                log.debug("Loading Trust Key Store from URL : " + url);
+
+                trustStore.load(url.openStream(), storePassword.toCharArray());
+                TrustManagerFactory trustManagerfactory = TrustManagerFactory.getInstance(
+                    TrustManagerFactory.getDefaultAlgorithm());
+                trustManagerfactory.init(trustStore);
+                trustManagers = trustManagerfactory.getTrustManagers();
+
+            } catch (GeneralSecurityException gse) {
+                log.error("Error loading Key store : " + location, gse);
+                throw new AxisFault("Error loading Key store : " + location, gse);
+            } catch (IOException ioe) {
+                log.error("Error opening Key store : " + location, ioe);
+                throw new AxisFault("Error opening Key store : " + location, ioe);
+            }
+        }
+
+        try {
+            SSLContext sslcontext = SSLContext.getInstance("TLS");
+            sslcontext.init(keymanagers, trustManagers, null);
+            return sslcontext;
+
+        } catch (GeneralSecurityException gse) {
+            log.error("Unable to create SSL context with the given configuration", gse);
+            throw new AxisFault("Unable to create SSL context with the given configuration", gse);
+        }
+    }
+
+    /*
+     *
+     * Create the SSLIOSessionHandler to initialize the host name verification at the following
+     * levels, through an Axis2 transport configuration parameter as follows:
+     * HostnameVerifier - Default, DefaultAndLocalhost, Strict, AllowAll
+     *
+     * @param transportOut the Axis2 transport configuration
+     * @return the SSLIOSessionHandler to be used
+     * @throws AxisFault if a configuration error occurs
+     */
+
+    protected SSLIOSessionHandler getSSLIOSessionHandler(TransportOutDescription transportOut) throws AxisFault {
+
+        final Parameter hostnameVerifier = transportOut.getParameter("HostnameVerifier");
+
+        return new SSLIOSessionHandler() {
+
+            public void initalize(SSLEngine sslengine, HttpParams params) {
+            }
+
+            public void verify(SocketAddress remoteAddress, SSLSession session)
+                throws SSLException {
+
+                String address = null;
+                if (remoteAddress instanceof InetSocketAddress) {
+                    address = ((InetSocketAddress) remoteAddress).getHostName();
+                } else {
+                    address = remoteAddress.toString();
+                }
+
+                boolean valid = false;
+                if (hostnameVerifier != null) {
+                    if ("Strict".equals(hostnameVerifier.getValue())) {
+                        valid = HostnameVerifier.STRICT.verify(address, session);
+                    } else if ("AllowAll".equals(hostnameVerifier.getValue())) {
+                        valid = HostnameVerifier.ALLOW_ALL.verify(address, session);
+                    } else if ("DefaultAndLocalhost".equals(hostnameVerifier.getValue())) {
+                        valid = HostnameVerifier.DEFAULT_AND_LOCALHOST.verify(address, session);
+                    }
+                } else {
+                    valid = HostnameVerifier.DEFAULT.verify(address, session);
+                }
+
+                if (!valid) {
+                    throw new SSLException("Host name verification failed for host : " + address);
+                }
+            }
+        };
+    }
+}
+

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLClientIOEventDispatch.java Thu Jun 21 11:50:22 2007
@@ -1,157 +1,157 @@
-///*
-// *  Licensed to the Apache Software Foundation (ASF) under one
-// *  or more contributor license agreements.  See the NOTICE file
-// *  distributed with this work for additional information
-// *  regarding copyright ownership.  The ASF licenses this file
-// *  to you under the Apache License, Version 2.0 (the
-// *  "License"); you may not use this file except in compliance
-// *  with the License.  You may obtain a copy of the License at
-// *
-// *   http://www.apache.org/licenses/LICENSE-2.0
-// *
-// *  Unless required by applicable law or agreed to in writing,
-// *  software distributed under the License is distributed on an
-// *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// *  KIND, either express or implied.  See the License for the
-// *  specific language governing permissions and limitations
-// *  under the License.
-// */
-//package org.apache.axis2.transport.nhttp;
-//
-//import java.io.IOException;
-//
-//import javax.net.ssl.SSLContext;
-//import javax.net.ssl.SSLException;
-//
-//import org.apache.http.impl.DefaultHttpResponseFactory;
-//import org.apache.http.impl.nio.DefaultNHttpClientConnection;
-//import org.apache.http.impl.nio.reactor.SSLIOSession;
-//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
-//import org.apache.http.impl.nio.reactor.SSLMode;
-//import org.apache.http.nio.NHttpClientHandler;
-//import org.apache.http.nio.reactor.IOEventDispatch;
-//import org.apache.http.nio.reactor.IOSession;
-//import org.apache.http.params.HttpParams;
-//
-//public class SSLClientIOEventDispatch implements IOEventDispatch {
-//
-//    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
-//    private static final String SSL_SESSION = "SYNAPSE.SSL_SESSION";
-//
-//    private final NHttpClientHandler handler;
-//    private final HttpParams params;
-//    private final SSLContext sslcontext;
-//    private final SSLIOSessionHandler sslHandler;
-//
-//    public SSLClientIOEventDispatch(
-//            final NHttpClientHandler handler,
-//            final SSLContext sslcontext,
-//            final SSLIOSessionHandler sslHandler,
-//            final HttpParams params) {
-//        super();
-//        if (handler == null) {
-//            throw new IllegalArgumentException("HTTP client handler may not be null");
-//        }
-//        if (sslcontext == null) {
-//            throw new IllegalArgumentException("SSL context may not be null");
-//        }
-//        if (params == null) {
-//            throw new IllegalArgumentException("HTTP parameters may not be null");
-//        }
-//        this.handler = new LoggingNHttpClientHandler(handler);
-//        this.params = params;
-//        this.sslcontext = sslcontext;
-//        this.sslHandler = sslHandler;
-//    }
-//
-//    public SSLClientIOEventDispatch(
-//            final NHttpClientHandler handler,
-//            final SSLContext sslcontext,
-//            final HttpParams params) {
-//        this(handler, sslcontext, null, params);
-//    }
-//
-//    public void connected(final IOSession session) {
-//
-//        SSLIOSession sslSession = new SSLIOSession(
-//                session,
-//                this.sslcontext,
-//                this.sslHandler);
-//
-//        DefaultNHttpClientConnection conn = new DefaultNHttpClientConnection(
-//                new LoggingIOSession(sslSession),
-//                new DefaultHttpResponseFactory(),
-//                this.params);
-//
-//        session.setAttribute(NHTTP_CONN, conn);
-//        session.setAttribute(SSL_SESSION, sslSession);
-//
-//        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
-//        this.handler.connected(conn, attachment);
-//
-//        try {
-//            sslSession.initialize(SSLMode.CLIENT, this.params);
-//        } catch (SSLException ex) {
-//            this.handler.exception(conn, ex);
-//            sslSession.shutdown();
-//        }
-//    }
-//
-//    public void disconnected(final IOSession session) {
-//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
-//                NHTTP_CONN);
-//
-//        this.handler.closed(conn);
-//    }
-//
-//    public void inputReady(final IOSession session) {
-//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
-//                SSL_SESSION);
-//        try {
-//            synchronized (sslSession) {
-//                while (sslSession.isAppInputReady()) {
-//                    conn.consumeInput(this.handler);
-//                }
-//                sslSession.inboundTransport();
-//            }
-//        } catch (IOException ex) {
-//            this.handler.exception(conn, ex);
-//            sslSession.shutdown();
-//        }
-//    }
-//
-//    public void outputReady(final IOSession session) {
-//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
-//                SSL_SESSION);
-//        try {
-//            synchronized (sslSession) {
-//                if (sslSession.isAppOutputReady()) {
-//                    conn.produceOutput(this.handler);
-//                }
-//                sslSession.outboundTransport();
-//            }
-//        } catch (IOException ex) {
-//            this.handler.exception(conn, ex);
-//            sslSession.shutdown();
-//        }
-//    }
-//
-//    public void timeout(final IOSession session) {
-//        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
-//                SSL_SESSION);
-//        this.handler.timeout(conn);
-//        synchronized (sslSession) {
-//            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
-//                // The session failed to terminate cleanly
-//                sslSession.shutdown();
-//            }
-//        }
-//    }
-//
-//}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.axis2.transport.nhttp;
+
+import java.io.IOException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.reactor.SSLIOSession;
+import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+import org.apache.http.impl.nio.reactor.SSLMode;
+import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.params.HttpParams;
+
+public class SSLClientIOEventDispatch implements IOEventDispatch {
+
+    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
+    private static final String SSL_SESSION = "SYNAPSE.SSL_SESSION";
+
+    private final NHttpClientHandler handler;
+    private final HttpParams params;
+    private final SSLContext sslcontext;
+    private final SSLIOSessionHandler sslHandler;
+
+    public SSLClientIOEventDispatch(
+            final NHttpClientHandler handler,
+            final SSLContext sslcontext,
+            final SSLIOSessionHandler sslHandler,
+            final HttpParams params) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP client handler may not be null");
+        }
+        if (sslcontext == null) {
+            throw new IllegalArgumentException("SSL context may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        this.handler = new LoggingNHttpClientHandler(handler);
+        this.params = params;
+        this.sslcontext = sslcontext;
+        this.sslHandler = sslHandler;
+    }
+
+    public SSLClientIOEventDispatch(
+            final NHttpClientHandler handler,
+            final SSLContext sslcontext,
+            final HttpParams params) {
+        this(handler, sslcontext, null, params);
+    }
+
+    public void connected(final IOSession session) {
+
+        SSLIOSession sslSession = new SSLIOSession(
+                session,
+                this.sslcontext,
+                this.sslHandler);
+
+        DefaultNHttpClientConnection conn = new DefaultNHttpClientConnection(
+                new LoggingIOSession(sslSession),
+                new DefaultHttpResponseFactory(),
+                this.params);
+
+        session.setAttribute(NHTTP_CONN, conn);
+        session.setAttribute(SSL_SESSION, sslSession);
+
+        Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
+        this.handler.connected(conn, attachment);
+
+        try {
+            sslSession.initialize(SSLMode.CLIENT, this.params);
+        } catch (SSLException ex) {
+            this.handler.exception(conn, ex);
+            sslSession.shutdown();
+        }
+    }
+
+    public void disconnected(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+
+        this.handler.closed(conn);
+    }
+
+    public void inputReady(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+                SSL_SESSION);
+        try {
+            synchronized (sslSession) {
+                while (sslSession.isAppInputReady()) {
+                    conn.consumeInput(this.handler);
+                }
+                sslSession.inboundTransport();
+            }
+        } catch (IOException ex) {
+            this.handler.exception(conn, ex);
+            sslSession.shutdown();
+        }
+    }
+
+    public void outputReady(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+                SSL_SESSION);
+        try {
+            synchronized (sslSession) {
+                if (sslSession.isAppOutputReady()) {
+                    conn.produceOutput(this.handler);
+                }
+                sslSession.outboundTransport();
+            }
+        } catch (IOException ex) {
+            this.handler.exception(conn, ex);
+            sslSession.shutdown();
+        }
+    }
+
+    public void timeout(final IOSession session) {
+        DefaultNHttpClientConnection conn = (DefaultNHttpClientConnection) session.getAttribute(
+                NHTTP_CONN);
+        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+                SSL_SESSION);
+        this.handler.timeout(conn);
+        synchronized (sslSession) {
+            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
+                // The session failed to terminate cleanly
+                sslSession.shutdown();
+            }
+        }
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/nhttp/SSLServerIOEventDispatch.java Thu Jun 21 11:50:22 2007
@@ -1,155 +1,155 @@
-///*
-// *  Licensed to the Apache Software Foundation (ASF) under one
-// *  or more contributor license agreements.  See the NOTICE file
-// *  distributed with this work for additional information
-// *  regarding copyright ownership.  The ASF licenses this file
-// *  to you under the Apache License, Version 2.0 (the
-// *  "License"); you may not use this file except in compliance
-// *  with the License.  You may obtain a copy of the License at
-// *
-// *   http://www.apache.org/licenses/LICENSE-2.0
-// *
-// *  Unless required by applicable law or agreed to in writing,
-// *  software distributed under the License is distributed on an
-// *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// *  KIND, either express or implied.  See the License for the
-// *  specific language governing permissions and limitations
-// *  under the License.
-// */
-//package org.apache.axis2.transport.nhttp;
-//
-//import java.io.IOException;
-//
-//import javax.net.ssl.SSLContext;
-//import javax.net.ssl.SSLException;
-//
-//import org.apache.http.impl.DefaultHttpRequestFactory;
-//import org.apache.http.impl.nio.DefaultNHttpServerConnection;
-//import org.apache.http.impl.nio.reactor.SSLIOSession;
-//import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
-//import org.apache.http.impl.nio.reactor.SSLMode;
-//import org.apache.http.nio.NHttpServiceHandler;
-//import org.apache.http.nio.reactor.IOEventDispatch;
-//import org.apache.http.nio.reactor.IOSession;
-//import org.apache.http.params.HttpParams;
-//
-//public class SSLServerIOEventDispatch implements IOEventDispatch {
-//
-//    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
-//    private static final String SSL_SESSION = "SYNAPSE.SSL_SESSION";
-//
-//    private final NHttpServiceHandler handler;
-//    private final SSLContext sslcontext;
-//    private final SSLIOSessionHandler sslHandler;
-//    private final HttpParams params;
-//
-//    public SSLServerIOEventDispatch(
-//            final NHttpServiceHandler handler,
-//            final SSLContext sslcontext,
-//            final SSLIOSessionHandler sslHandler,
-//            final HttpParams params) {
-//        super();
-//        if (handler == null) {
-//            throw new IllegalArgumentException("HTTP service handler may not be null");
-//        }
-//        if (sslcontext == null) {
-//            throw new IllegalArgumentException("SSL context may not be null");
-//        }
-//        if (params == null) {
-//            throw new IllegalArgumentException("HTTP parameters may not be null");
-//        }
-//        this.handler = new LoggingNHttpServiceHandler(handler);
-//        this.params = params;
-//        this.sslcontext = sslcontext;
-//        this.sslHandler = sslHandler;
-//    }
-//
-//    public SSLServerIOEventDispatch(
-//            final NHttpServiceHandler handler,
-//            final SSLContext sslcontext,
-//            final HttpParams params) {
-//        this(handler, sslcontext, null, params);
-//    }
-//
-//    public void connected(final IOSession session) {
-//
-//        SSLIOSession sslSession = new SSLIOSession(
-//                session,
-//                this.sslcontext,
-//                this.sslHandler);
-//
-//        DefaultNHttpServerConnection conn = new DefaultNHttpServerConnection(
-//                new LoggingIOSession(sslSession),
-//                new DefaultHttpRequestFactory(),
-//                this.params);
-//
-//        session.setAttribute(NHTTP_CONN, conn);
-//        session.setAttribute(SSL_SESSION, sslSession);
-//
-//        this.handler.connected(conn);
-//
-//        try {
-//            sslSession.initialize(SSLMode.SERVER, this.params);
-//        } catch (SSLException ex) {
-//            this.handler.exception(conn, ex);
-//            sslSession.shutdown();
-//        }
-//    }
-//
-//    public void disconnected(final IOSession session) {
-//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        this.handler.closed(conn);
-//    }
-//
-//    public void inputReady(final IOSession session) {
-//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
-//                SSL_SESSION);
-//        try {
-//            synchronized (sslSession) {
-//                if (sslSession.isAppInputReady()) {
-//                    conn.consumeInput(this.handler);
-//                }
-//                sslSession.inboundTransport();
-//            }
-//        } catch (IOException ex) {
-//            this.handler.exception(conn, ex);
-//            sslSession.shutdown();
-//        }
-//    }
-//
-//    public void outputReady(final IOSession session) {
-//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
-//                SSL_SESSION);
-//        try {
-//            synchronized (sslSession) {
-//                if (sslSession.isAppOutputReady()) {
-//                    conn.produceOutput(this.handler);
-//                }
-//                sslSession.outboundTransport();
-//            }
-//        } catch (IOException ex) {
-//            this.handler.exception(conn, ex);
-//            sslSession.shutdown();
-//        }
-//    }
-//
-//    public void timeout(final IOSession session) {
-//        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
-//                NHTTP_CONN);
-//        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
-//                SSL_SESSION);
-//        this.handler.timeout(conn);
-//        synchronized (sslSession) {
-//            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
-//                // The session failed to terminate cleanly
-//                sslSession.shutdown();
-//            }
-//        }
-//    }
-//
-//}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.axis2.transport.nhttp;
+
+import java.io.IOException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+
+import org.apache.http.impl.DefaultHttpRequestFactory;
+import org.apache.http.impl.nio.DefaultNHttpServerConnection;
+import org.apache.http.impl.nio.reactor.SSLIOSession;
+import org.apache.http.impl.nio.reactor.SSLIOSessionHandler;
+import org.apache.http.impl.nio.reactor.SSLMode;
+import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.params.HttpParams;
+
+public class SSLServerIOEventDispatch implements IOEventDispatch {
+
+    private static final String NHTTP_CONN = "SYNAPSE.NHTTP_CONN";
+    private static final String SSL_SESSION = "SYNAPSE.SSL_SESSION";
+
+    private final NHttpServiceHandler handler;
+    private final SSLContext sslcontext;
+    private final SSLIOSessionHandler sslHandler;
+    private final HttpParams params;
+
+    public SSLServerIOEventDispatch(
+            final NHttpServiceHandler handler,
+            final SSLContext sslcontext,
+            final SSLIOSessionHandler sslHandler,
+            final HttpParams params) {
+        super();
+        if (handler == null) {
+            throw new IllegalArgumentException("HTTP service handler may not be null");
+        }
+        if (sslcontext == null) {
+            throw new IllegalArgumentException("SSL context may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        this.handler = new LoggingNHttpServiceHandler(handler);
+        this.params = params;
+        this.sslcontext = sslcontext;
+        this.sslHandler = sslHandler;
+    }
+
+    public SSLServerIOEventDispatch(
+            final NHttpServiceHandler handler,
+            final SSLContext sslcontext,
+            final HttpParams params) {
+        this(handler, sslcontext, null, params);
+    }
+
+    public void connected(final IOSession session) {
+
+        SSLIOSession sslSession = new SSLIOSession(
+                session,
+                this.sslcontext,
+                this.sslHandler);
+
+        DefaultNHttpServerConnection conn = new DefaultNHttpServerConnection(
+                new LoggingIOSession(sslSession),
+                new DefaultHttpRequestFactory(),
+                this.params);
+
+        session.setAttribute(NHTTP_CONN, conn);
+        session.setAttribute(SSL_SESSION, sslSession);
+
+        this.handler.connected(conn);
+
+        try {
+            sslSession.initialize(SSLMode.SERVER, this.params);
+        } catch (SSLException ex) {
+            this.handler.exception(conn, ex);
+            sslSession.shutdown();
+        }
+    }
+
+    public void disconnected(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        this.handler.closed(conn);
+    }
+
+    public void inputReady(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+                SSL_SESSION);
+        try {
+            synchronized (sslSession) {
+                if (sslSession.isAppInputReady()) {
+                    conn.consumeInput(this.handler);
+                }
+                sslSession.inboundTransport();
+            }
+        } catch (IOException ex) {
+            this.handler.exception(conn, ex);
+            sslSession.shutdown();
+        }
+    }
+
+    public void outputReady(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+                SSL_SESSION);
+        try {
+            synchronized (sslSession) {
+                if (sslSession.isAppOutputReady()) {
+                    conn.produceOutput(this.handler);
+                }
+                sslSession.outboundTransport();
+            }
+        } catch (IOException ex) {
+            this.handler.exception(conn, ex);
+            sslSession.shutdown();
+        }
+    }
+
+    public void timeout(final IOSession session) {
+        DefaultNHttpServerConnection conn = (DefaultNHttpServerConnection) session.getAttribute(
+                NHTTP_CONN);
+        SSLIOSession sslSession = (SSLIOSession) session.getAttribute(
+                SSL_SESSION);
+        this.handler.timeout(conn);
+        synchronized (sslSession) {
+            if (sslSession.isOutboundDone() && !sslSession.isInboundDone()) {
+                // The session failed to terminate cleanly
+                sslSession.shutdown();
+            }
+        }
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/parent/pom.xml?view=diff&rev=549585&r1=549584&r2=549585
==============================================================================
--- webservices/axis2/trunk/java/modules/parent/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/parent/pom.xml Thu Jun 21 11:50:22 2007
@@ -639,11 +639,11 @@
                                 <artifactId>jakarta-httpcore-nio</artifactId>
                                 <version>${jakarta.httpcore.version}</version>
                         </dependency>
-                        <!--<dependency>
+                        <dependency>
                                 <groupId>org.apache.httpcomponents</groupId>
                                 <artifactId>jakarta-httpcore-niossl</artifactId>
                                 <version>${jakarta.httpcore.version}</version>
-                        </dependency>-->
+                        </dependency>
 			<dependency>
 				<groupId>commons-fileupload</groupId>
 				<artifactId>commons-fileupload</artifactId>



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message