You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2013/09/05 12:03:20 UTC
svn commit: r1520267 -
/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java
Author: sebb
Date: Thu Sep 5 10:03:20 2013
New Revision: 1520267
URL: http://svn.apache.org/r1520267
Log:
Proxy should support alias for keyserver entry
Added helper key manager that returns the specified alias
Bugzilla Id: 55525
Added:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java (with props)
Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java?rev=1520267&view=auto
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java (added)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java Thu Sep 5 10:03:20 2013
@@ -0,0 +1,85 @@
+/*
+ * 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.proxy;
+
+import java.net.Socket;
+import java.security.Principal;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.X509KeyManager;
+
+/**
+ * X509KeyManager wrapper class which returns a spacific server alias.
+ */
+class ServerAliasKeyManager implements X509KeyManager {
+
+ private final X509KeyManager km;
+
+ private final String serverAlias;
+
+ /**
+ * Create a wrapper class that always returns the specified server alias
+ *
+ * @param km the key manager to wrap
+ * @param serverAlias the server alias which {@link #chooseServerAlias(String, Principal[], Socket)} will return
+ */
+ ServerAliasKeyManager(KeyManager km, String serverAlias) {
+ this.km = (X509KeyManager) km;
+ this.serverAlias = serverAlias;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return always returns the specified server alias
+ */
+ @Override
+ public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
+ return serverAlias;
+ }
+
+ // Remaining implementations delegate to the wrapped key manager
+
+ @Override
+ public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
+ return km.chooseClientAlias(keyType, issuers, socket);
+ }
+
+ @Override
+ public X509Certificate[] getCertificateChain(String alias) {
+ return km.getCertificateChain(alias);
+ }
+
+ @Override
+ public String[] getClientAliases(String keyType, Principal[] issuers) {
+ return km.getClientAliases(keyType, issuers);
+ }
+
+ @Override
+ public PrivateKey getPrivateKey(String alias) {
+ return km.getPrivateKey(alias);
+ }
+
+ @Override
+ public String[] getServerAliases(String keyType, Principal[] issuers) {
+ return km.getServerAliases(keyType, issuers);
+ }
+
+}
Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ServerAliasKeyManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision