Package nl.altindag.ssl.pem.util
Class PemUtils
- java.lang.Object
-
- nl.altindag.ssl.pem.util.PemUtils
-
public final class PemUtils extends Object
Reads PEM formatted private keys and certificates as identity material and trust material and maps it to either aX509ExtendedKeyManagerorX509ExtendedTrustManager.
The PemUtils provides also other methods for example to:- load trusted certificates and map it into a list of
X509Certificate- load identity material and map it into aPrivateKeyThe PemUtils serves mainly as a helper class to easily supply the PEM formatted SSL material for the
SSLFactory, but can also be used for other purposes.- Author:
- Hakan Altindag
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PublicKeyextractPublicKey(PrivateKey privateKey)static List<X509Certificate>loadCertificate(InputStream... certificateStreams)Loads certificates from multiple InputStreams and maps it to a list ofX509Certificatestatic List<X509Certificate>loadCertificate(String... certificatePaths)Loads certificates from the classpath and maps it to a list ofX509Certificatestatic List<X509Certificate>loadCertificate(Path... certificatePaths)Loads certificates from the filesystem and maps it to a list ofX509Certificatestatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream identityStream)Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream identityStream, char[] keyPassword)Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream)Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream, char[] keyPassword)Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String identityPath)Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String identityPath, char[] keyPassword)Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String certificateChainPath, String privateKeyPath)Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String certificateChainPath, String privateKeyPath, char[] keyPassword)Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path identityPath)Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path identityPath, char[] keyPassword)Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path certificateChainPath, Path privateKeyPath)Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path certificateChainPath, Path privateKeyPath, char[] keyPassword)Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic PrivateKeyloadPrivateKey(InputStream identityStream)Loads the private key from an InputStream and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(InputStream identityStream, char[] keyPassword)Loads the private key from an InputStream and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(String identityPath)Loads the private key from the classpath and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(String identityPath, char[] keyPassword)Loads the private key from the classpath and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(Path identityPath)Loads the private key from the filesystem and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(Path identityPath, char[] keyPassword)Loads the private key from the filesystem and maps it to an instance ofPrivateKeystatic X509ExtendedTrustManagerloadTrustMaterial(InputStream... certificateStreams)Loads certificates from multiple InputStreams and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedTrustManagerloadTrustMaterial(String... certificatePaths)Loads certificates from the classpath and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedTrustManagerloadTrustMaterial(Path... certificatePaths)Loads certificates from the filesystem and maps it to an instance ofX509ExtendedTrustManagerstatic List<X509Certificate>parseCertificate(String certContent)static X509ExtendedKeyManagerparseIdentityMaterial(String identityContent)Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedKeyManagerparseIdentityMaterial(String identityContent, char[] keyPassword)Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedKeyManagerparseIdentityMaterial(String certificateChainContent, String privateKeyContent, char[] keyPassword)Parses the identity material based on a string representation of the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManagerstatic PrivateKeyparsePrivateKey(String identityContent)Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKeystatic PrivateKeyparsePrivateKey(String identityContent, char[] keyPassword)Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKey.static X509ExtendedTrustManagerparseTrustMaterial(String... certificateContents)Parses one or more certificates as a string representation and maps it to an instance ofX509ExtendedTrustManager
-
-
-
Method Detail
-
loadTrustMaterial
public static X509ExtendedTrustManager loadTrustMaterial(String... certificatePaths)
Loads certificates from the classpath and maps it to an instance ofX509ExtendedTrustManager
-
loadTrustMaterial
public static X509ExtendedTrustManager loadTrustMaterial(Path... certificatePaths)
Loads certificates from the filesystem and maps it to an instance ofX509ExtendedTrustManager
-
loadTrustMaterial
public static X509ExtendedTrustManager loadTrustMaterial(InputStream... certificateStreams)
Loads certificates from multiple InputStreams and maps it to an instance ofX509ExtendedTrustManager
-
loadCertificate
public static List<X509Certificate> loadCertificate(String... certificatePaths)
Loads certificates from the classpath and maps it to a list ofX509Certificate
-
loadCertificate
public static List<X509Certificate> loadCertificate(Path... certificatePaths)
Loads certificates from the filesystem and maps it to a list ofX509Certificate
-
loadCertificate
public static List<X509Certificate> loadCertificate(InputStream... certificateStreams)
Loads certificates from multiple InputStreams and maps it to a list ofX509Certificate
-
parseCertificate
public static List<X509Certificate> parseCertificate(String certContent)
-
parseTrustMaterial
public static X509ExtendedTrustManager parseTrustMaterial(String... certificateContents)
Parses one or more certificates as a string representation and maps it to an instance ofX509ExtendedTrustManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(String certificateChainPath, String privateKeyPath)
Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(String certificateChainPath, String privateKeyPath, char[] keyPassword)
Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream)
Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream, char[] keyPassword)
Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(Path certificateChainPath, Path privateKeyPath)
Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(Path certificateChainPath, Path privateKeyPath, char[] keyPassword)
Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(String identityPath)
Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(String identityPath, char[] keyPassword)
Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(Path identityPath)
Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(Path identityPath, char[] keyPassword)
Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream identityStream)
Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManager
-
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream identityStream, char[] keyPassword)
Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManager
-
parseIdentityMaterial
public static X509ExtendedKeyManager parseIdentityMaterial(String identityContent)
Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManager
-
parseIdentityMaterial
public static X509ExtendedKeyManager parseIdentityMaterial(String identityContent, char[] keyPassword)
Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManager
-
parseIdentityMaterial
public static X509ExtendedKeyManager parseIdentityMaterial(String certificateChainContent, String privateKeyContent, char[] keyPassword)
Parses the identity material based on a string representation of the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManager
-
loadPrivateKey
public static PrivateKey loadPrivateKey(String identityPath)
Loads the private key from the classpath and maps it to an instance ofPrivateKey
-
loadPrivateKey
public static PrivateKey loadPrivateKey(String identityPath, char[] keyPassword)
Loads the private key from the classpath and maps it to an instance ofPrivateKey
-
loadPrivateKey
public static PrivateKey loadPrivateKey(Path identityPath)
Loads the private key from the filesystem and maps it to an instance ofPrivateKey
-
loadPrivateKey
public static PrivateKey loadPrivateKey(Path identityPath, char[] keyPassword)
Loads the private key from the filesystem and maps it to an instance ofPrivateKey
-
loadPrivateKey
public static PrivateKey loadPrivateKey(InputStream identityStream)
Loads the private key from an InputStream and maps it to an instance ofPrivateKey
-
loadPrivateKey
public static PrivateKey loadPrivateKey(InputStream identityStream, char[] keyPassword)
Loads the private key from an InputStream and maps it to an instance ofPrivateKey
-
parsePrivateKey
public static PrivateKey parsePrivateKey(String identityContent)
Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKey
-
parsePrivateKey
public static PrivateKey parsePrivateKey(String identityContent, char[] keyPassword)
Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKey. If the identity content contains multiple private keys it will use only the first one.
-
extractPublicKey
public static PublicKey extractPublicKey(PrivateKey privateKey)
-
-