@Test public void testV1MultipleDigestAlgsInManifestAndSignatureFile() throws Exception { assertVerified(verify("v1-sha1-sha256-manifest-and-sha1-sf.apk")); assertVerified(verify("v1-sha1-sha256-manifest-and-sf.apk")); assertVerificationFailure( verify("v1-sha1-sha256-manifest-and-sf-with-sha1-wrong-in-manifest.apk"), Issue.JAR_SIG_ZIP_ENTRY_DIGEST_DID_NOT_VERIFY); assertVerificationFailure( verifyForMaxSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha1-wrong-in-manifest.apk", 17), Issue.JAR_SIG_ZIP_ENTRY_DIGEST_DID_NOT_VERIFY); assertVerified( verifyForMinSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha1-wrong-in-manifest.apk", 18)); assertVerificationFailure( verify("v1-sha1-sha256-manifest-and-sf-with-sha1-wrong-in-sf.apk"), Issue.JAR_SIG_MANIFEST_SECTION_DIGEST_DID_NOT_VERIFY); assertVerificationFailure( verifyForMaxSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha1-wrong-in-sf.apk", 17), Issue.JAR_SIG_MANIFEST_SECTION_DIGEST_DID_NOT_VERIFY); assertVerified( verifyForMinSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha1-wrong-in-sf.apk", 18)); assertVerificationFailure( verify("v1-sha1-sha256-manifest-and-sf-with-sha256-wrong-in-manifest.apk"), Issue.JAR_SIG_ZIP_ENTRY_DIGEST_DID_NOT_VERIFY); assertVerificationFailure( verifyForMinSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha256-wrong-in-manifest.apk", 18), Issue.JAR_SIG_ZIP_ENTRY_DIGEST_DID_NOT_VERIFY); assertVerified( verifyForMaxSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha256-wrong-in-manifest.apk", 17)); assertVerificationFailure( verify("v1-sha1-sha256-manifest-and-sf-with-sha256-wrong-in-sf.apk"), Issue.JAR_SIG_MANIFEST_SECTION_DIGEST_DID_NOT_VERIFY); assertVerificationFailure( verifyForMinSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha256-wrong-in-sf.apk", 18), Issue.JAR_SIG_MANIFEST_SECTION_DIGEST_DID_NOT_VERIFY); assertVerified( verifyForMaxSdkVersion( "v1-sha1-sha256-manifest-and-sf-with-sha256-wrong-in-sf.apk", 17)); }
public Result verify() throws IOException, ApkFormatException, NoSuchAlgorithmException, IllegalStateException { Closeable in = null; try { DataSource apk; if (mApkDataSource != null) { apk = mApkDataSource; } else if (mApkFile != null) { RandomAccessFile f = new RandomAccessFile(mApkFile, "r"); in = f; apk = DataSources.asDataSource(f, 0, f.length()); } else { throw new IllegalStateException("APK not provided"); } return verify(apk); } finally { if (in != null) { in.close(); } } }
ApkVerifier { public Result verify() throws IOException, ApkFormatException, NoSuchAlgorithmException, IllegalStateException { Closeable in = null; try { DataSource apk; if (mApkDataSource != null) { apk = mApkDataSource; } else if (mApkFile != null) { RandomAccessFile f = new RandomAccessFile(mApkFile, "r"); in = f; apk = DataSources.asDataSource(f, 0, f.length()); } else { throw new IllegalStateException("APK not provided"); } return verify(apk); } finally { if (in != null) { in.close(); } } } }
ApkVerifier { public Result verify() throws IOException, ApkFormatException, NoSuchAlgorithmException, IllegalStateException { Closeable in = null; try { DataSource apk; if (mApkDataSource != null) { apk = mApkDataSource; } else if (mApkFile != null) { RandomAccessFile f = new RandomAccessFile(mApkFile, "r"); in = f; apk = DataSources.asDataSource(f, 0, f.length()); } else { throw new IllegalStateException("APK not provided"); } return verify(apk); } finally { if (in != null) { in.close(); } } } private  ApkVerifier(
            File apkFile,
            DataSource apkDataSource,
            Integer minSdkVersion,
            int maxSdkVersion); }
ApkVerifier { public Result verify() throws IOException, ApkFormatException, NoSuchAlgorithmException, IllegalStateException { Closeable in = null; try { DataSource apk; if (mApkDataSource != null) { apk = mApkDataSource; } else if (mApkFile != null) { RandomAccessFile f = new RandomAccessFile(mApkFile, "r"); in = f; apk = DataSources.asDataSource(f, 0, f.length()); } else { throw new IllegalStateException("APK not provided"); } return verify(apk); } finally { if (in != null) { in.close(); } } } private  ApkVerifier(
            File apkFile,
            DataSource apkDataSource,
            Integer minSdkVersion,
            int maxSdkVersion); Result verify(); }
ApkVerifier { public Result verify() throws IOException, ApkFormatException, NoSuchAlgorithmException, IllegalStateException { Closeable in = null; try { DataSource apk; if (mApkDataSource != null) { apk = mApkDataSource; } else if (mApkFile != null) { RandomAccessFile f = new RandomAccessFile(mApkFile, "r"); in = f; apk = DataSources.asDataSource(f, 0, f.length()); } else { throw new IllegalStateException("APK not provided"); } return verify(apk); } finally { if (in != null) { in.close(); } } } private  ApkVerifier(
            File apkFile,
            DataSource apkDataSource,
            Integer minSdkVersion,
            int maxSdkVersion); Result verify();  }