Home / Class/ SslMasterKeyHandler Class — netty Architecture

SslMasterKeyHandler Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  16c3c161_9e82_cb54_67b5_0143c9e962b7["SslMasterKeyHandler"]
  5e28c5d8_22d9_e0e1_9f1b_6a0756a32405["SslMasterKeyHandler.java"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|defined in| 5e28c5d8_22d9_e0e1_9f1b_6a0756a32405
  01dd0b39_957e_8021_c5f2_b182e81cf62c["SslMasterKeyHandler()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| 01dd0b39_957e_8021_c5f2_b182e81cf62c
  a6f3afb8_a833_fd4d_fcb9_e2bee437541b["ensureSunSslEngineAvailability()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| a6f3afb8_a833_fd4d_fcb9_e2bee437541b
  f173292f_7483_42c5_9972_ff00b4977d02["Throwable()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| f173292f_7483_42c5_9972_ff00b4977d02
  e42c77d2_7605_113a_2167_f36f6b1d204f["isSunSslEngineAvailable()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| e42c77d2_7605_113a_2167_f36f6b1d204f
  da0bca2f_ce02_dc25_753d_1828ea88687e["accept()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| da0bca2f_ce02_dc25_753d_1828ea88687e
  493df280_2550_14ad_7187_54d157713b0f["userEventTriggered()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| 493df280_2550_14ad_7187_54d157713b0f
  47322b4c_7e1d_314f_5eb3_cce47f2dfd44["masterKeyHandlerEnabled()"]
  16c3c161_9e82_cb54_67b5_0143c9e962b7 -->|method| 47322b4c_7e1d_314f_5eb3_cce47f2dfd44

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/SslMasterKeyHandler.java lines 38–199

public abstract class SslMasterKeyHandler extends ChannelInboundHandlerAdapter {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(SslMasterKeyHandler.class);

    /**
     * The JRE SSLSessionImpl cannot be imported
     */
    private static final Class<?> SSL_SESSIONIMPL_CLASS;

    /**
     * The master key field in the SSLSessionImpl
     */
    private static final Field SSL_SESSIONIMPL_MASTER_SECRET_FIELD;

    /**
     * A system property that can be used to turn on/off the {@link SslMasterKeyHandler} dynamically without having
     * to edit your pipeline.
     * <code>-Dio.netty.ssl.masterKeyHandler=true</code>
     */
    public static final String SYSTEM_PROP_KEY = "io.netty.ssl.masterKeyHandler";

    /**
     * The unavailability cause of whether the private Sun implementation of SSLSessionImpl is available.
     */
    private static final Throwable UNAVAILABILITY_CAUSE;

    static {
        Throwable cause;
        Class<?> clazz = null;
        Field field = null;
        try {
            clazz = Class.forName("sun.security.ssl.SSLSessionImpl");
            field = clazz.getDeclaredField("masterSecret");
            cause = ReflectionUtil.trySetAccessible(field, true);
        } catch (Throwable e) {
            cause = e;
            if (logger.isTraceEnabled()) {
                logger.debug("sun.security.ssl.SSLSessionImpl is unavailable.", e);
            } else {
                logger.debug("sun.security.ssl.SSLSessionImpl is unavailable: {}", e.getMessage());
            }
        }
        UNAVAILABILITY_CAUSE = cause;
        SSL_SESSIONIMPL_CLASS = clazz;
        SSL_SESSIONIMPL_MASTER_SECRET_FIELD = field;
    }

    /**
     * Constructor.
    */
    protected SslMasterKeyHandler() {
    }

    /**
     * Ensure that SSLSessionImpl is available.
     * @throws UnsatisfiedLinkError if unavailable
     */
    public static void ensureSunSslEngineAvailability() {
        if (UNAVAILABILITY_CAUSE != null) {
            throw new IllegalStateException(
                    "Failed to find SSLSessionImpl on classpath", UNAVAILABILITY_CAUSE);
        }
    }

    /**
     * Returns the cause of unavailability.
     *
     * @return the cause if unavailable. {@code null} if available.
     */
    public static Throwable sunSslEngineUnavailabilityCause() {
        return UNAVAILABILITY_CAUSE;
    }

    /* Returns {@code true} if and only if sun.security.ssl.SSLSessionImpl exists in the runtime.
     */
    public static boolean isSunSslEngineAvailable() {
        return UNAVAILABILITY_CAUSE == null;
    }

    /**
     * Consume the master key for the session and the sessionId

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free