public class VerifySignature extends Object
Modifier and Type | Method and Description |
---|---|
static VerifySignature |
getInstance(ScriptType scriptType,
InputStream inputStream)
Use this method to get constructor when signature is attached to script file.
|
static VerifySignature |
getInstance(ScriptType scriptType,
InputStream inputStream,
InputStream signatureInputStream)
Use this method to get constructor when script contents and signature are separate.
|
boolean |
isCertChainValid()
Checks the validity of certificate.
|
boolean |
isCertChainValid(InputStream trustStoreLocation,
char[] trustStorePassword)
Checks the validity of certificate.
|
boolean |
isSelfSignedCertificate()
Checks whether certificate attached with script is self-signed or not.
|
boolean |
verify()
Verify given signature with provided public key of provided certificate.
|
public static VerifySignature getInstance(ScriptType scriptType, InputStream inputStream) throws ScriptSignatureException
scriptType
- provide ScriptType
instance of stream for scriptinputStream
- provide stream of script to verifyVerifySignature
when signature is present and can be properly loaded or null when signature is not presentScriptSignatureException
- when one or more parameters are not provided or signature format is improperpublic static VerifySignature getInstance(ScriptType scriptType, InputStream inputStream, InputStream signatureInputStream) throws ScriptSignatureException
scriptType
- provide ScriptType
instance of stream for scriptinputStream
- provide stream of script to verifysignatureInputStream
- provide stream where signature is storedVerifySignature
when signature can be properly loaded or null when signature is not presentScriptSignatureException
- when one or more parameters are not provided or signature format is improperpublic boolean isSelfSignedCertificate() throws ScriptSignatureException
true
if certificate is self-signed or false
if certificate is CA signedScriptSignatureException
- when script does not contain signature or there is an error while retrieving certificatepublic boolean isCertChainValid(InputStream trustStoreLocation, char[] trustStorePassword) throws ScriptSignatureException
trustStoreLocation
- provide location of truststoretrustStorePassword
- provide password for truststoretrue
if certificate is valid and trusted or false
if certificate is invalid or not trustedScriptSignatureException
- when truststore can't be loaded due to one or more certificates can't be loaded from it or appropriate provider can't be found or truststore
file can't be read or password does not correspond to truststore or truststore does not contain any trusted certificate entry or script does
not contain signaturepublic boolean isCertChainValid() throws ScriptSignatureException
#isCertChainValid(String, char[])
.true
if certificate is valid and trusted or false
if certificate is invalid or not trustedScriptSignatureException
- when one or more certificates can't be loaded from truststore or truststore can't be loadedpublic boolean verify() throws ScriptSignatureException
true
if signature is valid or false
if signature is invalidScriptSignatureException
- when script does not contain signature or there is an error while retrieving certificate