Package net.jsign.mscab
Class MSCabinetFile
- java.lang.Object
-
- net.jsign.mscab.MSCabinetFile
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Signable
public class MSCabinetFile extends Object implements Signable, Closeable
Microsoft Cabinet File. This class is thread safe.- Since:
- 4.0
- Author:
- Joseph Lee
- See Also:
- [MS-CAB]: Cabinet File Format
-
-
Constructor Summary
Constructors Constructor Description MSCabinetFile(File file)Create a MSCabinetFile from the specified file.MSCabinetFile(SeekableByteChannel channel)Create a MSCabinetFile from the specified channel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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 booleanisMSCabinetFile(File file)Tells if the specified file is a MS Cabinet file.voidsave()Saves the file.voidsetSignature(CMSSignedData signature)Sets the signature of the file, overwriting the previous one.
-
-
-
Constructor Detail
-
MSCabinetFile
public MSCabinetFile(File file) throws IOException
Create a MSCabinetFile from the specified file.- Parameters:
file- the file to open- Throws:
IOException- if an I/O error occurs
-
MSCabinetFile
public MSCabinetFile(SeekableByteChannel channel) throws IOException
Create a MSCabinetFile from the specified channel.- Parameters:
channel- the channel to read the file from- Throws:
IOException- if an I/O error occurs
-
-
Method Detail
-
isMSCabinetFile
public static boolean isMSCabinetFile(File file) throws IOException
Tells if the specified file is a MS Cabinet file.- Parameters:
file- the file to check- Returns:
trueif the file is a MS Cabinet,falseotherwise- Throws:
IOException- if an I/O error occurs
-
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
computeDigest
public byte[] computeDigest(MessageDigest digest) throws IOException
Description copied from interface:SignableComputes the digest of the file.- Specified by:
computeDigestin interfaceSignable- Parameters:
digest- the message digest to update- Returns:
- the digest of the file
- Throws:
IOException- if an I/O error occurs
-
createIndirectData
public ASN1Object createIndirectData(DigestAlgorithm digestAlgorithm) throws IOException
Description copied from interface:SignableCreates the SpcIndirectDataContent structure containing the digest of the file.- Specified by:
createIndirectDatain interfaceSignable- Parameters:
digestAlgorithm- the digest algorithm to use- Returns:
- the SpcIndirectDataContent structure in ASN.1 format
- Throws:
IOException- if an I/O error occurs
-
getSignatures
public List<CMSSignedData> getSignatures() throws IOException
Description copied from interface:SignableReturns the Authenticode signatures on the file.- Specified by:
getSignaturesin interfaceSignable- Returns:
- the signatures
- Throws:
IOException- if an I/O error occurs
-
setSignature
public void setSignature(CMSSignedData signature) throws IOException
Description copied from interface:SignableSets the signature of the file, overwriting the previous one.- Specified by:
setSignaturein interfaceSignable- Parameters:
signature- the signature to put- Throws:
IOException- if an I/O error occurs
-
-