APIdia Launch Partner
Top Inners Fields Constructors Methods
java.util.jar

pack-priv Class JarVerifier

extends Object
Class Inheritance
Imports
java.io.*, java.util.*, java.security.CodeSigner, .NoSuchAlgorithmException, .SignatureException, java.security.cert.Certificate, .CertificateException, sun.security.util.ManifestDigester, .ManifestEntryVerifier, .SignatureFileVerifier, .Debug

Author
Roland Schemers

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private boolean
private ByteArrayOutputStream
pack-priv static final Debug
private volatile ManifestDigester
manDig

The ManifestDigester object

private List<Object>
manifestDigests

collect -DIGEST-MANIFEST values for deny list

pack-priv final String
manifestName

the manifest name this JarVerifier is created upon

pack-priv byte[]
manifestRawBytes

the bytes for the manDig object

public static final String
private boolean
private boolean
private ArrayList<SignatureFileVerifier>
pendingBlocks

"queue" of pending PKCS7 blocks that we couldn't parse until we parsed the .SF file

private Hashtable<String, byte[]>
private Hashtable<String, CodeSigner[]>
private List<CodeSigner[]>
private Map<CodeSigner[], Map<String, Boolean>>
private Hashtable<String, CodeSigner[]>

Constructor Summary

AccessConstructor and Description
public
JarVerifier(String name, byte[] rawBytes)

Method Summary

Modifier and TypeMethod and Description
public void
beginEntry(JarEntry je, ManifestEntryVerifier mev)

This method scans to see which entry we're parsing and keeps various state information depending on what type of file is being parsed.

pack-priv void
doneWithMeta()

called to let us know we have processed all the META-INF entries, and if we re-read one of them, don't re-process it.

public Certificate[]
getCerts(JarEntry entry)

Return an array of Certificate objects for the given file in the jar.

public CodeSigner[]
getCodeSigners(JarEntry entry)

return an array of CodeSigner objects for the given file in the jar.

pack-priv boolean
isTrustedManifestEntry(String name)

Returns whether the name is trusted.

private static Certificate[]
pack-priv boolean
nothingToVerify()

returns true if there no files to verify.

private void
processEntry(ManifestEntryVerifier mev)

called when we reach the end of entry in one of the read() methods.

public void
update(int b, ManifestEntryVerifier mev)

update a single byte.

public void
update(int n, byte[] b, int off, int len, ManifestEntryVerifier mev)

update an array of bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

anyToVerifyback to summary
private boolean anyToVerify
baosback to summary
private ByteArrayOutputStream baos
debugback to summary
pack-priv static final Debug debug
manDigback to summary
private volatile ManifestDigester manDig

The ManifestDigester object

manifestDigestsback to summary
private List<Object> manifestDigests

collect -DIGEST-MANIFEST values for deny list

manifestNameback to summary
pack-priv final String manifestName

the manifest name this JarVerifier is created upon

manifestRawBytesback to summary
pack-priv byte[] manifestRawBytes

the bytes for the manDig object

MULTIPLE_MANIFEST_WARNINGback to summary
public static final String MULTIPLE_MANIFEST_WARNING
parsingBlockOrSFback to summary
private boolean parsingBlockOrSF
parsingMetaback to summary
private boolean parsingMeta
pendingBlocksback to summary
private ArrayList<SignatureFileVerifier> pendingBlocks

"queue" of pending PKCS7 blocks that we couldn't parse until we parsed the .SF file

sigFileDataback to summary
private Hashtable<String, byte[]> sigFileData
sigFileSignersback to summary
private Hashtable<String, CodeSigner[]> sigFileSigners
signerCacheback to summary
private List<CodeSigner[]> signerCache
signersToAlgsback to summary
private Map<CodeSigner[], Map<String, Boolean>> signersToAlgs
verifiedSignersback to summary
private Hashtable<String, CodeSigner[]> verifiedSigners

Constructor Detail

JarVerifierback to summary
public JarVerifier(String name, byte[] rawBytes)

Method Detail

beginEntryback to summary
public void beginEntry(JarEntry je, ManifestEntryVerifier mev) throws IOException

This method scans to see which entry we're parsing and keeps various state information depending on what type of file is being parsed.

doneWithMetaback to summary
pack-priv void doneWithMeta()

called to let us know we have processed all the META-INF entries, and if we re-read one of them, don't re-process it. Also gets rid of any data structures we needed when parsing META-INF entries.

getCertsback to summary
public Certificate[] getCerts(JarEntry entry)

Return an array of Certificate objects for the given file in the jar.

getCodeSignersback to summary
public CodeSigner[] getCodeSigners(JarEntry entry)

return an array of CodeSigner objects for the given file in the jar. this array is not cloned.

isTrustedManifestEntryback to summary
pack-priv boolean isTrustedManifestEntry(String name)

Returns whether the name is trusted. Used by Manifest#getTrustedAttributes(String).

mapSignersToCertArrayback to summary
private static Certificate[] mapSignersToCertArray(CodeSigner[] signers)
nothingToVerifyback to summary
pack-priv boolean nothingToVerify()

returns true if there no files to verify. should only be called after all the META-INF entries have been processed.

processEntryback to summary
private void processEntry(ManifestEntryVerifier mev) throws IOException

called when we reach the end of entry in one of the read() methods.

updateback to summary
public void update(int b, ManifestEntryVerifier mev) throws IOException

update a single byte.

updateback to summary
public void update(int n, byte[] b, int off, int len, ManifestEntryVerifier mev) throws IOException

update an array of bytes.

java.util.jar back to summary

pack-priv Class JarVerifier.VerifierStream

extends InputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private InputStream
private JarVerifier
private ManifestEntryVerifier
private long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

private void
public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[] b, int off, int len)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

Inherited from java.io.InputStream:
markmarkSupportednullInputStreamreadreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

isback to summary
private InputStream is
jvback to summary
private JarVerifier jv
mevback to summary
private ManifestEntryVerifier mev
numLeftback to summary
private long numLeft

Constructor Detail

VerifierStreamback to summary
pack-priv VerifierStream(Manifest man, JarEntry je, InputStream is, JarVerifier jv) throws IOException

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
ensureOpenback to summary
private void ensureOpen() throws IOException
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.