@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new Certificate( (TBSCertificate) values[0], (AlgorithmIdentifier) values[1], ((BitString) values[2]).bytes, // FIXME keep as BitString object in.getEncoded()); }
private byte[] getEncodedInternal() throws CertificateEncodingException { byte[] result = encoding; if (encoding == null) { encoding = result = certificate.getEncoded(); } return result; }
private byte[] getSignatureInternal() { byte[] result = signature; if (result == null) { signature = result = certificate.getSignatureValue(); } return result; }
/** * Constructs the instance on the base of existing Certificate object to * be wrapped. */ public X509CertImpl(Certificate certificate) { this.certificate = certificate; // cache the values of TBSCertificate and Extensions this.tbsCert = certificate.getTbsCertificate(); this.extensions = tbsCert.getExtensions(); }
@Override public String toString() { return certificate.toString(); }
/** * Constructs the instance on the base of ASN.1 encoded * form of X.509 certificate provided via stream parameter. * @param in input stream containing ASN.1 encoded form of certificate. * @throws CertificateException if some decoding problems occur. */ public X509CertImpl(InputStream in) throws CertificateException { try { // decode the Certificate object this.certificate = (Certificate) Certificate.ASN1.decode(in); // cache the values of TBSCertificate and Extensions this.tbsCert = certificate.getTbsCertificate(); this.extensions = tbsCert.getExtensions(); } catch (IOException e) { throw new CertificateException(e); } }
@Override public String toString() { return certificate.toString(); }
@Override public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { Signature signature = Signature.getInstance(getSigAlgName()); signature.initVerify(key); // retrieve the encoding of the TBSCertificate structure byte[] tbsCertificateLocal = getTbsCertificateInternal(); // compute and verify the signature signature.update(tbsCertificateLocal, 0, tbsCertificateLocal.length); if (!signature.verify(certificate.getSignatureValue())) { throw new SignatureException("Signature was not verified"); } }
/** * Constructs the instance on the base of existing Certificate object to * be wrapped. */ public X509CertImpl(Certificate certificate) { this.certificate = certificate; // cache the values of TBSCertificate and Extensions this.tbsCert = certificate.getTbsCertificate(); this.extensions = tbsCert.getExtensions(); }
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new Certificate( (TBSCertificate) values[0], (AlgorithmIdentifier) values[1], ((BitString) values[2]).bytes, // FIXME keep as BitString object in.getEncoded()); }
private byte[] getEncodedInternal() throws CertificateEncodingException { byte[] result = encoding; if (encoding == null) { encoding = result = certificate.getEncoded(); } return result; }
@Override public String toString() { return certificate.toString(); }
@Override public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { Signature signature = Signature.getInstance(getSigAlgName(), sigProvider); signature.initVerify(key); // retrieve the encoding of the TBSCertificate structure byte[] tbsCertificateLocal = getTbsCertificateInternal(); // compute and verify the signature signature.update(tbsCertificateLocal, 0, tbsCertificateLocal.length); if (!signature.verify(certificate.getSignatureValue())) { throw new SignatureException("Signature was not verified"); } }
/** * Constructs the instance on the base of existing Certificate object to * be wrapped. */ public X509CertImpl(Certificate certificate) { this.certificate = certificate; // cache the values of TBSCertificate and Extensions this.tbsCert = certificate.getTbsCertificate(); this.extensions = tbsCert.getExtensions(); }
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new Certificate( (TBSCertificate) values[0], (AlgorithmIdentifier) values[1], ((BitString) values[2]).bytes, // FIXME keep as BitString object in.getEncoded()); }
private byte[] getEncodedInternal() throws CertificateEncodingException { byte[] result = encoding; if (encoding == null) { encoding = result = certificate.getEncoded(); } return result; }
@Override public String toString() { return certificate.toString(); }
private byte[] getSignatureInternal() { byte[] result = signature; if (result == null) { signature = result = certificate.getSignatureValue(); } return result; }
/** * Constructs the instance on the base of existing Certificate object to * be wrapped. */ public X509CertImpl(Certificate certificate) { this.certificate = certificate; // cache the values of TBSCertificate and Extensions this.tbsCert = certificate.getTbsCertificate(); this.extensions = tbsCert.getExtensions(); }
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new Certificate( (TBSCertificate) values[0], (AlgorithmIdentifier) values[1], ((BitString) values[2]).bytes, // FIXME keep as BitString object in.getEncoded()); }