Class SignedDataObjects

java.lang.Object
xades4j.production.SignedDataObjects

public final class SignedDataObjects extends Object
Represents a set of data objects to be signed. Besides the data objects themselves, this class can be used to specify:
  • Properties that apply to ALL the signed data objects
  • A base URI for the data object references
  • ResourceResolvers to be used when processing the current set of data objects, in addition to the globally registered resolvers
A set of objects to be signed. Properties that apply to ALL the signed data objects can be specified via this class. This class checks for duplicate data object descriptions (not allowed).
Author:
Luís
See Also:
  • Constructor Details

    • SignedDataObjects

      public SignedDataObjects()
      Creates an empty container.
    • SignedDataObjects

      public SignedDataObjects(Iterable<DataObjectDesc> dataObjs)
      Creates a container with the given data objects.
      Parameters:
      dataObjs - the signed data objects
      Throws:
      NullPointerException - if dataObjs or any of the objects is null
    • SignedDataObjects

      public SignedDataObjects(DataObjectDesc... dataObjs)
      Creates a container with the given data objects.
      Parameters:
      dataObjs - the signed data objects
      Throws:
      NullPointerException - if dataObjs or any of the objects is null
  • Method Details

    • withBaseUri

      public SignedDataObjects withBaseUri(String baseUri)
      Sets the base URI for all the relative references. Fragment references (starting with '#') are not affected.
      Parameters:
      baseUri - the references' base URI
      Returns:
      the current instance
    • withCommitmentType

      public SignedDataObjects withCommitmentType(AllDataObjsCommitmentTypeProperty commitment)
      Adds a CommitmentType signed property shared among all data objects. The resulting property in the XAdES signature will contain the AllSignedDataObjects element. This method can be invoked multiple times with different properties since the signer may express multiple commitments towards the data objects.
      Parameters:
      commitment - the CommitmentType property
      Returns:
      the current instance
      Throws:
      PropertyTargetException - if the given property (instance) is already present
      NullPointerException - if the given property is null
    • withDataObjectsTimeStamp

      public SignedDataObjects withDataObjectsTimeStamp()
      Adds a AllDataObjectsTimeStamp signed property applied to all data objects. This method can be invoked multiple times since multiple times-stamps can be present.
      Returns:
      the current instance
    • withOtherDataObjectProperty

      public SignedDataObjects withOtherDataObjectProperty(OtherSignedDataObjectProperty otherSignedDataObjProp)
      Adds a custom global signed data object property. The purpose of this method is extensibility.

      Each custom property needs a corresponding PropertyDataObjectGenerator which can be supplied through XadesSigningProfile.

      Parameters:
      otherSignedDataObjProp - the custom property
      Returns:
      the current instance
      Throws:
      NullPointerException - if otherSignedDataObjProp is null
      PropertyTargetException - if the property is already present
      IllegalArgumentException - if the property if not properly annotated
    • withOtherDataObjectProperty

      public SignedDataObjects withOtherDataObjectProperty(OtherUnsignedDataObjectProperty otherUnsignedDataObjProp)
      Adds a custom global unsigned data object property. The purpose of this method is extensibility.

      Each custom property needs a corresponding PropertyDataObjectGenerator which can be supplied through XadesSigningProfile.

      Parameters:
      otherUnsignedDataObjProp - the custom property
      Returns:
      the current instance
      Throws:
      NullPointerException - if otherUnsignedDataObjProp is null
      PropertyTargetException - if the property is already present
      IllegalArgumentException - if the property if not properly annotated
    • withSignedDataObjects

      public SignedDataObjects withSignedDataObjects(Iterable<DataObjectDesc> objsInfo)
      Adds a set of data objects to be signed. Each data object description will result in a ds:Reference element in the final XAdES signature.
      Parameters:
      objsInfo - the data objects
      Returns:
      the current instance
      Throws:
      NullPointerException - if objsInfo or any of the objects is null
      IllegalStateException - if any of the data object descriptions is already present
    • withSignedDataObject

      public SignedDataObjects withSignedDataObject(DataObjectDesc object)
      Adds a data object to be signed. Each data object description will result in a ds:Reference element in the final XAdES signature.
      Parameters:
      object - the data object
      Returns:
      the current instance
      Throws:
      NullPointerException - if object is null
      IllegalStateException - if the data object description is already present
    • withResourceResolver

      public SignedDataObjects withResourceResolver(org.apache.xml.security.utils.resolver.ResourceResolverSpi resolver)
      Registers a ResourceResolverSpi to be used when signing the current set of data objects. The resolvers are considered in the same order they are added and have priority over the globally registered resolvers.
      Parameters:
      resolver - the resolver
      Returns:
      the current instance
      Throws:
      NullPointerException - if resolver is null