|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.emi.security.authn.x509.helpers.CertificateHelpers
public class CertificateHelpers
Utility methods for certificates handling and reading/writing PEM files.
| Nested Class Summary | |
|---|---|
static class |
CertificateHelpers.PEMContentsType
|
| Constructor Summary | |
|---|---|
CertificateHelpers()
|
|
| Method Summary | |
|---|---|
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)
Converts X500Principal to X500Name with the JavaAndBCStyle
style. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CertificateHelpers()
| Method Detail |
|---|
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 chain
IOException - if the passed chain is inconsistent
public static CertPath toCertPath(X509Certificate[] in)
throws CertificateException
CertPath
in - array
CertificateExceptionpublic static X500Name toX500Name(X500Principal srcDn)
X500Principal to X500Name with the JavaAndBCStyle
style.
srcDn - source object
public 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 match
InvalidKeyException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||