|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.elkoserver.foundation.json.Cryptor
public class Cryptor
Simple AES-based string encryptor/decryptor, for passing sealed bundles of data through an untrusted party.
| Constructor Summary | |
|---|---|
Cryptor(String keyStr)
Constructor. |
|
| Method Summary | |
|---|---|
String |
decrypt(String str)
Decrypt a (base-64 encoded) encrypted string |
JSONObject |
decryptJSONObject(String str)
Decrypt a (base-64 encoded) encrypted JSON object literal. |
Object |
decryptObject(Class baseType,
String str)
Decrypt and decode a (base-64 encoded) encrypted object serialized as a JSON object literal. |
String |
encrypt(String str)
Produce a (base-64 encoded) encrypted version of a string. |
static String |
generateKey()
Generate a new, random key. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Cryptor(String keyStr)
throws IOException
keyStr - Base64-encoded symmetric key.
IOException - if the key string is malformed.| Method Detail |
|---|
public String decrypt(String str)
throws IOException
str - Encrypted string to be decrypted, as generated by the encrypt
method of this class.
IOException - if the input string is malformed.
public JSONObject decryptJSONObject(String str)
throws IOException,
SyntaxError
str - Encrypted string to be decrypted.
IOException - if the input string is malformed
SyntaxError - if the decrypted JSON literal is invalid
public Object decryptObject(Class baseType,
String str)
throws IOException
baseType - The desired class of the resulting Java object. The
result will not necessarily be of this class, but will be assignable
to a variable of this class.str - Encrypted string to be decrypted.
IOException - if the input string is malformedpublic String encrypt(String str)
str - String to be encrypted
public static String generateKey()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||