public abstract class DefaultFileKeyManager extends FileKeyManager implements AsymmetricKeyManager, SymmetricKeyManager
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BTCPAY_SERVER_PRIVATE_KEYNAME |
protected static java.lang.String |
BTCPAY_SERVER_PUBLIC_KEYNAME |
protected BTCPayServerHelper |
btcPayServerHelper |
protected java.time.Clock |
clock |
protected java.security.Key |
secretKey |
protected static java.lang.String |
SYMMENTRIC_FILENAME |
log
Constructor and Description |
---|
DefaultFileKeyManager() |
Modifier and Type | Method and Description |
---|---|
protected java.security.Key |
generateAndStoreSymmetricKey(java.io.File keyFile,
char[] protectPassphrase) |
protected java.io.File |
genPublicBTCPayServerFile(java.lang.String sIN)
Method to return the BTC Pay Server public file name with sIN value filename.
|
protected java.security.KeyPair |
getAsymKeyPair()
Help method to parse existing keys or generate new ones if not exists.
|
protected abstract java.lang.String |
getAsymTrustStorePath()
Returns the path of directory where trusted public key files are stored.
|
protected java.security.KeyPair |
getBTCPayServerKeyPair()
Help method to parse existing keys for BTCPayServer or generate new ones if not exists.
|
protected java.security.KeyFactory |
getECKeyFactory() |
java.security.PrivateKey |
getPrivateKey(Context context)
Returns the private key that should be used for asymmetric operations for the given context.
|
java.security.PublicKey |
getPublicKey(Context context)
Returns the public key that should be used for asymmetric operations for the given context.
|
protected java.security.KeyFactory |
getRSAKeyFactory() |
java.security.Key |
getSymmetricKey(Context context)
Returns the key that should be used for symmetric operations for the given context.
|
protected java.io.File |
getSymmetricKeyFile() |
java.util.Map<java.lang.String,java.security.PublicKey> |
getTrustedKeys(Context context)
Method retrieve a list of trusted public keys used to verify signatures.
|
protected java.security.Key |
parseSymmetricKeyFile(java.io.File keyFile,
char[] protectPassphrase) |
getDirectory, getDirectory, getKeyStorePath, getProtectPassphrase, getProtectPassphraseWithDefault, getProvider
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProvider
protected static final java.lang.String BTCPAY_SERVER_PRIVATE_KEYNAME
protected static final java.lang.String BTCPAY_SERVER_PUBLIC_KEYNAME
protected static final java.lang.String SYMMENTRIC_FILENAME
protected java.security.Key secretKey
protected java.time.Clock clock
protected BTCPayServerHelper btcPayServerHelper
public java.security.PublicKey getPublicKey(Context context) throws java.lang.UnsupportedOperationException, InternalErrorException
getPublicKey
in interface AsymmetricKeyManager
context
- related context.java.lang.UnsupportedOperationException
- if operation in combination with given context isn't
supported.InternalErrorException
- if internal error occurred parsing/generating public key.public java.security.PrivateKey getPrivateKey(Context context) throws java.lang.UnsupportedOperationException, InternalErrorException
getPrivateKey
in interface AsymmetricKeyManager
context
- related context.java.lang.UnsupportedOperationException
- if operation in combination with given context isn't
supported.InternalErrorException
- if internal error occurred parsing/generating private key.public java.util.Map<java.lang.String,java.security.PublicKey> getTrustedKeys(Context context) throws java.lang.UnsupportedOperationException, InternalErrorException
getTrustedKeys
in interface AsymmetricKeyManager
context
- related context.java.lang.UnsupportedOperationException
- if operation in combination with given context isn't
supported.InternalErrorException
- if internal error occurred retrieving the public keys.public java.security.Key getSymmetricKey(Context context) throws java.lang.UnsupportedOperationException, InternalErrorException
getSymmetricKey
in interface SymmetricKeyManager
context
- related context. Same key is used for all contexts.java.lang.UnsupportedOperationException
- if operation in combination with given context isn't
supported.InternalErrorException
- if internal error occurred retrieving the key.protected abstract java.lang.String getAsymTrustStorePath() throws InternalErrorException
InternalErrorException
- if internal error occurred retrieving the trust store path.protected java.security.KeyPair getAsymKeyPair() throws InternalErrorException
InternalErrorException
- if problems occurred reading the keys from file.protected java.security.KeyPair getBTCPayServerKeyPair() throws InternalErrorException
InternalErrorException
- if problems occurred reading the keys from file.protected java.security.KeyFactory getRSAKeyFactory() throws InternalErrorException
InternalErrorException
protected java.security.KeyFactory getECKeyFactory() throws InternalErrorException
InternalErrorException
protected java.io.File getSymmetricKeyFile() throws InternalErrorException
InternalErrorException
protected java.security.Key parseSymmetricKeyFile(java.io.File keyFile, char[] protectPassphrase) throws InternalErrorException
InternalErrorException
protected java.security.Key generateAndStoreSymmetricKey(java.io.File keyFile, char[] protectPassphrase) throws InternalErrorException
InternalErrorException
protected java.io.File genPublicBTCPayServerFile(java.lang.String sIN) throws InternalErrorException
sIN
- the related sIN valueInternalErrorException
- if problems occurred looking up the file name.