Author: sebb
Date: Thu Apr 7 15:28:38 2011
New Revision: 1089913
URL: http://svn.apache.org/viewvc?rev=1089913&view=rev
Log:
SLOW_HTTPS needs an SSL Socket implementation
Added:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
(with props)
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Modified:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1089913&r1=1089912&r2=1089913&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Thu Apr 7 15:28:38 2011
@@ -93,6 +93,7 @@ import org.apache.jmeter.protocol.http.c
import org.apache.jmeter.protocol.http.util.EncoderCache;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
+import org.apache.jmeter.protocol.http.util.SlowHC4SSLSocketFactory;
import org.apache.jmeter.protocol.http.util.SlowHC4SocketFactory;
import org.apache.jmeter.testelement.property.CollectionProperty;
import org.apache.jmeter.testelement.property.PropertyIterator;
@@ -118,6 +119,16 @@ public class HTTPHC4Impl extends HTTPHCA
}
};
+ // Trust all certificates
+ private static final TrustStrategy TRUSTALL = new TrustStrategy(){
+ public boolean isTrusted(X509Certificate[] chain, String authType) {
+ return true;
+ }
+ };
+
+ // Allow all host names
+ private static final AllowAllHostnameVerifier ALLOW_ALL_HOSTNAMES = new
AllowAllHostnameVerifier();
+
// Scheme used for slow sockets. Cannot be set as a default, because must
be set on an HttpClient instance.
private static final Scheme SLOW_HTTP;
private static final Scheme SLOW_HTTPS;
@@ -148,7 +159,13 @@ public class HTTPHC4Impl extends HTTPHCA
SLOW_HTTP = null;
}
if (CPS_HTTPS > 0) {
- SLOW_HTTPS = new Scheme(PROTOCOL_HTTPS, DEFAULT_HTTPS_PORT, new
SlowHC4SocketFactory(CPS_HTTPS));
+ Scheme s = null;
+ try {
+ s = new Scheme(PROTOCOL_HTTPS, DEFAULT_HTTPS_PORT, new
SlowHC4SSLSocketFactory(CPS_HTTPS));
+ } catch (GeneralSecurityException e) {
+ log.warn("Failed to initialise SLOW_HTTPS scheme", e);
+ }
+ SLOW_HTTPS = s;
} else {
SLOW_HTTPS = null;
}
@@ -419,13 +436,8 @@ public class HTTPHC4Impl extends HTTPHCA
// Allow all hostnames and all certificates
try {
- TrustStrategy trustAll = new TrustStrategy(){
- public boolean isTrusted(X509Certificate[] chain, String
authType) {
- return true;
- }
- };
- SSLSocketFactory socketFactory = new
SSLSocketFactory(trustAll, new AllowAllHostnameVerifier());
- Scheme sch = new Scheme(PROTOCOL_HTTPS, 443, socketFactory);
+ SSLSocketFactory socketFactory = new
SSLSocketFactory(TRUSTALL, ALLOW_ALL_HOSTNAMES);
+ Scheme sch = new Scheme(PROTOCOL_HTTPS, DEFAULT_HTTPS_PORT,
socketFactory);
schemeRegistry.register(sch);
} catch (GeneralSecurityException e) {
log.warn("Failed to register trust-all socket factory", e);
Added:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java?rev=1089913&view=auto
==============================================================================
---
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
(added)
+++
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
Thu Apr 7 15:28:38 2011
@@ -0,0 +1,67 @@
+/*
+ * 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.jmeter.protocol.http.util;
+
+import java.net.Socket;
+import java.security.GeneralSecurityException;
+import java.security.cert.X509Certificate;
+
+import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.params.HttpParams;
+import org.apache.jmeter.util.SlowSocket;
+
+/**
+ * Apache HttpClient protocol factory to generate "slow" SSL sockets for
emulating dial-up modems
+ */
+
+public class SlowHC4SSLSocketFactory extends SSLSocketFactory {
+
+ private static final TrustStrategy TRUSTALL = new TrustStrategy(){
+ public boolean isTrusted(X509Certificate[] chain, String authType) {
+ return true;
+ }
+ };
+
+ private static final AllowAllHostnameVerifier ALLOW_ALL_HOSTS = new
AllowAllHostnameVerifier();
+
+ private final int CPS; // Characters per second to emulate
+
+ /**
+ * Create a factory
+ * @param cps - characters per second
+ * @throws GeneralSecurityException if there's a problem setting up the
security
+ */
+ public SlowHC4SSLSocketFactory(final int cps) throws
GeneralSecurityException {
+ super(TRUSTALL, ALLOW_ALL_HOSTS);
+ CPS = cps;
+ }
+
+ @Override
+ public Socket createSocket(final HttpParams params) {
+ return new SlowSocket(CPS);
+ }
+
+ @Override
+ public Socket createSocket() {
+ return new Socket();
+ }
+
+}
Propchange:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]