|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lumis.portal.crypto.AbstractCipher lumis.portal.crypto.SymmetricCipher
public class SymmetricCipher
Generic cipher implementation, based on symmetric ciphers available in the
Java Cryptography Architecture (JCA).
Also includes a Mac
in the encrypted value for integrity check.
Configuration elements:
provider
: may be used to specify a JCA provider for the algortithms.algorithm
: the symmetric cipher algorithm.mode
: the cipher mode.padding
: the padding type.keyGenerationSize
: the size, in bits, of the keys automatically
generated for this cipher.mac
: the MAC's algorithm.
javax.crypto
Constructor Summary | |
---|---|
SymmetricCipher()
|
Method Summary | |
---|---|
byte[] |
decrypt(byte[] encryptedValue)
Decrypts an array of bytes. |
byte[] |
encrypt(byte[] plainText)
Encrypts an array of bytes. |
protected SecretKey |
generateKey(int bitLength,
String algorithm,
String provider)
Generates a key. |
protected Cipher |
getCipher()
Returns a new Cipher instance, according to current configurations. |
protected Mac |
getMac()
Returns a new Mac instance, according to current configurations. |
void |
init(Node configuration)
This method is called only once and before any other method are called. |
Methods inherited from class lumis.portal.crypto.AbstractCipher |
---|
decrypt, encrypt, getStringCharset, getUseURLSafeBase64Variant |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SymmetricCipher()
Method Detail |
---|
public void init(Node configuration) throws PortalException
ICipherSpi
PortalException
protected SecretKey generateKey(int bitLength, String algorithm, String provider) throws GeneralSecurityException
bitLength
- the length of the key, in bits.algorithm
- the algorithm the key will be used for.provider
- the provider of the algorithm.
GeneralSecurityException
protected Cipher getCipher() throws GeneralSecurityException
Cipher
instance, according to current configurations.
GeneralSecurityException
Cipher.getInstance(String, String)
protected Mac getMac() throws GeneralSecurityException
Mac
instance, according to current configurations.
GeneralSecurityException
Mac.getInstance(String, String)
public byte[] decrypt(byte[] encryptedValue) throws InvalidEncryptedValueException
ICipher
encryptedValue
- the encrypted value.
InvalidEncryptedValueException
- if value
is
incompatible with this cipher (probably was not encrypted by it or
is corrupted).public byte[] encrypt(byte[] plainText)
ICipher
plainText
- the original value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |