Package eu.europa.esig.dss.signature
Class AbstractSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
java.lang.Object
eu.europa.esig.dss.signature.AbstractSignatureService<SP,TP>
- Type Parameters:
SP
- SignatureParametersTP
- TimestampParameters
- All Implemented Interfaces:
DocumentSignatureService<SP,
,TP> Serializable
- Direct Known Subclasses:
AbstractASiCSignatureService
,CAdESService
,JAdESService
,PAdESService
,XAdESService
public abstract class AbstractSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
extends Object
implements DocumentSignatureService<SP,TP>
The abstract class containing the main methods for a signature creation/extension
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CertificateVerifier
The CertificateVerifier used for a certificate chain validationprotected TSPSource
The TSPSource to use for timestamp requests -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractSignatureService
(CertificateVerifier certificateVerifier) To construct a signature service theCertificateVerifier
must be set and cannot be null. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertSigningCertificateValid
(AbstractSignatureParameters<?> parameters) This method raises an exception if the signing rules forbid the use the certificate.protected SignatureValue
ensureSignatureValue
(SignatureAlgorithm targetSignatureAlgorithm, SignatureValue signatureValue) This method ensures the providedsignatureValue
has the expectedtargetSignatureAlgorithm
protected String
getFinalDocumentName
(DSSDocument originalFile, SigningOperation operation, SignatureLevel level, MimeType containerMimeType) Generates and returns a final name for the document to createprotected String
getFinalDocumentName
(DSSDocument originalFile, SigningOperation operation, SignatureLevel level, SignaturePackaging packaging, MimeType containerMimeType) Generates and returns a final name for the document to createprotected String
getFinalFileName
(DSSDocument originalFile, SigningOperation operation) Returns the final name for the document to createprotected String
getFinalFileName
(DSSDocument originalFile, SigningOperation operation, SignatureLevel level) Returns the final name for the document to createprotected String
getFinalFileName
(DSSDocument originalFile, SigningOperation operation, SignatureLevel level, SignaturePackaging packaging) Returns the final name for the document to createboolean
isValidSignatureValue
(ToBeSigned toBeSigned, SignatureValue signatureValue, CertificateToken signingCertificate) Verifies the signature value against aToBeSigned
and aCertificateToken
void
setTspSource
(TSPSource tspSource) This setter allows to define the TSP (timestamp provider) source.timestamp
(DSSDocument toTimestampDocument, TP parameters) This method allows to add a timestamp to an unsigned documentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.europa.esig.dss.signature.DocumentSignatureService
extendDocument, getContentTimestamp, getDataToSign, signDocument
-
Field Details
-
certificateVerifier
The CertificateVerifier used for a certificate chain validation -
tspSource
The TSPSource to use for timestamp requests
-
-
Constructor Details
-
AbstractSignatureService
To construct a signature service theCertificateVerifier
must be set and cannot be null.- Parameters:
certificateVerifier
-CertificateVerifier
provides information on the sources to be used in the validation process in the context of a signature.
-
-
Method Details
-
setTspSource
Description copied from interface:DocumentSignatureService
This setter allows to define the TSP (timestamp provider) source.- Specified by:
setTspSource
in interfaceDocumentSignatureService<SP extends SerializableSignatureParameters,
TP extends SerializableTimestampParameters> - Parameters:
tspSource
- The time stamp source which is used when timestamping the signature.
-
assertSigningCertificateValid
This method raises an exception if the signing rules forbid the use the certificate.- Parameters:
parameters
- set of driving signing parameters
-
ensureSignatureValue
protected SignatureValue ensureSignatureValue(SignatureAlgorithm targetSignatureAlgorithm, SignatureValue signatureValue) This method ensures the providedsignatureValue
has the expectedtargetSignatureAlgorithm
- Parameters:
targetSignatureAlgorithm
-SignatureAlgorithm
to convert the signatureValue tosignatureValue
-SignatureValue
obtained from a signing token- Returns:
SignatureValue
with the definedSignatureAlgorithm
in parameters
-
getFinalDocumentName
protected String getFinalDocumentName(DSSDocument originalFile, SigningOperation operation, SignatureLevel level, SignaturePackaging packaging, MimeType containerMimeType) Generates and returns a final name for the document to create- Parameters:
originalFile
-DSSDocument
original signed/extended documentoperation
-SigningOperation
the performed signing operationlevel
-SignatureLevel
the final signature levelpackaging
-SignaturePackaging
the used packaging to create original signaturecontainerMimeType
-MimeType
the expected mimeType- Returns:
String
the document filename
-
getFinalFileName
Returns the final name for the document to create- Parameters:
originalFile
-DSSDocument
original signed/extended documentoperation
-SigningOperation
the performed signing operation- Returns:
String
the document filename
-
getFinalFileName
protected String getFinalFileName(DSSDocument originalFile, SigningOperation operation, SignatureLevel level) Returns the final name for the document to create- Parameters:
originalFile
-DSSDocument
original signed/extended documentoperation
-SigningOperation
the performed signing operationlevel
-SignatureLevel
the final signature level- Returns:
String
the document filename
-
getFinalFileName
protected String getFinalFileName(DSSDocument originalFile, SigningOperation operation, SignatureLevel level, SignaturePackaging packaging) Returns the final name for the document to create- Parameters:
originalFile
-DSSDocument
original signed/extended documentoperation
-SigningOperation
the performed signing operationlevel
-SignatureLevel
the final signature levelpackaging
-SignaturePackaging
the used packaging to create original signature- Returns:
String
the document filename
-
getFinalDocumentName
protected String getFinalDocumentName(DSSDocument originalFile, SigningOperation operation, SignatureLevel level, MimeType containerMimeType) Generates and returns a final name for the document to create- Parameters:
originalFile
-DSSDocument
original signed/extended documentoperation
-SigningOperation
the performed signing operationlevel
-SignatureLevel
the final signature levelcontainerMimeType
-MimeType
the expected mimeType- Returns:
String
the document filename
-
timestamp
Description copied from interface:DocumentSignatureService
This method allows to add a timestamp to an unsigned document- Specified by:
timestamp
in interfaceDocumentSignatureService<SP extends SerializableSignatureParameters,
TP extends SerializableTimestampParameters> - Parameters:
toTimestampDocument
- the document to be timestampedparameters
- set of the driving timestamping parameters- Returns:
- the timestamped document
-
isValidSignatureValue
public boolean isValidSignatureValue(ToBeSigned toBeSigned, SignatureValue signatureValue, CertificateToken signingCertificate) Description copied from interface:DocumentSignatureService
Verifies the signature value against aToBeSigned
and aCertificateToken
- Specified by:
isValidSignatureValue
in interfaceDocumentSignatureService<SP extends SerializableSignatureParameters,
TP extends SerializableTimestampParameters> - Parameters:
toBeSigned
- the signed datasignatureValue
- the signature valuesigningCertificate
- the used certificate to create the signature value- Returns:
- true if the signature value is valid
-