|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lumis.portal.crypto.AbstractCipher
public abstract class AbstractCipher
An abstract ICipher
implementation for easing concrete implementations.
This abstract class provides implementations for the string-based encryption and decryption operations, by encoding the encrypted bytes in Base64.
Constructor Summary | |
---|---|
AbstractCipher()
|
Method Summary | |
---|---|
String |
decrypt(String value)
Decrypts a string. |
String |
encrypt(String value)
Encrypts a string. |
protected String |
getStringCharset()
The charset used to perform the encoding between String and bytes of the plain text string values in encrypt(String) and decrypt(String) . |
protected boolean |
getUseURLSafeBase64Variant()
Indicates if a URL safe Base64 variant is to be used when encoding bytes to String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface lumis.portal.crypto.ICipherSpi |
---|
init |
Methods inherited from interface lumis.portal.crypto.ICipher |
---|
decrypt, encrypt |
Constructor Detail |
---|
public AbstractCipher()
Method Detail |
---|
protected String getStringCharset()
encrypt(String)
and decrypt(String)
.
The default value is UTF-8. This method may be overridden to change it.
protected boolean getUseURLSafeBase64Variant()
The default value is true. This method may be overridden to change it.
public String encrypt(String value)
This abstract implementation converts the given string to bytes based
on getStringCharset()
, encrypts it with ICipher.encrypt(byte[])
,
and encodes the result to a string using the Base64 algorithm.
encrypt
in interface ICipher
value
- the original string.
public String decrypt(String value) throws InvalidEncryptedValueException
This abstract implementation decodes the value to bytes using the
Base64 algorithm, decrypts it with ICipher.decrypt(byte[])
,
and creates the resulting plain text string based on getStringCharset()
.
decrypt
in interface ICipher
value
- the encrypted string.
InvalidEncryptedValueException
- if value
is
incompatible with this cipher (probably was not encrypted by it or
is corrupted).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |