Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
close jar file; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Liu Dong committed Oct 3, 2017
1 parent ad5ddbf commit 07ab4f1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Apk-parser has been submitted to maven central repo. With maven, you can add apk
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
</dependency>
```
From version 2.0, apk-parser requires java7. The last version support java6 is 1.7.4.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>apk-parser</artifactId>
<name>apk-parser</name>
<packaging>jar</packaging>
<version>2.2.0</version>
<version>2.2.1</version>
<url>https://github.com/xiaxiaocao/apk-parser</url>
<developers>
<developer>
Expand Down Expand Up @@ -92,7 +92,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadoc</id>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/dongliu/apk/parser/AbstractApkFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
* Common Apk Parser methods.
* This Class is not thread-safe
* This Class is not thread-safe.
*
* @author Liu Dong
*/
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/net/dongliu/apk/parser/ApkFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,24 @@ public ApkSignStatus verifyApk() throws IOException {
return ApkSignStatus.notSigned;
}

JarFile jarFile = new JarFile(this.apkFile);
Enumeration<JarEntry> entries = jarFile.entries();
byte[] buffer = new byte[8192];
try (JarFile jarFile = new JarFile(this.apkFile)) {
Enumeration<JarEntry> entries = jarFile.entries();
byte[] buffer = new byte[8192];

while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
if (e.isDirectory()) {
continue;
}
try (InputStream in = jarFile.getInputStream(e)) {
// Read in each jar entry. A security exception will be thrown if a signature/digest check fails.
int count;
while ((count = in.read(buffer, 0, buffer.length)) != -1) {
// Don't care
while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
if (e.isDirectory()) {
continue;
}
try (InputStream in = jarFile.getInputStream(e)) {
// Read in each jar entry. A security exception will be thrown if a signature/digest check fails.
int count;
while ((count = in.read(buffer, 0, buffer.length)) != -1) {
// Don't care
}
} catch (SecurityException se) {
return ApkSignStatus.incorrect;
}
} catch (SecurityException se) {
return ApkSignStatus.incorrect;
}
}
return ApkSignStatus.signed;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/dongliu/apk/parser/ApkParsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Locale;

/**
* Static utils method for parse apk file
* Convenient utils method for parse apk file
*
* @author Liu Dong
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public void parse() throws IOException, CertificateException {


private String md5Digest(byte[] input) throws IOException {
MessageDigest digest = getDigest("Md5");
MessageDigest digest = getDigest("md5");
digest.update(input);
return getHexString(digest.digest());
}

private String md5Digest(String input) throws IOException {
MessageDigest digest = getDigest("Md5");
MessageDigest digest = getDigest("md5");
digest.update(input.getBytes(StandardCharsets.UTF_8));
return getHexString(digest.digest());
}
Expand Down

0 comments on commit 07ab4f1

Please sign in to comment.