Package java.security.cert
Class TrustAnchor
- java.lang.Object
-
- java.security.cert.TrustAnchor
-
public class TrustAnchor extends Object
This class represents a trust anchor for validation of X.509 certification path.It is a trusted certificate authority (CA) and includes the public key of the CA, the CA's name and the constraints for the validation of certification paths. The constructor also allows to specify a binary representation of a so called "Name Constraints" extension as a byte array.
-
-
Constructor Summary
Constructors Constructor Description TrustAnchor(String caName, PublicKey caPublicKey, byte[] nameConstraints)Creates a newTrustAnchorwith the specified certificate authority name, its public key and the specified name constraints.TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints)Creates a newTrustAnchorwith the specified certificate and name constraints.TrustAnchor(X500Principal caPrincipal, PublicKey caPublicKey, byte[] nameConstraints)Creates a newTrustAnchorwith the specified certificate authority name as principal, its public key and the specified name constraints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description X500PrincipalgetCA()Returns the name of the certificate authority asX500Principal.StringgetCAName()Returns the name of the certificate authority asStringin RFC 2253 format.PublicKeygetCAPublicKey()Returns the public key of the certificate authority.byte[]getNameConstraints()Returns a copy of the name constraints in ASN.1 DER encoded form.X509CertificategetTrustedCert()Returns the certificate of this trusted certificate authority.StringtoString()Returns a string representation of thisTrustAnchorinstance.
-
-
-
Constructor Detail
-
TrustAnchor
public TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints)
Creates a newTrustAnchorwith the specified certificate and name constraints.The name constraints will be used as additional constraints during the validation of certification paths.
- Parameters:
trustedCert- the trusted certificatenameConstraints- the ASN.1 DER encoded form of the name constraints ornullif none.- Throws:
IllegalArgumentException- if the decoding of the name constraints fail.
-
TrustAnchor
public TrustAnchor(String caName, PublicKey caPublicKey, byte[] nameConstraints)
Creates a newTrustAnchorwith the specified certificate authority name, its public key and the specified name constraints.The name constraints will be used as additional constraints during the validation of certification paths.
- Parameters:
caName- the X.500 name of the certificate authority in RFC 2253Stringformat.caPublicKey- the public key of the certificate authoritynameConstraints- the ASN.1 DER encoded form of the name constraints ornullif none.- Throws:
IllegalArgumentException- if thecaNameis empty or if decoding of the name constraints fail.
-
TrustAnchor
public TrustAnchor(X500Principal caPrincipal, PublicKey caPublicKey, byte[] nameConstraints)
Creates a newTrustAnchorwith the specified certificate authority name as principal, its public key and the specified name constraints.The name constraints will be used as additional constraints during the validation of certification paths.
- Parameters:
caPrincipal- the name of the certificate authority as X500 principal.caPublicKey- the public key of the certificate authority.nameConstraints- the ASN.1 DER encoded form of the name constraints ornullif none.- Throws:
IllegalArgumentException- if decoding of the name constraints fail.
-
-
Method Detail
-
getNameConstraints
public final byte[] getNameConstraints()
Returns a copy of the name constraints in ASN.1 DER encoded form.- Returns:
- a copy of the name constraints in ASN.1 DER encoded form.
-
getTrustedCert
public final X509Certificate getTrustedCert()
Returns the certificate of this trusted certificate authority.- Returns:
- the certificate of this CA or
null, if the trust anchor of this instance was not created with a certificate.
-
getCA
public final X500Principal getCA()
Returns the name of the certificate authority asX500Principal.- Returns:
- the name of the certificate authority or
nullif the trust anchor of this instance was not created with aX500Principal.
-
getCAName
public final String getCAName()
Returns the name of the certificate authority asStringin RFC 2253 format.- Returns:
- the name of the certificate authority as
Stringin RFC 2253 format ornullif the trust anchor of this instance was not created with a CA name.
-
getCAPublicKey
public final PublicKey getCAPublicKey()
Returns the public key of the certificate authority.- Returns:
- the public key of the certificate authority or
nullif the trust anchor if this instance was not created with a public key.
-
-