Just An Application

August 15, 2014

And Another One: Part Fifteen — JarEntry.getCertificates And JarVerifier.getCertificates

Having read the contents of the file in the JAR the PackageParser.loadCertificates method returns the result of calling getCertificates on the given JarEntry.

JarEntry.getCertificates

File

    $(ANDROID_SRC)/libcore/luni/src/main/java/java/util/jar/JarEntry.java

Source

    ...
    
    public Certificate[] getCertificates() {
        if (parentJar == null) {
            return null;
        }
        JarVerifier jarVerifier = parentJar.verifier;
        if (jarVerifier == null) {
            return null;
        }
        return jarVerifier.getCertificates(getName());
    }

    ...

The JarEntry getCertificates method is effectively a wrapper around the JarVerifier getCertificates method.

JarVerifier.getCertificates

File

    $(ANDROID_SRC)/libcore/luni/src/main/java/java/util/jar/JarVerifier.java

Source

    ...
    
    Certificate[] getCertificates(String name) {
        Certificate[] verifiedCerts = verifiedEntries.get(name);
        if (verifiedCerts == null) {
            return null;
        }
        return verifiedCerts.clone();
    }
    ...

The JarVerifier getCertificates method returns a copy of the array of certificates, if any, found in the verifiedEntries Hashtable.

As we have seen the certificates would have been added by the verify method when it was called on the
JarVerifier.VerifierEntry associated with the given member of the JAR.


Copyright (c) 2014 By Simon Lewis. All Rights Reserved.

Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and owner Simon Lewis is strictly prohibited.

Excerpts and links may be used, provided that full and clear credit is given to Simon Lewis and justanapplication.wordpress.com with appropriate and specific direction to the original content.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: