com.sun.faces.renderkit
public final class ByteArrayGuard extends java.lang.Object
This utility class is to provide both encryption and
decryption Ciphers
to ResponseStateManager
implementations wishing to provide encryption support.
The algorithm used to encrypt byte array is AES with CBC.
Original author Inderjeet Singh, J2EE Blue Prints Team. Modified to suit JSF needs.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CIPHER_CODE |
private javax.crypto.Mac |
decryptMac |
private javax.crypto.Mac |
encryptMac |
private static int |
IV_LENGTH |
private static java.lang.String |
KEY_ALGORITHM |
private static int |
KEY_LENGTH |
private static java.util.logging.Logger |
LOGGER |
private static java.lang.String |
MAC_CODE |
private static int |
MAC_LENGTH |
private javax.crypto.SecretKey |
sk |
Constructor and Description |
---|
ByteArrayGuard() |
Modifier and Type | Method and Description |
---|---|
private boolean |
areArrayEqualsConstantTime(byte[] array1,
byte[] array2) |
private static byte[] |
concatBytes(byte[] array1,
byte[] array2)
This method concatenates two byte arrays
|
byte[] |
decrypt(byte[] bytes)
This method decrypts the provided byte array.
|
byte[] |
encrypt(byte[] bytes)
This method:
Encrypts bytes using a cipher.
|
private void |
setupKeyAndMac()
Generates secret key.
|
private static final java.util.logging.Logger LOGGER
private static final int MAC_LENGTH
private static final int KEY_LENGTH
private static final int IV_LENGTH
private static final java.lang.String KEY_ALGORITHM
private static final java.lang.String CIPHER_CODE
private static final java.lang.String MAC_CODE
private javax.crypto.Mac encryptMac
private javax.crypto.Mac decryptMac
private javax.crypto.SecretKey sk
public byte[] encrypt(byte[] bytes)
bytes
- The byte array to be encrypted.public byte[] decrypt(byte[] bytes)
bytes
- Encrypted byte array to be decrypted.private boolean areArrayEqualsConstantTime(byte[] array1, byte[] array2)
private void setupKeyAndMac()
private static byte[] concatBytes(byte[] array1, byte[] array2)
array1
- first byte array to be concatenatedarray2
- second byte array to be concatenatedCopyright © 2002-2010 Oracle America, Inc. All Rights Reserved.