Package org.eclipse.hono.config
Class KeyLoader
- java.lang.Object
-
- org.eclipse.hono.config.KeyLoader
-
public final class KeyLoader extends Object
A utility class for loading keys from files.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static KeyLoader
fromFiles(io.vertx.core.Vertx vertx, String keyPath, String certPath)
Creates a new loader for a key store.static KeyLoader
fromKeyStore(io.vertx.core.Vertx vertx, String keyStorePath, char[] password)
Creates a new loader for a key store.Certificate[]
getCertificateChain()
Gets the certificate chain.PrivateKey
getPrivateKey()
Gets the private key.PublicKey
getPublicKey()
Gets the public key.
-
-
-
Method Detail
-
getPrivateKey
public PrivateKey getPrivateKey()
Gets the private key.- Returns:
- The private key, may be
null
-
getCertificateChain
public Certificate[] getCertificateChain()
Gets the certificate chain.- Returns:
- The chain of
null
if no certificates have been loaded.
-
getPublicKey
public PublicKey getPublicKey()
Gets the public key.- Returns:
- The public key or
null
if not set.
-
fromKeyStore
public static KeyLoader fromKeyStore(io.vertx.core.Vertx vertx, String keyStorePath, char[] password)
Creates a new loader for a key store.- Parameters:
vertx
- The vertx instance to use for loading the key store.keyStorePath
- The absolute path to the key store to load keys from.password
- The password required for accessing the key store.- Returns:
- The loader.
- Throws:
NullPointerException
- if vertx or key store path arenull
.IllegalArgumentException
- if the key store does not exist.
-
fromFiles
public static KeyLoader fromFiles(io.vertx.core.Vertx vertx, String keyPath, String certPath)
Creates a new loader for a key store.- Parameters:
vertx
- The vertx instance to use for loading the key store.keyPath
- The absolute path to the PEM file containing the private key.certPath
- The absolute path to the PEM file containing the certificate (chain).- Returns:
- The loader.
- Throws:
NullPointerException
- if vertx isnull
.IllegalArgumentException
- if any of the files could not be loaded. Reasons might be things like missing, empty or malformed files.
-
-