PKSigningInformationUtil { public PKSigningInformation loadSigningInformationFromPKCS12AndIntermediateCertificate(final String keyPath,final String keyPassword, final String appleWWDRCAFilePath) throws IOException, CertificateException { try (InputStream walletCertStream = CertUtils.toInputStream(keyPath); InputStream appleWWDRCertStream = CertUtils.toInputStream(appleWWDRCAFilePath)) { KeyStore pkcs12KeyStore = loadPKCS12File(walletCertStream, keyPassword); X509Certificate appleWWDRCert = loadDERCertificate(appleWWDRCertStream); return loadSigningInformation(pkcs12KeyStore, keyPassword, appleWWDRCert); } }  PKSigningInformation loadSigningInformation(final String keyStoreFilePath,
                                                       final String keyStorePassword,
                                                       final String appleWWDRCAFilePath); PKSigningInformation loadSigningInformationFromPKCS12AndIntermediateCertificate(final String keyPath,final String keyPassword, final String appleWWDRCAFilePath); PKSigningInformation loadSigningInformationFromPKCS12AndIntermediateCertificate(InputStream keyStoreInputStream,
            String keyStorePassword, InputStream appleWWDRCAFileInputStream); @Deprecated KeyStore loadPKCS12File(String pathToP12, String password); @Deprecated KeyStore loadPKCS12File(InputStream inputStreamOfP12, String password); @Deprecated X509Certificate loadDERCertificate(String filePath); @Deprecated X509Certificate loadDERCertificate(InputStream certificateInputStream);  }
@Test public void testLoadStreams() throws Exception { try (InputStream keyStoreFIS = this.getClass().getResourceAsStream("/" + KEYSTORE_PATH); InputStream appleWWDRCAFIS = this.getClass().getResourceAsStream("/" + APPLE_WWDRCA)) { Assert.assertNotNull(keyStoreFIS, "Could not find key store file"); Assert.assertNotNull(appleWWDRCAFIS, "Could not find certificate file"); PKSigningInformation pkSigningInformation = new PKSigningInformationUtil() .loadSigningInformationFromPKCS12AndIntermediateCertificate(keyStoreFIS, KEYSTORE_PASSWORD, appleWWDRCAFIS); checkSigningInfoContent(pkSigningInformation); } }
@Test public void testLoadFiles() throws Exception { PKSigningInformation pkSigningInformation = new PKSigningInformationUtil().loadSigningInformationFromPKCS12AndIntermediateCertificate( KEYSTORE_PATH, KEYSTORE_PASSWORD, APPLE_WWDRCA); checkSigningInfoContent(pkSigningInformation); }
@Test(expectedExceptions = CertificateExpiredException.class) public void testLoadFiles_invalidCert() throws Exception { new PKSigningInformationUtil().loadSigningInformationFromPKCS12AndIntermediateCertificate(KEYSTORE_PATH_EXPIRED, KEYSTORE_PASSWORD_EXPIRED, APPLE_WWDRCA); }