Top Fields Constructors Methods
io.vertx.core.net.impl

public Class KeyStoreHelper

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, java.net.Socket, java.security.KeyFactory, .KeyStore, .KeyStoreException, .NoSuchAlgorithmException, .Principal, .PrivateKey, .Security, java.security.cert.Certificate, .CertificateException, .CertificateFactory, .X509Certificate, java.security.spec.InvalidKeySpecException, .PKCS8EncodedKeySpec, java.util.ArrayList, .Arrays, .Base64, .Collection, .Collections, .Enumeration, .HashMap, .Iterator, .List, .Map, .Objects, java.util.function.BiFunction, .Supplier, java.util.regex.Matcher, .Pattern, java.util.stream.Stream, javax.naming.ldap.LdapName, .Rdn, javax.net.ssl.KeyManager, .KeyManagerFactory, .TrustManager, .TrustManagerFactory, .X509KeyManager, io.netty.util.internal.PlatformDependent, io.vertx.core.VertxException, io.vertx.core.buffer.Buffer, io.vertx.core.impl.VertxInternal, io.vertx.core.net.impl.pkcs1.PrivateKeyParser

Author
Julien Viet

Field Summary

Modifier and TypeField and Description
private final String
private static final Pattern
private static final String
public static final String
private static final Pattern
private final Map<String, KeyManagerFactory>
private final Map<String, X509KeyManager>
private final String
private final KeyStore
private final Map<String, TrustManagerFactory>
private final Map<String, KeyManagerFactory>
private final Map<String, X509KeyManager>

Constructor Summary

AccessConstructor and Description
public
KeyStoreHelper(KeyStore ks, String password, String aliasPassword)

Method Summary

Modifier and TypeMethod and Description
private static KeyStore

Returns:

keystore instance
createEmptyKeyStore
()

Creates an empty keystore.

private static KeyFactory
public X509KeyManager
getKeyMgr(String serverName)

public KeyManager[]
public KeyManagerFactory
public KeyManagerFactory
public TrustManager[]
getTrustMgr(String serverName)

public TrustManagerFactory
public TrustManager[]
public static List<String>
private char[]
keyPassword(String aliasPassword, String password)

public static KeyStore
loadCA(Stream<Buffer> certValues)

private static X509Certificate[]
loadCerts(Buffer buffer)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

public static KeyStore
loadKeyCert(List<Buffer> keyValue, List<Buffer> certValue)

public static KeyStore
loadKeyStore(String type, String provider, String password, Supplier<Buffer> value, String alias)

private static <P> List<P>
loadPems(Buffer data, BiFunction<String, byte[], Collection<P>> pemFact)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

private static PrivateKey
loadPrivateKey(Buffer keyValue)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

public KeyStore

Returns:

the store
store
()

public static KeyManagerFactory
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aliasPasswordback to summary
private final String aliasPassword
BEGIN_PATTERNback to summary
private static final Pattern BEGIN_PATTERN
DUMMY_CERT_ALIASback to summary
private static final String DUMMY_CERT_ALIAS
DUMMY_PASSWORDback to summary
public static final String DUMMY_PASSWORD
END_PATTERNback to summary
private static final Pattern END_PATTERN
mgrFactoryMapback to summary
private final Map<String, KeyManagerFactory> mgrFactoryMap
mgrMapback to summary
private final Map<String, X509KeyManager> mgrMap
passwordback to summary
private final String password
storeback to summary
private final KeyStore store
trustMgrMapback to summary
private final Map<String, TrustManagerFactory> trustMgrMap
wildcardMgrFactoryMapback to summary
private final Map<String, KeyManagerFactory> wildcardMgrFactoryMap
wildcardMgrMapback to summary
private final Map<String, X509KeyManager> wildcardMgrMap

Constructor Detail

KeyStoreHelperback to summary
public KeyStoreHelper(KeyStore ks, String password, String aliasPassword) throws Exception

Method Detail

createEmptyKeyStoreback to summary
private static KeyStore createEmptyKeyStore() throws KeyStoreException

Creates an empty keystore. The keystore uses the default keystore type set in the file 'lib/security/security.java' (located in the JRE) by the 'keystore.type' property. However, if the default is set to the 'JKS' format, the this function will instead attempt to use the newer 'PKCS12' format, if it exists. The PKCS12 format is the default format for keystores for Java >=9 and available on GraalVM. PKCS12 is an extensible, standard, and widely-supported format for storing cryptographic keys. As of JDK 8, PKCS12 keystores can store private keys, trusted public key certificates, and secret keys. The "old" default "JKS" (available since Java 1.2) can only store private keys and trusted public-key certificates, and they are based on a proprietary format that is not easily extensible to new cryptographic algorithms.

Returns:KeyStore

keystore instance

Exceptions
KeyStoreException:
if the underlying engine cannot create an instance
getECKeyFactoryback to summary
private static KeyFactory getECKeyFactory()
getKeyMgrback to summary
public X509KeyManager getKeyMgr(String serverName)
getKeyMgrback to summary
public KeyManager[] getKeyMgr() throws Exception
getKeyMgrFactoryback to summary
public KeyManagerFactory getKeyMgrFactory() throws Exception
getKeyMgrFactoryback to summary
public KeyManagerFactory getKeyMgrFactory(String serverName)
getTrustMgrback to summary
public TrustManager[] getTrustMgr(String serverName)
getTrustMgrFactoryback to summary
public TrustManagerFactory getTrustMgrFactory(VertxInternal vertx) throws Exception
getTrustMgrsback to summary
public TrustManager[] getTrustMgrs(VertxInternal vertx) throws Exception
getX509CertificateCommonNamesback to summary
public static List<String> getX509CertificateCommonNames(String dn) throws Exception
keyPasswordback to summary
private char[] keyPassword(String aliasPassword, String password)
loadCAback to summary
public static KeyStore loadCA(Stream<Buffer> certValues) throws Exception
loadCertsback to summary
private static X509Certificate[] loadCerts(Buffer buffer) throws Exception

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

loadKeyCertback to summary
public static KeyStore loadKeyCert(List<Buffer> keyValue, List<Buffer> certValue) throws Exception
loadKeyStoreback to summary
public static KeyStore loadKeyStore(String type, String provider, String password, Supplier<Buffer> value, String alias) throws Exception
loadPemsback to summary
private static <P> List<P> loadPems(Buffer data, BiFunction<String, byte[], Collection<P>> pemFact) throws IOException

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

loadPrivateKeyback to summary
private static PrivateKey loadPrivateKey(Buffer keyValue) throws Exception

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

storeback to summary
public KeyStore store()
Returns:KeyStore

the store

toKeyManagerFactoryback to summary
public static KeyManagerFactory toKeyManagerFactory(X509KeyManager mgr) throws Exception