|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.geronimo.crypto.EncryptionManager
public class EncryptionManager
A static class that uses registered Encryption instances to encypt and decrypt objects, typically strings. The encrypted strings are preceded by the name of the Encryption object, such as {Simple}, followed by the base64 encoded encrypted bytes. Any number of Encryption instances can be registered but only the first to be explicitly registered will be used. However, when decrypting the Encryption instance is looked up from the name prefix so may be any registered Encryption instance. Furthermore, encrypt and decrypt are idempotent. Calling encrypt on a string encrypted with a registered Encryption that is not the one in use will decrypt the string and re-encrypt it with the one in use. This can be useful when changing Encryption. The default Encryption instance (that does not need to be registered) is SimpleEncryption which uses a fixed key hardcoded into the Encryption class itself. Thus it is useful only to hide information from those who don't read code. On the other hand you can't lose the key and make your server permanently unusable. n.b. calling these methods idempotent is a slight exageration as this would apply only if all arguments and return values are Strings.
Constructor Summary | |
---|---|
EncryptionManager()
|
Method Summary | |
---|---|
static Serializable |
decrypt(String source)
Idempotent method that given a String starting with a registered Encryption name will remove the name prefix and return the result of applying the Encryption to the suffix. |
static String |
encrypt(Serializable source)
Idempotent method that outputs string starting with the active registered encryption prefix followed by the output of the registered Encryption instance. |
static void |
setEncryptionPrefix(String prefix,
Encryption encryption)
Encryption instances should call this to register themselves. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EncryptionManager()
Method Detail |
---|
public static void setEncryptionPrefix(String prefix, Encryption encryption)
prefix
- id in form {name} for the Encryption instanceencryption
- Encryption instance to do the work.public static String encrypt(Serializable source)
source
- Serializable object to encrypt, usually a password string or an already encrypted string.
public static Serializable decrypt(String source)
source
- String that is possibly the output of calling encrypt, consisting of a Encryption name followed by its encrypt output.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |