Home / Class/ OpenSslSessionContext Class — netty Architecture

OpenSslSessionContext Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  6761f03c_910d_c89a_256f_4472ec59d426["OpenSslSessionContext"]
  7712d3fa_941d_0cdf_8145_362f575a3b8b["OpenSslSessionContext.java"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|defined in| 7712d3fa_941d_0cdf_8145_362f575a3b8b
  127bf5d7_1345_cb28_9681_5dbe46fa0d36["OpenSslSessionContext()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 127bf5d7_1345_cb28_9681_5dbe46fa0d36
  78bb5275_34ea_aa68_d734_3a74e7791119["useKeyManager()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 78bb5275_34ea_aa68_d734_3a74e7791119
  0e7b2ad1_8391_017e_964c_81d90e9b6db2["setSessionCacheSize()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 0e7b2ad1_8391_017e_964c_81d90e9b6db2
  d1c46e89_fed5_2fae_0b1e_219f3a519b05["getSessionCacheSize()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| d1c46e89_fed5_2fae_0b1e_219f3a519b05
  800ea46a_bbc8_6eab_6b44_15b2bca253f9["setSessionTimeout()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 800ea46a_bbc8_6eab_6b44_15b2bca253f9
  b69ecc6b_5013_8cab_8a2d_417e27ba9cfa["getSessionTimeout()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| b69ecc6b_5013_8cab_8a2d_417e27ba9cfa
  e72746b7_59e5_a6c3_31ba_e60c0dd9b967["SSLSession()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| e72746b7_59e5_a6c3_31ba_e60c0dd9b967
  cfeaa801_1bc3_0ad6_af5e_6a92365e4706["getIds()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| cfeaa801_1bc3_0ad6_af5e_6a92365e4706
  168f6c87_ca42_17ae_cf76_9ec18a09b228["setTicketKeys()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 168f6c87_ca42_17ae_cf76_9ec18a09b228
  531dfe6a_651c_ee81_6eda_bfbd32c65401["setSessionCacheEnabled()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 531dfe6a_651c_ee81_6eda_bfbd32c65401
  53e5ae0c_d655_cef9_4d89_fdd94f2a727b["isSessionCacheEnabled()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| 53e5ae0c_d655_cef9_4d89_fdd94f2a727b
  b00a7b27_9a34_4e59_9328_088fcd508059["OpenSslSessionStats()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| b00a7b27_9a34_4e59_9328_088fcd508059
  c745da6c_dd0f_3677_66a0_5838cc345e4c["removeFromCache()"]
  6761f03c_910d_c89a_256f_4472ec59d426 -->|method| c745da6c_dd0f_3677_66a0_5838cc345e4c

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/OpenSslSessionContext.java lines 33–229

public abstract class OpenSslSessionContext implements SSLSessionContext {

    private final OpenSslSessionStats stats;

    // The OpenSslKeyMaterialProvider is not really used by the OpenSslSessionContext but only be stored here
    // to make it easier to destroy it later because the ReferenceCountedOpenSslContext will hold a reference
    // to OpenSslSessionContext.
    private final OpenSslKeyMaterialProvider provider;

    final ReferenceCountedOpenSslContext context;

    private final OpenSslSessionCache sessionCache;
    private final long mask;

    // IMPORTANT: We take the OpenSslContext and not just the long (which points the native instance) to prevent
    //            the GC to collect OpenSslContext as this would also free the pointer and so could result in a
    //            segfault when the user calls any of the methods here that try to pass the pointer down to the native
    //            level.
    OpenSslSessionContext(ReferenceCountedOpenSslContext context, OpenSslKeyMaterialProvider provider, long mask,
                          OpenSslSessionCache cache) {
        this.context = context;
        this.provider = provider;
        this.mask = mask;
        stats = new OpenSslSessionStats(context);
        sessionCache = cache;
        SSLContext.setSSLSessionCache(context.ctx, cache);
    }

    final boolean useKeyManager() {
        return provider != null;
    }

    @Override
    public void setSessionCacheSize(int size) {
        ObjectUtil.checkPositiveOrZero(size, "size");
        sessionCache.setSessionCacheSize(size);
    }

    @Override
    public int getSessionCacheSize() {
        return sessionCache.getSessionCacheSize();
    }

    @Override
    public void setSessionTimeout(int seconds) {
        ObjectUtil.checkPositiveOrZero(seconds, "seconds");

        Lock writerLock = context.ctxLock.writeLock();
        writerLock.lock();
        try {
            SSLContext.setSessionCacheTimeout(context.ctx, seconds);
            sessionCache.setSessionTimeout(seconds);
        } finally {
            writerLock.unlock();
        }
    }

    @Override
    public int getSessionTimeout() {
        return sessionCache.getSessionTimeout();
    }

    @Override
    public SSLSession getSession(byte[] bytes) {
        return sessionCache.getSession(new OpenSslSessionId(bytes));
    }

    @Override
    public Enumeration<byte[]> getIds() {
        return new Enumeration<byte[]>() {
            private final Iterator<OpenSslSessionId> ids = sessionCache.getIds().iterator();
            @Override
            public boolean hasMoreElements() {
                return ids.hasNext();
            }

            @Override
            public byte[] nextElement() {
                return ids.next().cloneBytes();
            }
        };

Frequently Asked Questions

What is the OpenSslSessionContext class?
OpenSslSessionContext is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/OpenSslSessionContext.java.
Where is OpenSslSessionContext defined?
OpenSslSessionContext is defined in handler/src/main/java/io/netty/handler/ssl/OpenSslSessionContext.java at line 33.

Analyze Your Own Codebase

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

Try Supermodel Free