Home / Class/ BoringSSLSessionCallback Class — netty Architecture

BoringSSLSessionCallback Class — netty Architecture

Architecture documentation for the BoringSSLSessionCallback class in BoringSSLSessionCallback.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  94eb0a3b_5243_5bc2_d05f_6c638aba2c5d["BoringSSLSessionCallback"]
  a366e5ec_e77c_58a6_6879_6c60e7495159["BoringSSLSessionCallback.java"]
  94eb0a3b_5243_5bc2_d05f_6c638aba2c5d -->|defined in| a366e5ec_e77c_58a6_6879_6c60e7495159
  4388c269_35f6_49e2_6da8_d46724a982f6["BoringSSLSessionCallback()"]
  94eb0a3b_5243_5bc2_d05f_6c638aba2c5d -->|method| 4388c269_35f6_49e2_6da8_d46724a982f6
  2ff17fec_bf74_715c_d31e_b69b2fcd115c["newSession()"]
  94eb0a3b_5243_5bc2_d05f_6c638aba2c5d -->|method| 2ff17fec_bf74_715c_d31e_b69b2fcd115c
  542fec67_9434_e1a5_46f0_2a5cbe2252cc["toQuicheQuicSession()"]
  94eb0a3b_5243_5bc2_d05f_6c638aba2c5d -->|method| 542fec67_9434_e1a5_46f0_2a5cbe2252cc

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLSessionCallback.java lines 29–85

final class BoringSSLSessionCallback {
    private static final InternalLogger logger = InternalLoggerFactory.getInstance(BoringSSLSessionCallback.class);
    private final QuicClientSessionCache sessionCache;
    private final QuicheQuicSslEngineMap engineMap;

    BoringSSLSessionCallback(QuicheQuicSslEngineMap engineMap, @Nullable QuicClientSessionCache sessionCache) {
        this.engineMap = engineMap;
        this.sessionCache = sessionCache;
    }

    @SuppressWarnings("unused")
    void newSession(long ssl, long creationTime, long timeout, byte[] session, boolean isSingleUse,
                    byte @Nullable [] peerParams) {
        if (sessionCache == null) {
            return;
        }

        QuicheQuicSslEngine engine = engineMap.get(ssl);
        if (engine == null) {
            logger.warn("engine is null ssl: {}", ssl);
            return;
        }

        if (peerParams == null) {
            peerParams = EmptyArrays.EMPTY_BYTES;
        }
        if (logger.isDebugEnabled()) {
            logger.debug("ssl: {}, session: {}, peerParams: {}", ssl, Arrays.toString(session),
                    Arrays.toString(peerParams));
        }
        byte[] quicSession = toQuicheQuicSession(session, peerParams);
        if (quicSession != null) {
            logger.debug("save session host={}, port={}",
                    engine.getSession().getPeerHost(), engine.getSession().getPeerPort());
            sessionCache.saveSession(engine.getSession().getPeerHost(), engine.getSession().getPeerPort(),
                    TimeUnit.SECONDS.toMillis(creationTime), TimeUnit.SECONDS.toMillis(timeout),
                    quicSession, isSingleUse);
        }
    }

    // Mimic the encoding of quiche: https://github.com/cloudflare/quiche/blob/0.10.0/src/lib.rs#L1668
    private static byte @Nullable [] toQuicheQuicSession(byte @Nullable [] sslSession, byte @Nullable [] peerParams) {
        if (sslSession != null && peerParams != null) {
            try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
                 DataOutputStream dos = new DataOutputStream(bos)) {
                dos.writeLong(sslSession.length);
                dos.write(sslSession);
                dos.writeLong(peerParams.length);
                dos.write(peerParams);
                return bos.toByteArray();
            } catch (IOException e) {
                return null;
            }
        }
        return null;
    }
}

Frequently Asked Questions

What is the BoringSSLSessionCallback class?
BoringSSLSessionCallback is a class in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLSessionCallback.java.
Where is BoringSSLSessionCallback defined?
BoringSSLSessionCallback is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/BoringSSLSessionCallback.java at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free