Package proguard.io
Class SignedJarWriter
java.lang.Object
proguard.io.JarWriter
proguard.io.SignedJarWriter
- All Implemented Interfaces:
AutoCloseable,DataEntryWriter
-
Nested Class Summary
Nested classes/interfaces inherited from class proguard.io.JarWriter
JarWriter.MyMultiDigestOutputStream -
Field Summary
Fields inherited from class proguard.io.JarWriter
creator, currentManifestEntry, DEFAULT_DIGEST_ALGORITHM, digestAlgorithms, manifestEntryWriter, zipEntryWriter -
Constructor Summary
ConstructorsConstructorDescriptionSignedJarWriter(KeyStore.PrivateKeyEntry privateKeyEntry, String[] digestAlgorithms, String creator, int[] apkSignatureSchemeIDs, DataEntryWriter zipEntryWriter) Creates a new SignedJarWriter with the given settings.SignedJarWriter(KeyStore.PrivateKeyEntry privateKeyEntry, String[] digestAlgorithms, String creator, DataEntryWriter zipEntryWriter) Creates a new SignedJarWriter with the given settings.SignedJarWriter(KeyStore.PrivateKeyEntry privateKeyEntry, DataEntryWriter zipEntryWriter) Creates a new SignedJarWriter. -
Method Summary
Modifier and TypeMethodDescriptionprotected OutputStreamcreateManifestOutputStream(DataEntry manifestEntry) Creates an output stream for the specified manifest file.createOutputStream(DataEntry dataEntry) Creates a new output stream for writing data.protected voidfinish()Writes out the collected manifest file before closing the jar, if any.static voidProvides 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 voidPrepares streams and writers for capturing digests of a parent entry.voidprintln(PrintWriter pw, String prefix) Prints out the structure of the data entry writer.Methods inherited from class proguard.io.JarWriter
close, createDirectory, finishIfNecessary, printWriter, sameOutputStream
-
Constructor Details
-
SignedJarWriter
Creates a new SignedJarWriter.- Parameters:
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.
-
SignedJarWriter
public SignedJarWriter(KeyStore.PrivateKeyEntry privateKeyEntry, String[] digestAlgorithms, String creator, DataEntryWriter zipEntryWriter) Creates a new SignedJarWriter with the given settings.- Parameters:
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.
-
SignedJarWriter
public SignedJarWriter(KeyStore.PrivateKeyEntry privateKeyEntry, String[] digestAlgorithms, String creator, int[] apkSignatureSchemeIDs, DataEntryWriter zipEntryWriter) Creates a new SignedJarWriter with the given settings.- Parameters:
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.
-
-
Method Details
-
createOutputStream
Description copied from interface:DataEntryWriterCreates a new output stream for writing data. The caller is responsible for closing the stream.- Specified by:
createOutputStreamin interfaceDataEntryWriter- Overrides:
createOutputStreamin classJarWriter- Parameters:
dataEntry- the data entry for which the output stream is to be created.- Returns:
- the output stream. The stream may be
nullto indicate that the data entry should not be written. - Throws:
IOException
-
println
Description copied from interface:DataEntryWriterPrints out the structure of the data entry writer.- Specified by:
printlnin interfaceDataEntryWriter- Overrides:
printlnin classJarWriter- Parameters:
pw- the print stream to which the structure should be printed.prefix- a prefix for every printed line.
-
openManifestFiles
Description copied from class:JarWriterPrepares streams and writers for capturing digests of a parent entry.- Overrides:
openManifestFilesin classJarWriter- Throws:
IOException
-
createManifestOutputStream
Description copied from class:JarWriterCreates an output stream for the specified manifest file.- Overrides:
createManifestOutputStreamin classJarWriter- Throws:
IOException
-
finish
Description copied from class:JarWriterWrites out the collected manifest file before closing the jar, if any.- Overrides:
finishin classJarWriter- Throws:
IOException
-
main
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. Arguments: keystore keystore_password alias password jar_filename Create a keystore with: keytool -genkey -dname 'CN=John Doe, OU=Development, O=Guardsquare, STREET=Tervuursevest, L=Leuven, ST=Brabant, C=Belgium' -keystore /tmp/test.keystore -storepass android -alias AndroidDebugKey -keypass android -keyalg RSA -keysize 512 List the contents of the keystore with keytool -v -list -keystore /tmp/test.keystore -alias androiddebugkey -storepass android Verify the signed jar with: jarsigner -verify -verbose /tmp/test.jar or with: android-sdk/build-tools/24.0.3/apksigner verify --min-sdk-version 19 -v /tmp/test.jar
-