Methods Summary |
---|
public void | checkValidity()
this.checkValidity(new Date());
|
public void | checkValidity(java.util.Date date)
if (date.after(this.getNotAfter()))
{
throw new CertificateExpiredException("certificate expired on " + this.getNotAfter());
}
if (date.before(this.getNotBefore()))
{
throw new CertificateNotYetValidException("certificate not valid till " + this.getNotBefore());
}
|
public X509Attribute[] | getAttributes()
ASN1Sequence seq = cert.getAcinfo().getAttributes();
X509Attribute[] attrs = new X509Attribute[seq.size()];
for (int i = 0; i != seq.size(); i++)
{
attrs[i] = new X509Attribute((ASN1Encodable)seq.getObjectAt(i));
}
return attrs;
|
public X509Attribute[] | getAttributes(java.lang.String oid)
ASN1Sequence seq = cert.getAcinfo().getAttributes();
List list = new ArrayList();
for (int i = 0; i != seq.size(); i++)
{
X509Attribute attr = new X509Attribute((ASN1Encodable)seq.getObjectAt(i));
if (attr.getOID().equals(oid))
{
list.add(attr);
}
}
if (list.size() == 0)
{
return null;
}
return (X509Attribute[])list.toArray(new X509Attribute[list.size()]);
|
public java.util.Set | getCriticalExtensionOIDs()
return getExtensionOIDs(true);
|
public byte[] | getEncoded()
return cert.getEncoded();
|
private java.util.Set | getExtensionOIDs(boolean critical)
X509Extensions extensions = cert.getAcinfo().getExtensions();
if (extensions != null)
{
Set set = new HashSet();
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (ext.isCritical() == critical)
{
set.add(oid.getId());
}
}
return set;
}
return null;
|
public byte[] | getExtensionValue(java.lang.String oid)
X509Extensions extensions = cert.getAcinfo().getExtensions();
if (extensions != null)
{
X509Extension ext = extensions.getExtension(new DERObjectIdentifier(oid));
if (ext != null)
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
dOut.writeObject(ext.getValue());
return bOut.toByteArray();
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
|
public AttributeCertificateHolder | getHolder()
return new AttributeCertificateHolder((ASN1Sequence)cert.getAcinfo().getHolder().toASN1Object());
|
public AttributeCertificateIssuer | getIssuer()
return new AttributeCertificateIssuer(cert.getAcinfo().getIssuer());
|
public boolean[] | getIssuerUniqueID()
DERBitString id = cert.getAcinfo().getIssuerUniqueID();
if (id != null)
{
byte[] bytes = id.getBytes();
boolean[] boolId = new boolean[bytes.length * 8 - id.getPadBits()];
for (int i = 0; i != boolId.length; i++)
{
boolId[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
}
return boolId;
}
return null;
|
public java.util.Set | getNonCriticalExtensionOIDs()
return getExtensionOIDs(false);
|
public java.util.Date | getNotAfter()
return notAfter;
|
public java.util.Date | getNotBefore()
return notBefore;
|
public java.math.BigInteger | getSerialNumber()
return cert.getAcinfo().getSerialNumber().getValue();
|
public byte[] | getSignature()
return cert.getSignatureValue().getBytes();
|
public int | getVersion()
return cert.getAcinfo().getVersion().getValue().intValue();
|
public boolean | hasUnsupportedCriticalExtension()
Set extensions = getCriticalExtensionOIDs();
return extensions != null && !extensions.isEmpty();
|
public final void | verify(java.security.PublicKey key, java.lang.String provider)
Signature signature = null;
if (!cert.getSignatureAlgorithm().equals(cert.getAcinfo().getSignature()))
{
throw new CertificateException("Signature algorithm in certificate info not same as outer certificate");
}
signature = Signature.getInstance(cert.getSignatureAlgorithm().getObjectId().getId(), provider);
signature.initVerify(key);
try
{
signature.update(cert.getAcinfo().getEncoded());
}
catch (IOException e)
{
throw new SignatureException("Exception encoding certificate info object");
}
if (!signature.verify(this.getSignature()))
{
throw new InvalidKeyException("Public key presented not for certificate signature");
}
|