Class AbstractNotarizationService

java.lang.Object
org.saidone.component.BaseComponent
org.saidone.service.notarization.AbstractNotarizationService
All Implemented Interfaces:
NotarizationService, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
EthereumService

public abstract class AbstractNotarizationService extends BaseComponent implements NotarizationService
Base implementation for services performing document notarization.

Concrete implementations only need to provide the mechanisms used to persist and read back document hashes via putHash(String, String) and getHash(String). All other operations such as computing the hash of a node's content and updating the node metadata are handled here.

  • Constructor Details

    • AbstractNotarizationService

      public AbstractNotarizationService()
  • Method Details

    • putHash

      protected abstract String putHash(String nodeId, String hash)
      Persists the given hash.
      Parameters:
      nodeId - the node identifier
      hash - the hash value to store
      Returns:
      an implementation specific transaction id
    • getHash

      protected abstract String getHash(String txId)
      Retrieves the stored hash for the given transaction id.
      Parameters:
      txId - the transaction identifier
      Returns:
      the stored hash value
    • notarizeNode

      public void notarizeNode(String nodeId)
      Computes the hash of the node content and stores it through putHash(java.lang.String, java.lang.String).
      Specified by:
      notarizeNode in interface NotarizationService
      Parameters:
      nodeId - the identifier of the node to notarize
    • checkNotarization

      public void checkNotarization(String nodeId)
      Validates that the notarization for the specified node is still valid.

      The method retrieves the stored transaction id from the node, fetches the hash back from the notarization system and compares it with the hash computed from the current content.

      Specified by:
      checkNotarization in interface NotarizationService
      Parameters:
      nodeId - the identifier of the node to check
      Throws:
      NotarizationException - if the node is not notarized or hashes do not match