Skip to content

Commit

Permalink
add sslSession method (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan authored Jan 17, 2025
1 parent 03c4c40 commit abe8b7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions avaje-jex/src/main/java/io/avaje/jex/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

import javax.net.ssl.SSLSession;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;

Expand Down Expand Up @@ -444,6 +447,13 @@ default Context headers(Map<String, String> headers) {
/** Return true if the response has been sent. */
boolean responseSent();

/**
* Get the {@link SSLSession} for this exchange.
*
* @return the {@code SSLSession}
*/
SSLSession sslSession();

/**
* This interface represents a cookie used in HTTP communication. Cookies are small pieces of data
* sent from a server to a web browser and stored on the user's computer. They can be used to
Expand Down
9 changes: 9 additions & 0 deletions avaje-jex/src/main/java/io/avaje/jex/core/JdkContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
import java.util.Set;
import java.util.stream.Stream;

import javax.net.ssl.SSLSession;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpsExchange;

import io.avaje.jex.Context;
import io.avaje.jex.compression.CompressedOutputStream;
Expand Down Expand Up @@ -519,4 +522,10 @@ private static BasicAuthCredentials getBasicAuthCredentials(String authorization

return new BasicAuthCredentials(credentials[0], credentials[1]);
}

@Override
public SSLSession sslSession() {

return exchange instanceof HttpsExchange ex ? ex.getSSLSession() : null;
}
}

0 comments on commit abe8b7d

Please sign in to comment.