public class SslContextHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AWS_CERTIFICATE_FILE_PATH
Property to get the path to the device's certificate.
|
static String |
AWS_CERTIFICATE_LIST
Property to get the list of certificate to load.
|
static String |
AWS_PRIVATE_KEY_FILE_PASSWORD
Property to get the password of device's private key.
|
static String |
AWS_PRIVATE_KEY_FILE_PATH
Property to get the path to the device's private key.
|
static String |
TLS_V_1_2
TLSv1.2.
|
static String |
X509
X509.
|
Modifier and Type | Method and Description |
---|---|
static KeyManager[] |
getDefaultKeyManagers(CertificateLoader certificateLoader,
Properties properties)
Gets the key managers, generated based on properties :
- "aws.device.private.key.password": password of the password of device's private key. - "aws.device.private.key.path": path to the device's private key file. - "aws.device.certificate.path": path to the device's certificate file. |
static KeyManager[] |
getKeyManagers(CertificateLoader certificateLoader,
String certificateFileName,
String keyFileName,
String keyStorePassword)
Gets the key managers.
|
static KeyManager[] |
getKeyManagers(String keyStorePassword,
Certificate clientCert,
byte[] key)
Gets the key managers.
|
static KeyStore |
getNewKeyStore()
Create a new Key store.
|
static String |
getProperty(Properties properties,
String key)
Gets a property from a property file, if not found tries the
System.getProperty(String) |
static SSLContext |
getSslContext(KeyManager[] keyManagers,
TrustManager[] trustManagers)
Gets the SSL Context for AWS.
|
static SSLContext |
getSslContext(Properties properties,
CertificateLoader certificateLoader)
Gets the SSL Context for AWS.
|
static TrustManager[] |
getTrustManagers(CertificateLoader certificateLoader,
Properties properties)
Gets the trust managers, generated based on the property :
- "aws.certificate.list": a list of certificate to load separated by comma. |
public static final String AWS_CERTIFICATE_FILE_PATH
public static final String AWS_CERTIFICATE_LIST
public static final String AWS_PRIVATE_KEY_FILE_PASSWORD
public static final String AWS_PRIVATE_KEY_FILE_PATH
public static final String TLS_V_1_2
public static final String X509
public static KeyManager[] getDefaultKeyManagers(CertificateLoader certificateLoader, Properties properties) throws CertificateException, IOException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
certificateLoader
- the loader to use for each certificate file.properties
- the properties set to use.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.IOException
- if IOException occurred.CertificateException
- if CertificateException occurred.KeyStoreException
- if KeyStoreException occurred.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.public static KeyManager[] getKeyManagers(CertificateLoader certificateLoader, String certificateFileName, String keyFileName, String keyStorePassword) throws CertificateException, IOException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
certificateLoader
- the loader to use for each certificate file.certificateFileName
- the certificate file name.keyFileName
- the file name of the private key associated to the certificate.keyStorePassword
- the password of the key store.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.IOException
- if IOException occurred.CertificateException
- if CertificateException occurred.KeyStoreException
- if KeyStoreException occurred.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.public static KeyManager[] getKeyManagers(String keyStorePassword, Certificate clientCert, byte[] key) throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, UnrecoverableKeyException
keyStorePassword
- the password of the key store.clientCert
- the certificate of the client.key
- the private key.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.IOException
- if IOException occurred.CertificateException
- if CertificateException occurred.KeyStoreException
- if KeyStoreException occurred.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.public static KeyStore getNewKeyStore() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException
NoSuchAlgorithmException
- if the algorithm used to checkthe integrity of the keystore cannot be foundCertificateException
- if any of the certificates in thekeystore could not be loadedIOException
- if there is an I/O or format problem with thekeystore data, if a password is required but not
given,or if the given password was incorrect. If the error is due to awrong password, the cause of
the IOException should be an UnrecoverableKeyExceptionKeyStoreException
- if no Provider supports aKeyStoreSpi implementation for thespecified type.public static String getProperty(Properties properties, String key) throws IOException
System.getProperty(String)
properties
- the properties.key
- the key to look for.IOException
- if the property is not found.public static SSLContext getSslContext(KeyManager[] keyManagers, TrustManager[] trustManagers) throws NoSuchAlgorithmException, KeyManagementException
keyManagers
- the key managers.trustManagers
- the trust managers.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.KeyManagementException
- if NoSuchAlgorithmException occurred.public static SSLContext getSslContext(Properties properties, CertificateLoader certificateLoader) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException
properties
- set of properties to use.certificateLoader
- the certificate loader to use.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.IOException
- if IOException occurred.CertificateException
- if CertificateException occurred.KeyStoreException
- if KeyStoreException occurred.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.KeyManagementException
- if NoSuchAlgorithmException occurred.getDefaultKeyManagers(CertificateLoader, Properties)
,
getTrustManagers(CertificateLoader, Properties)
public static TrustManager[] getTrustManagers(CertificateLoader certificateLoader, Properties properties) throws NoSuchAlgorithmException, IOException, KeyStoreException, CertificateException
certificateLoader
- the loader to use for each certificate file.properties
- the properties set to use.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.IOException
- if IOException occurred.CertificateException
- if CertificateException occurred.KeyStoreException
- if KeyStoreException occurred.