public void checkValidity( Date date) throws CertificateExpiredException, CertificateNotYetValidException { 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 boolean hasUnsupportedCriticalExtension() { Set extensions = getCriticalExtensionOIDs(); return extensions != null && !extensions.isEmpty(); }
public int hashCode() { try { return Arrays.hashCode(this.getEncoded()); } catch (IOException e) { return 0; } } }
private X509AttributeCertificate readPEMCertificate( InputStream in) throws IOException { ASN1Sequence seq = PEM_PARSER.readPEMObject(in); if (seq != null) { return new X509V2AttributeCertificate(seq.getEncoded()); } return null; }
public Set getNonCriticalExtensionOIDs() { return getExtensionOIDs(false); }
public X509V2AttributeCertificate( byte[] encoded) throws IOException { this(new ByteArrayInputStream(encoded)); }
public final void verify( PublicKey key, String provider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { 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().getAlgorithm().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"); } }
private X509AttributeCertificate getCertificate() throws IOException { if (sData != null) { while (sDataObjectCount < sData.size()) { Object obj = sData.getObjectAt(sDataObjectCount++); if (obj instanceof ASN1TaggedObject && ((ASN1TaggedObject)obj).getTagNo() == 2) { return new X509V2AttributeCertificate( ASN1Sequence.getInstance((ASN1TaggedObject)obj, false).getEncoded()); } } } return null; }
public Set getCriticalExtensionOIDs() { return getExtensionOIDs(true); }
private X509AttributeCertificate readDERCertificate( InputStream in) throws IOException { ASN1InputStream dIn = new ASN1InputStream(in); ASN1Sequence seq = (ASN1Sequence)dIn.readObject(); if (seq.size() > 1 && seq.getObjectAt(0) instanceof ASN1ObjectIdentifier) { if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData)) { sData = new SignedData(ASN1Sequence.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates(); return getCertificate(); } } return new X509V2AttributeCertificate(seq.getEncoded()); }
public boolean equals( Object o) { if (o == this) { return true; } if (!(o instanceof X509AttributeCertificate)) { return false; } X509AttributeCertificate other = (X509AttributeCertificate)o; try { byte[] b1 = this.getEncoded(); byte[] b2 = other.getEncoded(); return Arrays.areEqual(b1, b2); } catch (IOException e) { return false; } }