Skip to content

Commit 47ff6e7

Browse files
committed
Make only the SSLSession public
1 parent 1cde8a7 commit 47ff6e7

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

src/main/java/org/java_websocket/WebSocket.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.java_websocket.exceptions.WebsocketNotConnectedException;
3636
import org.java_websocket.framing.Framedata;
3737

38-
import javax.net.ssl.SSLEngine;
38+
import javax.net.ssl.SSLSession;
3939

4040
public interface WebSocket {
4141

@@ -212,16 +212,16 @@ public interface WebSocket {
212212

213213
/**
214214
* Does this websocket use an encrypted (wss/ssl) or unencrypted (ws) connection
215-
* @return true, if the websocket does use wss and therefore has a SSLEngine
215+
* @return true, if the websocket does use wss and therefore has a SSLSession
216216
* @since 1.4.1
217217
*/
218-
boolean hasSSLEngine();
218+
boolean hasSSLSupport();
219219

220220
/**
221-
* Returns the ssl engine of websocket, if ssl/wss is used for this instance.
222-
* @return the ssl engine of this websocket instance
223-
* @throws IllegalArgumentException the underlying channel does not use ssl (use hasSSLEngine() to check)
221+
* Returns the ssl session of websocket, if ssl/wss is used for this instance.
222+
* @return the ssl session of this websocket instance
223+
* @throws IllegalArgumentException the underlying channel does not use ssl (use hasSSLSupport() to check)
224224
* @since 1.4.1
225225
*/
226-
SSLEngine getSSLEngine() throws IllegalArgumentException;
226+
SSLSession getSSLSession() throws IllegalArgumentException;
227227
}

src/main/java/org/java_websocket/WebSocketImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import org.slf4j.Logger;
5353
import org.slf4j.LoggerFactory;
5454

55-
import javax.net.ssl.SSLEngine;
55+
import javax.net.ssl.SSLSession;
5656

5757
/**
5858
* Represents one end (client or server) of a single WebSocketImpl connection.
@@ -824,16 +824,16 @@ public <T> T getAttachment() {
824824
}
825825

826826
@Override
827-
public boolean hasSSLEngine() {
827+
public boolean hasSSLSupport() {
828828
return channel instanceof ISSLChannel;
829829
}
830830

831831
@Override
832-
public SSLEngine getSSLEngine() {
833-
if (!hasSSLEngine()) {
834-
throw new IllegalArgumentException("This websocket does use ws instead of wss. No SSLEngine available.");
832+
public SSLSession getSSLSession() {
833+
if (!hasSSLSupport()) {
834+
throw new IllegalArgumentException("This websocket does use ws instead of wss. No SSLSession available.");
835835
}
836-
return ((ISSLChannel) channel).getSSLEngine();
836+
return ((ISSLChannel) channel).getSSLEngine().getSession();
837837
}
838838

839839
@Override

src/main/java/org/java_websocket/client/WebSocketClient.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141
import java.util.concurrent.TimeUnit;
4242

4343
import javax.net.SocketFactory;
44-
import javax.net.ssl.SSLContext;
45-
import javax.net.ssl.SSLEngine;
46-
import javax.net.ssl.SSLException;
47-
import javax.net.ssl.SSLSocketFactory;
44+
import javax.net.ssl.*;
4845

4946
import org.java_websocket.AbstractWebSocket;
5047
import org.java_websocket.WebSocket;
@@ -852,13 +849,13 @@ public String getResourceDescriptor() {
852849
}
853850

854851
@Override
855-
public boolean hasSSLEngine() {
856-
return engine.hasSSLEngine();
852+
public boolean hasSSLSupport() {
853+
return engine.hasSSLSupport();
857854
}
858855

859856
@Override
860-
public SSLEngine getSSLEngine() {
861-
return engine.getSSLEngine();
857+
public SSLSession getSSLSession() {
858+
return engine.getSSLSession();
862859
}
863860

864861
/**

0 commit comments

Comments
 (0)