Package eu.europa.esig.dss.token
Class AbstractSignatureTokenConnection
java.lang.Object
eu.europa.esig.dss.token.AbstractSignatureTokenConnection
- All Implemented Interfaces:
SignatureTokenConnection,AutoCloseable
- Direct Known Subclasses:
AbstractKeyStoreTokenConnection
public abstract class AbstractSignatureTokenConnection
extends Object
implements SignatureTokenConnection
The abstract implementation of a remote token connection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AlgorithmParameterSpeccreatePSSParam(DigestAlgorithm digestAlgo) Createsjava.security.spec.AlgorithmParameterSpecfor the givendigestAlgoprotected DigestensureDigestUniform(SignatureAlgorithm signatureAlgorithm, Digest digest) This method ensures the digest value is provided in the correct format for signing according to the givensignatureAlgorithmNOTE: When RSA (without PSS) is used, the digest value shall be ASN.1 DigestInfo encoded before signingprotected SignaturegetSignatureInstance(String javaSignatureAlgorithm) Returns thejava.security.Signatureinstance for the givenjavaSignatureAlgorithmprotected AlgorithmParameterSpecinitParameters(SignatureAlgorithm signatureAlgorithm, DigestAlgorithm digestAlgorithm) This method instantiates signature parameters, when applicablesign(ToBeSigned toBeSigned, DigestAlgorithm digestAlgorithm, DSSPrivateKeyEntry keyEntry) This method signs thetoBeSigneddata with the digestdigestAlgorithmand the givenkeyEntry.sign(ToBeSigned toBeSigned, SignatureAlgorithm signatureAlgorithm, DSSPrivateKeyEntry keyEntry) This method signs thetoBeSigneddata with the pre-defined signature algorithmsignatureAlgorithm, and the givenkeyEntry.signDigest(Digest digest, SignatureAlgorithm signatureAlgorithm, DSSPrivateKeyEntry keyEntry) This method signs thedigestdata with the pre-definedsignatureAlgorithmand the givenkeyEntry.signDigest(Digest digest, DSSPrivateKeyEntry keyEntry) This method signs thedigestdata with the givenkeyEntry.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.europa.esig.dss.token.SignatureTokenConnection
close, getKeys
-
Constructor Details
-
AbstractSignatureTokenConnection
protected AbstractSignatureTokenConnection()Default constructor
-
-
Method Details
-
sign
public SignatureValue sign(ToBeSigned toBeSigned, DigestAlgorithm digestAlgorithm, DSSPrivateKeyEntry keyEntry) throws DSSException Description copied from interface:SignatureTokenConnectionThis method signs thetoBeSigneddata with the digestdigestAlgorithmand the givenkeyEntry.- Specified by:
signin interfaceSignatureTokenConnection- Parameters:
toBeSigned- The data that need to be signeddigestAlgorithm- The digest algorithm to be used before signingkeyEntry- The private key to be used- Returns:
- the signature value representation with the used algorithm and the binary value
- Throws:
DSSException- If there is any problem during the signature process
-
sign
public SignatureValue sign(ToBeSigned toBeSigned, SignatureAlgorithm signatureAlgorithm, DSSPrivateKeyEntry keyEntry) throws DSSException Description copied from interface:SignatureTokenConnectionThis method signs thetoBeSigneddata with the pre-defined signature algorithmsignatureAlgorithm, and the givenkeyEntry.- Specified by:
signin interfaceSignatureTokenConnection- Parameters:
toBeSigned- The data that need to be signedsignatureAlgorithm- The signature algorithm to be used before signingkeyEntry- The private key to be used- Returns:
- the signature value representation with the used algorithm and the binary value
- Throws:
DSSException- If there is any problem during the signature process
-
signDigest
Description copied from interface:SignatureTokenConnectionThis method signs thedigestdata with the givenkeyEntry.- Specified by:
signDigestin interfaceSignatureTokenConnection- Parameters:
digest- The digested data that need to be signedkeyEntry- The private key to be used- Returns:
- the signature value representation with the used algorithm and the binary value
- Throws:
DSSException- If there is any problem during the signature process
-
signDigest
public SignatureValue signDigest(Digest digest, SignatureAlgorithm signatureAlgorithm, DSSPrivateKeyEntry keyEntry) throws DSSException Description copied from interface:SignatureTokenConnectionThis method signs thedigestdata with the pre-definedsignatureAlgorithmand the givenkeyEntry.- Specified by:
signDigestin interfaceSignatureTokenConnection- Parameters:
digest- The digested data that need to be signedsignatureAlgorithm- The signature algorithmkeyEntry- The private key to be used- Returns:
- the signature value representation with the used algorithm and the binary value
- Throws:
DSSException- If there is any problem during the signature process
-
ensureDigestUniform
This method ensures the digest value is provided in the correct format for signing according to the givensignatureAlgorithmNOTE: When RSA (without PSS) is used, the digest value shall be ASN.1 DigestInfo encoded before signing- Parameters:
signatureAlgorithm-SignatureAlgorithmto be used on signingdigest-Digestto verify- Returns:
Digestcontaining an encoded digest value, when needed
-
initParameters
protected AlgorithmParameterSpec initParameters(SignatureAlgorithm signatureAlgorithm, DigestAlgorithm digestAlgorithm) This method instantiates signature parameters, when applicable- Parameters:
signatureAlgorithm-SignatureAlgorithmused on signingdigestAlgorithm-DigestAlgorithmused to compute the digest value- Returns:
AlgorithmParameterSpec
-
getSignatureInstance
protected Signature getSignatureInstance(String javaSignatureAlgorithm) throws NoSuchAlgorithmException Returns thejava.security.Signatureinstance for the givenjavaSignatureAlgorithm- Parameters:
javaSignatureAlgorithm-Stringrepresenting the Java name of a signature algorithm- Returns:
Signature- Throws:
NoSuchAlgorithmException- if the algorithm is not found
-
createPSSParam
Createsjava.security.spec.AlgorithmParameterSpecfor the givendigestAlgo- Parameters:
digestAlgo-DigestAlgorithm- Returns:
AlgorithmParameterSpec
-