public class SslContextHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AWS_CERTIFICATE_FILE_PATH
Property to get the path to the device's certificate.
|
static java.lang.String |
AWS_CERTIFICATE_LIST
Property to get the list of certificate to load.
|
static java.lang.String |
AWS_PRIVATE_KEY_FILE_PASSWORD
Property to get the password of device's private key.
|
static java.lang.String |
AWS_PRIVATE_KEY_FILE_PATH
Property to get the path to the device's private key.
|
static java.lang.String |
TLS_V_1_2
TLSv1.2.
|
static java.lang.String |
X509
X509.
|
Modifier and Type | Method and Description |
---|---|
static javax.net.ssl.KeyManager[] |
getDefaultKeyManagers(CertificateLoader certificateLoader,
java.util.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 javax.net.ssl.KeyManager[] |
getKeyManagers(CertificateLoader certificateLoader,
java.lang.String certificateFileName,
java.lang.String keyFileName,
java.lang.String keyStorePassword)
Gets the key managers.
|
static javax.net.ssl.KeyManager[] |
getKeyManagers(java.lang.String keyStorePassword,
java.security.cert.Certificate clientCert,
byte[] key)
Gets the key managers.
|
static java.security.KeyStore |
getNewKeyStore()
Create a new Key store.
|
static java.lang.String |
getProperty(java.util.Properties properties,
java.lang.String key)
Gets a property from a property file, if not found tries the
System.getProperty(String) |
static javax.net.ssl.SSLContext |
getSslContext(javax.net.ssl.KeyManager[] keyManagers,
javax.net.ssl.TrustManager[] trustManagers)
Gets the SSL Context for AWS.
|
static javax.net.ssl.SSLContext |
getSslContext(java.util.Properties properties,
CertificateLoader certificateLoader)
Gets the SSL Context for AWS.
|
static javax.net.ssl.TrustManager[] |
getTrustManagers(CertificateLoader certificateLoader,
java.util.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 java.lang.String AWS_CERTIFICATE_LIST
public static final java.lang.String AWS_PRIVATE_KEY_FILE_PASSWORD
public static final java.lang.String AWS_PRIVATE_KEY_FILE_PATH
public static final java.lang.String AWS_CERTIFICATE_FILE_PATH
public static final java.lang.String TLS_V_1_2
public static final java.lang.String X509
public static javax.net.ssl.SSLContext getSslContext(java.util.Properties properties, CertificateLoader certificateLoader) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException, java.security.UnrecoverableKeyException, java.security.KeyManagementException
properties
- set of properties to use.certificateLoader
- the certificate loader to use.java.security.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.java.io.IOException
- if IOException occurred.java.security.cert.CertificateException
- if CertificateException occurred.java.security.KeyStoreException
- if KeyStoreException occurred.java.security.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.java.security.KeyManagementException
- if NoSuchAlgorithmException occurred.getDefaultKeyManagers(CertificateLoader, Properties)
,
getTrustManagers(CertificateLoader, Properties)
public static javax.net.ssl.SSLContext getSslContext(javax.net.ssl.KeyManager[] keyManagers, javax.net.ssl.TrustManager[] trustManagers) throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
keyManagers
- the key managers.trustManagers
- the trust managers.java.security.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.java.security.KeyManagementException
- if NoSuchAlgorithmException occurred.public static javax.net.ssl.TrustManager[] getTrustManagers(CertificateLoader certificateLoader, java.util.Properties properties) throws java.security.NoSuchAlgorithmException, java.io.IOException, java.security.KeyStoreException, java.security.cert.CertificateException
certificateLoader
- the loader to use for each certificate file.properties
- the properties set to use.java.security.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.java.io.IOException
- if IOException occurred.java.security.cert.CertificateException
- if CertificateException occurred.java.security.KeyStoreException
- if KeyStoreException occurred.public static javax.net.ssl.KeyManager[] getDefaultKeyManagers(CertificateLoader certificateLoader, java.util.Properties properties) throws java.security.cert.CertificateException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException
certificateLoader
- the loader to use for each certificate file.properties
- the properties set to use.java.security.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.java.io.IOException
- if IOException occurred.java.security.cert.CertificateException
- if CertificateException occurred.java.security.KeyStoreException
- if KeyStoreException occurred.java.security.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.public static javax.net.ssl.KeyManager[] getKeyManagers(CertificateLoader certificateLoader, java.lang.String certificateFileName, java.lang.String keyFileName, java.lang.String keyStorePassword) throws java.security.cert.CertificateException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.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.java.security.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.java.io.IOException
- if IOException occurred.java.security.cert.CertificateException
- if CertificateException occurred.java.security.KeyStoreException
- if KeyStoreException occurred.java.security.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.public static javax.net.ssl.KeyManager[] getKeyManagers(java.lang.String keyStorePassword, java.security.cert.Certificate clientCert, byte[] key) throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException, java.security.KeyStoreException, java.security.UnrecoverableKeyException
keyStorePassword
- the password of the key store.clientCert
- the certificate of the client.key
- the private key.java.security.NoSuchAlgorithmException
- if NoSuchAlgorithmException occurred.java.io.IOException
- if IOException occurred.java.security.cert.CertificateException
- if CertificateException occurred.java.security.KeyStoreException
- if KeyStoreException occurred.java.security.UnrecoverableKeyException
- if UnrecoverableKeyException occurred.public static java.lang.String getProperty(java.util.Properties properties, java.lang.String key) throws java.io.IOException
System.getProperty(String)
properties
- the properties.key
- the key to look for.java.io.IOException
- if the property is not found.public static java.security.KeyStore getNewKeyStore() throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException, java.security.KeyStoreException
java.security.NoSuchAlgorithmException
- if the algorithm used to checkthe integrity of the keystore cannot be foundjava.security.cert.CertificateException
- if any of the certificates in thekeystore could not be loadedjava.io.IOException
- 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 UnrecoverableKeyExceptionjava.security.KeyStoreException
- if no Provider supports aKeyStoreSpi implementation for thespecified type.