Top Description Fields Constructors Methods
org.bouncycastle.x509

public Class X509V2AttributeCertificate

extends Object
implements X509AttributeCertificate
Class Inheritance
All Implemented Interfaces
org.bouncycastle.x509.X509AttributeCertificate, java.security.cert.X509Extension
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, java.math.BigInteger, java.security.InvalidKeyException, .NoSuchAlgorithmException, .NoSuchProviderException, .PublicKey, .Signature, .SignatureException, java.security.cert.CertificateException, .CertificateExpiredException, .CertificateNotYetValidException, java.text.ParseException, java.util.ArrayList, .Date, .Enumeration, .HashSet, .List, .Set, org.bouncycastle.asn1.ASN1BitString, .ASN1Encodable, .ASN1Encoding, .ASN1InputStream, .ASN1ObjectIdentifier, .ASN1Sequence, org.bouncycastle.asn1.x509.AttributeCertificate, .Extension, .Extensions, org.bouncycastle.util.Arrays

Deprecated

use org.bouncycastle.cert.X509AttributeCertificateHolder

An implementation of a version 2 X.509 Attribute Certificate.

Field Summary

Modifier and TypeField and Description
private AttributeCertificate
private Date
private Date

Constructor Summary

AccessConstructor and Description
public
public
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public X509Attribute[]
getAttributes()

Implements org.bouncycastle.x509.X509AttributeCertificate.getAttributes.

Deprecated as a consequence of X509Attribute being deprecated.
Return the attributes contained in the attribute block in the certificate.
public X509Attribute[]
getAttributes(String
the object identifier we wish to match.
oid
)

Implements org.bouncycastle.x509.X509AttributeCertificate.getAttributes.

Deprecated as a consequence of X509Attribute being deprecated.
Return the attributes with the same type as the passed in oid.
public Set<E>
getCriticalExtensionOIDs()

Implements java.security.cert.X509Extension.getCriticalExtensionOIDs.

Gets a Set of the OID strings for the extension(s) marked CRITICAL in the certificate/CRL managed by the object implementing this interface.
public byte[]
getEncoded()

Implements org.bouncycastle.x509.X509AttributeCertificate.getEncoded.

Return an ASN.1 encoded byte array representing the attribute certificate.
private Set<E>
getExtensionOIDs(boolean critical)

public byte[]
getExtensionValue(String
the Object Identifier value for the extension.
oid
)

Implements java.security.cert.X509Extension.getExtensionValue.

Gets the DER-encoded OCTET string for the extension value (extnValue) identified by the passed-in oid String.
public AttributeCertificateHolder
getHolder()

Implements org.bouncycastle.x509.X509AttributeCertificate.getHolder.

Deprecated as a consequence of AttributeCertificateHolder being deprecated.
Return the holder of the certificate.
public AttributeCertificateIssuer
getIssuer()

Implements org.bouncycastle.x509.X509AttributeCertificate.getIssuer.

Deprecated as a consequence of AttributeCertificateIssuer being deprecated.
Return the issuer details for the certificate.
public boolean[]
public Set<E>
getNonCriticalExtensionOIDs()

Implements java.security.cert.X509Extension.getNonCriticalExtensionOIDs.

Gets a Set of the OID strings for the extension(s) marked NON-CRITICAL in the certificate/CRL managed by the object implementing this interface.
public Date
getNotAfter()

Implements org.bouncycastle.x509.X509AttributeCertificate.getNotAfter.

Return the date after which the certificate is not valid.
public Date
getNotBefore()

Implements org.bouncycastle.x509.X509AttributeCertificate.getNotBefore.

Return the date before which the certificate is not valid.
private static AttributeCertificate
public BigInteger
getSerialNumber()

Implements org.bouncycastle.x509.X509AttributeCertificate.getSerialNumber.

Return the serial number for the certificate.
public byte[]
public int
getVersion()

Implements org.bouncycastle.x509.X509AttributeCertificate.getVersion.

Return the version number for the certificate.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
hasUnsupportedCriticalExtension()

Implements java.security.cert.X509Extension.hasUnsupportedCriticalExtension.

Check if there is a critical extension that is not supported.
public final void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

certback to summary
private AttributeCertificate cert
notAfterback to summary
private Date notAfter
notBeforeback to summary
private Date notBefore

Constructor Detail

X509V2AttributeCertificateback to summary
public X509V2AttributeCertificate(InputStream encIn) throws IOException
X509V2AttributeCertificateback to summary
public X509V2AttributeCertificate(byte[] encoded) throws IOException
X509V2AttributeCertificateback to summary
pack-priv X509V2AttributeCertificate(AttributeCertificate cert) throws IOException

Method Detail

checkValidityback to summary
public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException

Implements org.bouncycastle.x509.X509AttributeCertificate.checkValidity.

checkValidityback to summary
public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException

Implements org.bouncycastle.x509.X509AttributeCertificate.checkValidity.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getAttributesback to summary
public X509Attribute[] getAttributes()

Implements org.bouncycastle.x509.X509AttributeCertificate.getAttributes.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getAttributes.

Deprecated

as a consequence of X509Attribute being deprecated. See corresponding docs for further information.

Return the attributes contained in the attribute block in the certificate.

Returns:X509Attribute[]

an array of attributes.

getAttributesback to summary
public X509Attribute[] getAttributes(String oid)

Implements org.bouncycastle.x509.X509AttributeCertificate.getAttributes.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getAttributes.

Deprecated

as a consequence of X509Attribute being deprecated. See corresponding docs for further information.

Return the attributes with the same type as the passed in oid.

Parameters
oid:String

the object identifier we wish to match.

Returns:X509Attribute[]

an array of matched attributes, null if there is no match.

getCriticalExtensionOIDsback to summary
public Set<E> getCriticalExtensionOIDs()

Implements java.security.cert.X509Extension.getCriticalExtensionOIDs.

Doc from java.security.cert.X509Extension.getCriticalExtensionOIDs.

Gets a Set of the OID strings for the extension(s) marked CRITICAL in the certificate/CRL managed by the object implementing this interface. Here is sample code to get a Set of critical extensions from an X509Certificate and print the OIDs:

X509Certificate cert = null;
try (InputStream inStrm = new FileInputStream("DER-encoded-Cert")) {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    cert = (X509Certificate)cf.generateCertificate(inStrm);
}

Set<String> critSet = cert.getCriticalExtensionOIDs();
if (critSet != null && !critSet.isEmpty()) {
    System.out.println("Set of critical extensions:");
    for (String oid : critSet) {
        System.out.println(oid);
    }
}
Returns:Set<E>

a Set (or an empty Set if none are marked critical) of the extension OID strings for extensions that are marked critical. If there are no extensions present at all, then this method returns null.

getEncodedback to summary
public byte[] getEncoded() throws IOException

Implements org.bouncycastle.x509.X509AttributeCertificate.getEncoded.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getEncoded.

Return an ASN.1 encoded byte array representing the attribute certificate.

Returns:byte[]

an ASN.1 encoded byte array.

Exceptions
IOException:
if the certificate cannot be encoded.
getExtensionOIDsback to summary
private Set<E> getExtensionOIDs(boolean critical)
getExtensionValueback to summary
public byte[] getExtensionValue(String oid)

Implements java.security.cert.X509Extension.getExtensionValue.

Doc from java.security.cert.X509Extension.getExtensionValue.

Gets the DER-encoded OCTET string for the extension value (extnValue) identified by the passed-in oid String. The oid string is represented by a set of nonnegative whole numbers separated by periods.

For example:

Examples of OIDs and extension names
OID (Object Identifier) Extension Name
2.5.29.14 SubjectKeyIdentifier
2.5.29.15 KeyUsage
2.5.29.16 PrivateKeyUsage
2.5.29.17 SubjectAlternativeName
2.5.29.18 IssuerAlternativeName
2.5.29.19 BasicConstraints
2.5.29.30 NameConstraints
2.5.29.33 PolicyMappings
2.5.29.35 AuthorityKeyIdentifier
2.5.29.36 PolicyConstraints
Parameters
oid:String

the Object Identifier value for the extension.

Returns:byte[]

the DER-encoded octet string of the extension value or null if it is not present.

getHolderback to summary
public AttributeCertificateHolder getHolder()

Implements org.bouncycastle.x509.X509AttributeCertificate.getHolder.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getHolder.

Deprecated

as a consequence of AttributeCertificateHolder being deprecated. See corresponding docs for further information.

Return the holder of the certificate.

Returns:AttributeCertificateHolder

the holder.

getIssuerback to summary
public AttributeCertificateIssuer getIssuer()

Implements org.bouncycastle.x509.X509AttributeCertificate.getIssuer.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getIssuer.

Deprecated

as a consequence of AttributeCertificateIssuer being deprecated. See corresponding docs for further information.

Return the issuer details for the certificate.

Returns:AttributeCertificateIssuer

the issuer details.

getIssuerUniqueIDback to summary
public boolean[] getIssuerUniqueID()

Implements org.bouncycastle.x509.X509AttributeCertificate.getIssuerUniqueID.

getNonCriticalExtensionOIDsback to summary
public Set<E> getNonCriticalExtensionOIDs()

Implements java.security.cert.X509Extension.getNonCriticalExtensionOIDs.

Doc from java.security.cert.X509Extension.getNonCriticalExtensionOIDs.

Gets a Set of the OID strings for the extension(s) marked NON-CRITICAL in the certificate/CRL managed by the object implementing this interface. Here is sample code to get a Set of non-critical extensions from an X509CRL revoked certificate entry and print the OIDs:

CertificateFactory cf = null;
X509CRL crl = null;
try (InputStream inStrm = new FileInputStream("DER-encoded-CRL")) {
    cf = CertificateFactory.getInstance("X.509");
    crl = (X509CRL)cf.generateCRL(inStrm);
}

byte[] certData = <DER-encoded certificate data>
ByteArrayInputStream bais = new ByteArrayInputStream(certData);
X509Certificate cert = (X509Certificate)cf.generateCertificate(bais);
X509CRLEntry badCert =
             crl.getRevokedCertificate(cert.getSerialNumber());

if (badCert != null) {
    Set<String> nonCritSet = badCert.getNonCriticalExtensionOIDs();
    if (nonCritSet != null)
        for (String oid : nonCritSet) {
            System.out.println(oid);
        }
}
Returns:Set<E>

a Set (or an empty Set if none are marked non-critical) of the extension OID strings for extensions that are marked non-critical. If there are no extensions present at all, then this method returns null.

getNotAfterback to summary
public Date getNotAfter()

Implements org.bouncycastle.x509.X509AttributeCertificate.getNotAfter.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getNotAfter.

Return the date after which the certificate is not valid.

Returns:Date

the "not valid afer" date.

getNotBeforeback to summary
public Date getNotBefore()

Implements org.bouncycastle.x509.X509AttributeCertificate.getNotBefore.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getNotBefore.

Return the date before which the certificate is not valid.

Returns:Date

the "not valid before" date.

getObjectback to summary
private static AttributeCertificate getObject(InputStream in) throws IOException
getSerialNumberback to summary
public BigInteger getSerialNumber()

Implements org.bouncycastle.x509.X509AttributeCertificate.getSerialNumber.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getSerialNumber.

Return the serial number for the certificate.

Returns:BigInteger

the serial number.

getSignatureback to summary
public byte[] getSignature()

Implements org.bouncycastle.x509.X509AttributeCertificate.getSignature.

getVersionback to summary
public int getVersion()

Implements org.bouncycastle.x509.X509AttributeCertificate.getVersion.

Doc from org.bouncycastle.x509.X509AttributeCertificate.getVersion.

Return the version number for the certificate.

Returns:int

the version number.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

hasUnsupportedCriticalExtensionback to summary
public boolean hasUnsupportedCriticalExtension()

Implements java.security.cert.X509Extension.hasUnsupportedCriticalExtension.

Doc from java.security.cert.X509Extension.hasUnsupportedCriticalExtension.

Check if there is a critical extension that is not supported.

Returns:boolean

true if a critical extension is found that is not supported, otherwise false.

verifyback to summary
public final void verify(PublicKey key, String provider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException

Implements org.bouncycastle.x509.X509AttributeCertificate.verify.