Class SignatureWrapper

java.lang.Object
eu.europa.esig.dss.diagnostic.AbstractTokenProxy
eu.europa.esig.dss.diagnostic.SignatureWrapper
All Implemented Interfaces:
TokenProxy

public class SignatureWrapper extends AbstractTokenProxy
Contains user-friendly methods to extract information from an XmlSignature
  • Constructor Details

    • SignatureWrapper

      public SignatureWrapper(XmlSignature signature)
      Default constructor
      Parameters:
      signature - XmlSignature
  • Method Details

    • getId

      public String getId()
      Description copied from interface: TokenProxy
      Returns the unique identifier of the object
      Returns:
      String id
    • getDAIdentifier

      public String getDAIdentifier()
      Returns the signature document identifier of the signature
      Returns:
      String
    • getDigestMatchers

      public List<XmlDigestMatcher> getDigestMatchers()
      Description copied from interface: TokenProxy
      Returns a list of DigestMatchers used in the validation process for a signature or timestamp
      Specified by:
      getDigestMatchers in interface TokenProxy
      Overrides:
      getDigestMatchers in class AbstractTokenProxy
      Returns:
      a list of XmlDigestMatchers
    • getMessageDigest

      public XmlDigestMatcher getMessageDigest()
      Returns the message-digest for a CMS signature
      Returns:
      XmlDigestMatcher
    • getCurrentBasicSignature

      protected XmlBasicSignature getCurrentBasicSignature()
      Description copied from class: AbstractTokenProxy
      Returns a basic signature validation
      Specified by:
      getCurrentBasicSignature in class AbstractTokenProxy
      Returns:
      XmlBasicSignature
    • getCurrentCertificateChain

      protected List<XmlChainItem> getCurrentCertificateChain()
      Description copied from class: AbstractTokenProxy
      Returns the token's certificate chain
      Specified by:
      getCurrentCertificateChain in class AbstractTokenProxy
      Returns:
      a list of XmlChainItems
    • getCurrentSigningCertificate

      protected XmlSigningCertificate getCurrentSigningCertificate()
      Description copied from class: AbstractTokenProxy
      Returns the signing certificate of the token
      Specified by:
      getCurrentSigningCertificate in class AbstractTokenProxy
      Returns:
      XmlSigningCertificate
    • foundCertificates

      public FoundCertificatesProxy foundCertificates()
      Returns FoundCertificatesProxy to access embedded certificates
      Specified by:
      foundCertificates in interface TokenProxy
      Overrides:
      foundCertificates in class AbstractTokenProxy
      Returns:
      FoundCertificatesProxy
    • foundRevocations

      public FoundRevocationsProxy foundRevocations()
      Returns FoundRevocationsProxy to access embedded revocation data
      Specified by:
      foundRevocations in interface TokenProxy
      Overrides:
      foundRevocations in class AbstractTokenProxy
      Returns:
      FoundRevocationsProxy
    • getSignatureFilename

      public String getSignatureFilename()
      Returns a signature filename
      Returns:
      String
    • isStructuralValidationValid

      public boolean isStructuralValidationValid()
      Gets if a structural validation of the signature is valid
      Returns:
      TRUE if the structure of the signature is valid, FALSE otherwise
    • getStructuralValidationMessages

      public List<String> getStructuralValidationMessages()
      Returns structural validation error messages, when applicable
      Returns:
      a list of String error messages
    • getClaimedSigningTime

      public Date getClaimedSigningTime()
      Returns the claimed signing time extracted from the signature
      Returns:
      Date
    • getContentType

      public String getContentType()
      Returns the content type
      Returns:
      String
    • getMimeType

      public String getMimeType()
      Returns the MimeType
      Returns:
      String
    • getContentHints

      public String getContentHints()
      Returns the content hints string
      Returns:
      String
    • getContentIdentifier

      public String getContentIdentifier()
      Returns the content identifier
      Returns:
      String
    • isCounterSignature

      public boolean isCounterSignature()
      Gets if the current signature counter-signs another signature within the document
      Returns:
      TRUE if the signature is counter-signature, FALSE otherwise
    • isSignatureDuplicated

      public boolean isSignatureDuplicated()
      Checks if the signature's Id is duplicated within the validating document
      Returns:
      TRUE if there is a duplicated signature Id, FALSE otherwise
    • getSignatureDigestReference

      public XmlSignatureDigestReference getSignatureDigestReference()
      Returns Signature Digest Reference
      Returns:
      XmlSignatureDigestReference
    • getDataToBeSignedRepresentation

      public XmlDigestAlgoAndValue getDataToBeSignedRepresentation()
      Returns a DataToBeSigned digest
      Returns:
      XmlDigestAlgoAndValue
    • getTimestampList

      public List<TimestampWrapper> getTimestampList()
      Returns a list of associated timestamps
      Returns:
      a list of TimestampWrappers
    • getTimestampListByType

      public List<TimestampWrapper> getTimestampListByType(TimestampType timestampType)
      Returns a list of associated timestamps by type
      Parameters:
      timestampType - TimestampType to get timestamps
      Returns:
      a list of TimestampWrappers
    • isSignatureProductionPlacePresent

      public boolean isSignatureProductionPlacePresent()
      Gets if the signature production place is claimed within the signature
      Returns:
      TRUE if the signature production place is present, FALSE otherwise
    • getStreetAddress

      public String getStreetAddress()
      Returns the signature production place's street address, when present
      Returns:
      String
    • getCity

      public String getCity()
      Returns the signature production place's city, when present
      Returns:
      String
    • getCountryName

      public String getCountryName()
      Returns the signature production place's country name, when present
      Returns:
      String
    • getPostOfficeBoxNumber

      public String getPostOfficeBoxNumber()
      Returns the signature production place's post office box number, when present
      Returns:
      String
    • getPostalCode

      public String getPostalCode()
      Returns the signature production place's postal code, when present
      Returns:
      String
    • getStateOrProvince

      public String getStateOrProvince()
      Returns the signature production place's state or province, when present
      Returns:
      String
    • getPostalAddress

      public List<String> getPostalAddress()
      Returns the signature production place's postal address, when present
      Returns:
      String
    • getSignatureFormat

      public SignatureLevel getSignatureFormat()
      Returns the signature level (format)
      Returns:
      SignatureLevel
    • getErrorMessage

      public String getErrorMessage()
      Returns an error message
      Returns:
      String
    • isSigningCertificateIdentified

      public boolean isSigningCertificateIdentified()
      Gets if a signing certificate has been unambiguously identified
      Returns:
      TRUE if the signing certificate has been identifier, FALSE otherwise
    • getPolicyId

      public String getPolicyId()
      Returns the signature policy Id, when present
      Returns:
      String
    • isPolicyZeroHash

      public boolean isPolicyZeroHash()
      Returns if the signature policy's hash should not be compared (zero hash is used)
      Returns:
      TRUE if zero hash has been used, FALSE otherwise
    • getPolicyDigestAlgoAndValue

      public XmlPolicyDigestAlgoAndValue getPolicyDigestAlgoAndValue()
      Returns the signature policy digest
      Returns:
      XmlPolicyDigestAlgoAndValue
    • isPolicyStorePresent

      public boolean isPolicyStorePresent()
      Checks if a SignaturePolicyStore unsigned property is present
      Returns:
      TRUE if SignaturePolicyStore is present, FALSE otherwise
    • getPolicyStoreId

      public String getPolicyStoreId()
      Gets the signature policy store id
      Returns:
      String
    • getPolicyStoreDescription

      public String getPolicyStoreDescription()
      Gets the signature policy store description
      Returns:
      String
    • getPolicyStoreDigestAlgoAndValue

      public XmlDigestAlgoAndValue getPolicyStoreDigestAlgoAndValue()
      Gets the digest of a signature policy containing within the signature policy store
      Returns:
      XmlDigestAlgoAndValue
    • getPolicyStoreDocumentationReferences

      public List<String> getPolicyStoreDocumentationReferences()
      Returns a signature policy store documentation references
      Returns:
      a list of Strings
    • getPolicyStoreLocalURI

      public String getPolicyStoreLocalURI()
      Returns a signature policy store local URI
      Returns:
      String
    • isBLevelTechnicallyValid

      public boolean isBLevelTechnicallyValid()
      Gets if the B-level of the signature is valid
      Returns:
      TRUE if the B-level of the signature is valid, FALSE otherwise
    • isThereXLevel

      public boolean isThereXLevel()
      Returns if there is the X-Level within the signature
      Returns:
      TRUE if there is the X-Level, FALSE otherwise
    • isXLevelTechnicallyValid

      public boolean isXLevelTechnicallyValid()
      Gets if the X-level of the signature is valid
      Returns:
      TRUE if the X-level of the signature is valid, FALSE otherwise
    • getTimestampLevelX

      public List<TimestampWrapper> getTimestampLevelX()
      Returns a list of validation-data-refs-only- and validation-data- time-stamps for the signature
      Returns:
      a list of TimestampWrappers
    • isThereALevel

      public boolean isThereALevel()
      Returns if there is the A-Level within the signature
      Returns:
      TRUE if there is the A-Level, FALSE otherwise
    • isALevelTechnicallyValid

      public boolean isALevelTechnicallyValid()
      Gets if the A-level of the signature is valid
      Returns:
      TRUE if the A-level of the signature is valid, FALSE otherwise
    • getALevelTimestamps

      public List<TimestampWrapper> getALevelTimestamps()
      Returns a list of archive timestamps for the signature
      Returns:
      a list of TimestampWrappers
    • getArchiveTimestamps

      public List<TimestampWrapper> getArchiveTimestamps()
      Returns a list of archive timestamps for the signature
      Returns:
      a list of TimestampWrappers
    • isThereTLevel

      public boolean isThereTLevel()
      Returns if there is the T-Level within the signature
      Returns:
      TRUE if there is the T-Level, FALSE otherwise
    • isTLevelTechnicallyValid

      public boolean isTLevelTechnicallyValid()
      Gets if the T-level of the signature is valid
      Returns:
      TRUE if the T-level of the signature is valid, FALSE otherwise
    • getTLevelTimestamps

      public List<TimestampWrapper> getTLevelTimestamps()
      Returns a list of signature timestamps for the signature
      Returns:
      a list of TimestampWrappers
    • getContentTimestamps

      public List<TimestampWrapper> getContentTimestamps()
      Returns a list of content timestamps of the signature
      Returns:
      a list of TimestampWrappers
    • getAllTimestampsProducedAfterSignatureCreation

      public List<TimestampWrapper> getAllTimestampsProducedAfterSignatureCreation()
      Returns all non-content timestamps
      Returns:
      a list of TimestampWrappers
    • getSignatureTimestamps

      public List<TimestampWrapper> getSignatureTimestamps()
      Returns all signature timestamps
      Returns:
      a list of TimestampWrappers
    • getDocumentTimestamps

      public List<TimestampWrapper> getDocumentTimestamps()
      Returns all PDF document timestamps
      Returns:
      a list of TimestampWrappers
    • getTimestampIdsList

      public List<String> getTimestampIdsList()
      Returns a list of timestamp IDs
      Returns:
      a list of String IDs
    • getKeyIdentifierReference

      public CertificateRefWrapper getKeyIdentifierReference()
      This method returns a reference extracted from a 'kid' (key identifier) header (used in JAdES)
      Returns:
      CertificateRefWrapper
    • getParent

      public SignatureWrapper getParent()
      Returns a master-signature in case of a counter-signature
      Returns:
      SignatureWrapper
    • getSignatureScopes

      public List<XmlSignatureScope> getSignatureScopes()
      Returns Signature Scopes
      Returns:
      a list of XmlSignatureScopes
    • getSignerRoles

      public List<XmlSignerRole> getSignerRoles()
      Returns list of all found SignerRoles
      Returns:
      list of XmlSignerRoles
    • getClaimedRoles

      public List<XmlSignerRole> getClaimedRoles()
      Returns list of found ClaimedRoles
      Returns:
      list of XmlSignerRoles
    • getCertifiedRoles

      public List<XmlSignerRole> getCertifiedRoles()
      Returns list of found CertifiedRoles
      Returns:
      list of XmlSignerRoles
    • getSignedAssertions

      public List<XmlSignerRole> getSignedAssertions()
      Returns list of all found SignedAssertions
      Returns:
      list of XmlSignerRoles
    • getSignerRoleDetails

      public List<String> getSignerRoleDetails(List<XmlSignerRole> listOfSignerRoles)
      Returns a list of Strings describing the role for the given listOfSignerRoles
      Parameters:
      listOfSignerRoles - - list of XmlSignerRole to get string role details from
      Returns:
      list of role details
    • getCommitmentTypeIndications

      public List<XmlCommitmentTypeIndication> getCommitmentTypeIndications()
      Returns a list of commitment type indications
      Returns:
      a lust of XmlCommitmentTypeIndications
    • isPolicyPresent

      public boolean isPolicyPresent()
      Checks if a SignaturePolicyIdentifier is present
      Returns:
      TRUE if a SignaturePolicyIdentifier is found, FALSE otherwise
    • getPolicyProcessingError

      public String getPolicyProcessingError()
      Returns an error string occurred during a SignaturePolicy proceeding, when applicable
      Returns:
      String representing a policy validation error message, empty when no errors found
    • getPolicyDescription

      public String getPolicyDescription()
      Returns XMLPolicy description if it is not empty
      Returns:
      String
    • getPolicyDocumentationReferences

      public List<String> getPolicyDocumentationReferences()
      Returns DocumentationReferences defined for the signature policy
      Returns:
      a list of Strings
    • getPolicyTransforms

      public List<String> getPolicyTransforms()
      Returns a list of Policy transformations NOTE: used only for XAdES signatures
      Returns:
      a list of Strings
    • getPolicyUrl

      public String getPolicyUrl()
      Returns the signature policy url
      Returns:
      String
    • getPolicyUserNotice

      public XmlUserNotice getPolicyUserNotice()
      Returns the policy UserNotice
      Returns:
      XmlUserNotice
    • getPolicyDocSpecification

      public XmlSPDocSpecification getPolicyDocSpecification()
      Returns the signature policy document specification
      Returns:
      XmlSPDocSpecification
    • isPolicyAsn1Processable

      public boolean isPolicyAsn1Processable()
      Gets if the signature policy is ASN.1 processable
      Returns:
      TRUE if the signature policy is ASN.1, FALSE otherwise
    • isPolicyIdentified

      public boolean isPolicyIdentified()
      Gets if the signature policy has been found
      Returns:
      TRUE if the signature policy has been found, FALSE otherwise
    • isPolicyDigestValid

      public boolean isPolicyDigestValid()
      Gets if the signature policy digest validation succeeds
      Returns:
      TRUE if the signature policy digest are valid, FALSE otherwise
    • isPolicyDigestAlgorithmsEqual

      public boolean isPolicyDigestAlgorithmsEqual()
      Gets if the validated signature policy algorithm match
      Returns:
      TRUE if the signature policy digest algorithms match, FALSE otherwise
    • getPDFRevision

      public XmlPDFRevision getPDFRevision()
      Returns a PAdES-specific PDF Revision info NOTE: applicable only for PAdES
      Returns:
      XmlPDFRevision
    • arePdfModificationsDetected

      public boolean arePdfModificationsDetected()
      Checks if any visual modifications detected in the PDF
      Returns:
      TRUE if modifications detected in a PDF, FALSE otherwise
    • getPdfAnnotationsOverlapConcernedPages

      public List<BigInteger> getPdfAnnotationsOverlapConcernedPages()
      Returns a list of PDF annotation overlap concerned pages
      Returns:
      a list of page numbers
    • getPdfVisualDifferenceConcernedPages

      public List<BigInteger> getPdfVisualDifferenceConcernedPages()
      Returns a list of PDF visual difference concerned pages
      Returns:
      a list of page numbers
    • getPdfPageDifferenceConcernedPages

      public List<BigInteger> getPdfPageDifferenceConcernedPages()
      Returns a list of pages missing/added to the final revision in a comparison with a signed one
      Returns:
      a list of page numbers
    • arePdfObjectModificationsDetected

      public boolean arePdfObjectModificationsDetected()
      This method checks whether object modifications are present after the current PDF revisions
      Returns:
      TRUE if PDF has been modified, FALSE otherwise
    • getPdfExtensionChanges

      public List<XmlObjectModification> getPdfExtensionChanges()
      Returns a list of changes occurred in a PDF after the current signature's revision associated with a signature/document extension
      Returns:
      a list of XmlObjectModifications
    • getPdfSignatureOrFormFillChanges

      public List<XmlObjectModification> getPdfSignatureOrFormFillChanges()
      Returns a list of changes occurred in a PDF after the current signature's revision associated with a signature creation, form filling
      Returns:
      a list of XmlObjectModifications
    • getPdfAnnotationChanges

      public List<XmlObjectModification> getPdfAnnotationChanges()
      Returns a list of changes occurred in a PDF after the current signature's revision associated with annotation(s) modification
      Returns:
      a list of XmlObjectModifications
    • getPdfUndefinedChanges

      public List<XmlObjectModification> getPdfUndefinedChanges()
      Returns a list of undefined changes occurred in a PDF after the current signature's revision
      Returns:
      a list of XmlObjectModifications
    • getModifiedFieldNames

      public List<String> getModifiedFieldNames()
      This method returns a list of field names modified after the current signature's revision
      Returns:
      a list of Strings
    • getFirstFieldName

      public String getFirstFieldName()
      Returns the first signature field name
      Returns:
      String field name
    • getSignatureFieldNames

      public List<String> getSignatureFieldNames()
      Returns a list of signature field names, where the signature is referenced from
      Returns:
      a list of String signature field names
    • getSignatureInformationStore

      public List<XmlSignerInfo> getSignatureInformationStore()
      Returns a list if Signer Infos (Signer Information Store) from CAdES CMS Signed Data
      Returns:
      list of XmlSignerInfos
    • getSignerName

      public String getSignerName()
      Returns the signer's name
      Returns:
      String
    • getSignatureDictionaryType

      public String getSignatureDictionaryType()
      Returns the PDF signature dictionary /Type value
      Returns:
      String
    • getFilter

      public String getFilter()
      Returns the PDF signature dictionary /Filter value
      Returns:
      String
    • getSubFilter

      public String getSubFilter()
      Returns the PDF signature dictionary /SubFilter value
      Returns:
      String
    • getContactInfo

      public String getContactInfo()
      Returns the PDF signature dictionary /ContactInfo value
      Returns:
      String
    • getLocation

      public String getLocation()
      Returns the PDF signature dictionary /Location value
      Returns:
      String
    • getReason

      public String getReason()
      Returns the PDF signature dictionary /Reason value
      Returns:
      String
    • getSignatureByteRange

      public List<BigInteger> getSignatureByteRange()
      Returns the PDF signature dictionary /ByteRange value
      Returns:
      byte range
    • getDocMDPPermissions

      public CertificationPermission getDocMDPPermissions()
      Returns a CertificationPermission value of a /DocMDP dictionary, when present
      Returns:
      CertificationPermission
    • getFieldMDP

      public XmlPDFLockDictionary getFieldMDP()
      Returns a /FieldMDP dictionary content, when present
      Returns:
      XmlPDFLockDictionary
    • getSigFieldLock

      public XmlPDFLockDictionary getSigFieldLock()
      Returns a /SigFieldLock dictionary, when present
      Returns:
      XmlPDFLockDictionary
    • getSignatureValue

      public byte[] getSignatureValue()
      Gets the SignatureValue
      Returns:
      binaries
    • isDocHashOnly

      public boolean isDocHashOnly()
      Gets if the signature is a document hash only
      Returns:
      TRUE if the signature is a document hash only, FALSE otherwise
    • isHashOnly

      public boolean isHashOnly()
      Gets if the signature is a hash only
      Returns:
      TRUE if the signature is a hash only, FALSE otherwise
    • getBinaries

      public byte[] getBinaries()
      Description copied from class: AbstractTokenProxy
      Returns binaries of the token, when present
      Specified by:
      getBinaries in class AbstractTokenProxy
      Returns:
      a byte array