public class SymmetricCipher extends AbstractCipher
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 and Description |
---|
SymmetricCipher() |
Modifier and Type | Method and Description |
---|---|
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.
|
decrypt, encrypt, getStringCharset, getUseURLSafeBase64Variant
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.LumisXP 12.0.0.190809 - Copyright © 2006–2019 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.