Package com.identity4j.util.crypt.impl
Class CompoundEncoder
- java.lang.Object
-
- com.identity4j.util.crypt.impl.AbstractEncoder
-
- com.identity4j.util.crypt.impl.CompoundEncoder
-
- All Implemented Interfaces:
Encoder
- Direct Known Subclasses:
Base64AES192Encoder,Base64AES256Encoder,Base64AESEncoder,Base64FIPSEncoder,Base64NSSEncoder,Base64PBEWithMD5AndDESEncoder,MD5Base64Encoder,MessageDigestStringEncoder,SHABase64Encoder
public class CompoundEncoder extends AbstractEncoder
-
-
Constructor Summary
Constructors Constructor Description CompoundEncoder(String id, Encoder... encoders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEncoder(Encoder encoder)byte[]decode(byte[] toDecode, byte[] salt, byte[] passphrase, String charset)Decode bytes (if supported) to text.byte[]encode(byte[] toEncode, byte[] salt, byte[] passphrase, String charset)Encode a stringbooleanisOfType(byte[] encodedBytes, String charset)Determine if this encoder may have been used to create the provided encoded bytes.booleanmatch(byte[] encodedData, byte[] unencodedData, byte[] passphrase, String charset)Check if the provide un-encoded data would match the encoded data if it was encoded.-
Methods inherited from class com.identity4j.util.crypt.impl.AbstractEncoder
getId, randomBytes
-
-
-
-
Method Detail
-
addEncoder
public void addEncoder(Encoder encoder)
-
decode
public byte[] decode(byte[] toDecode, byte[] salt, byte[] passphrase, String charset) throws EncoderExceptionDescription copied from interface:EncoderDecode bytes (if supported) to text.- Specified by:
decodein interfaceEncoder- Overrides:
decodein classAbstractEncoder- Parameters:
toDecode- bytes to decodesalt- TODOpassphrase- passphrase if supportedcharset- character set- Returns:
- decoded text
- Throws:
EncoderException- if encoding fails
-
match
public boolean match(byte[] encodedData, byte[] unencodedData, byte[] passphrase, String charset)Description copied from interface:EncoderCheck if the provide un-encoded data would match the encoded data if it was encoded.- Specified by:
matchin interfaceEncoder- Overrides:
matchin classAbstractEncoder- Parameters:
encodedData- encoded dataunencodedData- un-encoded datapassphrase- passphrase if supportedcharset- character set- Returns:
- matches
-
encode
public byte[] encode(byte[] toEncode, byte[] salt, byte[] passphrase, String charset) throws EncoderExceptionDescription copied from interface:EncoderEncode a string- Parameters:
toEncode- data to encodesalt- salt if supportedpassphrase- passphrase if supportedcharset- character set- Returns:
- encoded bytes
- Throws:
EncoderException- if encoding fails
-
isOfType
public boolean isOfType(byte[] encodedBytes, String charset)Description copied from interface:EncoderDetermine if this encoder may have been used to create the provided encoded bytes. This method should only be used if it is very likely to be the right encoder.- Specified by:
isOfTypein interfaceEncoder- Overrides:
isOfTypein classAbstractEncoder- Parameters:
encodedBytes- encoded bytescharset- character set- Returns:
- this almost certainly was encoded with a similar encoder
-
-