Package org.eclipse.ease.sign
Class VerifySignature
java.lang.Object
org.eclipse.ease.sign.VerifySignature
public class VerifySignature extends Object
-
Method Summary
Modifier and Type Method 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.
-
Method Details
-
getInstance
public static VerifySignature getInstance(ScriptType scriptType, InputStream inputStream) throws ScriptSignatureExceptionUse this method to get constructor when signature is attached to script file.- Parameters:
scriptType
- provideScriptType
instance of stream for scriptinputStream
- provide stream of script to verify- Returns:
- instance of
VerifySignature
when signature is present and can be properly loaded or null when signature is not present - Throws:
ScriptSignatureException
- when one or more parameters are not provided or signature format is improper
-
getInstance
public static VerifySignature getInstance(ScriptType scriptType, InputStream inputStream, InputStream signatureInputStream) throws ScriptSignatureExceptionUse this method to get constructor when script contents and signature are separate. Use only when it is guaranteed that input stream of signature is for corresponding input stream of file.- Parameters:
scriptType
- provideScriptType
instance of stream for scriptinputStream
- provide stream of script to verifysignatureInputStream
- provide stream where signature is stored- Returns:
- instance of
VerifySignature
when signature can be properly loaded or null when signature is not present - Throws:
ScriptSignatureException
- when one or more parameters are not provided or signature format is improper
-
isSelfSignedCertificate
Checks whether certificate attached with script is self-signed or not.- Returns:
true
if certificate is self-signed orfalse
if certificate is CA signed- Throws:
ScriptSignatureException
- when script does not contain signature or there is an error while retrieving certificate
-
isCertChainValid
public boolean isCertChainValid(InputStream trustStoreLocation, char[] trustStorePassword) throws ScriptSignatureExceptionChecks the validity of certificate. If certificate is CA signed, then it checks the validity of CA with trust-store.- Parameters:
trustStoreLocation
- provide location of truststoretrustStorePassword
- provide password for truststore- Returns:
true
if certificate is valid and trusted orfalse
if certificate is invalid or not trusted- Throws:
ScriptSignatureException
- 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 signature
-
isCertChainValid
Checks the validity of certificate. If certificate is CA signed, then it checks the validity of CA with trust-store. It uses default truststore present at JRE_PATH/lib/security/cacerts and "changeit" as password. If password has been modified, useisCertChainValid(InputStream, char[])
.- Returns:
true
if certificate is valid and trusted orfalse
if certificate is invalid or not trusted- Throws:
ScriptSignatureException
- when one or more certificates can't be loaded from truststore or truststore can't be loaded
-
verify
Verify given signature with provided public key of provided certificate.- Returns:
true
if signature is valid orfalse
if signature is invalid- Throws:
ScriptSignatureException
- when script does not contain signature or there is an error while retrieving certificate
-