public class CertificateChainUtil extends Object
Modifier and Type | Field | Description |
---|---|---|
static boolean |
ALLOW_LOG_SELF_SIGN_TESTS |
Modifier and Type | Method | Description |
---|---|---|
static List<X509Certificate> |
buildChainFor(KeyPair keypair,
Collection<X509Certificate> certs) |
|
static List<X509Certificate> |
buildChainFor(PublicKey key,
Collection<X509Certificate> certs) |
|
static X509Certificate |
getCertificateFor(PublicKey publicKey,
Collection<X509Certificate> certs) |
|
static X509Certificate |
getIssuer(X509Certificate subject,
Collection<X509Certificate> certs) |
|
static X500Principal[] |
getIssuerDNsFromChain(List<X509Certificate> chain) |
Extracts the DNs of the issuers from a certificate chain.
|
static X500Principal[] |
getPrincipals(List<X509Certificate> chain) |
|
static X500Principal |
getSubjectDNFromChain(List<X509Certificate> chain) |
Extracts the Subject: the final certificate in a chain
|
static boolean |
isSelfSigned(X509Certificate certificate) |
Determines if a certificate is a self signed certificate
|
static boolean |
isSignedBy(X509Certificate subject,
PublicKey signer) |
|
static List<X509Certificate> |
normaliseChain(List<X509Certificate> chain) |
Take a chain and return a (Read-only) chain with the root certificate as the first entry
|
static List<X509Certificate> |
toRootFirst(List<X509Certificate> chain) |
Take a chain and return a (Read-only) chain with the root certificate as the first entry
|
static List<X509Certificate> |
toRootLast(List<X509Certificate> chain) |
Take a chain and return a (Read-only) chain with the root certificate as the last entry
|
static void |
verifyChain(List<X509Certificate> chain) |
Verifies that a certificate chain is valid
|
public static final boolean ALLOW_LOG_SELF_SIGN_TESTS
public static X500Principal[] getIssuerDNsFromChain(List<X509Certificate> chain)
chain
- a normalised chainpublic static X500Principal getSubjectDNFromChain(List<X509Certificate> chain)
chain
- a normalised chainIllegalArgumentException
- if the chain is null or emptypublic static boolean isSelfSigned(X509Certificate certificate)
certificate
- the certificate to testpublic static boolean isSignedBy(X509Certificate subject, PublicKey signer)
public static List<X509Certificate> buildChainFor(PublicKey key, Collection<X509Certificate> certs)
public static List<X509Certificate> buildChainFor(KeyPair keypair, Collection<X509Certificate> certs)
public static X500Principal[] getPrincipals(List<X509Certificate> chain)
public static X509Certificate getCertificateFor(PublicKey publicKey, Collection<X509Certificate> certs)
public static X509Certificate getIssuer(X509Certificate subject, Collection<X509Certificate> certs)
public static List<X509Certificate> normaliseChain(List<X509Certificate> chain)
chain
- a chain with the certificates in order (either leading away from root or leading towards root)IllegalArgumentException
- if the chain is null or emptypublic static List<X509Certificate> toRootFirst(List<X509Certificate> chain)
chain
- a chain with the certificates in order (either leading away from root or leading towards root)IllegalArgumentException
- if the chain is null or emptypublic static List<X509Certificate> toRootLast(List<X509Certificate> chain)
chain
- a chain with the certificates in order (either leading away from root or leading towards root)IllegalArgumentException
- if the chain is null or emptypublic static void verifyChain(List<X509Certificate> chain)
chain
- a certificate chain with the root certificate firstIllegalArgumentException
- if the chain is invalid, null or emptyCopyright © 2018. All rights reserved.