public class CertificateHelpers extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CertificateHelpers.PEMContentsType |
Constructor and Description |
---|
CertificateHelpers() |
Modifier and Type | Method and Description |
---|---|
static void |
checkKeysMatching(PrivateKey privKey,
PublicKey pubKey)
Throws an exception if the private key is not matching the public key.
|
static byte[] |
getExtensionBytes(X509Certificate cert,
String oid)
Gets the certificate extension identified by the oid and returns the
value bytes unwrapped by the ASN1OctetString.
|
static CertificateHelpers.PEMContentsType |
getPEMType(String name)
Assumes that the input is the contents of the PEM identification line,
after '-----BEGIN ' prefix.
|
static Certificate |
readDERCertificate(InputStream input) |
static Collection<? extends Certificate> |
readDERCertificates(InputStream input) |
static X509Certificate[] |
sortChain(List<X509Certificate> certificates)
Creates a chain of certificates, where the top-most certificate (the one without
issuing certificate) is the last in the returned array.
|
static CertPath |
toCertPath(X509Certificate[] in)
Converts certificates array to
CertPath |
static X500Name |
toX500Name(X500Principal srcDn)
|
public static CertificateHelpers.PEMContentsType getPEMType(String name)
name
- PEM first line to be checked.public static Collection<? extends Certificate> readDERCertificates(InputStream input) throws IOException
IOException
public static Certificate readDERCertificate(InputStream input) throws IOException
IOException
public static X509Certificate[] sortChain(List<X509Certificate> certificates) throws IOException
certificates
- unsorted certificates of one chainIOException
- if the passed chain is inconsistentpublic static CertPath toCertPath(X509Certificate[] in) throws CertificateException
CertPath
in
- arrayCertificateException
- certificate exceptionpublic static X500Name toX500Name(X500Principal srcDn)
srcDn
- source objectpublic static byte[] getExtensionBytes(X509Certificate cert, String oid) throws IOException
cert
- The certificate to inspect.oid
- The extension OID to fetch.IOException
- thrown in case the certificate parsing fails.public static void checkKeysMatching(PrivateKey privKey, PublicKey pubKey) throws InvalidKeyException
privKey
- first key to matchpubKey
- 2nd key to matchInvalidKeyException
- invalid key exceptionCopyright © 2012-2017 European Middleware Initiative. All Rights Reserved.