/** * @see java.security.cert.CertPath#getEncoded(String) */ @Override public byte[] getEncoded(String encoding) throws CertificateEncodingException { final Encoding encType = Encoding.findByApiName(encoding); if (encType == null) { throw new CertificateEncodingException("Unsupported encoding: " + encoding); } return getEncoded(encType); }
cert = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(certificateInput); } catch (Exception e) { throw new CertificateEncodingException(e); } finally { if (certificateInput != null) {
"Failed to sign using signer \"" + signerName + "\"", e); } catch (CertificateEncodingException e) { throw new CertificateEncodingException( "Failed to sign using signer \"" + signerName + "\"", e); } catch (SignatureException e) {
cert = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(certificateInput); } catch (Exception e) { throw new CertificateEncodingException(e); } finally { if (certificateInput != null) {
throw new CertificateEncodingException("Error during creation of self-signed Certificate: " + ioe.getMessage(), ioe);
/** * @see #getEncoded(String) */ private byte[] getEncoded(Encoding encoding) throws CertificateEncodingException { switch (encoding) { case PKI_PATH: if (pkiPathEncoding == null) { pkiPathEncoding = ASN1.encode(this); } return pkiPathEncoding.clone(); case PKCS7: if (pkcs7Encoding == null) { pkcs7Encoding = PKCS7_SIGNED_DATA_OBJECT.encode(this); } return pkcs7Encoding.clone(); default: throw new CertificateEncodingException("Unsupported encoding: " + encoding); } }
byte[] data = Base64.decode(buf.toString(), true); if (data == null) throw new CertificateEncodingException("bad base64 cert"); PrivateKey rv = null;
cert = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(certificateInput); } catch (Exception e) { throw new CertificateEncodingException(e); } finally { if (certificateInput != null) {
public byte[] getEncoded() throws CertificateEncodingException { try { return c.getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
public static OpenSSLX509Certificate fromCertificate(Certificate cert) throws CertificateEncodingException { if (cert instanceof OpenSSLX509Certificate) { return (OpenSSLX509Certificate) cert; } else if (cert instanceof X509Certificate) { return fromX509Der(cert.getEncoded()); } else { throw new CertificateEncodingException("Only X.509 certificates are supported"); } }
public byte[] getTBSCertificate() throws CertificateEncodingException { try { return c.getTBSCertificate().getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
public byte[] getTBSCertificate() throws CertificateEncodingException { try { return c.getTBSCertificate().getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
public byte[] getTBSCertificate() throws CertificateEncodingException { try { return c.getTBSCertificate().getEncoded(ASN1Encoding.DER); } catch (IOException e) { throw new CertificateEncodingException(e.toString()); } }
/** * @see java.security.cert.CertPath#getEncoded(String) */ @Override public byte[] getEncoded(String encoding) throws CertificateEncodingException { final Encoding encType = Encoding.findByApiName(encoding); if (encType == null) { throw new CertificateEncodingException("Unsupported encoding: " + encoding); } return getEncoded(encType); }
@Override public byte[] getEncoded(String encoding) throws CertificateEncodingException { Encoding enc = Encoding.findByApiName(encoding); if (enc == null) { throw new CertificateEncodingException("Invalid encoding: " + encoding); } return getEncoded(enc); }
private static CertPath fromEncoding(InputStream inStream, Encoding encoding) throws CertificateException { switch (encoding) { case PKI_PATH: return fromPkiPathEncoding(inStream); case PKCS7: return fromPkcs7Encoding(inStream); default: throw new CertificateEncodingException("Unknown encoding"); } }
public static X509Certificate parseCert(byte[] certBytes) throws CertificateException { Args.notNull(certBytes, "certBytes"); X509Certificate cert = (X509Certificate) getCertFactory().generateCertificate( new ByteArrayInputStream(toDerEncoded(certBytes))); if (cert == null) { throw new CertificateEncodingException("the given one is not a valid X.509 certificate"); } return cert; }
private static CertPath fromEncoding(InputStream inStream, Encoding encoding) throws CertificateException { switch (encoding) { case PKI_PATH: return fromPkiPathEncoding(inStream); case PKCS7: return fromPkcs7Encoding(inStream); default: throw new CertificateEncodingException("Unknown encoding"); } }
public static X509Certificate toX509Cert( final org.bouncycastle.asn1.x509.Certificate asn1Cert) throws CertificateException { byte[] encodedCert; try { encodedCert = asn1Cert.getEncoded(); } catch (IOException ex) { throw new CertificateEncodingException("could not get encoded certificate", ex); } return parseCert(encodedCert); }
public static byte[] extractAki(org.bouncycastle.asn1.x509.Certificate cert) throws CertificateEncodingException { Args.notNull(cert, "cert"); try { AuthorityKeyIdentifier aki = AuthorityKeyIdentifier.fromExtensions( cert.getTBSCertificate().getExtensions()); return (aki == null) ? null : aki.getKeyIdentifier(); } catch (IllegalArgumentException ex) { throw new CertificateEncodingException("invalid extension AuthorityKeyIdentifier: " + ex.getMessage()); } }