org.eclipse.ease.sign

## Class VerifySignature

- java.lang.Object
- - org.eclipse.ease.sign.VerifySignature

    public class VerifySignature
    extends java.lang.Object

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static VerifySignature` `getInstance(ScriptType scriptType, java.io.InputStream inputStream)` Use this method to get constructor when signature is attached to script file.
`static VerifySignature` `getInstance(ScriptType scriptType, java.io.InputStream inputStream, java.io.InputStream signatureInputStream)` Use this method to get constructor when script contents and signature are separate.
`boolean` `isCertChainValid()` Checks the validity of certificate.
`boolean` `isCertChainValid(java.io.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.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getInstance

    public static VerifySignature getInstance(ScriptType scriptType,
                                              java.io.InputStream inputStream)
                                       throws ScriptSignatureException

Use this method to get constructor when signature is attached to script file.

Parameters:
  `scriptType` - provide `ScriptType` instance of stream for script
  `inputStream` - 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,
                                              java.io.InputStream inputStream,
                                              java.io.InputStream signatureInputStream)
                                       throws ScriptSignatureException

Use 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` - provide `ScriptType` instance of stream for script
  `inputStream` - provide stream of script to verify
  `signatureInputStream` - 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

    public boolean isSelfSignedCertificate()
                                    throws ScriptSignatureException

Checks whether certificate attached with script is self-signed or not.

Returns:
  `true` if certificate is self-signed or `false` 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(java.io.InputStream trustStoreLocation,
                                    char[] trustStorePassword)
                             throws ScriptSignatureException

Checks the validity of certificate. If certificate is CA signed, then it checks the validity of CA with trust-store.

Parameters:
  `trustStoreLocation` - provide location of truststore
  `trustStorePassword` - provide password for truststore
Returns:
  `true` if certificate is valid and trusted or `false` 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

    public boolean isCertChainValid()
                             throws ScriptSignatureException

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, use `#isCertChainValid(String, char[])`.

Returns:
  `true` if certificate is valid and trusted or `false` 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

    public boolean verify()
                   throws ScriptSignatureException

Verify given signature with provided public key of provided certificate.

Returns:
  `true` if signature is valid or `false` if signature is invalid
Throws:
  `ScriptSignatureException` - when script does not contain signature or there is an error while retrieving certificate