public class SecretKeyRepositoryImpl extends Object implements SecretKeyRepository
SecretKeyRepository, which uses JCE Key Store.| Modifier and Type | Field and Description |
|---|---|
protected String |
defaultKeyAlgorithm |
static String |
ERROR_KEY_GET_KEY_ERROR |
static String |
ERROR_KEY_KEY_STORE_LOAD_ERROR |
static String |
ERROR_KEY_KEY_STORE_STORE_ERROR |
static String |
ERROR_KEY_SAVE_KEY_ERROR |
static String |
KEY_STORE_TYPE |
protected KeyStore |
keyStore |
protected File |
keyStoreFile |
protected char[] |
keyStorePassword |
static String |
LOG_KEY_KEY_CREATED |
static String |
LOG_KEY_KEY_FOUND |
static String |
LOG_KEY_KEY_NOT_FOUND |
static String |
LOG_KEY_KEY_SAVED |
static String |
LOG_KEY_KEY_STORE_LOADED |
static String |
LOG_KEY_KEY_STORE_STORED |
| Constructor and Description |
|---|
SecretKeyRepositoryImpl() |
| Modifier and Type | Method and Description |
|---|---|
SecretKey |
getKey(String name,
boolean create)
Returns the secret key for the specified key name
|
void |
init() |
protected void |
loadKeyStore() |
void |
saveKey(String name,
SecretKey key)
Saves the secret key in the repository, with the specified name
|
void |
setDefaultKeyAlgorithm(String defaultKeyAlgorithm) |
void |
setKeyStoreFile(File keyStoreFile) |
void |
setKeyStorePassword(String keyStorePassword) |
protected void |
storeKeyStore() |
public static final String KEY_STORE_TYPE
public static final String LOG_KEY_KEY_FOUND
public static final String LOG_KEY_KEY_NOT_FOUND
public static final String LOG_KEY_KEY_CREATED
public static final String LOG_KEY_KEY_SAVED
public static final String LOG_KEY_KEY_STORE_LOADED
public static final String LOG_KEY_KEY_STORE_STORED
public static final String ERROR_KEY_KEY_STORE_LOAD_ERROR
public static final String ERROR_KEY_KEY_STORE_STORE_ERROR
public static final String ERROR_KEY_GET_KEY_ERROR
public static final String ERROR_KEY_SAVE_KEY_ERROR
protected File keyStoreFile
protected char[] keyStorePassword
protected String defaultKeyAlgorithm
protected KeyStore keyStore
public void setKeyStoreFile(File keyStoreFile)
public void setKeyStorePassword(String keyStorePassword)
public void setDefaultKeyAlgorithm(String defaultKeyAlgorithm)
@PostConstruct public void init() throws CryptoException
CryptoExceptionpublic SecretKey getKey(String name, boolean create) throws CryptoException
SecretKeyRepositorygetKey in interface SecretKeyRepositoryname - the key's name in the repositorycreate - true to create new key if there's no key with the specified name in the repository.CryptoExceptionpublic void saveKey(String name, SecretKey key) throws CryptoException
SecretKeyRepositorysaveKey in interface SecretKeyRepositoryname - the key's name in the repositorykey - the key to saveCryptoExceptionprotected void loadKeyStore()
throws CryptoException
CryptoExceptionprotected void storeKeyStore()
throws CryptoException
CryptoExceptionCopyright © 2018 CrafterCMS. All rights reserved.