Home / Class/ OpenSslX509KeyManagerFactory Class — netty Architecture

OpenSslX509KeyManagerFactory Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  199f8b9b_2f00_b228_eb0f_8ee3bfa49d8e["OpenSslX509KeyManagerFactory"]
  892beaa7_380c_8fb8_48c5_080b863277a3["OpenSslX509KeyManagerFactory.java"]
  199f8b9b_2f00_b228_eb0f_8ee3bfa49d8e -->|defined in| 892beaa7_380c_8fb8_48c5_080b863277a3
  6a06d42d_2c22_87c9_f396_9820170add26["OpenSslX509KeyManagerFactory()"]
  199f8b9b_2f00_b228_eb0f_8ee3bfa49d8e -->|method| 6a06d42d_2c22_87c9_f396_9820170add26
  ede60e9c_73ad_bca2_3602_024f6b5588f9["OpenSslKeyManagerFactorySpi()"]
  199f8b9b_2f00_b228_eb0f_8ee3bfa49d8e -->|method| ede60e9c_73ad_bca2_3602_024f6b5588f9
  772b9c23_b924_fd41_d8a8_608f78f3e5dc["OpenSslKeyMaterialProvider()"]
  199f8b9b_2f00_b228_eb0f_8ee3bfa49d8e -->|method| 772b9c23_b924_fd41_d8a8_608f78f3e5dc

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java lines 66–416

public final class OpenSslX509KeyManagerFactory extends KeyManagerFactory {

    private final OpenSslKeyManagerFactorySpi spi;

    public OpenSslX509KeyManagerFactory() {
        this(newOpenSslKeyManagerFactorySpi(null));
    }

    public OpenSslX509KeyManagerFactory(Provider provider) {
        this(newOpenSslKeyManagerFactorySpi(provider));
    }

    public OpenSslX509KeyManagerFactory(String algorithm, Provider provider) throws NoSuchAlgorithmException {
        this(newOpenSslKeyManagerFactorySpi(algorithm, provider));
    }

    private OpenSslX509KeyManagerFactory(OpenSslKeyManagerFactorySpi spi) {
        super(spi, spi.kmf.getProvider(), spi.kmf.getAlgorithm());
        this.spi = spi;
    }

    private static OpenSslKeyManagerFactorySpi newOpenSslKeyManagerFactorySpi(Provider provider) {
        try {
            return newOpenSslKeyManagerFactorySpi(null, provider);
        } catch (NoSuchAlgorithmException e) {
            // This should never happen as we use the default algorithm.
            throw new IllegalStateException(e);
        }
    }

    private static OpenSslKeyManagerFactorySpi newOpenSslKeyManagerFactorySpi(String algorithm, Provider provider)
            throws NoSuchAlgorithmException {
        if (algorithm == null) {
            algorithm = KeyManagerFactory.getDefaultAlgorithm();
        }
        return new OpenSslKeyManagerFactorySpi(
                provider == null ? KeyManagerFactory.getInstance(algorithm) :
                        KeyManagerFactory.getInstance(algorithm, provider));
    }

    OpenSslKeyMaterialProvider newProvider() {
        return spi.newProvider();
    }

    private static final class OpenSslKeyManagerFactorySpi extends KeyManagerFactorySpi {
        final KeyManagerFactory kmf;
        private volatile ProviderFactory providerFactory;

        OpenSslKeyManagerFactorySpi(KeyManagerFactory kmf) {
            this.kmf = ObjectUtil.checkNotNull(kmf, "kmf");
        }

        @Override
        protected synchronized void engineInit(KeyStore keyStore, char[] chars)
                throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
            if (providerFactory != null) {
                throw new KeyStoreException("Already initialized");
            }
            if (!keyStore.aliases().hasMoreElements()) {
                throw new KeyStoreException("No aliases found");
            }

            kmf.init(keyStore, chars);
            providerFactory = new ProviderFactory(ReferenceCountedOpenSslContext.chooseX509KeyManager(
                    kmf.getKeyManagers()), password(chars), Collections.list(keyStore.aliases()));
        }

        private static String password(char[] password) {
            if (password == null || password.length == 0) {
                return null;
            }
            return new String(password);
        }

        @Override
        protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
                throws InvalidAlgorithmParameterException {
            throw new InvalidAlgorithmParameterException("Not supported");
        }

        @Override

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free