/** * Return an AttributeCertificate interpretation of otherCert. * @deprecated use getOtherCert and getOtherTag to make sure message is really what it should be. * * @return an AttributeCertificate */ public AttributeCertificate getX509v2AttrCert() { return AttributeCertificate.getInstance(otherCert); }
/** * Create a X509AttributeCertificateHolder from the passed in ASN.1 structure. * * @param attrCert an ASN.1 AttributeCertificate structure. */ public X509AttributeCertificateHolder(AttributeCertificate attrCert) { this.attrCert = attrCert; this.extensions = attrCert.getAcinfo().getExtensions(); }
/** * Return the ASN.1 encoding of this holder's attribute certificate. * * @return a DER encoded byte array. * @throws IOException if an encoding cannot be generated. */ public byte[] getEncoded() throws IOException { return attrCert.getEncoded(); }
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"); } }
/** * Return the bytes making up the signature associated with this attribute certificate. * * @return the attribute certificate signature bytes. */ public byte[] getSignature() { return attrCert.getSignatureValue().getOctets(); }
/** * Return the details of the signature algorithm used to create this attribute certificate. * * @return the AlgorithmIdentifier describing the signature algorithm used to create this attribute certificate. */ public AlgorithmIdentifier getSignatureAlgorithm() { return attrCert.getSignatureAlgorithm(); }
/** * @param obj * @return an AttributeCertificate object */ public static AttributeCertificate getInstance(Object obj) { if (obj instanceof AttributeCertificate) { return (AttributeCertificate)obj; } else if (obj != null) { return new AttributeCertificate(ASN1Sequence.getInstance(obj)); } return null; }
public int hashCode() { return this.attrCert.hashCode(); } }
public boolean equals( Object o) { if (o == this) { return true; } if (!(o instanceof X509AttributeCertificateHolder)) { return false; } X509AttributeCertificateHolder other = (X509AttributeCertificateHolder)o; return this.attrCert.equals(other.attrCert); }
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().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"); } }
/** * Return the bytes making up the signature associated with this attribute certificate. * * @return the attribute certificate signature bytes. */ public byte[] getSignature() { return attrCert.getSignatureValue().getOctets(); }
/** * Return the details of the signature algorithm used to create this attribute certificate. * * @return the AlgorithmIdentifier describing the signature algorithm used to create this attribute certificate. */ public AlgorithmIdentifier getSignatureAlgorithm() { return attrCert.getSignatureAlgorithm(); }
/** * @param obj * @return an AttributeCertificate object */ public static AttributeCertificate getInstance(Object obj) { if (obj instanceof AttributeCertificate) { return (AttributeCertificate)obj; } else if (obj != null) { return new AttributeCertificate(ASN1Sequence.getInstance(obj)); } return null; }
public int hashCode() { return this.attrCert.hashCode(); }
public boolean equals( Object o) { if (o == this) { return true; } if (!(o instanceof X509AttributeCertificateHolder)) { return false; } X509AttributeCertificateHolder other = (X509AttributeCertificateHolder)o; return this.attrCert.equals(other.attrCert); }
private void init(AttributeCertificate attrCert) { this.attrCert = attrCert; this.extensions = attrCert.getAcinfo().getExtensions(); }
private void readObject( ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); init(AttributeCertificate.getInstance(in.readObject())); }
/** * Validate the signature on the attribute certificate in this holder. * * @param verifierProvider a ContentVerifierProvider that can generate a verifier for the signature. * @return true if the signature is valid, false otherwise. * @throws CertException if the signature cannot be processed or is inappropriate. */ public boolean isSignatureValid(ContentVerifierProvider verifierProvider) throws CertException { AttributeCertificateInfo acinfo = attrCert.getAcinfo(); if (!CertUtils.isAlgIdEqual(acinfo.getSignature(), attrCert.getSignatureAlgorithm())) { throw new CertException("signature invalid - algorithm identifier mismatch"); } ContentVerifier verifier; try { verifier = verifierProvider.get((acinfo.getSignature())); OutputStream sOut = verifier.getOutputStream(); DEROutputStream dOut = new DEROutputStream(sOut); dOut.writeObject(acinfo); sOut.close(); } catch (Exception e) { throw new CertException("unable to process signature: " + e.getMessage(), e); } return verifier.verify(this.getSignature()); }
public byte[] getEncoded() throws IOException { return cert.getEncoded(); }
public byte[] getSignature() { return cert.getSignatureValue().getBytes(); }