You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/11/13 22:02:42 UTC
[3/8] activemq-artemis git commit: ARTEMIS-1511 Refactor AMQP
Transport for use with other test clients
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransport.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransport.java
new file mode 100644
index 0000000..b06be3e
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransport.java
@@ -0,0 +1,57 @@
+/*
+ * 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.activemq.transport.netty;
+
+import java.io.IOException;
+import java.net.URI;
+import java.security.Principal;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelFuture;
+
+/**
+ * Base for all Netty based Transports in this client.
+ */
+public interface NettyTransport {
+
+ void connect() throws IOException;
+
+ boolean isConnected();
+
+ boolean isSSL();
+
+ void close() throws IOException;
+
+ ByteBuf allocateSendBuffer(int size) throws IOException;
+
+ ChannelFuture send(ByteBuf output) throws IOException;
+
+ NettyTransportListener getTransportListener();
+
+ void setTransportListener(NettyTransportListener listener);
+
+ NettyTransportOptions getTransportOptions();
+
+ URI getRemoteLocation();
+
+ Principal getLocalPrincipal();
+
+ void setMaxFrameSize(int maxFrameSize);
+
+ int getMaxFrameSize();
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportFactory.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportFactory.java
new file mode 100644
index 0000000..5eab404
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportFactory.java
@@ -0,0 +1,82 @@
+/*
+ * 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.activemq.transport.netty;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.activemq.transport.amqp.client.util.PropertyUtil;
+
+/**
+ * Factory for creating the Netty based TCP Transport.
+ */
+public final class NettyTransportFactory {
+
+ private NettyTransportFactory() {
+ }
+
+ /**
+ * Creates an instance of the given Transport and configures it using the properties set on
+ * the given remote broker URI.
+ *
+ * @param remoteURI
+ * The URI used to connect to a remote Peer.
+ *
+ * @return a new Transport instance.
+ *
+ * @throws Exception
+ * if an error occurs while creating the Transport instance.
+ */
+ public static NettyTransport createTransport(URI remoteURI) throws Exception {
+ Map<String, String> map = PropertyUtil.parseQuery(remoteURI.getQuery());
+ Map<String, String> transportURIOptions = PropertyUtil.filterProperties(map, "transport.");
+ NettyTransportOptions transportOptions = null;
+
+ remoteURI = PropertyUtil.replaceQuery(remoteURI, map);
+
+ if (!remoteURI.getScheme().equalsIgnoreCase("ssl") && !remoteURI.getScheme().equalsIgnoreCase("wss")) {
+ transportOptions = NettyTransportOptions.INSTANCE.clone();
+ } else {
+ transportOptions = NettyTransportSslOptions.INSTANCE.clone();
+ }
+
+ Map<String, String> unused = PropertyUtil.setProperties(transportOptions, transportURIOptions);
+ if (!unused.isEmpty()) {
+ String msg = " Not all transport options could be set on the TCP based" +
+ " Transport. Check the options are spelled correctly." +
+ " Unused parameters=[" + unused + "]." +
+ " This provider instance cannot be started.";
+ throw new IllegalArgumentException(msg);
+ }
+
+ NettyTransport result = null;
+
+ String scheme = remoteURI.getScheme().toLowerCase();
+ if (scheme.startsWith("tcp") || scheme.startsWith("ssl")) {
+ result = new NettyTcpTransport(remoteURI, transportOptions);
+ } else if (scheme.startsWith("ws") || scheme.startsWith("wss")) {
+ // Check for ws subprotocol
+ if (scheme.contains("+")) {
+ transportOptions.setWsSubProtocol(scheme.substring(scheme.indexOf("+") + 1));
+ }
+ result = new NettyWSTransport(remoteURI, transportOptions);
+ } else {
+ throw new IllegalArgumentException("Invalid URI Scheme: " + remoteURI.getScheme());
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportListener.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportListener.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportListener.java
new file mode 100644
index 0000000..2921dc0
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportListener.java
@@ -0,0 +1,48 @@
+/*
+ * 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.activemq.transport.netty;
+
+import io.netty.buffer.ByteBuf;
+
+/**
+ * Listener interface that should be implemented by users of the various QpidJMS Transport
+ * classes.
+ */
+public interface NettyTransportListener {
+
+ /**
+ * Called when new incoming data has become available.
+ *
+ * @param incoming
+ * the next incoming packet of data.
+ */
+ void onData(ByteBuf incoming);
+
+ /**
+ * Called if the connection state becomes closed.
+ */
+ void onTransportClosed();
+
+ /**
+ * Called when an error occurs during normal Transport operations.
+ *
+ * @param cause
+ * the error that triggered this event.
+ */
+ void onTransportError(Throwable cause);
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportOptions.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportOptions.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportOptions.java
new file mode 100644
index 0000000..4dda889
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportOptions.java
@@ -0,0 +1,219 @@
+/*
+ * 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.activemq.transport.netty;
+
+/**
+ * Encapsulates all the TCP Transport options in one configuration object.
+ */
+public class NettyTransportOptions implements Cloneable {
+
+ public static final int DEFAULT_SEND_BUFFER_SIZE = 64 * 1024;
+ public static final int DEFAULT_RECEIVE_BUFFER_SIZE = DEFAULT_SEND_BUFFER_SIZE;
+ public static final int DEFAULT_TRAFFIC_CLASS = 0;
+ public static final boolean DEFAULT_TCP_NO_DELAY = true;
+ public static final boolean DEFAULT_TCP_KEEP_ALIVE = false;
+ public static final int DEFAULT_SO_LINGER = Integer.MIN_VALUE;
+ public static final int DEFAULT_SO_TIMEOUT = -1;
+ public static final int DEFAULT_CONNECT_TIMEOUT = 60000;
+ public static final int DEFAULT_TCP_PORT = 5672;
+ public static final boolean DEFAULT_TRACE_BYTES = false;
+ public static final String DEFAULT_WS_SUBPROTOCOL = NettyWSTransport.AMQP_SUB_PROTOCOL;
+
+ public static final NettyTransportOptions INSTANCE = new NettyTransportOptions();
+
+ private int sendBufferSize = DEFAULT_SEND_BUFFER_SIZE;
+ private int receiveBufferSize = DEFAULT_RECEIVE_BUFFER_SIZE;
+ private int trafficClass = DEFAULT_TRAFFIC_CLASS;
+ private int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
+ private int soTimeout = DEFAULT_SO_TIMEOUT;
+ private int soLinger = DEFAULT_SO_LINGER;
+ private boolean tcpKeepAlive = DEFAULT_TCP_KEEP_ALIVE;
+ private boolean tcpNoDelay = DEFAULT_TCP_NO_DELAY;
+ private int defaultTcpPort = DEFAULT_TCP_PORT;
+ private boolean traceBytes = DEFAULT_TRACE_BYTES;
+ private String wsSubProtocol = DEFAULT_WS_SUBPROTOCOL;
+
+ /**
+ * @return the currently set send buffer size in bytes.
+ */
+ public int getSendBufferSize() {
+ return sendBufferSize;
+ }
+
+ /**
+ * Sets the send buffer size in bytes, the value must be greater than zero or an
+ * {@link IllegalArgumentException} will be thrown.
+ *
+ * @param sendBufferSize
+ * the new send buffer size for the TCP Transport.
+ *
+ * @throws IllegalArgumentException
+ * if the value given is not in the valid range.
+ */
+ public void setSendBufferSize(int sendBufferSize) {
+ if (sendBufferSize <= 0) {
+ throw new IllegalArgumentException("The send buffer size must be > 0");
+ }
+
+ this.sendBufferSize = sendBufferSize;
+ }
+
+ /**
+ * @return the currently configured receive buffer size in bytes.
+ */
+ public int getReceiveBufferSize() {
+ return receiveBufferSize;
+ }
+
+ /**
+ * Sets the receive buffer size in bytes, the value must be greater than zero or an
+ * {@link IllegalArgumentException} will be thrown.
+ *
+ * @param receiveBufferSize
+ * the new receive buffer size for the TCP Transport.
+ *
+ * @throws IllegalArgumentException
+ * if the value given is not in the valid range.
+ */
+ public void setReceiveBufferSize(int receiveBufferSize) {
+ if (receiveBufferSize <= 0) {
+ throw new IllegalArgumentException("The send buffer size must be > 0");
+ }
+
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
+ /**
+ * @return the currently configured traffic class value.
+ */
+ public int getTrafficClass() {
+ return trafficClass;
+ }
+
+ /**
+ * Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.
+ *
+ * @param trafficClass
+ * the new traffic class value.
+ *
+ * @throws IllegalArgumentException
+ * if the value given is not in the valid range.
+ */
+ public void setTrafficClass(int trafficClass) {
+ if (trafficClass < 0 || trafficClass > 255) {
+ throw new IllegalArgumentException("Traffic class must be in the range [0..255]");
+ }
+
+ this.trafficClass = trafficClass;
+ }
+
+ public int getSoTimeout() {
+ return soTimeout;
+ }
+
+ public void setSoTimeout(int soTimeout) {
+ this.soTimeout = soTimeout;
+ }
+
+ public boolean isTcpNoDelay() {
+ return tcpNoDelay;
+ }
+
+ public void setTcpNoDelay(boolean tcpNoDelay) {
+ this.tcpNoDelay = tcpNoDelay;
+ }
+
+ public int getSoLinger() {
+ return soLinger;
+ }
+
+ public void setSoLinger(int soLinger) {
+ this.soLinger = soLinger;
+ }
+
+ public boolean isTcpKeepAlive() {
+ return tcpKeepAlive;
+ }
+
+ public void setTcpKeepAlive(boolean keepAlive) {
+ this.tcpKeepAlive = keepAlive;
+ }
+
+ public int getConnectTimeout() {
+ return connectTimeout;
+ }
+
+ public void setConnectTimeout(int connectTimeout) {
+ this.connectTimeout = connectTimeout;
+ }
+
+ public int getDefaultTcpPort() {
+ return defaultTcpPort;
+ }
+
+ public void setDefaultTcpPort(int defaultTcpPort) {
+ this.defaultTcpPort = defaultTcpPort;
+ }
+
+ /**
+ * @return true if the transport should enable byte tracing
+ */
+ public boolean isTraceBytes() {
+ return traceBytes;
+ }
+
+ /**
+ * Determines if the transport should add a logger for bytes in / out
+ *
+ * @param traceBytes
+ * should the transport log the bytes in and out.
+ */
+ public void setTraceBytes(boolean traceBytes) {
+ this.traceBytes = traceBytes;
+ }
+
+ public boolean isSSL() {
+ return false;
+ }
+
+ public String getWsSubProtocol() {
+ return wsSubProtocol;
+ }
+
+ public void setWsSubProtocol(String wsSubProtocol) {
+ this.wsSubProtocol = wsSubProtocol;
+ }
+
+ @Override
+ public NettyTransportOptions clone() {
+ return copyOptions(new NettyTransportOptions());
+ }
+
+ protected NettyTransportOptions copyOptions(NettyTransportOptions copy) {
+ copy.setConnectTimeout(getConnectTimeout());
+ copy.setReceiveBufferSize(getReceiveBufferSize());
+ copy.setSendBufferSize(getSendBufferSize());
+ copy.setSoLinger(getSoLinger());
+ copy.setSoTimeout(getSoTimeout());
+ copy.setTcpKeepAlive(isTcpKeepAlive());
+ copy.setTcpNoDelay(isTcpNoDelay());
+ copy.setTrafficClass(getTrafficClass());
+ copy.setWsSubProtocol(getWsSubProtocol());
+
+ return copy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSslOptions.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSslOptions.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSslOptions.java
new file mode 100644
index 0000000..c575bda
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSslOptions.java
@@ -0,0 +1,302 @@
+/*
+ * 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.activemq.transport.netty;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Holds the defined SSL options for connections that operate over a secure transport. Options
+ * are read from the environment and can be overridden by specifying them on the connection URI.
+ */
+public class NettyTransportSslOptions extends NettyTransportOptions {
+
+ public static final String DEFAULT_STORE_TYPE = "jks";
+ public static final String DEFAULT_CONTEXT_PROTOCOL = "TLS";
+ public static final boolean DEFAULT_TRUST_ALL = false;
+ public static final boolean DEFAULT_VERIFY_HOST = false;
+ public static final List<String> DEFAULT_DISABLED_PROTOCOLS = Collections.unmodifiableList(Arrays.asList(new String[] {"SSLv2Hello", "SSLv3"}));
+ public static final int DEFAULT_SSL_PORT = 5671;
+
+ public static final NettyTransportSslOptions INSTANCE = new NettyTransportSslOptions();
+
+ private String keyStoreLocation;
+ private String keyStorePassword;
+ private String trustStoreLocation;
+ private String trustStorePassword;
+ private String storeType = DEFAULT_STORE_TYPE;
+ private String[] enabledCipherSuites;
+ private String[] disabledCipherSuites;
+ private String[] enabledProtocols;
+ private String[] disabledProtocols = DEFAULT_DISABLED_PROTOCOLS.toArray(new String[0]);
+ private String contextProtocol = DEFAULT_CONTEXT_PROTOCOL;
+
+ private boolean trustAll = DEFAULT_TRUST_ALL;
+ private boolean verifyHost = DEFAULT_VERIFY_HOST;
+ private String keyAlias;
+ private int defaultSslPort = DEFAULT_SSL_PORT;
+
+ static {
+ INSTANCE.setKeyStoreLocation(System.getProperty("javax.net.ssl.keyStore"));
+ INSTANCE.setKeyStorePassword(System.getProperty("javax.net.ssl.keyStorePassword"));
+ INSTANCE.setTrustStoreLocation(System.getProperty("javax.net.ssl.trustStore"));
+ INSTANCE.setTrustStorePassword(System.getProperty("javax.net.ssl.keyStorePassword"));
+ }
+
+ /**
+ * @return the keyStoreLocation currently configured.
+ */
+ public String getKeyStoreLocation() {
+ return keyStoreLocation;
+ }
+
+ /**
+ * Sets the location on disk of the key store to use.
+ *
+ * @param keyStoreLocation
+ * the keyStoreLocation to use to create the key manager.
+ */
+ public void setKeyStoreLocation(String keyStoreLocation) {
+ this.keyStoreLocation = keyStoreLocation;
+ }
+
+ /**
+ * @return the keyStorePassword
+ */
+ public String getKeyStorePassword() {
+ return keyStorePassword;
+ }
+
+ /**
+ * @param keyStorePassword
+ * the keyStorePassword to set
+ */
+ public void setKeyStorePassword(String keyStorePassword) {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ /**
+ * @return the trustStoreLocation
+ */
+ public String getTrustStoreLocation() {
+ return trustStoreLocation;
+ }
+
+ /**
+ * @param trustStoreLocation
+ * the trustStoreLocation to set
+ */
+ public void setTrustStoreLocation(String trustStoreLocation) {
+ this.trustStoreLocation = trustStoreLocation;
+ }
+
+ /**
+ * @return the trustStorePassword
+ */
+ public String getTrustStorePassword() {
+ return trustStorePassword;
+ }
+
+ /**
+ * @param trustStorePassword
+ * the trustStorePassword to set
+ */
+ public void setTrustStorePassword(String trustStorePassword) {
+ this.trustStorePassword = trustStorePassword;
+ }
+
+ /**
+ * @return the storeType
+ */
+ public String getStoreType() {
+ return storeType;
+ }
+
+ /**
+ * @param storeType
+ * the format that the store files are encoded in.
+ */
+ public void setStoreType(String storeType) {
+ this.storeType = storeType;
+ }
+
+ /**
+ * @return the enabledCipherSuites
+ */
+ public String[] getEnabledCipherSuites() {
+ return enabledCipherSuites;
+ }
+
+ /**
+ * @param enabledCipherSuites
+ * the enabledCipherSuites to set
+ */
+ public void setEnabledCipherSuites(String[] enabledCipherSuites) {
+ this.enabledCipherSuites = enabledCipherSuites;
+ }
+
+ /**
+ * @return the disabledCipherSuites
+ */
+ public String[] getDisabledCipherSuites() {
+ return disabledCipherSuites;
+ }
+
+ /**
+ * @param disabledCipherSuites
+ * the disabledCipherSuites to set
+ */
+ public void setDisabledCipherSuites(String[] disabledCipherSuites) {
+ this.disabledCipherSuites = disabledCipherSuites;
+ }
+
+ /**
+ * @return the enabledProtocols or null if the defaults should be used
+ */
+ public String[] getEnabledProtocols() {
+ return enabledProtocols;
+ }
+
+ /**
+ * The protocols to be set as enabled.
+ *
+ * @param enabledProtocols
+ * the enabled protocols to set, or null if the defaults should be used.
+ */
+ public void setEnabledProtocols(String[] enabledProtocols) {
+ this.enabledProtocols = enabledProtocols;
+ }
+
+ /**
+ *
+ * @return the protocols to disable or null if none should be
+ */
+ public String[] getDisabledProtocols() {
+ return disabledProtocols;
+ }
+
+ /**
+ * The protocols to be disable.
+ *
+ * @param disabledProtocols
+ * the protocols to disable, or null if none should be.
+ */
+ public void setDisabledProtocols(String[] disabledProtocols) {
+ this.disabledProtocols = disabledProtocols;
+ }
+
+ /**
+ * @return the context protocol to use
+ */
+ public String getContextProtocol() {
+ return contextProtocol;
+ }
+
+ /**
+ * The protocol value to use when creating an SSLContext via
+ * SSLContext.getInstance(protocol).
+ *
+ * @param contextProtocol
+ * the context protocol to use.
+ */
+ public void setContextProtocol(String contextProtocol) {
+ this.contextProtocol = contextProtocol;
+ }
+
+ /**
+ * @return the trustAll
+ */
+ public boolean isTrustAll() {
+ return trustAll;
+ }
+
+ /**
+ * @param trustAll
+ * the trustAll to set
+ */
+ public void setTrustAll(boolean trustAll) {
+ this.trustAll = trustAll;
+ }
+
+ /**
+ * @return the verifyHost
+ */
+ public boolean isVerifyHost() {
+ return verifyHost;
+ }
+
+ /**
+ * @param verifyHost
+ * the verifyHost to set
+ */
+ public void setVerifyHost(boolean verifyHost) {
+ this.verifyHost = verifyHost;
+ }
+
+ /**
+ * @return the key alias
+ */
+ public String getKeyAlias() {
+ return keyAlias;
+ }
+
+ /**
+ * @param keyAlias
+ * the key alias to use
+ */
+ public void setKeyAlias(String keyAlias) {
+ this.keyAlias = keyAlias;
+ }
+
+ public int getDefaultSslPort() {
+ return defaultSslPort;
+ }
+
+ public void setDefaultSslPort(int defaultSslPort) {
+ this.defaultSslPort = defaultSslPort;
+ }
+
+ @Override
+ public boolean isSSL() {
+ return true;
+ }
+
+ @Override
+ public NettyTransportSslOptions clone() {
+ return copyOptions(new NettyTransportSslOptions());
+ }
+
+ protected NettyTransportSslOptions copyOptions(NettyTransportSslOptions copy) {
+ super.copyOptions(copy);
+
+ copy.setKeyStoreLocation(getKeyStoreLocation());
+ copy.setKeyStorePassword(getKeyStorePassword());
+ copy.setTrustStoreLocation(getTrustStoreLocation());
+ copy.setTrustStorePassword(getTrustStorePassword());
+ copy.setStoreType(getStoreType());
+ copy.setEnabledCipherSuites(getEnabledCipherSuites());
+ copy.setDisabledCipherSuites(getDisabledCipherSuites());
+ copy.setEnabledProtocols(getEnabledProtocols());
+ copy.setDisabledProtocols(getDisabledProtocols());
+ copy.setTrustAll(isTrustAll());
+ copy.setVerifyHost(isVerifyHost());
+ copy.setKeyAlias(getKeyAlias());
+ copy.setContextProtocol(getContextProtocol());
+ return copy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSupport.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSupport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSupport.java
new file mode 100644
index 0000000..9e0c2d7
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTransportSupport.java
@@ -0,0 +1,304 @@
+/*
+ * 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.activemq.transport.netty;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.SecureRandom;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509ExtendedKeyManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.netty.handler.ssl.SslHandler;
+
+/**
+ * Static class that provides various utility methods used by Transport implementations.
+ */
+public class NettyTransportSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NettyTransportSupport.class);
+
+ /**
+ * Creates a Netty SslHandler instance for use in Transports that require an SSL encoder /
+ * decoder.
+ *
+ * @param remote
+ * The URI of the remote peer that the SslHandler will be used against.
+ * @param options
+ * The SSL options object to build the SslHandler instance from.
+ *
+ * @return a new SslHandler that is configured from the given options.
+ *
+ * @throws Exception
+ * if an error occurs while creating the SslHandler instance.
+ */
+ public static SslHandler createSslHandler(URI remote, NettyTransportSslOptions options) throws Exception {
+ return new SslHandler(createSslEngine(remote, createSslContext(options), options));
+ }
+
+ /**
+ * Create a new SSLContext using the options specific in the given TransportSslOptions
+ * instance.
+ *
+ * @param options
+ * the configured options used to create the SSLContext.
+ *
+ * @return a new SSLContext instance.
+ *
+ * @throws Exception
+ * if an error occurs while creating the context.
+ */
+ public static SSLContext createSslContext(NettyTransportSslOptions options) throws Exception {
+ try {
+ String contextProtocol = options.getContextProtocol();
+ LOG.trace("Getting SSLContext instance using protocol: {}", contextProtocol);
+
+ SSLContext context = SSLContext.getInstance(contextProtocol);
+ KeyManager[] keyMgrs = loadKeyManagers(options);
+ TrustManager[] trustManagers = loadTrustManagers(options);
+
+ context.init(keyMgrs, trustManagers, new SecureRandom());
+ return context;
+ } catch (Exception e) {
+ LOG.error("Failed to create SSLContext: {}", e, e);
+ throw e;
+ }
+ }
+
+ /**
+ * Create a new SSLEngine instance in client mode from the given SSLContext and
+ * TransportSslOptions instances.
+ *
+ * @param context
+ * the SSLContext to use when creating the engine.
+ * @param options
+ * the TransportSslOptions to use to configure the new SSLEngine.
+ *
+ * @return a new SSLEngine instance in client mode.
+ *
+ * @throws Exception
+ * if an error occurs while creating the new SSLEngine.
+ */
+ public static SSLEngine createSslEngine(SSLContext context, NettyTransportSslOptions options) throws Exception {
+ return createSslEngine(null, context, options);
+ }
+
+ /**
+ * Create a new SSLEngine instance in client mode from the given SSLContext and
+ * TransportSslOptions instances.
+ *
+ * @param remote
+ * the URI of the remote peer that will be used to initialize the engine, may be null
+ * if none should.
+ * @param context
+ * the SSLContext to use when creating the engine.
+ * @param options
+ * the TransportSslOptions to use to configure the new SSLEngine.
+ *
+ * @return a new SSLEngine instance in client mode.
+ *
+ * @throws Exception
+ * if an error occurs while creating the new SSLEngine.
+ */
+ public static SSLEngine createSslEngine(URI remote, SSLContext context, NettyTransportSslOptions options) throws Exception {
+ SSLEngine engine = null;
+ if (remote == null) {
+ engine = context.createSSLEngine();
+ } else {
+ engine = context.createSSLEngine(remote.getHost(), remote.getPort());
+ }
+
+ engine.setEnabledProtocols(buildEnabledProtocols(engine, options));
+ engine.setEnabledCipherSuites(buildEnabledCipherSuites(engine, options));
+ engine.setUseClientMode(true);
+
+ if (options.isVerifyHost()) {
+ SSLParameters sslParameters = engine.getSSLParameters();
+ sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
+ engine.setSSLParameters(sslParameters);
+ }
+
+ return engine;
+ }
+
+ private static String[] buildEnabledProtocols(SSLEngine engine, NettyTransportSslOptions options) {
+ List<String> enabledProtocols = new ArrayList<>();
+
+ if (options.getEnabledProtocols() != null) {
+ List<String> configuredProtocols = Arrays.asList(options.getEnabledProtocols());
+ LOG.trace("Configured protocols from transport options: {}", configuredProtocols);
+ enabledProtocols.addAll(configuredProtocols);
+ } else {
+ List<String> engineProtocols = Arrays.asList(engine.getEnabledProtocols());
+ LOG.trace("Default protocols from the SSLEngine: {}", engineProtocols);
+ enabledProtocols.addAll(engineProtocols);
+ }
+
+ String[] disabledProtocols = options.getDisabledProtocols();
+ if (disabledProtocols != null) {
+ List<String> disabled = Arrays.asList(disabledProtocols);
+ LOG.trace("Disabled protocols: {}", disabled);
+ enabledProtocols.removeAll(disabled);
+ }
+
+ LOG.trace("Enabled protocols: {}", enabledProtocols);
+
+ return enabledProtocols.toArray(new String[0]);
+ }
+
+ private static String[] buildEnabledCipherSuites(SSLEngine engine, NettyTransportSslOptions options) {
+ List<String> enabledCipherSuites = new ArrayList<>();
+
+ if (options.getEnabledCipherSuites() != null) {
+ List<String> configuredCipherSuites = Arrays.asList(options.getEnabledCipherSuites());
+ LOG.trace("Configured cipher suites from transport options: {}", configuredCipherSuites);
+ enabledCipherSuites.addAll(configuredCipherSuites);
+ } else {
+ List<String> engineCipherSuites = Arrays.asList(engine.getEnabledCipherSuites());
+ LOG.trace("Default cipher suites from the SSLEngine: {}", engineCipherSuites);
+ enabledCipherSuites.addAll(engineCipherSuites);
+ }
+
+ String[] disabledCipherSuites = options.getDisabledCipherSuites();
+ if (disabledCipherSuites != null) {
+ List<String> disabled = Arrays.asList(disabledCipherSuites);
+ LOG.trace("Disabled cipher suites: {}", disabled);
+ enabledCipherSuites.removeAll(disabled);
+ }
+
+ LOG.trace("Enabled cipher suites: {}", enabledCipherSuites);
+
+ return enabledCipherSuites.toArray(new String[0]);
+ }
+
+ private static TrustManager[] loadTrustManagers(NettyTransportSslOptions options) throws Exception {
+ if (options.isTrustAll()) {
+ return new TrustManager[] {createTrustAllTrustManager()};
+ }
+
+ if (options.getTrustStoreLocation() == null) {
+ return null;
+ }
+
+ TrustManagerFactory fact = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+
+ String storeLocation = options.getTrustStoreLocation();
+ String storePassword = options.getTrustStorePassword();
+ String storeType = options.getStoreType();
+
+ LOG.trace("Attempt to load TrustStore from location {} of type {}", storeLocation, storeType);
+
+ KeyStore trustStore = loadStore(storeLocation, storePassword, storeType);
+ fact.init(trustStore);
+
+ return fact.getTrustManagers();
+ }
+
+ private static KeyManager[] loadKeyManagers(NettyTransportSslOptions options) throws Exception {
+ if (options.getKeyStoreLocation() == null) {
+ return null;
+ }
+
+ KeyManagerFactory fact = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+
+ String storeLocation = options.getKeyStoreLocation();
+ String storePassword = options.getKeyStorePassword();
+ String storeType = options.getStoreType();
+ String alias = options.getKeyAlias();
+
+ LOG.trace("Attempt to load KeyStore from location {} of type {}", storeLocation, storeType);
+
+ KeyStore keyStore = loadStore(storeLocation, storePassword, storeType);
+ fact.init(keyStore, storePassword != null ? storePassword.toCharArray() : null);
+
+ if (alias == null) {
+ return fact.getKeyManagers();
+ } else {
+ validateAlias(keyStore, alias);
+ return wrapKeyManagers(alias, fact.getKeyManagers());
+ }
+ }
+
+ private static KeyManager[] wrapKeyManagers(String alias, KeyManager[] origKeyManagers) {
+ KeyManager[] keyManagers = new KeyManager[origKeyManagers.length];
+ for (int i = 0; i < origKeyManagers.length; i++) {
+ KeyManager km = origKeyManagers[i];
+ if (km instanceof X509ExtendedKeyManager) {
+ km = new X509AliasKeyManager(alias, (X509ExtendedKeyManager) km);
+ }
+
+ keyManagers[i] = km;
+ }
+
+ return keyManagers;
+ }
+
+ private static void validateAlias(KeyStore store, String alias) throws IllegalArgumentException, KeyStoreException {
+ if (!store.containsAlias(alias)) {
+ throw new IllegalArgumentException("The alias '" + alias + "' doesn't exist in the key store");
+ }
+
+ if (!store.isKeyEntry(alias)) {
+ throw new IllegalArgumentException("The alias '" + alias + "' in the keystore doesn't represent a key entry");
+ }
+ }
+
+ private static KeyStore loadStore(String storePath, final String password, String storeType) throws Exception {
+ KeyStore store = KeyStore.getInstance(storeType);
+ try (InputStream in = new FileInputStream(new File(storePath));) {
+ store.load(in, password != null ? password.toCharArray() : null);
+ }
+
+ return store;
+ }
+
+ private static TrustManager createTrustAllTrustManager() {
+ return new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java
new file mode 100644
index 0000000..08f4816
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java
@@ -0,0 +1,172 @@
+/*
+ * 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.activemq.transport.netty;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+
+import io.netty.channel.ChannelFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.codec.http.DefaultHttpHeaders;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpClientCodec;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
+import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
+import io.netty.handler.codec.http.websocketx.ContinuationWebSocketFrame;
+import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
+import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
+import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
+import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
+import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
+import io.netty.handler.codec.http.websocketx.WebSocketFrame;
+import io.netty.handler.codec.http.websocketx.WebSocketVersion;
+
+/**
+ * Transport for communicating over WebSockets
+ */
+public class NettyWSTransport extends NettyTcpTransport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NettyWSTransport.class);
+
+ public static final String AMQP_SUB_PROTOCOL = "amqp";
+
+ /**
+ * Create a new transport instance
+ *
+ * @param remoteLocation
+ * the URI that defines the remote resource to connect to.
+ * @param options
+ * the transport options used to configure the socket connection.
+ */
+ public NettyWSTransport(URI remoteLocation, NettyTransportOptions options) {
+ this(null, remoteLocation, options);
+ }
+
+ /**
+ * Create a new transport instance
+ *
+ * @param listener
+ * the TransportListener that will receive events from this Transport.
+ * @param remoteLocation
+ * the URI that defines the remote resource to connect to.
+ * @param options
+ * the transport options used to configure the socket connection.
+ */
+ public NettyWSTransport(NettyTransportListener listener, URI remoteLocation, NettyTransportOptions options) {
+ super(listener, remoteLocation, options);
+ }
+
+ @Override
+ public ChannelFuture send(ByteBuf output) throws IOException {
+ checkConnected();
+ int length = output.readableBytes();
+ if (length == 0) {
+ return null;
+ }
+
+ LOG.trace("Attempted write of: {} bytes", length);
+
+ return channel.writeAndFlush(new BinaryWebSocketFrame(output));
+ }
+
+ @Override
+ protected ChannelInboundHandlerAdapter createChannelHandler() {
+ return new NettyWebSocketTransportHandler();
+ }
+
+ @Override
+ protected void addAdditionalHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast(new HttpClientCodec());
+ pipeline.addLast(new HttpObjectAggregator(8192));
+ }
+
+ @Override
+ protected void handleConnected(Channel channel) throws Exception {
+ LOG.trace("Channel has become active, awaiting WebSocket handshake! Channel is {}", channel);
+ }
+
+ // ----- Handle connection events -----------------------------------------//
+
+ private class NettyWebSocketTransportHandler extends NettyDefaultHandler<Object> {
+
+ private final WebSocketClientHandshaker handshaker;
+
+ NettyWebSocketTransportHandler() {
+ handshaker = WebSocketClientHandshakerFactory.newHandshaker(
+ getRemoteLocation(), WebSocketVersion.V13, options.getWsSubProtocol(),
+ true, new DefaultHttpHeaders(), getMaxFrameSize());
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext context) throws Exception {
+ handshaker.handshake(context.channel());
+
+ super.channelActive(context);
+ }
+
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, Object message) throws Exception {
+ LOG.trace("New data read: incoming: {}", message);
+
+ Channel ch = ctx.channel();
+ if (!handshaker.isHandshakeComplete()) {
+ handshaker.finishHandshake(ch, (FullHttpResponse) message);
+ LOG.trace("WebSocket Client connected! {}", ctx.channel());
+ // Now trigger super processing as we are really connected.
+ NettyWSTransport.super.handleConnected(ch);
+ return;
+ }
+
+ // We shouldn't get this since we handle the handshake previously.
+ if (message instanceof FullHttpResponse) {
+ FullHttpResponse response = (FullHttpResponse) message;
+ throw new IllegalStateException(
+ "Unexpected FullHttpResponse (getStatus=" + response.status() + ", content=" + response.content().toString(StandardCharsets.UTF_8) + ')');
+ }
+
+ WebSocketFrame frame = (WebSocketFrame) message;
+ if (frame instanceof TextWebSocketFrame) {
+ TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
+ LOG.warn("WebSocket Client received message: " + textFrame.text());
+ ctx.fireExceptionCaught(new IOException("Received invalid frame over WebSocket."));
+ } else if (frame instanceof BinaryWebSocketFrame) {
+ BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame;
+ LOG.trace("WebSocket Client received data: {} bytes", binaryFrame.content().readableBytes());
+ listener.onData(binaryFrame.content());
+ } else if (frame instanceof ContinuationWebSocketFrame) {
+ ContinuationWebSocketFrame continuationFrame = (ContinuationWebSocketFrame) frame;
+ LOG.trace("WebSocket Client received data continuation: {} bytes", continuationFrame.content().readableBytes());
+ listener.onData(continuationFrame.content());
+ } else if (frame instanceof PingWebSocketFrame) {
+ LOG.trace("WebSocket Client received ping, response with pong");
+ ch.write(new PongWebSocketFrame(frame.content()));
+ } else if (frame instanceof CloseWebSocketFrame) {
+ LOG.trace("WebSocket Client received closing");
+ ch.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/X509AliasKeyManager.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/X509AliasKeyManager.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/X509AliasKeyManager.java
new file mode 100644
index 0000000..101b348
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/X509AliasKeyManager.java
@@ -0,0 +1,86 @@
+/*
+ * 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.activemq.transport.netty;
+
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.X509ExtendedKeyManager;
+import java.net.Socket;
+import java.security.Principal;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+/**
+ * An X509ExtendedKeyManager wrapper which always chooses and only
+ * returns the given alias, and defers retrieval to the delegate
+ * key manager.
+ */
+public class X509AliasKeyManager extends X509ExtendedKeyManager {
+
+ private X509ExtendedKeyManager delegate;
+ private String alias;
+
+ public X509AliasKeyManager(String alias, X509ExtendedKeyManager delegate) throws IllegalArgumentException {
+ if (alias == null) {
+ throw new IllegalArgumentException("The given key alias must not be null.");
+ }
+
+ this.alias = alias;
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
+ return alias;
+ }
+
+ @Override
+ public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
+ return alias;
+ }
+
+ @Override
+ public X509Certificate[] getCertificateChain(String alias) {
+ return delegate.getCertificateChain(alias);
+ }
+
+ @Override
+ public String[] getClientAliases(String keyType, Principal[] issuers) {
+ return new String[]{alias};
+ }
+
+ @Override
+ public PrivateKey getPrivateKey(String alias) {
+ return delegate.getPrivateKey(alias);
+ }
+
+ @Override
+ public String[] getServerAliases(String keyType, Principal[] issuers) {
+ return new String[]{alias};
+ }
+
+ @Override
+ public String chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine) {
+ return alias;
+ }
+
+ @Override
+ public String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) {
+ return alias;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5211afdf/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyHandshakeTimeoutTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyHandshakeTimeoutTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyHandshakeTimeoutTest.java
index 3098979..ec9c995 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyHandshakeTimeoutTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyHandshakeTimeoutTest.java
@@ -25,9 +25,9 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.junit.Wait;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
-import org.apache.activemq.transport.amqp.client.transport.NettyTransport;
-import org.apache.activemq.transport.amqp.client.transport.NettyTransportFactory;
-import org.apache.activemq.transport.amqp.client.transport.NettyTransportListener;
+import org.apache.activemq.transport.netty.NettyTransport;
+import org.apache.activemq.transport.netty.NettyTransportFactory;
+import org.apache.activemq.transport.netty.NettyTransportListener;
import org.junit.Test;
import java.net.URI;