Class PerformSignature

java.lang.Object
org.eclipse.ease.sign.PerformSignature

public class PerformSignature
extends Object
Class containing methods to perform signature. Methods include loading of keystore, private key and performing signature to provided file.
  • Constructor Details

    • PerformSignature

      public PerformSignature()
  • Method Details

    • loadKeyStore

      public static KeyStore loadKeyStore​(InputStream inputStream, String type, String provider, String keyStorePass) throws ScriptSignatureException, UnrecoverableKeyException, IOException
      Checks keystore of given type and provider can be instantiated and if so, instantiates keystore. Then, loads the keyStore from file using provided password.
      Parameters:
      inputStream - provide inputStream of keystore
      type - name type of the keystore like JKS, JCEKS, PKCS12, PKCS12S2. Provide null or empty string or 'default' to set default type
      provider - name provider of the keystore like SUN, SUNRsaSign, SUNJCE, etc. Provide null or empty string or 'preferred' to let system take decision
      keyStorePass - provide password to unlock keystore
      Returns:
      instance of keystore if loaded properly
      Throws:
      ScriptSignatureException - when exception can be recovered without closing the application. For e.g., arguments provided for keystore or password are invalid, keystore file can't be read, etc.
      UnrecoverableKeyException - when password for keystore is incorrect
      IOException - when there is an error loading keystore because of IO of format problem
    • getAliases

      public static Collection<String> getAliases​(KeyStore keyStore)
      Gets all aliases from keystore.
      Parameters:
      keyStore - provide keystore instance to read aliases
      Returns:
      collection of string of aliases in keystore or null if keystore is not loaded properly
    • getCertificate

      public static String getCertificate​(KeyStore keyStore, String alias, boolean canAttachSelfSign) throws ScriptSignatureException
      Obtains certificate for corresponding alias.
      Parameters:
      keyStore - provide instance of loaded keystore
      alias - provide alias of which certificate is required
      canAttachSelfSign - tell whether to allow to attach self-signed certificate
      Returns:
      certificate chain in Base64 String format, each certificate separated by colon(:) or null if keystore is not initialized properly
      Throws:
      ScriptSignatureException - if alias can't be found or certificate can't be loaded
    • createSignature

      public static String createSignature​(KeyStore keyStore, InputStream dataStream, String alias, String privateKeyPass, String provider, String messageDigestAlgo) throws ScriptSignatureException, UnrecoverableKeyException
      Initializes private key and gets signature of provided file.
      Parameters:
      keyStore - provide instance of loaded keystore
      dataStream - give input stream of the script which is to be signed
      alias - give alias corresponding to private key used to sign file
      privateKeyPass - provide password protecting the private key
      provider - give provider used to perform signature. Provide null or empty string or 'preferred' to let system take decision
      messageDigestAlgo - name the message-digest algorithm to perform signature. Provide null or empty string or 'default' to chose default algorithm
      Returns:
      provider of signature and signature in string Base64 format separated by colon(:) or null if keystore not initialized properly
      Throws:
      ScriptSignatureException - if alias or privateKeyPass is null, signature can't be performed, password to alias is wrong, parameters for private key are wrong
      UnrecoverableKeyException - when password for alias is incorrect