Home / Class/ JdkAlpnSslUtils Class — netty Architecture

JdkAlpnSslUtils Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  9ce2ca62_8327_82fd_ae99_528b2f7562c1["JdkAlpnSslUtils"]
  e034bdf2_417a_0253_ca83_a3e99d786fb3["JdkAlpnSslUtils.java"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|defined in| e034bdf2_417a_0253_ca83_a3e99d786fb3
  8999cf1e_e94a_a12f_62a4_4d191f9d2e7b["JdkAlpnSslUtils()"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|method| 8999cf1e_e94a_a12f_62a4_4d191f9d2e7b
  5c4e3e58_1588_a29f_b023_55fe7f3d6357["supportsAlpn()"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|method| 5c4e3e58_1588_a29f_b023_55fe7f3d6357
  4fc1894a_a0b7_a818_81e1_b0315188377e["String()"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|method| 4fc1894a_a0b7_a818_81e1_b0315188377e
  981cc28d_23b6_7c10_859b_e115f56f6513["setApplicationProtocols()"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|method| 981cc28d_23b6_7c10_859b_e115f56f6513
  a64d5e36_df06_8777_2ab2_41776f09f77f["setHandshakeApplicationProtocolSelector()"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|method| a64d5e36_df06_8777_2ab2_41776f09f77f
  48b35cda_c6ea_55f2_3f62_b220320b886e["getHandshakeApplicationProtocolSelector()"]
  9ce2ca62_8327_82fd_ae99_528b2f7562c1 -->|method| 48b35cda_c6ea_55f2_3f62_b220320b886e

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/JdkAlpnSslUtils.java lines 32–178

final class JdkAlpnSslUtils {
    private static final InternalLogger logger = InternalLoggerFactory.getInstance(JdkAlpnSslUtils.class);
    private static final Method SET_APPLICATION_PROTOCOLS;
    private static final Method GET_APPLICATION_PROTOCOL;
    private static final Method GET_HANDSHAKE_APPLICATION_PROTOCOL;
    private static final Method SET_HANDSHAKE_APPLICATION_PROTOCOL_SELECTOR;
    private static final Method GET_HANDSHAKE_APPLICATION_PROTOCOL_SELECTOR;

    static {
        Method getHandshakeApplicationProtocol;
        Method getApplicationProtocol;
        Method setApplicationProtocols;
        Method setHandshakeApplicationProtocolSelector;
        Method getHandshakeApplicationProtocolSelector;

        try {
            SSLContext context = SSLContext.getInstance(JdkSslContext.PROTOCOL);
            context.init(null, null, null);
            SSLEngine engine = context.createSSLEngine();
            getHandshakeApplicationProtocol = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
                @Override
                public Method run() throws Exception {
                    return SSLEngine.class.getMethod("getHandshakeApplicationProtocol");
                }
            });
            getHandshakeApplicationProtocol.invoke(engine);
            getApplicationProtocol = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
                @Override
                public Method run() throws Exception {
                    return SSLEngine.class.getMethod("getApplicationProtocol");
                }
            });
            getApplicationProtocol.invoke(engine);

            setApplicationProtocols = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
                @Override
                public Method run() throws Exception {
                    return SSLParameters.class.getMethod("setApplicationProtocols", String[].class);
                }
            });
            setApplicationProtocols.invoke(engine.getSSLParameters(), new Object[]{EmptyArrays.EMPTY_STRINGS});

            setHandshakeApplicationProtocolSelector =
                    AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
                @Override
                public Method run() throws Exception {
                    return SSLEngine.class.getMethod("setHandshakeApplicationProtocolSelector", BiFunction.class);
                }
            });
            setHandshakeApplicationProtocolSelector.invoke(engine, new BiFunction<SSLEngine, List<String>, String>() {
                @Override
                public String apply(SSLEngine sslEngine, List<String> strings) {
                    return null;
                }
            });

            getHandshakeApplicationProtocolSelector =
                    AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
                @Override
                public Method run() throws Exception {
                    return SSLEngine.class.getMethod("getHandshakeApplicationProtocolSelector");
                }
            });
            getHandshakeApplicationProtocolSelector.invoke(engine);
        } catch (Throwable t) {
            int version = PlatformDependent.javaVersion();
            if (version >= 9) {
                // We only log when run on java9+ as this is expected on some earlier java8 versions
                logger.error("Unable to initialize JdkAlpnSslUtils, but the detected java version was: {}", version, t);
            }
            getHandshakeApplicationProtocol = null;
            getApplicationProtocol = null;
            setApplicationProtocols = null;
            setHandshakeApplicationProtocolSelector = null;
            getHandshakeApplicationProtocolSelector = null;
        }
        GET_HANDSHAKE_APPLICATION_PROTOCOL = getHandshakeApplicationProtocol;
        GET_APPLICATION_PROTOCOL = getApplicationProtocol;
        SET_APPLICATION_PROTOCOLS = setApplicationProtocols;
        SET_HANDSHAKE_APPLICATION_PROTOCOL_SELECTOR = setHandshakeApplicationProtocolSelector;
        GET_HANDSHAKE_APPLICATION_PROTOCOL_SELECTOR = getHandshakeApplicationProtocolSelector;

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free