Package com.heroku.sdk
Class EnvKeyStore
- java.lang.Object
-
- com.heroku.sdk.EnvKeyStore
-
public class EnvKeyStore extends Object
This class is used to create a java.security.KeyStore from environment variables.- Author:
- Joe Kutner
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EnvKeyStoreaddToDefaultTrustStore(String trustEnvVar)Create a TrustStore representation from an environment variable and add it to the default TrustStore.voidasFile(Consumer<File> c)static EnvKeyStorecreate(String trustEnvVar, String passwordEnvVar)Create a TrustStore representation from an environment variable.static EnvKeyStorecreate(String keyEnvVar, String certEnvVar, String passwordEnvVar)Create a KeyStore representation from environment variables.static EnvKeyStorecreateFromPEMStrings(String trust, String password)Create a TrustStore representation from an environment variable.static EnvKeyStorecreateFromPEMStrings(String key, String cert, String password)Create a KeyStore representation from an environment variable.static EnvKeyStorecreateWithRandomPassword(String trustEnvVar)Create a TrustStore representation from an environment variable.static EnvKeyStorecreateWithRandomPassword(String keyEnvVar, String certEnvVar)Create a KeyStore representation from environment variables.KeyStorekeyStore()Stringpassword()voidstore(OutputStream out)voidstore(Path path)FilestoreTemp()byte[]toBytes()InputStreamtoInputStream()Stringtype()
-
-
-
Method Detail
-
create
public static EnvKeyStore create(String keyEnvVar, String certEnvVar, String passwordEnvVar) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a KeyStore representation from environment variables.- Parameters:
keyEnvVar- The environment variable name of the keycertEnvVar- The environment variable name of the certificatepasswordEnvVar- The environment variable name of the password- Returns:
- an EnvKeyStore with a loaded KeyStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
create
public static EnvKeyStore create(String trustEnvVar, String passwordEnvVar) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a TrustStore representation from an environment variable.- Parameters:
trustEnvVar- The environment variable name of the certificatepasswordEnvVar- The environment variable name of the password- Returns:
- an EnvKeyStore with a loaded TrustStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
addToDefaultTrustStore
public static EnvKeyStore addToDefaultTrustStore(String trustEnvVar) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a TrustStore representation from an environment variable and add it to the default TrustStore.- Parameters:
trustEnvVar- The environment variable name of the certificate- Returns:
- an EnvKeyStore with a loaded TrustStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
createFromPEMStrings
public static EnvKeyStore createFromPEMStrings(String key, String cert, String password) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a KeyStore representation from an environment variable.- Parameters:
key- The the certificate as a stringcert- The certificate as a stringpassword- The password as a string- Returns:
- an EnvKeyStore with a loaded TrustStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
createFromPEMStrings
public static EnvKeyStore createFromPEMStrings(String trust, String password) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a TrustStore representation from an environment variable.- Parameters:
trust- The the certificate as a stringpassword- The password as a string- Returns:
- an EnvKeyStore with a loaded TrustStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
createWithRandomPassword
public static EnvKeyStore createWithRandomPassword(String keyEnvVar, String certEnvVar) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a KeyStore representation from environment variables.- Parameters:
keyEnvVar- The environment variable name of the keycertEnvVar- The environment variable name of the certificate- Returns:
- an EnvKeyStore with a loaded KeyStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
createWithRandomPassword
public static EnvKeyStore createWithRandomPassword(String trustEnvVar) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
Create a TrustStore representation from an environment variable.- Parameters:
trustEnvVar- The environment variable name of the certificate- Returns:
- an EnvKeyStore with a loaded TrustStore
- Throws:
CertificateExceptionNoSuchAlgorithmExceptionKeyStoreExceptionIOException
-
password
public String password()
-
keyStore
public KeyStore keyStore()
-
type
public String type()
-
toInputStream
public InputStream toInputStream() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
-
toBytes
public byte[] toBytes() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
-
store
public void store(OutputStream out) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
-
store
public void store(Path path) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
-
storeTemp
public File storeTemp() throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException
-
asFile
public void asFile(Consumer<File> c) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException
-
-