Methods Summary |
---|
public void | addAttribute(X509Attribute attribute)add an attribute
acInfoGen.addAttribute(Attribute.getInstance(attribute.toASN1Object()));
|
public void | addExtension(java.lang.String OID, boolean critical, org.bouncycastle.asn1.ASN1Encodable value)add a given extension field for the standard extensions tag
this.addExtension(OID, critical, value.getEncoded());
|
public void | addExtension(java.lang.String OID, boolean critical, byte[] value)add a given extension field for the standard extensions tag
The value parameter becomes the contents of the octet string associated
with the extension.
if (extensions == null)
{
extensions = new Hashtable();
extOrdering = new Vector();
}
DERObjectIdentifier oid = new DERObjectIdentifier(OID);
extensions.put(oid, new X509Extension(critical, new DEROctetString(value)));
extOrdering.addElement(oid);
|
public X509AttributeCertificate | generateCertificate(java.security.PrivateKey key, java.lang.String provider)generate an X509 certificate, based on the current issuer and subject,
using the passed in provider for the signing.
return generateCertificate(key, provider, null);
|
public X509AttributeCertificate | generateCertificate(java.security.PrivateKey key, java.lang.String provider, java.security.SecureRandom random)generate an X509 certificate, based on the current issuer and subject,
using the passed in provider for the signing and the supplied source
of randomness, if required.
Signature sig = null;
if (sigOID == null)
{
throw new IllegalStateException("no signature algorithm specified");
}
try
{
sig = Signature.getInstance(sigOID.getId(), provider);
}
catch (NoSuchAlgorithmException ex)
{
try
{
sig = Signature.getInstance(signatureAlgorithm, provider);
}
catch (NoSuchAlgorithmException e)
{
throw new SecurityException("exception creating signature: " + e.toString());
}
}
if (random != null)
{
sig.initSign(key, random);
}
else
{
sig.initSign(key);
}
if (extensions != null)
{
acInfoGen.setExtensions(new X509Extensions(extOrdering, extensions));
}
AttributeCertificateInfo acInfo = acInfoGen.generateAttributeCertificateInfo();
try
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
dOut.writeObject(acInfo);
sig.update(bOut.toByteArray());
}
catch (Exception e)
{
throw new SecurityException("exception encoding Attribute cert - " + e);
}
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(acInfo);
v.add(sigAlgId);
v.add(new DERBitString(sig.sign()));
try
{
return new X509V2AttributeCertificate(new AttributeCertificate(new DERSequence(v)));
}
catch (IOException e)
{
throw new RuntimeException("constructed invalid certificate!");
}
|
public java.util.Iterator | getSignatureAlgNames()Return an iterator of the signature names supported by the generator.
return X509Util.getAlgNames();
|
public void | reset()reset the generator
acInfoGen = new V2AttributeCertificateInfoGenerator();
extensions = null;
extOrdering = null;
|
public void | setHolder(AttributeCertificateHolder holder)Set the Holder of this Attribute Certificate
acInfoGen.setHolder(holder.holder);
|
public void | setIssuer(AttributeCertificateIssuer issuer)Set the issuer
acInfoGen.setIssuer(AttCertIssuer.getInstance(issuer.form));
|
public void | setIssuerUniqueId(boolean[] iui)
// [TODO] convert boolean array to bit string
//acInfoGen.setIssuerUniqueID(iui);
throw new RuntimeException("not implemented (yet)");
|
public void | setNotAfter(java.util.Date date)
acInfoGen.setEndDate(new DERGeneralizedTime(date));
|
public void | setNotBefore(java.util.Date date)
acInfoGen.setStartDate(new DERGeneralizedTime(date));
|
public void | setSerialNumber(java.math.BigInteger serialNumber)set the serial number for the certificate.
acInfoGen.setSerialNumber(new DERInteger(serialNumber));
|
public void | setSignatureAlgorithm(java.lang.String signatureAlgorithm)Set the signature algorithm. This can be either a name or an OID, names
are treated as case insensitive.
this.signatureAlgorithm = signatureAlgorithm;
try
{
sigOID = X509Util.getAlgorithmOID(signatureAlgorithm);
}
catch (Exception e)
{
throw new IllegalArgumentException("Unknown signature type requested");
}
// BEGIN android-changed
sigAlgId = new AlgorithmIdentifier(this.sigOID, DERNull.THE_ONE);
// END android-changed
acInfoGen.setSignature(sigAlgId);
|