import hudson.model.Hudson;
Glorified
String that uses encryption in the persisted form, to avoid accidental exposure of a secret.
Note that since the cryptography relies on Hudson.getSecretKey(), this is not meant as a protection
against code running in the same VM, nor against an attacker who has local file system access.
- Author(s):
- Kohsuke Kawaguchi
Obtains the secret in a plain text.
- See also:
- getEncryptedValue()
Turns
Hudson.getSecretKey() into an AES key.
if(secret==null) return Hudson.getInstance().getSecretKeyAsAES128();
return Util.toAes128Key(secret);
Encrypts
value and returns it in an encoded printable form.
Reverse operation of
getEncryptedValue(). Returns null
if the given cipher text was invalid.
if(data==null) return null;
Attempts to treat the given string first as a cipher text, and if it doesn't work,
treat the given string as the unencrypted secret value.
Useful for recovering a value from a form field.
if(s==null) s=new Secret(data);
For testing only. Override the secret key so that we can test this class without
Hudson.