You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/12/16 21:49:14 UTC
svn commit: r1050153 [2/2] - in /httpcomponents/httpasyncclient/trunk/src:
main/java/org/apache/http/impl/nio/client/
main/java/org/apache/http/impl/nio/conn/
main/java/org/apache/http/impl/nio/pool/
main/java/org/apache/http/nio/client/ main/java/org/...
Added: httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java?rev=1050153&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java (added)
+++ httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java Thu Dec 16 20:49:14 2010
@@ -0,0 +1,63 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.nio.conn.ssl;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.http.conn.ssl.TrustStrategy;
+
+class TrustManagerDecorator implements X509TrustManager {
+
+ private final X509TrustManager trustManager;
+ private final TrustStrategy trustStrategy;
+
+ TrustManagerDecorator(final X509TrustManager trustManager, final TrustStrategy trustStrategy) {
+ super();
+ this.trustManager = trustManager;
+ this.trustStrategy = trustStrategy;
+ }
+
+ public void checkClientTrusted(
+ final X509Certificate[] chain, final String authType) throws CertificateException {
+ this.trustManager.checkClientTrusted(chain, authType);
+ }
+
+ public void checkServerTrusted(
+ final X509Certificate[] chain, final String authType) throws CertificateException {
+ if (!this.trustStrategy.isTrusted(chain, authType)) {
+ this.trustManager.checkServerTrusted(chain, authType);
+ }
+ }
+
+ public X509Certificate[] getAcceptedIssuers() {
+ return this.trustManager.getAcceptedIssuers();
+ }
+
+}
Propchange: httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpasyncclient/trunk/src/main/java/org/apache/http/nio/conn/ssl/TrustManagerDecorator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpasyncclient/trunk/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java?rev=1050153&r1=1050152&r2=1050153&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java (original)
+++ httpcomponents/httpasyncclient/trunk/src/test/java/org/apache/http/impl/nio/client/TestHttpAsync.java Thu Dec 16 20:49:14 2010
@@ -18,6 +18,8 @@ import org.apache.http.localserver.Serve
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.client.HttpAsyncClient;
+import org.apache.http.nio.conn.scheme.Scheme;
+import org.apache.http.nio.conn.scheme.SchemeRegistry;
import org.apache.http.nio.entity.NByteArrayEntity;
import org.apache.http.nio.reactor.ConnectingIOReactor;
import org.apache.http.params.CoreConnectionPNames;
@@ -52,7 +54,9 @@ public class TestHttpAsync extends Serve
.setParameter(CoreProtocolPNames.USER_AGENT, "HttpComponents/1.1");
ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(2, params);
- this.sessionManager = new PoolingClientConnectionManager(ioReactor, params);
+ SchemeRegistry schemeRegistry = new SchemeRegistry();
+ schemeRegistry.register(new Scheme("http", 80, null));
+ this.sessionManager = new PoolingClientConnectionManager(ioReactor, schemeRegistry, params);
this.httpclient = new BasicHttpAsyncClient(ioReactor, this.sessionManager, params);
}