This is an automated email from the ASF dual-hosted git repository. johnnyv pushed a commit to branch bugfix/DIRMINA1132 in repository https://gitbox.apache.org/repos/asf/mina.git
The following commit(s) were added to refs/heads/bugfix/DIRMINA1132 by this push: new 86119e3 improves engine customization 86119e3 is described below commit 86119e3c8ce9a9a2363dbe7d4d928ef42790f298 Author: Jonathan Valliere <john...@apache.org> AuthorDate: Fri Aug 6 12:29:07 2021 -0400 improves engine customization - removes #onEngineCreated and adds #createEngine. Using #createEngine allows for overrides to apply more customizations such as the InetSocketAddress and other properties earlier in the pipeline. --- .../org/apache/mina/filter/ssl2/SSL2Filter.java | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/mina-core/src/main/java/org/apache/mina/filter/ssl2/SSL2Filter.java b/mina-core/src/main/java/org/apache/mina/filter/ssl2/SSL2Filter.java index d5119ac..0b36259 100644 --- a/mina-core/src/main/java/org/apache/mina/filter/ssl2/SSL2Filter.java +++ b/mina-core/src/main/java/org/apache/mina/filter/ssl2/SSL2Filter.java @@ -213,18 +213,8 @@ public class SSL2Filter extends IoFilterAdapter { SSL2Handler x = SSL2Handler.class.cast(session.getAttribute(SSL_HANDLER)); if (x == null) { - InetSocketAddress s = InetSocketAddress.class.cast(session.getRemoteAddress()); - SSLEngine e = mContext.createSSLEngine(s.getHostString(), s.getPort()); - e.setNeedClientAuth(mNeedClientAuth); - e.setWantClientAuth(mWantClientAuth); - if (this.mEnabledCipherSuites != null) { - e.setEnabledCipherSuites(this.mEnabledCipherSuites); - } - if (this.mEnabledProtocols != null) { - e.setEnabledProtocols(this.mEnabledProtocols); - } - e.setUseClientMode(!session.isServer()); - this.onEngineCreated(session, e); + final InetSocketAddress s = InetSocketAddress.class.cast(session.getRemoteAddress()); + final SSLEngine e = this.createEngine(session, s); x = new SSL2HandlerG0(e, EXECUTOR, session); session.setAttribute(SSL_HANDLER, x); } @@ -233,13 +223,25 @@ public class SSL2Filter extends IoFilterAdapter { } /** - * Customization handler for init of the engine + * Customization handler for creating the engine * * @param session - * @param engine + * @param s + * @return an SSLEngine */ - protected void onEngineCreated(IoSession session, SSLEngine engine) { - + protected SSLEngine createEngine(IoSession session, InetSocketAddress s) { + SSLEngine e = (s != null) ? mContext.createSSLEngine(s.getHostString(), s.getPort()) + : mContext.createSSLEngine(); + e.setNeedClientAuth(mNeedClientAuth); + e.setWantClientAuth(mWantClientAuth); + if (this.mEnabledCipherSuites != null) { + e.setEnabledCipherSuites(this.mEnabledCipherSuites); + } + if (this.mEnabledProtocols != null) { + e.setEnabledProtocols(this.mEnabledProtocols); + } + e.setUseClientMode(!session.isServer()); + return e; } /**