Package org.bouncycastle.cert
Class X509v2AttributeCertificateBuilder
java.lang.Object
org.bouncycastle.cert.X509v2AttributeCertificateBuilder
class to produce an X.509 Version 2 AttributeCertificate.
-
Constructor Summary
ConstructorsConstructorDescriptionX509v2AttributeCertificateBuilder
(AttributeCertificateHolder holder, AttributeCertificateIssuer issuer, BigInteger serialNumber, Date notBefore, Date notAfter) Base constructor.X509v2AttributeCertificateBuilder
(AttributeCertificateHolder holder, AttributeCertificateIssuer issuer, BigInteger serialNumber, Date notBefore, Date notAfter, Locale dateLocale) Base constructor with locale for interpreting dates.Create a builder for a version 2 attribute certificate, initialised with another certificate. -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute
(org.bouncycastle.asn1.ASN1ObjectIdentifier attrType, org.bouncycastle.asn1.ASN1Encodable attrValue) Add an attribute to the certification request we are building.addAttribute
(org.bouncycastle.asn1.ASN1ObjectIdentifier attrType, org.bouncycastle.asn1.ASN1Encodable[] attrValues) Add an attribute with multiple values to the certification request we are building.addExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, byte[] encodedValue) Add a given extension field for the standard extensions using a byte encoding of the extension value.addExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, org.bouncycastle.asn1.ASN1Encodable value) Add a given extension field for the standard extensions tag made up of the passed in parameters.addExtension
(org.bouncycastle.asn1.x509.Extension extension) Add a given extension field for the standard extensions.build
(ContentSigner signer) Generate an X509 certificate, based on the current issuer and subject using the passed in signer.org.bouncycastle.asn1.x509.Extension
getExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Return the current value of the extension for OID.boolean
hasExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Return if the extension indicated by OID is present.removeExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Remove the extension indicated by OID.replaceExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, byte[] encodedValue) Replace a given extension field for the standard extensions tag (tag 3) with the passed in byte encoded extension value.replaceExtension
(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, org.bouncycastle.asn1.ASN1Encodable value) Replace the extension field for the passed in extension's extension ID with a new version.replaceExtension
(org.bouncycastle.asn1.x509.Extension extension) Replace the extension field for the passed in extension's extension ID with a new version.void
setIssuerUniqueId
(boolean[] iui)
-
Constructor Details
-
X509v2AttributeCertificateBuilder
public X509v2AttributeCertificateBuilder(AttributeCertificateHolder holder, AttributeCertificateIssuer issuer, BigInteger serialNumber, Date notBefore, Date notAfter) Base constructor.- Parameters:
holder
- holder certificate detailsissuer
- issuer of this attribute certificate.serialNumber
- serial number of this attribute certificate.notBefore
- the date before which the certificate is not valid.notAfter
- the date after which the certificate is not valid.
-
X509v2AttributeCertificateBuilder
public X509v2AttributeCertificateBuilder(AttributeCertificateHolder holder, AttributeCertificateIssuer issuer, BigInteger serialNumber, Date notBefore, Date notAfter, Locale dateLocale) Base constructor with locale for interpreting dates. You may need to use this constructor if the default locale doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations.- Parameters:
holder
- holder certificate detailsissuer
- issuer of this attribute certificate.serialNumber
- serial number of this attribute certificate.notBefore
- the date before which the certificate is not valid.notAfter
- the date after which the certificate is not valid.dateLocale
- locale to be used for date interpretation.
-
X509v2AttributeCertificateBuilder
Create a builder for a version 2 attribute certificate, initialised with another certificate.- Parameters:
template
- template certificate to base the new one on.
-
-
Method Details
-
hasExtension
public boolean hasExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Return if the extension indicated by OID is present.- Parameters:
oid
- the OID for the extension of interest.- Returns:
- the Extension, or null if it is not present.
-
getExtension
public org.bouncycastle.asn1.x509.Extension getExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Return the current value of the extension for OID.- Parameters:
oid
- the OID for the extension we want to fetch.- Returns:
- true if a matching extension is present, false otherwise.
-
addAttribute
public X509v2AttributeCertificateBuilder addAttribute(org.bouncycastle.asn1.ASN1ObjectIdentifier attrType, org.bouncycastle.asn1.ASN1Encodable attrValue) Add an attribute to the certification request we are building.- Parameters:
attrType
- the OID giving the type of the attribute.attrValue
- the ASN.1 structure that forms the value of the attribute.- Returns:
- this builder object.
-
addAttribute
public X509v2AttributeCertificateBuilder addAttribute(org.bouncycastle.asn1.ASN1ObjectIdentifier attrType, org.bouncycastle.asn1.ASN1Encodable[] attrValues) Add an attribute with multiple values to the certification request we are building.- Parameters:
attrType
- the OID giving the type of the attribute.attrValues
- an array of ASN.1 structures that form the value of the attribute.- Returns:
- this builder object.
-
setIssuerUniqueId
public void setIssuerUniqueId(boolean[] iui) -
addExtension
public X509v2AttributeCertificateBuilder addExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, org.bouncycastle.asn1.ASN1Encodable value) throws CertIOException Add a given extension field for the standard extensions tag made up of the passed in parameters.- Parameters:
oid
- the OID defining the extension type.isCritical
- true if the extension is critical, false otherwise.value
- the ASN.1 structure that forms the extension's value.- Returns:
- this builder object.
- Throws:
CertIOException
-
addExtension
public X509v2AttributeCertificateBuilder addExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, byte[] encodedValue) throws CertIOException Add a given extension field for the standard extensions using a byte encoding of the extension value.- Parameters:
oid
- the OID defining the extension type.isCritical
- true if the extension is critical, false otherwise.encodedValue
- a byte array representing the encoding of the extension value.- Returns:
- this builder object.
- Throws:
CertIOException
-
addExtension
public X509v2AttributeCertificateBuilder addExtension(org.bouncycastle.asn1.x509.Extension extension) throws CertIOException Add a given extension field for the standard extensions.- Parameters:
extension
- the full extension value.- Returns:
- this builder object.
- Throws:
CertIOException
-
replaceExtension
public X509v2AttributeCertificateBuilder replaceExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, org.bouncycastle.asn1.ASN1Encodable value) throws CertIOException Replace the extension field for the passed in extension's extension ID with a new version.- Parameters:
oid
- the OID defining the extension type.isCritical
- true if the extension is critical, false otherwise.value
- the ASN.1 structure that forms the extension's value.- Returns:
- this builder object.
- Throws:
CertIOException
- if there is an issue with the new extension value.IllegalArgumentException
- if the extension to be replaced is not present.
-
replaceExtension
public X509v2AttributeCertificateBuilder replaceExtension(org.bouncycastle.asn1.x509.Extension extension) throws CertIOException Replace the extension field for the passed in extension's extension ID with a new version.- Parameters:
extension
- the full extension value.- Returns:
- this builder object.
- Throws:
CertIOException
- if there is an issue with the new extension value.IllegalArgumentException
- if the extension to be replaced is not present.
-
replaceExtension
public X509v2AttributeCertificateBuilder replaceExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid, boolean isCritical, byte[] encodedValue) throws CertIOException Replace a given extension field for the standard extensions tag (tag 3) with the passed in byte encoded extension value.- Parameters:
oid
- the OID defining the extension type.isCritical
- true if the extension is critical, false otherwise.encodedValue
- a byte array representing the encoding of the extension value.- Returns:
- this builder object.
- Throws:
CertIOException
- if there is an issue with the new extension value.IllegalArgumentException
- if the extension to be replaced is not present.
-
removeExtension
public X509v2AttributeCertificateBuilder removeExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Remove the extension indicated by OID.- Parameters:
oid
- the OID of the extension to be removed.- Returns:
- this builder object.
- Throws:
IllegalArgumentException
- if the extension to be removed is not present.
-
build
Generate an X509 certificate, based on the current issuer and subject using the passed in signer.- Parameters:
signer
- the content signer to be used to generate the signature validating the certificate.- Returns:
- a holder containing the resulting signed certificate.
-