Home / Class/ ProviderFactory Class — netty Architecture

ProviderFactory Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  9f99d495_bdaf_e403_d707_f0c4a2cbffbf["ProviderFactory"]
  892beaa7_380c_8fb8_48c5_080b863277a3["OpenSslX509KeyManagerFactory.java"]
  9f99d495_bdaf_e403_d707_f0c4a2cbffbf -->|defined in| 892beaa7_380c_8fb8_48c5_080b863277a3
  09b2e1d5_03c8_5d6b_61f1_b8b039fb9a93["ProviderFactory()"]
  9f99d495_bdaf_e403_d707_f0c4a2cbffbf -->|method| 09b2e1d5_03c8_5d6b_61f1_b8b039fb9a93
  c7bb06f0_3c3f_46f8_a011_98bc16434682["OpenSslKeyMaterialProvider()"]
  9f99d495_bdaf_e403_d707_f0c4a2cbffbf -->|method| c7bb06f0_3c3f_46f8_a011_98bc16434682

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/OpenSslX509KeyManagerFactory.java lines 163–234

        private static final class ProviderFactory {
            private final X509KeyManager keyManager;
            private final String password;
            private final Iterable<String> aliases;

            ProviderFactory(X509KeyManager keyManager, String password, Iterable<String> aliases) {
                this.keyManager = keyManager;
                this.password = password;
                this.aliases = aliases;
            }

            OpenSslKeyMaterialProvider newProvider() {
                return new OpenSslPopulatedKeyMaterialProvider(keyManager,
                        password, aliases);
            }

            /**
             * {@link OpenSslKeyMaterialProvider} implementation that pre-compute the {@link OpenSslKeyMaterial} for
             * all aliases.
             */
            private static final class OpenSslPopulatedKeyMaterialProvider extends OpenSslKeyMaterialProvider {
                private final Map<String, Object> materialMap;

                OpenSslPopulatedKeyMaterialProvider(
                        X509KeyManager keyManager, String password, Iterable<String> aliases) {
                    super(keyManager, password);
                    materialMap = new HashMap<String, Object>();
                    boolean initComplete = false;
                    try {
                        for (String alias: aliases) {
                            if (alias != null && !materialMap.containsKey(alias)) {
                                try {
                                    materialMap.put(alias, super.chooseKeyMaterial(
                                            UnpooledByteBufAllocator.DEFAULT, alias));
                                } catch (Exception e) {
                                    // Just store the exception and rethrow it when we try to choose the keymaterial
                                    // for this alias later on.
                                    materialMap.put(alias, e);
                                }
                            }
                        }
                        initComplete = true;
                    } finally {
                        if (!initComplete) {
                            destroy();
                        }
                    }
                    checkNonEmpty(materialMap, "materialMap");
                }

                @Override
                OpenSslKeyMaterial chooseKeyMaterial(ByteBufAllocator allocator, String alias) throws Exception {
                    Object value = materialMap.get(alias);
                    if (value == null) {
                        // There is no keymaterial for the requested alias, return null
                        return null;
                    }
                    if (value instanceof OpenSslKeyMaterial) {
                        return ((OpenSslKeyMaterial) value).retain();
                    }
                    throw (Exception) value;
                }

                @Override
                void destroy() {
                    for (Object material: materialMap.values()) {
                        ReferenceCountUtil.release(material);
                    }
                    materialMap.clear();
                }
            }
        }

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free