Class EncryptingSerializer
java.lang.Object
org.apache.commons.jcs3.utils.serialization.StandardSerializer
org.apache.commons.jcs3.utils.serialization.EncryptingSerializer
- All Implemented Interfaces:
IElementSerializer
Performs serialization and de-serialization. It encrypts and decrypts the
value.
- Since:
- 3.1
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorEncryptingSerializer
(IElementSerializer serializer) Wrapper constructor -
Method Summary
Modifier and TypeMethodDescription<T> T
deSerialize
(byte[] data, ClassLoader loader) Uses default de-serialization to turn a byte array into an object.<T> byte[]
serialize
(T obj) Serializes an object using default serialization.void
setAesCipherTransformation
(String transformation) Set the cipher transformation for encryption and decryption Default is AES/ECB/PKCS5Paddingvoid
setPreSharedKey
(String psk) Set the pre-shared key for encryption and decryptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.jcs3.engine.behavior.IElementSerializer
deSerializeFrom, deSerializeFrom, deSerializeFrom, serializeTo, serializeTo, serializeTo
-
Constructor Details
-
EncryptingSerializer
public EncryptingSerializer()Default constructor -
EncryptingSerializer
Wrapper constructor- Parameters:
serializer
- the wrapped serializer
-
-
Method Details
-
setAesCipherTransformation
Set the cipher transformation for encryption and decryption Default is AES/ECB/PKCS5Padding- Parameters:
transformation
- the transformation
-
serialize
Serializes an object using default serialization. Encrypts the byte array.- Specified by:
serialize
in interfaceIElementSerializer
- Overrides:
serialize
in classStandardSerializer
- Type Parameters:
T
- the type of the object- Parameters:
obj
- object- Returns:
- byte[]
- Throws:
IOException
- on i/o problem
-
deSerialize
public <T> T deSerialize(byte[] data, ClassLoader loader) throws IOException, ClassNotFoundException Uses default de-serialization to turn a byte array into an object. Decrypts the value first. All exceptions are converted into IOExceptions.- Specified by:
deSerialize
in interfaceIElementSerializer
- Overrides:
deSerialize
in classStandardSerializer
- Parameters:
data
- data bytesloader
- class loader to use- Returns:
- Object
- Throws:
IOException
- on i/o problemClassNotFoundException
- if class is not found during deserialization