Class SimpleKeyFile
java.lang.Object
org.jpos.security.SimpleKeyFile
- All Implemented Interfaces:
Configurable, SecureKeyStore, LogSource
Implements SecureKeyStore using a properties file.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface SecureKeyStore
SecureKeyStore.SecureKeyStoreExceptionModifier and TypeInterfaceDescriptionstatic classException type raised bySecureKeyStoreimplementations. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.SimpleKeyFile(String keyFileName) Constructs the store and immediately loads keys fromkeyFileName. -
Method Summary
Modifier and TypeMethodDescriptionReturns the key assiciated with the given alias.getKeys()Returns map of existing keys assiciated with aliases.Returns the Logger associated with this source.getProperty(String alias, String subName) Returns the trimmed property stored underalias.subName.getRealm()Returns the log realm associated with this source.voidLoads (or creates) the underlying properties file and reads its contents.voidConfigures this object with the suppliedConfiguration.voidAssigns the given key to the given alias.voidAttaches aLoggerand realm to this log source.voidsetProperty(String alias, String subName, String value) Sets the property stored underalias.subName.
-
Field Details
-
logger
-
realm
-
-
Constructor Details
-
SimpleKeyFile
public SimpleKeyFile()Default constructor. -
SimpleKeyFile
Constructs the store and immediately loads keys fromkeyFileName.- Parameters:
keyFileName- path to the properties file backing this store- Throws:
SecureKeyStore.SecureKeyStoreException- if the file cannot be created or loaded
-
-
Method Details
-
init
Loads (or creates) the underlying properties file and reads its contents.- Parameters:
keyFileName- path to the properties file backing this store- Throws:
SecureKeyStore.SecureKeyStoreException- if the file cannot be created or loaded
-
setLogger
-
getLogger
-
getRealm
-
setConfiguration
Description copied from interface:ConfigurableConfigures this object with the suppliedConfiguration.- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- configuration object- Throws:
ConfigurationException- if configuration is invalid
-
getKey
Description copied from interface:SecureKeyStoreReturns the key assiciated with the given alias.- Specified by:
getKeyin interfaceSecureKeyStore- Parameters:
alias- the alias name- Returns:
- the requested key, or
nullif the given alias does not exist. - Throws:
SecureKeyStore.SecureKeyStoreException- if SecureKeyStore is not initialized or if the operation fails for some other reason.
-
setKey
Description copied from interface:SecureKeyStoreAssigns the given key to the given alias. If the given alias already exists, the keystore information associated with it is overridden by the given key.- Specified by:
setKeyin interfaceSecureKeyStore- Parameters:
alias- the alias namesecureKey- the key to be associated with the alias- Throws:
SecureKeyStore.SecureKeyStoreException- if SecureKeyStore is not initialized or the key can't be recovered.
-
getProperty
public String getProperty(String alias, String subName) throws SecureKeyStore.SecureKeyStoreException Returns the trimmed property stored underalias.subName.- Parameters:
alias- key aliassubName- property name within the alias- Returns:
- the trimmed property value
- Throws:
SecureKeyStore.SecureKeyStoreException- if the property is not present
-
setProperty
Sets the property stored underalias.subName.- Parameters:
alias- key aliassubName- property name within the aliasvalue- new property value
-
getKeys
Description copied from interface:SecureKeyStoreReturns map of existing keys assiciated with aliases.- Specified by:
getKeysin interfaceSecureKeyStore- Returns:
- map of existing keys assiciated with aliases.
- Throws:
SecureKeyStore.SecureKeyStoreException- if SecureKeyStore is not initialized or if the operation fails for some other reason.
-