Package com.spotify.docker.client
Class DockerCertificates
- java.lang.Object
-
- com.spotify.docker.client.DockerCertificates
-
- All Implemented Interfaces:
DockerCertificatesStore
public class DockerCertificates extends java.lang.Object implements DockerCertificatesStore
DockerCertificates holds certificates for connecting to an HTTPS-secured Docker instance with client/server authentication.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DockerCertificates.Builder
private static class
DockerCertificates.DefaultSslContextFactory
static interface
DockerCertificates.SslContextFactory
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_CA_CERT_NAME
static java.lang.String
DEFAULT_CLIENT_CERT_NAME
static java.lang.String
DEFAULT_CLIENT_KEY_NAME
private static char[]
KEY_STORE_PASSWORD
private static org.slf4j.Logger
log
private static java.util.Set<java.lang.String>
PRIVATE_KEY_ALGS
private javax.net.ssl.SSLContext
sslContext
-
Constructor Summary
Constructors Modifier Constructor Description private
DockerCertificates(DockerCertificates.Builder builder)
DockerCertificates(java.nio.file.Path dockerCertPath)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DockerCertificates.Builder
builder()
private static java.security.PrivateKey
generatePrivateKey(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo)
javax.net.ssl.HostnameVerifier
hostnameVerifier()
private java.security.KeyStore
newKeyStore()
private java.util.List<java.security.cert.Certificate>
readCertificates(java.nio.file.Path file)
private java.security.PrivateKey
readPrivateKey(java.nio.file.Path file)
javax.net.ssl.SSLContext
sslContext()
private static java.security.PrivateKey
tryGeneratePrivateKey(java.security.spec.PKCS8EncodedKeySpec spec, java.util.Set<java.lang.String> algorithms)
-
-
-
Field Detail
-
DEFAULT_CA_CERT_NAME
public static final java.lang.String DEFAULT_CA_CERT_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_CERT_NAME
public static final java.lang.String DEFAULT_CLIENT_CERT_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_KEY_NAME
public static final java.lang.String DEFAULT_CLIENT_KEY_NAME
- See Also:
- Constant Field Values
-
KEY_STORE_PASSWORD
private static final char[] KEY_STORE_PASSWORD
-
PRIVATE_KEY_ALGS
private static final java.util.Set<java.lang.String> PRIVATE_KEY_ALGS
-
log
private static final org.slf4j.Logger log
-
sslContext
private final javax.net.ssl.SSLContext sslContext
-
-
Constructor Detail
-
DockerCertificates
public DockerCertificates(java.nio.file.Path dockerCertPath) throws DockerCertificateException
- Throws:
DockerCertificateException
-
DockerCertificates
private DockerCertificates(DockerCertificates.Builder builder) throws DockerCertificateException
- Throws:
DockerCertificateException
-
-
Method Detail
-
newKeyStore
private java.security.KeyStore newKeyStore() throws java.security.cert.CertificateException, java.security.NoSuchAlgorithmException, java.io.IOException, java.security.KeyStoreException
- Throws:
java.security.cert.CertificateException
java.security.NoSuchAlgorithmException
java.io.IOException
java.security.KeyStoreException
-
readPrivateKey
private java.security.PrivateKey readPrivateKey(java.nio.file.Path file) throws java.io.IOException, java.security.spec.InvalidKeySpecException, DockerCertificateException
- Throws:
java.io.IOException
java.security.spec.InvalidKeySpecException
DockerCertificateException
-
generatePrivateKey
private static java.security.PrivateKey generatePrivateKey(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo) throws java.io.IOException, java.security.spec.InvalidKeySpecException
- Throws:
java.io.IOException
java.security.spec.InvalidKeySpecException
-
tryGeneratePrivateKey
private static java.security.PrivateKey tryGeneratePrivateKey(java.security.spec.PKCS8EncodedKeySpec spec, java.util.Set<java.lang.String> algorithms) throws java.security.spec.InvalidKeySpecException
- Throws:
java.security.spec.InvalidKeySpecException
-
readCertificates
private java.util.List<java.security.cert.Certificate> readCertificates(java.nio.file.Path file) throws java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.cert.CertificateException
java.io.IOException
-
sslContext
public javax.net.ssl.SSLContext sslContext()
- Specified by:
sslContext
in interfaceDockerCertificatesStore
-
hostnameVerifier
public javax.net.ssl.HostnameVerifier hostnameVerifier()
- Specified by:
hostnameVerifier
in interfaceDockerCertificatesStore
-
builder
public static DockerCertificates.Builder builder()
-
-