sun.security.pkcs.ParsingException Java Examples
The following examples show how to use
sun.security.pkcs.ParsingException.
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: MacData.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #2
Source File: MacData.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #3
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 #4
Source File: X509Factory.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { Collection<X509CRLImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(is); } } return coll; }
Example #5
Source File: MacData.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #6
Source File: MacData.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #7
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 #8
Source File: MacData.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #9
Source File: X509Factory.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { Collection<X509CRLImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(is); } } return coll; }
Example #10
Source File: MacData.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #11
Source File: MacData.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #12
Source File: MacData.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #13
Source File: MacData.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #14
Source File: MacData.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #15
Source File: MacData.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #16
Source File: MacData.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #17
Source File: MacData.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #18
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 #19
Source File: MacData.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Parses a PKCS#12 MAC data. */ MacData(DerInputStream derin) throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); this.digestAlgorithmName = digestAlgorithmId.getName(); this.digestAlgorithmParams = digestAlgorithmId.getParameters(); // Get the digest. this.digest = digestInfo[1].getOctetString(); // Get the salt. this.macSalt = macData[1].getOctetString(); // Iterations is optional. The default value is 1. if (macData.length > 2) { this.iterations = macData[2].getInteger(); } else { this.iterations = 1; } }
Example #20
Source File: X509Factory.java From j2objc with Apache License 2.0 | 5 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { Collection<X509CRLImpl> coll = new ArrayList<>(); byte[] data = readOneBlock(is); if (data == null) { return new ArrayList<>(0); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(is); } } return coll; }
Example #21
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 #22
Source File: X509Factory.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CRLImpl> 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 CRL. 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 CRL // data has been found. if (data == null) { throw new CRLException("No CRL data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example #23
Source File: X509Factory.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CRLImpl> 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 CRL. 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 CRL // data has been found. if (data == null) { throw new CRLException("No CRL data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example #24
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 #25
Source File: X509Factory.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CRLImpl> 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 CRL. 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 CRL // data has been found. if (data == null) { throw new CRLException("No CRL data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example #26
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; }
Example #27
Source File: X509Factory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CRLImpl> 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 CRL. 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 CRL // data has been found. if (data == null) { throw new CRLException("No CRL data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example #28
Source File: X509Factory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CRLImpl> 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 CRL. 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 CRL // data has been found. if (data == null) { throw new CRLException("No CRL data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example #29
Source File: X509Factory.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is) throws CRLException, IOException { int peekByte; byte[] data; PushbackInputStream pbis = new PushbackInputStream(is); Collection<X509CRLImpl> 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 CRL. 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 CRL // data has been found. if (data == null) { throw new CRLException("No CRL data found"); } try { PKCS7 pkcs7 = new PKCS7(data); X509CRL[] crls = pkcs7.getCRLs(); // CRLs are optional in PKCS #7 if (crls != null) { return Arrays.asList(crls); } else { // no crls provided return new ArrayList<>(0); } } catch (ParsingException e) { while (data != null) { coll.add(new X509CRLImpl(data)); data = readOneBlock(pbis); } } return coll; }
Example #30
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; }