Package gov.usgs.earthquake.product
Class ProductDigest
java.lang.Object
gov.usgs.earthquake.product.ProductDigest
- All Implemented Interfaces:
ProductHandler
Used to generate product digests.
All product attributes and content are used when generating a digest, except
any existing signature, since the digest is used to generate or verify
signatures.
Calls to ProductOutput methods on this class must occur in identical order to
generate consistent signatures. Therefore it is almost required to use the
ObjectProductInput, which fulfills this requirement.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProductDigest(CryptoUtils.Version version) Construct a new ProductDigest. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Free any resources associated with this handler.static byte[]digestProduct(Product product, CryptoUtils.Version version) byte[]static voidCLI access into ProductDigestvoidonBeginProduct(ProductId id, String status) Digest the id, update time, status, and URL.voidDigest the path, content attributes, and content bytes.voidFinish computing digest.voidDigest the link relation and href.voidonProperty(ProductId id, String name, String value) Digest the property name and value.voidonSignature(ProductId id, String signature) Don't digest the signature.voidonSignatureHistory(ProductId id, List<ProductSignature> signatureHistory) Don't digest the signature history.voidonSignatureVersion(ProductId id, CryptoUtils.Version version) Don't digest signature version.
-
Field Details
-
CHARSET
Character set used when computing digests. -
MESSAGE_DIGEST_ALGORITHM
Algorithm used when generating product digest.- See Also:
-
MESSAGE_DIGEST_V2_ALGORITHM
v2 digest algorithm- See Also:
-
-
Constructor Details
-
ProductDigest
Construct a new ProductDigest.- Parameters:
version- signature version- Throws:
NoSuchAlgorithmException- if not SHA1 or SHA-256
-
-
Method Details
-
digestProduct
- Parameters:
product- A productversion- What version of product digest- Returns:
- A byte array of the product digest
- Throws:
Exception- if error occurs
-
getDigest
public byte[] getDigest()- Returns:
- the computed digest, or null if not finished yet.
-
onBeginProduct
Digest the id, update time, status, and URL.- Specified by:
onBeginProductin interfaceProductHandler- Parameters:
id- which product.status- the product's status.- Throws:
Exception- if error occurs
-
onContent
Digest the path, content attributes, and content bytes.- Specified by:
onContentin interfaceProductHandler- Parameters:
id- which product.path- path to content within product.content- the product content.- Throws:
Exception- if error occurs
-
onEndProduct
Finish computing digest.- Specified by:
onEndProductin interfaceProductHandler- Parameters:
id- which product.- Throws:
Exception- if error occurs
-
onLink
Digest the link relation and href.- Specified by:
onLinkin interfaceProductHandler- Parameters:
id- which product.relation- how the URI is related to this product.href- the URI that is related to this product.- Throws:
Exception- if error occurs
-
onProperty
Digest the property name and value.- Specified by:
onPropertyin interfaceProductHandler- Parameters:
id- which product.name- the property name.value- the property value.- Throws:
Exception- if error occurs
-
onSignatureVersion
Don't digest signature version.- Specified by:
onSignatureVersionin interfaceProductHandler- Parameters:
id- which product.version- product version- Throws:
Exception- if error occurs
-
onSignature
Don't digest the signature.- Specified by:
onSignaturein interfaceProductHandler- Parameters:
id- which product.signature- the product signature, which can be verified using the ProductSigner class.- Throws:
Exception- if error occurs
-
onSignatureHistory
public void onSignatureHistory(ProductId id, List<ProductSignature> signatureHistory) throws Exception Don't digest the signature history.- Specified by:
onSignatureHistoryin interfaceProductHandler- Parameters:
id- which product.signatureHistory- signature history of product.- Throws:
Exception- if error occurs
-
close
public void close()Free any resources associated with this handler.- Specified by:
closein interfaceProductHandler
-
main
CLI access into ProductDigest- Parameters:
args- CLI Args- Throws:
Exception- if error occurs
-