407 */ |
407 */ |
408 private Collection<? extends java.security.cert.Certificate> |
408 private Collection<? extends java.security.cert.Certificate> |
409 parseX509orPKCS7Cert(InputStream is) |
409 parseX509orPKCS7Cert(InputStream is) |
410 throws CertificateException, IOException |
410 throws CertificateException, IOException |
411 { |
411 { |
412 Collection<X509CertImpl> coll = new ArrayList<X509CertImpl>(); |
412 Collection<X509CertImpl> coll = new ArrayList<>(); |
413 byte[] data = readOneBlock(is); |
413 byte[] data = readOneBlock(is); |
414 if (data == null) { |
414 if (data == null) { |
415 return new ArrayList<X509CertImpl>(0); |
415 return new ArrayList<>(0); |
416 } |
416 } |
417 try { |
417 try { |
418 PKCS7 pkcs7 = new PKCS7(data); |
418 PKCS7 pkcs7 = new PKCS7(data); |
419 X509Certificate[] certs = pkcs7.getCertificates(); |
419 X509Certificate[] certs = pkcs7.getCertificates(); |
420 // certs are optional in PKCS #7 |
420 // certs are optional in PKCS #7 |
421 if (certs != null) { |
421 if (certs != null) { |
422 return Arrays.asList(certs); |
422 return Arrays.asList(certs); |
423 } else { |
423 } else { |
424 // no crls provided |
424 // no crls provided |
425 return new ArrayList<X509Certificate>(0); |
425 return new ArrayList<>(0); |
426 } |
426 } |
427 } catch (ParsingException e) { |
427 } catch (ParsingException e) { |
428 while (data != null) { |
428 while (data != null) { |
429 coll.add(new X509CertImpl(data)); |
429 coll.add(new X509CertImpl(data)); |
430 data = readOneBlock(is); |
430 data = readOneBlock(is); |
440 */ |
440 */ |
441 private Collection<? extends java.security.cert.CRL> |
441 private Collection<? extends java.security.cert.CRL> |
442 parseX509orPKCS7CRL(InputStream is) |
442 parseX509orPKCS7CRL(InputStream is) |
443 throws CRLException, IOException |
443 throws CRLException, IOException |
444 { |
444 { |
445 Collection<X509CRLImpl> coll = new ArrayList<X509CRLImpl>(); |
445 Collection<X509CRLImpl> coll = new ArrayList<>(); |
446 byte[] data = readOneBlock(is); |
446 byte[] data = readOneBlock(is); |
447 if (data == null) { |
447 if (data == null) { |
448 return new ArrayList<X509CRL>(0); |
448 return new ArrayList<>(0); |
449 } |
449 } |
450 try { |
450 try { |
451 PKCS7 pkcs7 = new PKCS7(data); |
451 PKCS7 pkcs7 = new PKCS7(data); |
452 X509CRL[] crls = pkcs7.getCRLs(); |
452 X509CRL[] crls = pkcs7.getCRLs(); |
453 // CRLs are optional in PKCS #7 |
453 // CRLs are optional in PKCS #7 |
454 if (crls != null) { |
454 if (crls != null) { |
455 return Arrays.asList(crls); |
455 return Arrays.asList(crls); |
456 } else { |
456 } else { |
457 // no crls provided |
457 // no crls provided |
458 return new ArrayList<X509CRL>(0); |
458 return new ArrayList<>(0); |
459 } |
459 } |
460 } catch (ParsingException e) { |
460 } catch (ParsingException e) { |
461 while (data != null) { |
461 while (data != null) { |
462 coll.add(new X509CRLImpl(data)); |
462 coll.add(new X509CRLImpl(data)); |
463 data = readOneBlock(is); |
463 data = readOneBlock(is); |