public class PerformSignature
extends java.lang.Object
Constructor and Description |
---|
PerformSignature() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
createSignature(java.security.KeyStore keyStore,
java.io.InputStream dataStream,
java.lang.String alias,
java.lang.String privateKeyPass,
java.lang.String provider,
java.lang.String messageDigestAlgo)
Initializes private key and gets signature of provided file.
|
static java.util.Collection<java.lang.String> |
getAliases(java.security.KeyStore keyStore)
Gets all aliases from keystore.
|
static java.lang.String |
getCertificate(java.security.KeyStore keyStore,
java.lang.String alias,
boolean canAttachSelfSign)
Obtains certificate for corresponding alias.
|
static java.security.KeyStore |
loadKeyStore(java.io.InputStream inputStream,
java.lang.String type,
java.lang.String provider,
java.lang.String keyStorePass)
Checks keystore of given type and provider can be instantiated and if so, instantiates keystore.
|
public static java.security.KeyStore loadKeyStore(java.io.InputStream inputStream, java.lang.String type, java.lang.String provider, java.lang.String keyStorePass) throws ScriptSignatureException, java.security.UnrecoverableKeyException, java.io.IOException
inputStream
- provide inputStream of keystoretype
- name type of the keystore like JKS, JCEKS, PKCS12, PKCS12S2. Provide null
or empty string or 'default' to set default typeprovider
- name provider of the keystore like SUN, SUNRsaSign, SUNJCE, etc. Provide null
or empty string or 'preferred' to let system take
decisionkeyStorePass
- provide password to unlock keystoreScriptSignatureException
- 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.java.security.UnrecoverableKeyException
- when password for keystore is incorrectjava.io.IOException
- when there is an error loading keystore because of IO of format problempublic static java.util.Collection<java.lang.String> getAliases(java.security.KeyStore keyStore)
keyStore
- provide keystore instance to read aliasesnull
if keystore is not loaded properlypublic static java.lang.String getCertificate(java.security.KeyStore keyStore, java.lang.String alias, boolean canAttachSelfSign) throws ScriptSignatureException
keyStore
- provide instance of loaded keystorealias
- provide alias of which certificate is requiredcanAttachSelfSign
- tell whether to allow to attach self-signed certificatenull
if keystore is not initialized properlyScriptSignatureException
- if alias can't be found or certificate can't be loadedpublic static java.lang.String createSignature(java.security.KeyStore keyStore, java.io.InputStream dataStream, java.lang.String alias, java.lang.String privateKeyPass, java.lang.String provider, java.lang.String messageDigestAlgo) throws ScriptSignatureException, java.security.UnrecoverableKeyException
keyStore
- provide instance of loaded keystoredataStream
- give input stream of the script which is to be signedalias
- give alias corresponding to private key used to sign fileprivateKeyPass
- provide password protecting the private keyprovider
- give provider used to perform signature. Provide null
or empty string or 'preferred' to let system take decisionmessageDigestAlgo
- name the message-digest algorithm to perform signature. Provide null
or empty string or 'default' to chose default algorithmnull
if keystore not initialized properlyScriptSignatureException
- if alias or privateKeyPass is null
, signature can't be performed, password to alias is wrong, parameters for private key are
wrongjava.security.UnrecoverableKeyException
- when password for alias is incorrect