Package gov.usgs.earthquake.distribution
Class SignatureVerifier
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.distribution.SignatureVerifier
-
- All Implemented Interfaces:
Configurable
public class SignatureVerifier extends DefaultConfigurable
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_VERIFY_SIGNATURE
Don't verify signatures (Default).static java.lang.String
KEYCHAIN_FILE_PROPERTY_NAME
Property for a file of keys.static java.lang.String
KEYCHAIN_PROPERTY_NAME
Property for a list of keys.static java.lang.String
ONLY_VERIFY_KNOWN
Allow products that do not have a configured key.static java.lang.String
TEST_VERIFY_SIGNATURE
Test signatures, but don't reject invalid.static java.lang.String
VERIFY_SIGNATURES_PROPERTY_NAME
Property for whether or not to verify signatures.
-
Constructor Summary
Constructors Constructor Description SignatureVerifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Config config)
Process configuration settings.ProductKeyChain
getKeychain()
boolean
isAllowUnknownSigner()
boolean
isRejectInvalidSignatures()
boolean
isTestSignatures()
void
setAllowUnknownSigner(boolean allowUnknownSigner)
void
setKeychain(ProductKeyChain keychain)
void
setRejectInvalidSignatures(boolean rejectInvalidSignatures)
void
setTestSignatures(boolean testSignatures)
boolean
verifySignature(Product product)
Attempt to verify a products signature.-
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName, shutdown, startup
-
-
-
-
Field Detail
-
VERIFY_SIGNATURES_PROPERTY_NAME
public static final java.lang.String VERIFY_SIGNATURES_PROPERTY_NAME
Property for whether or not to verify signatures.- See Also:
- Constant Field Values
-
DEFAULT_VERIFY_SIGNATURE
public static final java.lang.String DEFAULT_VERIFY_SIGNATURE
Don't verify signatures (Default).- See Also:
- Constant Field Values
-
TEST_VERIFY_SIGNATURE
public static final java.lang.String TEST_VERIFY_SIGNATURE
Test signatures, but don't reject invalid.- See Also:
- Constant Field Values
-
ONLY_VERIFY_KNOWN
public static final java.lang.String ONLY_VERIFY_KNOWN
Allow products that do not have a configured key.- See Also:
- Constant Field Values
-
KEYCHAIN_PROPERTY_NAME
public static final java.lang.String KEYCHAIN_PROPERTY_NAME
Property for a list of keys.- See Also:
- Constant Field Values
-
KEYCHAIN_FILE_PROPERTY_NAME
public static final java.lang.String KEYCHAIN_FILE_PROPERTY_NAME
Property for a file of keys.- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(Config config) throws java.lang.Exception
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config object with settings.- Throws:
java.lang.Exception
- if configuration exceptions occur.
-
isRejectInvalidSignatures
public boolean isRejectInvalidSignatures()
- Returns:
- boolean RejectInvalidSignatures
-
setRejectInvalidSignatures
public void setRejectInvalidSignatures(boolean rejectInvalidSignatures)
- Parameters:
rejectInvalidSignatures
- boolean to set
-
isTestSignatures
public boolean isTestSignatures()
- Returns:
- boolean TestSignatures
-
setTestSignatures
public void setTestSignatures(boolean testSignatures)
- Parameters:
testSignatures
- boolean to set
-
getKeychain
public ProductKeyChain getKeychain()
- Returns:
- Product keychain
-
setKeychain
public void setKeychain(ProductKeyChain keychain)
- Parameters:
keychain
- ProductKeyChain to set
-
isAllowUnknownSigner
public boolean isAllowUnknownSigner()
- Returns:
- boolean AllowUnknownSigner
-
setAllowUnknownSigner
public void setAllowUnknownSigner(boolean allowUnknownSigner)
- Parameters:
allowUnknownSigner
- boolean to set
-
verifySignature
public boolean verifySignature(Product product) throws java.lang.Exception
Attempt to verify a products signature.- Parameters:
product
- product to verify.- Returns:
- true if the signature is from a key in the keychain.
- Throws:
InvalidSignatureException
- if rejectInvalidSignatures=true, and signature was not verified; allowUnknownSigner=true prevents this exception when no keys are found in the keychain for the product.java.lang.Exception
- if error occurs
-
-