org.mmbase.util.transformers
Class EncryptionTransformerFactory
java.lang.Object
org.mmbase.util.transformers.EncryptionTransformerFactory
- All Implemented Interfaces:
- ParameterizedTransformerFactory<CharTransformer>
public class EncryptionTransformerFactory
- extends Object
- implements ParameterizedTransformerFactory<CharTransformer>
This transformerfactory can encrypt and decrypt strings. The algorithm which is
used for encryption/decryption is parameterized, and defaults to AES. Since
these encryption algorithms return raw bytes, an encoding must be supplied
which is used to convert bytes to characters: either hexadecimal encoding
or base64.
- Author:
- Sander de Boer
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PARAMS
protected static final Parameter[] PARAMS
EncryptionTransformerFactory
public EncryptionTransformerFactory()
encode
public static String encode(byte[] input,
String format)
- Encode a given array of bytes to a string, using the given format.
This can be 'hex' or 'base64'.
decode
public static byte[] decode(String input,
String format)
throws IllegalArgumentException
- Decode a given string to an array of bytes, using a given format.
This can throw an 'IllegalArgumentException' when the given input
string isn't correct according to the format.
- Throws:
IllegalArgumentException
createParameters
public Parameters createParameters()
- Description copied from interface:
ParameterizedTransformerFactory
- Create empty
Parameters object for use with ParameterizedTransformerFactory.createTransformer(Parameters).
- Specified by:
createParameters in interface ParameterizedTransformerFactory<CharTransformer>
createTransformer
public CharTransformer createTransformer(Parameters parameters)
- Return a parameterized transformer, based on the given parameters. These can be the following:
- algorithm, defaults to 'AES'
- direction, can be 'encrypt' or 'decrypt'
- format, can be 'base64' or 'hex'
- key, defaults to '1234567890abcdef' (NOTE: the length of this key must match the requirements set by the algorithm
- Specified by:
createTransformer in interface ParameterizedTransformerFactory<CharTransformer>
MMBase 2.0-SNAPSHOT - null