Package net.jsign
Interface Signable
-
- All Known Implementing Classes:
JScript,MSCabinetFile,MSIFile,PEFile,PowerShellScript,PowerShellXMLScript,VBScript,WindowsScript
public interface Signable
A file that can be signed with Authenticode.- Author:
- Emmanuel Bourg
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]computeDigest(MessageDigest digest)Computes the digest of the file.ASN1ObjectcreateIndirectData(DigestAlgorithm digestAlgorithm)Creates the SpcIndirectDataContent structure containing the digest of the file.List<CMSSignedData>getSignatures()Returns the Authenticode signatures on the file.static Signableof(File file)Returns a signable object for the file specified.static Signableof(File file, Charset encoding)Returns a signable object for the file specified.voidsave()Saves the file.voidsetSignature(CMSSignedData signature)Sets the signature of the file, overwriting the previous one.
-
-
-
Method Detail
-
computeDigest
byte[] computeDigest(MessageDigest digest) throws IOException
Computes the digest of the file.- Parameters:
digest- the message digest to update- Returns:
- the digest of the file
- Throws:
IOException- if an I/O error occurs
-
createIndirectData
ASN1Object createIndirectData(DigestAlgorithm digestAlgorithm) throws IOException
Creates the SpcIndirectDataContent structure containing the digest of the file.- Parameters:
digestAlgorithm- the digest algorithm to use- Returns:
- the SpcIndirectDataContent structure in ASN.1 format
- Throws:
IOException- if an I/O error occurs
-
getSignatures
List<CMSSignedData> getSignatures() throws IOException
Returns the Authenticode signatures on the file.- Returns:
- the signatures
- Throws:
IOException- if an I/O error occurs
-
setSignature
void setSignature(CMSSignedData signature) throws IOException
Sets the signature of the file, overwriting the previous one.- Parameters:
signature- the signature to put- Throws:
IOException- if an I/O error occurs
-
save
void save() throws IOException
Saves the file.- Throws:
IOException- if an I/O error occurs
-
of
static Signable of(File file) throws IOException
Returns a signable object for the file specified.- Parameters:
file- the file that is intended to to be signed- Returns:
- the signable object for the specified file
- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the file specified isn't supported
-
of
static Signable of(File file, Charset encoding) throws IOException
Returns a signable object for the file specified.- Parameters:
file- the file that is intended to to be signedencoding- the character encoding (for text files only). If the file has a byte order mark this parameter is ignored.- Returns:
- the signable object for the specified file
- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the file specified isn't supported
-
-