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 KeyStoreasKeyStore()Get thisTrustas aKeyStore, a.k.a.booleanequals(Object other)Set<X509Certificate>getTrustAnchorCertificates()A trust anchor is the authoritative entity for which trust is assumed and not derived, i.e.Set<TrustAnchor>getTrustAnchors()KeyStoregetTrustAnchorsKeyStore()Get only the trust anchor certificates of thisTrustas aKeyStore, a.k.a.Map<X500Principal,Set<X509Certificate>>getTrustedIntermediateCertificates()inthashCode()static Trustin(Clock clock, X509Certificate... trustedCertificates)Construct a Trust from the given trusted certificates.static Trustin(Clock clock, Stream<X509Certificate> trustedCertificates)Construct a Trust from the given trusted certificates.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
-
in
public static Trust in(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
-
in
public static Trust in(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()
Get only the trust anchor certificates of thisTrustas aKeyStore, a.k.a. a trust store. Consider usingasKeyStore()unless you have a very spesific need for only the trust anchors.- Returns:
- a
KeyStorepopulated with thetrust anchor certificatesof thisTrust - See Also:
asKeyStore()
-
asKeyStore
public KeyStore asKeyStore()
Get thisTrustas aKeyStore, a.k.a. a trust store.- Returns:
- a
KeyStorepopulated with all the certificates (bothtrust anchorsandintermediate certificates) of thisTrust
-
getTrustedIntermediateCertificates
public Map<X500Principal,Set<X509Certificate>> getTrustedIntermediateCertificates()
-
-