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, javax.crypto.Cipher, .KeyGenerator, .SecretKey, .BadPaddingException, .IllegalBlockSizeException, .NoSuchPaddingException, javax.crypto.spec.IvParameterSpec, .SecretKeySpec, javax.faces.FacesException, java.util.SortedMap, java.util.logging.Level, .Logger, javax.naming.InitialContext, .NamingException, javax.xml.bind.DatatypeConverter

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.

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
private IvParameterSpec
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
public String
decrypt(String value)

public String

Returns:

the encrypted byte array.
encrypt
(String
The byte array 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
IV_LENGTHback to summary
private static final int IV_LENGTH
ivspecback to summary
private IvParameterSpec ivspec
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

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 byte array to be encrypted.

Returns:String

the encrypted byte array.

setupKeyAndCharsetback to summary
private void setupKeyAndCharset()