Package org.takes.facets.auth.codecs
Class CcAes
- java.lang.Object
-
- org.takes.facets.auth.codecs.CcAes
-
- All Implemented Interfaces:
Codec
public final class CcAes extends Object implements Codec
AES codec which supports 128 bits key.It's recommended to use it in conjunction with
CcSigned
codec, which can be applied before or after encryption.The class is immutable and thread-safe.
- Since:
- 0.13.8
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Identity
decode(byte[] bytes)
Decode identity from text (or throwDecodingException
).byte[]
encode(Identity identity)
Encode identity into bytes.
-
-
-
Constructor Detail
-
CcAes
public CcAes(Codec codec, String key)
Constructor for the class.- Parameters:
codec
- Original codeckey
- The encryption key- Since:
- 0.22
-
CcAes
public CcAes(Codec codec, byte[] key)
Constructor for the class.- Parameters:
codec
- Original codeckey
- The encryption key
-
CcAes
public CcAes(Codec codec, SecureRandom random, Key key)
Constructor for the class.- Parameters:
codec
- Original codecrandom
- Random generatorkey
- The encryption key
-
-
Method Detail
-
encode
public byte[] encode(Identity identity) throws IOException
Description copied from interface:Codec
Encode identity into bytes.- Specified by:
encode
in interfaceCodec
- Parameters:
identity
- The identity- Returns:
- Text
- Throws:
IOException
- If fails
-
decode
public Identity decode(byte[] bytes) throws IOException
Description copied from interface:Codec
Decode identity from text (or throwDecodingException
).This method may throw
DecodingException
, if it's not possible to decode the incoming byte array. This exception will mean that the user can't be authenticated andIdentity.ANONYMOUS
object will be identified.- Specified by:
decode
in interfaceCodec
- Parameters:
bytes
- Text- Returns:
- Identity
- Throws:
IOException
- If fails
-
-