public class DefaultApkSignerEngine extends Object implements ApkSignerEngine
ApkSignerEngine
.
Use DefaultApkSignerEngine.SignerConfig.Builder
to obtain instances of this engine.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultApkSignerEngine.Builder
Builder of
DefaultApkSignerEngine instances. |
static class |
DefaultApkSignerEngine.SignerConfig
Configuration of a signer.
|
ApkSignerEngine.InputJarEntryInstructions, ApkSignerEngine.InspectJarEntryRequest, ApkSignerEngine.OutputApkSigningBlockRequest, ApkSignerEngine.OutputJarSignatureRequest
Modifier and Type | Method and Description |
---|---|
void |
close()
Indicates to this engine that it will no longer be used.
|
void |
inputApkSigningBlock(DataSource apkSigningBlock)
Indicates to this engine that the input APK contains the provided APK Signing Block.
|
ApkSignerEngine.InputJarEntryInstructions |
inputJarEntry(String entryName)
Indicates to this engine that the specified JAR entry was encountered in the input APK.
|
ApkSignerEngine.InputJarEntryInstructions.OutputPolicy |
inputJarEntryRemoved(String entryName)
Indicates to this engine that the specified JAR entry was removed from the input.
|
void |
outputDone()
Indicates to this engine that the signed APK was output.
|
ApkSignerEngine.OutputJarSignatureRequest |
outputJarEntries()
Indicates to this engine that all JAR entries have been output.
|
ApkSignerEngine.InspectJarEntryRequest |
outputJarEntry(String entryName)
Indicates to this engine that the specified JAR entry was output.
|
void |
outputJarEntryRemoved(String entryName)
Indicates to this engine that the specified JAR entry was removed from the output.
|
ApkSignerEngine.OutputApkSigningBlockRequest |
outputZipSections(DataSource zipEntries,
DataSource zipCentralDirectory,
DataSource zipEocd)
Indicates to this engine that the ZIP sections comprising the output APK have been output.
|
public void inputApkSigningBlock(DataSource apkSigningBlock)
ApkSignerEngine
inputApkSigningBlock
in interface ApkSignerEngine
apkSigningBlock
- APK signing block of the input APK. The provided data source is
guaranteed to not be used by the engine after this method terminates.public ApkSignerEngine.InputJarEntryInstructions inputJarEntry(String entryName)
ApkSignerEngine
When an input entry is updated/changed, it's OK to not invoke
ApkSignerEngine.inputJarEntryRemoved(String)
before invoking this method.
inputJarEntry
in interface ApkSignerEngine
public ApkSignerEngine.InspectJarEntryRequest outputJarEntry(String entryName)
ApkSignerEngine
It is unnecessary to invoke this method for entries added to output by this engine (e.g.,
requested by ApkSignerEngine.outputJarEntries()
) provided the entries were output with exactly the
data requested by the engine.
When an already output entry is updated/changed, it's OK to not invoke
ApkSignerEngine.outputJarEntryRemoved(String)
before invoking this method.
outputJarEntry
in interface ApkSignerEngine
null
if the engine does not need to inspect
the entry. The request must be fulfilled before ApkSignerEngine.outputJarEntries()
is
invoked.public ApkSignerEngine.InputJarEntryInstructions.OutputPolicy inputJarEntryRemoved(String entryName)
ApkSignerEngine
ApkSignerEngine.inputJarEntry(String)
hasn't been invoked.inputJarEntryRemoved
in interface ApkSignerEngine
public void outputJarEntryRemoved(String entryName)
ApkSignerEngine
ApkSignerEngine.outputJarEntry(String)
hasn't been invoked.outputJarEntryRemoved
in interface ApkSignerEngine
public ApkSignerEngine.OutputJarSignatureRequest outputJarEntries() throws ApkFormatException, InvalidKeyException, SignatureException, NoSuchAlgorithmException
ApkSignerEngine
outputJarEntries
in interface ApkSignerEngine
null
if there is no need to add
a JAR signature. The request will contain additional JAR entries to be output. The
request must be fulfilled before
ApkSignerEngine.outputZipSections(DataSource, DataSource, DataSource)
is invoked.ApkFormatException
- if the APK is malformed in a way which is preventing this engine
from producing a valid signature. For example, if the engine uses the provided
META-INF/MANIFEST.MF
as a template and the file is malformed.InvalidKeyException
- if a signature could not be generated because a signing key is
not suitable for generating the signatureSignatureException
- if an error occurred while generating a signatureNoSuchAlgorithmException
- if a signature could not be generated because a required
cryptographic algorithm implementation is missingpublic ApkSignerEngine.OutputApkSigningBlockRequest outputZipSections(DataSource zipEntries, DataSource zipCentralDirectory, DataSource zipEocd) throws IOException, InvalidKeyException, SignatureException, NoSuchAlgorithmException
ApkSignerEngine
The provided data sources are guaranteed to not be used by the engine after this method terminates.
outputZipSections
in interface ApkSignerEngine
zipEntries
- the section of ZIP archive containing Local File Header records and data of
the ZIP entries. In a well-formed archive, this section starts at the start of the
archive and extends all the way to the ZIP Central Directory.zipCentralDirectory
- ZIP Central Directory sectionzipEocd
- ZIP End of Central Directory (EoCD) recordnull
if the output must
not contain an APK Signing Block. The request must be fulfilled before
ApkSignerEngine.outputDone()
is invoked.IOException
- if an I/O error occurs while reading the provided ZIP sectionsInvalidKeyException
- if a signature could not be generated because a signing key is
not suitable for generating the signatureSignatureException
- if an error occurred while generating a signatureNoSuchAlgorithmException
- if a signature could not be generated because a required
cryptographic algorithm implementation is missingpublic void outputDone()
ApkSignerEngine
This does not change the output APK. The method helps the client confirm that the current output is signed.
outputDone
in interface ApkSignerEngine
public void close()
ApkSignerEngine
This does not change the output APK. For example, if the output APK is not yet fully signed, it will remain so after this method terminates.
close
in interface ApkSignerEngine
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2016. All rights reserved.