public class SignedJarWriter extends JarWriter
JarWriter.MyMultiDigestOutputStream
creator, currentManifestEntry, DEFAULT_DIGEST_ALGORITHM, digestAlgorithms, manifestEntryWriter, zipEntryWriter
Constructor and Description |
---|
SignedJarWriter(java.security.KeyStore.PrivateKeyEntry privateKeyEntry,
DataEntryWriter zipEntryWriter)
Creates a new SignedJarWriter.
|
SignedJarWriter(java.security.KeyStore.PrivateKeyEntry privateKeyEntry,
java.lang.String[] digestAlgorithms,
java.lang.String creator,
DataEntryWriter zipEntryWriter)
Creates a new SignedJarWriter with the given settings.
|
SignedJarWriter(java.security.KeyStore.PrivateKeyEntry privateKeyEntry,
java.lang.String[] digestAlgorithms,
java.lang.String creator,
int[] apkSignatureSchemeIDs,
DataEntryWriter zipEntryWriter)
Creates a new SignedJarWriter with the given settings.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.OutputStream |
createManifestOutputStream(DataEntry manifestEntry)
Creates an output stream for the specified manifest file.
|
java.io.OutputStream |
createOutputStream(DataEntry dataEntry)
Creates a new output stream for writing data.
|
protected void |
finish()
Writes out the collected manifest file before closing the jar, if any.
|
static void |
main(java.lang.String[] args)
Provides a simple test for this class, creating a signed apk file (only
v1) with the given name and a few aligned/compressed/uncompressed
zip entries.
|
protected void |
openManifestFiles()
Prepares streams and writers for capturing digests of a parent entry.
|
void |
println(java.io.PrintWriter pw,
java.lang.String prefix)
Prints out the structure of the data entry writer.
|
close, createDirectory, finishIfNecessary, printWriter, sameOutputStream
public SignedJarWriter(java.security.KeyStore.PrivateKeyEntry privateKeyEntry, DataEntryWriter zipEntryWriter)
privateKeyEntry
- the private key to be used for signing the zip
entries.zipEntryWriter
- the data entry writer that can provide output
streams for the jar entries.public SignedJarWriter(java.security.KeyStore.PrivateKeyEntry privateKeyEntry, java.lang.String[] digestAlgorithms, java.lang.String creator, DataEntryWriter zipEntryWriter)
privateKeyEntry
- the private key to be used for signing the
zip entries.digestAlgorithms
- the manifest digest algorithms, e.g.
"SHA-256".creator
- the creator to mention in the manifest
file.zipEntryWriter
- the data entry writer that can provide
output streams for the jar entries.public SignedJarWriter(java.security.KeyStore.PrivateKeyEntry privateKeyEntry, java.lang.String[] digestAlgorithms, java.lang.String creator, int[] apkSignatureSchemeIDs, DataEntryWriter zipEntryWriter)
privateKeyEntry
- the private key to be used for signing the
zip entries.digestAlgorithms
- the manifest digest algorithms, e.g.
"SHA-256".creator
- the creator to mention in the manifest
file.apkSignatureSchemeIDs
- an optional list of external APK signature
scheme IDs to be specified with the
attribute "X-Android-APK-Signed" in *.SF
files.zipEntryWriter
- the data entry writer that can provide
output streams for the jar entries.public java.io.OutputStream createOutputStream(DataEntry dataEntry) throws java.io.IOException
DataEntryWriter
createOutputStream
in interface DataEntryWriter
createOutputStream
in class JarWriter
dataEntry
- the data entry for which the output stream is to be
created.null
to
indicate that the data entry should not be written.java.io.IOException
public void println(java.io.PrintWriter pw, java.lang.String prefix)
DataEntryWriter
println
in interface DataEntryWriter
println
in class JarWriter
pw
- the print stream to which the structure should be printed.prefix
- a prefix for every printed line.protected void openManifestFiles() throws java.io.IOException
JarWriter
openManifestFiles
in class JarWriter
java.io.IOException
protected java.io.OutputStream createManifestOutputStream(DataEntry manifestEntry) throws java.io.IOException
JarWriter
createManifestOutputStream
in class JarWriter
java.io.IOException
protected void finish() throws java.io.IOException
JarWriter
public static void main(java.lang.String[] args)