public class EncryptionServiceImpl extends Object implements EncryptionService, org.springframework.beans.factory.InitializingBean
Leverages a configured EncryptionStrategy
for determining what algorithm to use for encryption. The
strategy can either be injected into this class or configured in the ConfigContext
. The algorithm is
configured using the "encryption.algorithm" parameter. The only two options are "DES" and "DESede".
If no encryption strategy is injected or configured, then this class will default to using "DES" as the algorithm.
This class defaults to using the UTF-8 charset, but that can be modified via setCharset(String)
Modifier and Type | Class and Description |
---|---|
static class |
EncryptionServiceImpl.DESedeEncryptionStrategy
An EncryptionStrategy for the DESede encryption algorithm.
|
static class |
EncryptionServiceImpl.DESEncryptionStrategy
An EncryptionStrategy for the DES encryption algorithm.
|
ENCRYPTION_POST_PREFIX, HASH_POST_PREFIX
Constructor and Description |
---|
EncryptionServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
checkEnabled()
Performs a check to see if the encryption service is enabled.
|
String |
decrypt(String ciphertext)
Decrypts a value
|
byte[] |
decryptBytes(byte[] ciphertext)
Decrypts a value
|
String |
encrypt(Object valueToHide)
Encrypts a value
|
byte[] |
encryptBytes(byte[] valueToHide)
Encrypts a value
|
EncryptionStrategy |
getEncryptionStrategy() |
String |
hash(Object valueToHide)
Hash the value by converting to a string, running the hash algorithm, and then base64'ng the results.
|
boolean |
isEnabled()
Returns true if encryption is enabled within KEW, false otherwise.
|
void |
setCharset(String charset) |
void |
setEncryptionStrategy(EncryptionStrategy encryptionStrategy) |
void |
setSecretKey(String secretKeyValue)
Sets the secretKey attribute value.
|
public EncryptionServiceImpl()
public void afterPropertiesSet() throws GeneralSecurityException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
GeneralSecurityException
public boolean isEnabled()
EncryptionService
isEnabled
in interface EncryptionService
public String encrypt(Object valueToHide) throws GeneralSecurityException
EncryptionService
encrypt
in interface EncryptionService
valueToHide
- - original valueGeneralSecurityException
public String decrypt(String ciphertext) throws GeneralSecurityException
EncryptionService
decrypt
in interface EncryptionService
ciphertext
- - encrypted valueGeneralSecurityException
public byte[] encryptBytes(byte[] valueToHide) throws GeneralSecurityException
EncryptionService
encryptBytes
in interface EncryptionService
valueToHide
- - original valueGeneralSecurityException
public byte[] decryptBytes(byte[] ciphertext) throws GeneralSecurityException
EncryptionService
decryptBytes
in interface EncryptionService
ciphertext
- - encrypted valueGeneralSecurityException
public void setSecretKey(String secretKeyValue) throws GeneralSecurityException
secretKeyValue
- The secretKey to set.Exception
GeneralSecurityException
public EncryptionStrategy getEncryptionStrategy()
public void setEncryptionStrategy(EncryptionStrategy encryptionStrategy)
public String hash(Object valueToHide) throws GeneralSecurityException
hash
in interface EncryptionService
valueToHide
- - original valueGeneralSecurityException
protected void checkEnabled()
public void setCharset(String charset)
Copyright © 2005–2016 The Kuali Foundation. All rights reserved.