Skip to content

Commit

Permalink
Make only the SSLSession public
Browse files Browse the repository at this point in the history
  • Loading branch information
marci4 committed May 20, 2019
1 parent 1cde8a7 commit 47ff6e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/java_websocket/WebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.java_websocket.framing.Framedata;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

public interface WebSocket {

Expand Down Expand Up @@ -212,16 +212,16 @@ public interface WebSocket {

/**
* Does this websocket use an encrypted (wss/ssl) or unencrypted (ws) connection
* @return true, if the websocket does use wss and therefore has a SSLEngine
* @return true, if the websocket does use wss and therefore has a SSLSession
* @since 1.4.1
*/
boolean hasSSLEngine();
boolean hasSSLSupport();

/**
* Returns the ssl engine of websocket, if ssl/wss is used for this instance.
* @return the ssl engine of this websocket instance
* @throws IllegalArgumentException the underlying channel does not use ssl (use hasSSLEngine() to check)
* Returns the ssl session of websocket, if ssl/wss is used for this instance.
* @return the ssl session of this websocket instance
* @throws IllegalArgumentException the underlying channel does not use ssl (use hasSSLSupport() to check)
* @since 1.4.1
*/
SSLEngine getSSLEngine() throws IllegalArgumentException;
SSLSession getSSLSession() throws IllegalArgumentException;
}
12 changes: 6 additions & 6 deletions src/main/java/org/java_websocket/WebSocketImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

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

@Override
public boolean hasSSLEngine() {
public boolean hasSSLSupport() {
return channel instanceof ISSLChannel;
}

@Override
public SSLEngine getSSLEngine() {
if (!hasSSLEngine()) {
throw new IllegalArgumentException("This websocket does use ws instead of wss. No SSLEngine available.");
public SSLSession getSSLSession() {
if (!hasSSLSupport()) {
throw new IllegalArgumentException("This websocket does use ws instead of wss. No SSLSession available.");
}
return ((ISSLChannel) channel).getSSLEngine();
return ((ISSLChannel) channel).getSSLEngine().getSession();
}

@Override
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/java_websocket/client/WebSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
import java.util.concurrent.TimeUnit;

import javax.net.SocketFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.*;

import org.java_websocket.AbstractWebSocket;
import org.java_websocket.WebSocket;
Expand Down Expand Up @@ -852,13 +849,13 @@ public String getResourceDescriptor() {
}

@Override
public boolean hasSSLEngine() {
return engine.hasSSLEngine();
public boolean hasSSLSupport() {
return engine.hasSSLSupport();
}

@Override
public SSLEngine getSSLEngine() {
return engine.getSSLEngine();
public SSLSession getSSLSession() {
return engine.getSSLSession();
}

/**
Expand Down

0 comments on commit 47ff6e7

Please sign in to comment.