You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2016/01/28 13:42:03 UTC
mina git commit: Added a public method that initiates the SSL
Handshake if the autoStart flag is set to false.
Repository: mina
Updated Branches:
refs/heads/2.0 31ccc3e98 -> 81b84d1f7
Added a public method that initiates the SSL Handshake if the autoStart
flag is set to false.
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/81b84d1f
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/81b84d1f
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/81b84d1f
Branch: refs/heads/2.0
Commit: 81b84d1f7cdc469966fed2b289e070ec34e4ff79
Parents: 31ccc3e
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Thu Jan 28 13:41:38 2016 +0100
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Thu Jan 28 13:41:38 2016 +0100
----------------------------------------------------------------------
.../org/apache/mina/filter/ssl/SslFilter.java | 24 ++++++++++++++++++++
1 file changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/81b84d1f/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java b/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
index 115ad1c..542708e 100644
--- a/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
+++ b/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
@@ -30,6 +30,7 @@ import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSession;
import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.filterchain.IoFilter;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.filterchain.IoFilterChain;
import org.apache.mina.core.future.DefaultWriteFuture;
@@ -691,6 +692,29 @@ public class SslFilter extends IoFilterAdapter {
}
}
+ /**
+ * Initiate the SSL handshake. This can be invoked if you have set the 'autoStart' to
+ * false when creating the SslFilter instance.
+ *
+ * @param session The session for which the SSL handshake should be done
+ * @throws SSLException If the handshake failed
+ */
+ public void initiateHandshake(IoSession session) throws SSLException {
+ IoFilterChain filterChain = session.getFilterChain();
+
+ if (filterChain == null) {
+ throw new SSLException("No filter chain");
+ }
+
+ IoFilter.NextFilter nextFilter = filterChain.getNextFilter(SslFilter.class);
+
+ if (nextFilter == null) {
+ throw new SSLException("No SSL next filter in the chain");
+ }
+
+ initiateHandshake(nextFilter, session);
+ }
+
private void initiateHandshake(NextFilter nextFilter, IoSession session) throws SSLException {
LOGGER.debug("{} : Starting the first handshake", getSessionInfo(session));
SslHandler sslHandler = getSslSessionHandler(session);