OpenSslKeyMaterialProviderTest Class — netty Architecture
Architecture documentation for the OpenSslKeyMaterialProviderTest class in OpenSslKeyMaterialProviderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 014487c2_548f_89a4_daad_07995dfebf3f["OpenSslKeyMaterialProviderTest"] 78be5b3d_224e_de24_38e0_2a5d2ff82c4f["OpenSslKeyMaterialProviderTest.java"] 014487c2_548f_89a4_daad_07995dfebf3f -->|defined in| 78be5b3d_224e_de24_38e0_2a5d2ff82c4f 9a21db65_007d_c762_4bac_5ec7b95e3e2d["checkOpenSsl()"] 014487c2_548f_89a4_daad_07995dfebf3f -->|method| 9a21db65_007d_c762_4bac_5ec7b95e3e2d a6dec731_1e72_6411_5da4_15299e329566["KeyManagerFactory()"] 014487c2_548f_89a4_daad_07995dfebf3f -->|method| a6dec731_1e72_6411_5da4_15299e329566 e168e670_6981_6688_8f4a_4f06025ea28e["OpenSslKeyMaterialProvider()"] 014487c2_548f_89a4_daad_07995dfebf3f -->|method| e168e670_6981_6688_8f4a_4f06025ea28e 75526ad7_335c_2880_311b_e81041d0ffcc["assertRelease()"] 014487c2_548f_89a4_daad_07995dfebf3f -->|method| 75526ad7_335c_2880_311b_e81041d0ffcc af54c4e4_bde6_8f15_8883_fbaba42a9fc1["testChooseKeyMaterial()"] 014487c2_548f_89a4_daad_07995dfebf3f -->|method| af54c4e4_bde6_8f15_8883_fbaba42a9fc1 ae9ee12b_27b8_9225_c9e1_08cd33258ea2["testChooseOpenSslPrivateKeyMaterial()"] 014487c2_548f_89a4_daad_07995dfebf3f -->|method| ae9ee12b_27b8_9225_c9e1_08cd33258ea2
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/OpenSslKeyMaterialProviderTest.java lines 41–190
public class OpenSslKeyMaterialProviderTest {
static final String PASSWORD = "example";
static final String EXISTING_ALIAS = "1";
private static final String NON_EXISTING_ALIAS = "nonexisting";
@BeforeAll
static void checkOpenSsl() {
OpenSsl.ensureAvailability();
}
protected KeyManagerFactory newKeyManagerFactory() throws Exception {
return newKeyManagerFactory(KeyManagerFactory.getDefaultAlgorithm());
}
protected KeyManagerFactory newKeyManagerFactory(String algorithm) throws Exception {
char[] password = PASSWORD.toCharArray();
final KeyStore keystore = KeyStore.getInstance("PKCS12");
try (InputStream resourceAsStream = getClass().getResourceAsStream("mutual_auth_server.p12")) {
keystore.load(resourceAsStream, password);
KeyManagerFactory kmf =
KeyManagerFactory.getInstance(algorithm);
kmf.init(keystore, password);
return kmf;
}
}
protected OpenSslKeyMaterialProvider newMaterialProvider(KeyManagerFactory factory, String password) {
return new OpenSslKeyMaterialProvider(ReferenceCountedOpenSslContext.chooseX509KeyManager(
factory.getKeyManagers()), password);
}
protected void assertRelease(OpenSslKeyMaterial material) {
assertTrue(material.release());
}
@Test
public void testChooseKeyMaterial() throws Exception {
OpenSslKeyMaterialProvider provider = newMaterialProvider(newKeyManagerFactory(), PASSWORD);
OpenSslKeyMaterial nonExistingMaterial = provider.chooseKeyMaterial(
UnpooledByteBufAllocator.DEFAULT, NON_EXISTING_ALIAS);
assertNull(nonExistingMaterial);
OpenSslKeyMaterial material = provider.chooseKeyMaterial(UnpooledByteBufAllocator.DEFAULT, EXISTING_ALIAS);
assertNotNull(material);
assertNotEquals(0, material.certificateChainAddress());
assertNotEquals(0, material.privateKeyAddress());
assertRelease(material);
provider.destroy();
}
/**
* Test class used by testChooseOpenSslPrivateKeyMaterial().
*/
private static final class SingleKeyManager implements X509KeyManager {
private final String keyAlias;
private final PrivateKey pk;
private final X509Certificate[] certChain;
SingleKeyManager(String keyAlias, PrivateKey pk, X509Certificate[] certChain) {
this.keyAlias = keyAlias;
this.pk = pk;
this.certChain = certChain;
}
@Override
public String[] getClientAliases(String keyType, Principal[] issuers) {
return new String[]{keyAlias};
}
@Override
public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
return keyAlias;
}
@Override
public String[] getServerAliases(String keyType, Principal[] issuers) {
return new String[]{keyAlias};
}
Source
Frequently Asked Questions
What is the OpenSslKeyMaterialProviderTest class?
OpenSslKeyMaterialProviderTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/OpenSslKeyMaterialProviderTest.java.
Where is OpenSslKeyMaterialProviderTest defined?
OpenSslKeyMaterialProviderTest is defined in handler/src/test/java/io/netty/handler/ssl/OpenSslKeyMaterialProviderTest.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free