Top Description Fields Constructors Methods
com.sun.faces.util

public final Class ByteArrayGuardAESCTR

extends Object
Class Inheritance
Imports
java.nio.charset.Charset, java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .NoSuchAlgorithmException, .SecureRandom, java.util.Base64, .SortedMap, java.util.logging.Level, .Logger, javax.crypto.BadPaddingException, .Cipher, .IllegalBlockSizeException, .KeyGenerator, .NoSuchPaddingException, .SecretKey, javax.crypto.spec.IvParameterSpec, .SecretKeySpec, javax.naming.InitialContext, .NamingException, jakarta.faces.FacesException

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 Faces needs.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final int
private static final Logger
private SecretKey
private Charset

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte[]

Returns:

a byte array of array1||array2
concatBytes
(byte[]
first byte array to be concatenated
array1
,
byte[]
second byte array to be concatenated
array2
)

This method concatenates two byte arrays

public String
decrypt(String value)

public String

Returns:

the encrypted value.
encrypt
(String
The value to be encrypted.
value
)

This method: Encrypts bytes using a cipher.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CIPHER_CODEback to summary
private static final String CIPHER_CODE
KEY_ALGORITHMback to summary
private static final String KEY_ALGORITHM
KEY_LENGTHback to summary
private static final int KEY_LENGTH
LOGGERback to summary
private static final Logger LOGGER
skback to summary
private SecretKey sk
utf8back to summary
private Charset utf8

Constructor Detail

ByteArrayGuardAESCTRback to summary
public ByteArrayGuardAESCTR()

Method Detail

concatBytesback to summary
private static byte[] concatBytes(byte[] array1, byte[] array2)

This method concatenates two byte arrays

Parameters
array1:byte[]

first byte array to be concatenated

array2:byte[]

second byte array to be concatenated

Returns:byte[]

a byte array of array1||array2

decryptback to summary
public String decrypt(String value) throws InvalidKeyException
encryptback to summary
public String encrypt(String value)

This method: Encrypts bytes using a cipher. Generates MAC for intialization vector of the cipher Generates MAC for encrypted data Returns a byte array consisting of the following concatenated together: |MAC for cnrypted Data | MAC for Init Vector | Encrypted Data |

Parameters
value:String

The value to be encrypted.

Returns:String

the encrypted value.

setupKeyAndCharsetback to summary
private void setupKeyAndCharset()