Package no.digipost.security.cert
Class Trust
- java.lang.Object
-
- no.digipost.security.cert.Trust
-
public final class Trust extends Object
The Trust contains the root certificates and any intermediate certificates you choose to trust in your application. It can then be used to resolvethe certificatation pathof a certificate, and determined if itis trustedor not.
-
-
Constructor Summary
Constructors Constructor Description Trust(Stream<X509Certificate> trustAnchorCertificates, Stream<X509Certificate> intermediateCertificates)Trust(Stream<X509Certificate> trustAnchorCertificates, Stream<X509Certificate> intermediateCertificates, Clock clock)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)static Trustfrom(Clock clock, X509Certificate... trustedCertificates)Construct a Trust from the given trusted certificates.static Trustfrom(Clock clock, Stream<X509Certificate> trustedCertificates)Construct a Trust from the given trusted certificates.Set<X509Certificate>getTrustAnchorCertificates()A trust anchor is the authoritative entity for which trust is assumed and not derived, i.e.Set<TrustAnchor>getTrustAnchors()KeyStoregetTrustAnchorsKeyStore()Map<X500Principal,Set<X509Certificate>>getTrustedIntermediateCertificates()inthashCode()static Trustmerge(Trust t1, Trust t2)Merge twoTrusts.ReviewedCertPathresolveCertPath(X509Certificate certificate)Resolve the certificate path of an X.509 certificate.booleantrusts(CertPath certPath)Determine if a certificate path is trusted or not
-
-
-
Constructor Detail
-
Trust
public Trust(Stream<X509Certificate> trustAnchorCertificates, Stream<X509Certificate> intermediateCertificates)
-
Trust
public Trust(Stream<X509Certificate> trustAnchorCertificates, Stream<X509Certificate> intermediateCertificates, Clock clock)
-
-
Method Detail
-
from
public static Trust from(Clock clock, X509Certificate... trustedCertificates)
Construct a Trust from the given trusted certificates.- Parameters:
trustedCertificates- all the certificates, both trust anchors and any intermediate certificates issued from any of the trust anchorsclock- the clock to use for asserting certificate validity- Returns:
- the Trust for the given certificates
-
from
public static Trust from(Clock clock, Stream<X509Certificate> trustedCertificates)
Construct a Trust from the given trusted certificates.- Parameters:
trustedCertificates- all the certificates, both trust anchors and any intermediate certificates issued from any of the trust anchorsclock- the clock to use for asserting certificate validity- Returns:
- the Trust for the given certificates
-
merge
public static Trust merge(Trust t1, Trust t2)
Merge twoTrusts. The resulting trust will be the union of the given trusts.- Parameters:
t1- the first trustt2- the second trust- Returns:
- the resulting trust from merging
t1andt2
-
resolveCertPath
public ReviewedCertPath resolveCertPath(X509Certificate certificate)
Resolve the certificate path of an X.509 certificate.- Parameters:
certificate- the certificate to resolve the whole path for.- Returns:
- the certificate path, wrapped as a
ReviewedCertPath, with methods to determine if itis trusted, and to retrieve thetrusted certificate and its issuer.
-
trusts
public boolean trusts(CertPath certPath)
Determine if a certificate path is trusted or not- Returns:
trueif the path is trusted,falseotherwise.
-
getTrustAnchors
public Set<TrustAnchor> getTrustAnchors()
- Returns:
- the
TrustAnchors of thisTrust - See Also:
getTrustAnchorCertificates()
-
getTrustAnchorCertificates
public Set<X509Certificate> getTrustAnchorCertificates()
A trust anchor is the authoritative entity for which trust is assumed and not derived, i.e. the root certificates from which the whole chain of trust is derived.- Returns:
- the
trust anchor certificatesof thisTrust
-
getTrustAnchorsKeyStore
public KeyStore getTrustAnchorsKeyStore()
- Returns:
- a
KeyStorepopulated with thetrust anchor certificatesof thisTrust
-
getTrustedIntermediateCertificates
public Map<X500Principal,Set<X509Certificate>> getTrustedIntermediateCertificates()
-
-