Home / Class/ SimpleTrustManagerFactory Class — netty Architecture

SimpleTrustManagerFactory Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  235fd1bc_3379_6a7f_a2ab_07bb2e526a72["SimpleTrustManagerFactory"]
  ac087f6e_c81e_e574_e150_3641f405807d["SimpleTrustManagerFactory.java"]
  235fd1bc_3379_6a7f_a2ab_07bb2e526a72 -->|defined in| ac087f6e_c81e_e574_e150_3641f405807d
  4e4bbf6f_f838_64b2_6e2d_9ee09d9563d0["SimpleTrustManagerFactory()"]
  235fd1bc_3379_6a7f_a2ab_07bb2e526a72 -->|method| 4e4bbf6f_f838_64b2_6e2d_9ee09d9563d0
  c428c2b2_102f_0914_dae9_60aa2647c1de["engineInit()"]
  235fd1bc_3379_6a7f_a2ab_07bb2e526a72 -->|method| c428c2b2_102f_0914_dae9_60aa2647c1de
  94ae5d64_2698_e85a_7f4e_c68cd41a3163["engineGetTrustManagers()"]
  235fd1bc_3379_6a7f_a2ab_07bb2e526a72 -->|method| 94ae5d64_2698_e85a_7f4e_c68cd41a3163

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/util/SimpleTrustManagerFactory.java lines 36–151

public abstract class SimpleTrustManagerFactory extends TrustManagerFactory {

    private static final Provider PROVIDER = new Provider("", 0.0, "") {
        private static final long serialVersionUID = -2680540247105807895L;
    };

    /**
     * {@link SimpleTrustManagerFactorySpi} must have a reference to {@link SimpleTrustManagerFactory}
     * to delegate its callbacks back to {@link SimpleTrustManagerFactory}.  However, it is impossible to do so,
     * because {@link TrustManagerFactory} requires {@link TrustManagerFactorySpi} at construction time and
     * does not provide a way to access it later.
     *
     * To work around this issue, we use an ugly hack which uses a {@link ThreadLocal}.
     */
    private static final FastThreadLocal<SimpleTrustManagerFactorySpi> CURRENT_SPI =
            new FastThreadLocal<SimpleTrustManagerFactorySpi>() {
                @Override
                protected SimpleTrustManagerFactorySpi initialValue() {
                    return new SimpleTrustManagerFactorySpi();
                }
            };

    /**
     * Creates a new instance.
     */
    protected SimpleTrustManagerFactory() {
        this("");
    }

    /**
     * Creates a new instance.
     *
     * @param name the name of this {@link TrustManagerFactory}
     */
    protected SimpleTrustManagerFactory(String name) {
        super(CURRENT_SPI.get(), PROVIDER, name);
        CURRENT_SPI.get().init(this);
        CURRENT_SPI.remove();

        ObjectUtil.checkNotNull(name, "name");
    }

    /**
     * Initializes this factory with a source of certificate authorities and related trust material.
     *
     * @see TrustManagerFactorySpi#engineInit(KeyStore)
     */
    protected abstract void engineInit(KeyStore keyStore) throws Exception;

    /**
     * Initializes this factory with a source of provider-specific key material.
     *
     * @see TrustManagerFactorySpi#engineInit(ManagerFactoryParameters)
     */
    protected abstract void engineInit(ManagerFactoryParameters managerFactoryParameters) throws Exception;

    /**
     * Returns one trust manager for each type of trust material.
     *
     * @see TrustManagerFactorySpi#engineGetTrustManagers()
     */
    protected abstract TrustManager[] engineGetTrustManagers();

    static final class SimpleTrustManagerFactorySpi extends TrustManagerFactorySpi {

        private SimpleTrustManagerFactory parent;
        private volatile TrustManager[] trustManagers;

        void init(SimpleTrustManagerFactory parent) {
            this.parent = parent;
        }

        @Override
        protected void engineInit(KeyStore keyStore) throws KeyStoreException {
            try {
                parent.engineInit(keyStore);
            } catch (KeyStoreException e) {
                throw e;
            } catch (Exception e) {
                throw new KeyStoreException(e);
            }

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free