Package net.jsign.script
Class PowerShellScript
- java.lang.Object
-
- net.jsign.script.PowerShellScript
-
- All Implemented Interfaces:
Signable
public class PowerShellScript extends Object
A PowerShell script.- Since:
- 3.0
- Author:
- Björn Kautler
-
-
Constructor Summary
Constructors Constructor Description PowerShellScript()Create a PowerShell script.PowerShellScript(File file)Create a PowerShell script from the specified file and load its content.PowerShellScript(File file, Charset encoding)Create a PowerShell script from the specified file and load its content.
-
Method Summary
All Methods Instance Methods Concrete 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.StringgetContent()Returns the content of the script.List<CMSSignedData>getSignatures()Returns the Authenticode signatures on the file.voidsave()Saves the file.voidsave(File file)Save the script to the specified file.voidsetContent(String content)Sets the content of the script.voidsetSignature(CMSSignedData signature)Sets the signature of the file, overwriting the previous one.
-
-
-
Constructor Detail
-
PowerShellScript
public PowerShellScript()
Create a PowerShell script. The encoding is assumed to be UTF-8.
-
PowerShellScript
public PowerShellScript(File file) throws IOException
Create a PowerShell script from the specified file and load its content. If the file has no byte order mark the encoding is assumed to be UTF-8.- Parameters:
file- the PowerShell script- Throws:
IOException- if an I/O error occurs
-
PowerShellScript
public PowerShellScript(File file, Charset encoding) throws IOException
Create a PowerShell script from the specified file and load its content.- Parameters:
file- the PowerShell scriptencoding- the encoding of the script if there is no byte order mark (if null UTF-8 is used by default)- Throws:
IOException- if an I/O error occurs
-
-
Method Detail
-
getContent
public String getContent()
Returns the content of the script.- Returns:
- the content of the script
-
setContent
public void setContent(String content)
Sets the content of the script.- Parameters:
content- the content of the script
-
getSignatures
public List<CMSSignedData> getSignatures()
Description copied from interface:SignableReturns the Authenticode signatures on the file.- Specified by:
getSignaturesin interfaceSignable- Returns:
- the signatures
-
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
-
computeDigest
public byte[] computeDigest(MessageDigest digest)
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
-
createIndirectData
public ASN1Object createIndirectData(DigestAlgorithm digestAlgorithm)
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
-
save
public void save() throws IOExceptionDescription copied from interface:SignableSaves the file.- Specified by:
savein interfaceSignable- Throws:
IOException- if an I/O error occurs
-
save
public void save(File file) throws IOException
Save the script to the specified file.- Parameters:
file- the file to write- Throws:
IOException- if an I/O error occurs
-
-