Package org.saidone.service.notarization
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkNotarization
(String nodeId) Validates that the notarization for the specified node is still valid.protected abstract String
Retrieves the stored hash for the given transaction id.void
notarizeNode
(String nodeId) Computes the hash of the node content and stores it throughputHash(java.lang.String, java.lang.String)
.protected abstract String
Persists the given hash.Methods inherited from class org.saidone.component.BaseComponent
init, setApplicationContext, shutDown, stop
-
Constructor Details
-
AbstractNotarizationService
public AbstractNotarizationService()
-
-
Method Details
-
putHash
Persists the given hash.- Parameters:
nodeId
- the node identifierhash
- the hash value to store- Returns:
- an implementation specific transaction id
-
getHash
Retrieves the stored hash for the given transaction id.- Parameters:
txId
- the transaction identifier- Returns:
- the stored hash value
-
notarizeNode
Computes the hash of the node content and stores it throughputHash(java.lang.String, java.lang.String)
.- Specified by:
notarizeNode
in interfaceNotarizationService
- Parameters:
nodeId
- the identifier of the node to notarize
-
checkNotarization
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 interfaceNotarizationService
- Parameters:
nodeId
- the identifier of the node to check- Throws:
NotarizationException
- if the node is not notarized or hashes do not match
-