程序包 proguard.io

类 SignedJarWriter

  • 所有已实现的接口:
    java.lang.AutoCloseable, DataEntryWriter

    public class SignedJarWriter
    extends JarWriter
    This JarWriter sends data entries to a given jar file, automatically adding a manifest file and signing it with JAR signature scheme v1.

    You'll typically wrap a ZipWriter or one of its extensions:

         new SignedApkWriter(privateKeyEntry, new ZipWriter(...))
     
    • 构造器详细资料

      • SignedJarWriter

        public SignedJarWriter​(java.security.KeyStore.PrivateKeyEntry privateKeyEntry,
                               DataEntryWriter zipEntryWriter)
        Creates a new SignedJarWriter.
        参数:
        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​(java.security.KeyStore.PrivateKeyEntry privateKeyEntry,
                               java.lang.String[] digestAlgorithms,
                               java.lang.String creator,
                               DataEntryWriter zipEntryWriter)
        Creates a new SignedJarWriter with the given settings.
        参数:
        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​(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.
        参数:
        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.
    • 方法详细资料

      • createOutputStream

        public java.io.OutputStream createOutputStream​(DataEntry dataEntry)
                                                throws java.io.IOException
        从接口复制的说明: DataEntryWriter
        Creates a new output stream for writing data. The caller is responsible for closing the stream.
        指定者:
        createOutputStream 在接口中 DataEntryWriter
        覆盖:
        createOutputStream 在类中 JarWriter
        参数:
        dataEntry - the data entry for which the output stream is to be created.
        返回:
        the output stream. The stream may be null to indicate that the data entry should not be written.
        抛出:
        java.io.IOException
      • println

        public void println​(java.io.PrintWriter pw,
                            java.lang.String prefix)
        从接口复制的说明: DataEntryWriter
        Prints out the structure of the data entry writer.
        指定者:
        println 在接口中 DataEntryWriter
        覆盖:
        println 在类中 JarWriter
        参数:
        pw - the print stream to which the structure should be printed.
        prefix - a prefix for every printed line.
      • openManifestFiles

        protected void openManifestFiles()
                                  throws java.io.IOException
        从类复制的说明: JarWriter
        Prepares streams and writers for capturing digests of a parent entry.
        覆盖:
        openManifestFiles 在类中 JarWriter
        抛出:
        java.io.IOException
      • createManifestOutputStream

        protected java.io.OutputStream createManifestOutputStream​(DataEntry manifestEntry)
                                                           throws java.io.IOException
        从类复制的说明: JarWriter
        Creates an output stream for the specified manifest file.
        覆盖:
        createManifestOutputStream 在类中 JarWriter
        抛出:
        java.io.IOException
      • finish

        protected void finish()
                       throws java.io.IOException
        从类复制的说明: JarWriter
        Writes out the collected manifest file before closing the jar, if any.
        覆盖:
        finish 在类中 JarWriter
        抛出:
        java.io.IOException
      • main

        public 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. 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