This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c63d794eb83f214862680f7c62402f32761c25bc
Author: Benoit Tellier <[email protected]>
AuthorDate: Wed Mar 23 10:24:19 2022 +0700

    JAMES-3738 Hide java details behind encryption
---
 .../james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java | 2 +-
 .../src/main/java/org/apache/james/protocols/netty/Encryption.java    | 4 ++++
 .../main/java/org/apache/james/imapserver/netty/NettyImapSession.java | 2 +-
 .../james/protocols/lib/AbstractConfigurableAsyncServerTest.java      | 4 ++--
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
index 74770856f1..30a4ac914f 100644
--- 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
+++ 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
@@ -60,6 +60,6 @@ public abstract class 
AbstractSSLAwareChannelPipelineFactory<C extends SocketCha
      * Return if the socket is using SSL/TLS
      */
     protected boolean isSSLSocket() {
-        return secure != null && secure.getContext() != null && 
!secure.isStartTLS();
+        return secure != null && secure.supportsEncryption() && 
!secure.isStartTLS();
     }
 }
diff --git 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/Encryption.java
 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/Encryption.java
index 09982d5fe6..f45bed3682 100644
--- 
a/protocols/netty/src/main/java/org/apache/james/protocols/netty/Encryption.java
+++ 
b/protocols/netty/src/main/java/org/apache/james/protocols/netty/Encryption.java
@@ -97,6 +97,10 @@ public final class Encryption {
         return starttls;
     }
 
+    public boolean supportsEncryption() {
+        return context != null;
+    }
+
     /**
      * Return the Ciphersuites that are allowed for the {@link Encryption} or
      * <code>null</code> if all should be allowed
diff --git 
a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
 
b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
index c8845ebc24..9c63406a3f 100644
--- 
a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
+++ 
b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
@@ -199,7 +199,7 @@ public class NettyImapSession implements ImapSession, 
NettyConstants {
 
     @Override
     public boolean supportStartTLS() {
-        return secure != null && secure.getContext() != null;
+        return secure != null && secure.supportsEncryption();
     }
 
     @Override
diff --git 
a/server/protocols/protocols-library/src/test/java/org/apache/james/protocols/lib/AbstractConfigurableAsyncServerTest.java
 
b/server/protocols/protocols-library/src/test/java/org/apache/james/protocols/lib/AbstractConfigurableAsyncServerTest.java
index df072ea1d7..eee4a1b6ed 100644
--- 
a/server/protocols/protocols-library/src/test/java/org/apache/james/protocols/lib/AbstractConfigurableAsyncServerTest.java
+++ 
b/server/protocols/protocols-library/src/test/java/org/apache/james/protocols/lib/AbstractConfigurableAsyncServerTest.java
@@ -203,7 +203,7 @@ class AbstractConfigurableAsyncServerTest {
         assertThat(testServer.getEncryption().isStartTLS()).isFalse();
         
assertThat(testServer.getEncryption().getEnabledCipherSuites()).isEmpty(); // 
no default constraints
         
assertThat(testServer.getEncryption().getClientAuth()).isEqualTo(ClientAuth.NONE);
-        assertThat(testServer.getEncryption().getContext()).isNotNull();
+        assertThat(testServer.getEncryption().supportsEncryption()).isTrue();
     }
 
     @Test
@@ -217,7 +217,7 @@ class AbstractConfigurableAsyncServerTest {
         assertThat(testServer.getEncryption().isStartTLS()).isTrue();
         
assertThat(testServer.getEncryption().getEnabledCipherSuites()).isEmpty(); // 
no default constraints
         
assertThat(testServer.getEncryption().getClientAuth()).isEqualTo(ClientAuth.NONE);
-        assertThat(testServer.getEncryption().getContext()).isNotNull();
+        assertThat(testServer.getEncryption().supportsEncryption()).isTrue();
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to