Java Code Examples for sun.security.pkcs.PKCS7#getCertificates()
The following examples show how to use
sun.security.pkcs.PKCS7#getCertificates() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CertificateParser.java From ApkToolPlus with Apache License 2.0 | 6 votes |
/** * get certificate info * * @throws IOException * @throws CertificateEncodingException */ public void parse() throws IOException, CertificateException { PKCS7 pkcs7 = new PKCS7(Utils.toByteArray(in)); X509Certificate[] certificates = pkcs7.getCertificates(); certificateMetas = new ArrayList<>(); for (X509Certificate certificate : certificates) { CertificateMeta certificateMeta = new CertificateMeta(); certificateMetas.add(certificateMeta); byte[] bytes = certificate.getEncoded(); String certMd5 = md5Digest(bytes); String publicKeyString = byteToHexString(bytes); String certBase64Md5 = md5Digest(publicKeyString); certificateMeta.setData(bytes); certificateMeta.setCertBase64Md5(certBase64Md5); certificateMeta.setCertMd5(certMd5); certificateMeta.setStartDate(certificate.getNotBefore()); certificateMeta.setEndDate(certificate.getNotAfter()); certificateMeta.setSignAlgorithm(certificate.getSigAlgName()); certificateMeta.setSignAlgorithmOID(certificate.getSigAlgOID()); } }
Example 2
Source File: X509Factory.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { Collection<X509CertImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(is); } } return coll; }
Example 3
Source File: X509Factory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { Collection<X509CertImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(is); } } return coll; }
Example 4
Source File: X509Factory.java From j2objc with Apache License 2.0 | 5 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { Collection<X509CertImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(is); } } return coll; }
Example 5
Source File: X509Factory.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 6
Source File: X509Factory.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 7
Source File: X509Factory.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 8
Source File: X509Factory.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 9
Source File: X509Factory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 10
Source File: X509Factory.java From Bytecoder with Apache License 2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 11
Source File: X509Factory.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 12
Source File: X509Factory.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 13
Source File: X509Factory.java From hottub with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 14
Source File: X509Factory.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 15
Source File: X509Factory.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example 16
Source File: X509Factory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.Certificate> parseX509orPKCS7Cert(InputStream is) throws CertificateException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CertImpl> coll = new ArrayList<>(); // Test the InputStream for end-of-stream. If the stream's // initial state is already at end-of-stream then return // an empty collection. Otherwise, push the byte back into the // stream and let readOneBlock look for the first certificate. peekByte = pbis.read(); if (peekByte == -1) { return new ArrayList<>(0); } else { pbis.unread(peekByte); data = readOneBlock(pbis); } // If we end up with a null value after reading the first block // then we know the end-of-stream has been reached and no certificate // data has been found. if (data == null) { throw new CertificateException("No certificate data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509Certificate[] certs = pkcs7.getCertificates(); // certs are optional in PKCS #7 if (certs != null) { return Arrays.asList(certs); } else { // no certificates provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CertImpl(data)); data = readOneBlock(pbis); } } return coll; }