|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.common.rolemap.Cryptography
A collection of methods related to encrypting and decrypting strings.
The class uses a password value assumed to be within an
ogsadai.password
system property.
Field Summary | |
private static java.lang.String |
ALGORITHM
|
private static java.lang.String |
COPYRIGHT_NOTICE
|
private static int |
COUNT
|
private static java.lang.String |
PASSWORD
|
private static byte[] |
SALT
|
Constructor Summary | |
Cryptography()
|
Method Summary | |
private static byte[] |
decode(byte[] string)
Base64 decode an array of bytes. |
private static byte[] |
decrypt(java.lang.String password,
byte[] cypherText)
Decrypt an array of bytes, using the given password, and return the decrypted bytes. |
private static byte[] |
decrypt(java.lang.String password,
java.lang.String cypherText)
Decrypt a string, using the given password, and return the decrypted string as an array of bytes. |
private static byte[] |
encode(byte[] string)
Base64 encode an array of bytes. |
private static byte[] |
encrypt(java.lang.String password,
byte[] plainText)
Encrypt an array of bytes, using the given password, and return the encrypted bytes. |
private static byte[] |
encrypt(java.lang.String password,
java.lang.String plainText)
Encrypt a string, using the given password, and return the encrypted string as an array of bytes. |
private static javax.crypto.Cipher |
getCypher(java.lang.String password,
int encryptMode)
Returns a fully-initialised Cipher object which can be
used for encryption or decryption. |
static java.lang.String |
getPassword()
Returns the value of the ogsadai.password system
property. |
static java.lang.String |
scramble(java.lang.String password,
byte[] plainText)
Encrypts an array of bytes, using a given password, and returns the encrypted bytes as a Base64 encoded string. |
static java.lang.String |
scramble(java.lang.String password,
java.lang.String plainText)
Encrypts a string, using a given password, and returns the encrypted text as a Base64 encoded string. |
static java.lang.String |
unscramble(java.lang.String scrambled)
Unencrypts a Base64 encoded string, using the value of the ogsadai.password system property as a password,
and returns the unencrypted string. |
static java.lang.String |
unscramble(java.lang.String password,
byte[] scrambled)
Unencrypts an array of Base64 encoded bytes, using a given password, and returns the unencrypted bytes as a string. |
static java.lang.String |
unscramble(java.lang.String password,
java.lang.String scrambled)
Unencrypts a Base64 encoded string, using a given password, and returns the unencrypted string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private static final java.lang.String ALGORITHM
private static final byte[] SALT
private static final int COUNT
private static final java.lang.String PASSWORD
Constructor Detail |
public Cryptography()
Method Detail |
public static java.lang.String getPassword() throws MissingSystemPropertyException
ogsadai.password
system
property.
MissingSystemPropertyException
- if the property is not set.public static java.lang.String scramble(java.lang.String password, byte[] plainText) throws CryptographyException
password
- The password to use as a key.plainText
- The bytes to encrypt.
CryptographyException
- if a problem occurred.public static java.lang.String scramble(java.lang.String password, java.lang.String plainText) throws CryptographyException
password
- The password to use as a key.plainText
- The string to encrypt.
CryptographyException
- if a problem occurred.public static java.lang.String unscramble(java.lang.String password, byte[] scrambled) throws CryptographyException
password
- The password to use as a key.scrambled
- The Base64 encoded and encrypted bytes to decrypt.
CryptographyException
- if a problem occurred.public static java.lang.String unscramble(java.lang.String password, java.lang.String scrambled) throws CryptographyException
password
- The password to use as a key.scrambled
- The Base64 encoded and encrypted string to decrypt.
CryptographyException
- if a problem occurred.public static java.lang.String unscramble(java.lang.String scrambled) throws CryptographyException, MissingSystemPropertyException
ogsadai.password
system property as a password,
and returns the unencrypted string.
scrambled
- The Base64 encoded and encrypted string to decrypt.
CryptographyException
- if a problem occurred.
MissingSystemPropertyException
- if the property is not set.private static byte[] encode(byte[] string)
string
- The bytes to encode.
Base64.encode(byte[])
private static byte[] decode(byte[] string)
string
- The bytes to decode.
Base64.decode(byte[])
private static byte[] decrypt(java.lang.String password, byte[] cypherText) throws CryptographyException
password
- The password to use as a key.cypherText
- The encrypted bytes to decrypt
CryptographyException
- if a problem occurred.private static byte[] decrypt(java.lang.String password, java.lang.String cypherText) throws CryptographyException
password
- The password to use as a key.cypherText
- The encrypted string to decrypt
CryptographyException
- if a problem occurred.private static byte[] encrypt(java.lang.String password, byte[] plainText) throws CryptographyException
password
- The password to use as a key.plainText
- The plain text bytes to encrypt
CryptographyException
- if a problem occurred.private static byte[] encrypt(java.lang.String password, java.lang.String plainText) throws CryptographyException
password
- The password to use as a key.plainText
- The plain text string to encrypt
CryptographyException
- if a problem occurred.private static javax.crypto.Cipher getCypher(java.lang.String password, int encryptMode) throws CryptographyException
Cipher
object which can be
used for encryption or decryption.
password
- The password to use as a key.encryptMode
- Either Cipher.ENCRYPT_MODE
or
Cipher.DECRYPT_MODE
.
Cipher
object.
CryptographyException
- if a problem occurred.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |