public final class MailPasswordUtil
extends java.lang.Object
MailPasswordUtil - Utility class to encrypt/decrypt passwords with a key aka password based encryption
(PBE).
PBE is a form of symmetric encryption where the same key or password is used to encrypt and decrypt a string.
| Modifier and Type | Field and Description |
|---|---|
static com.openexchange.secret.SecretEncryptionStrategy<com.openexchange.mailaccount.internal.GenericProperty> |
STRATEGY
Mail account secret encryption strategy.
|
| Constructor and Description |
|---|
MailPasswordUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
decrypt(java.lang.String encryptedPassword,
java.security.Key key)
Decrypts specified encrypted password with given key.
|
static java.lang.String |
decrypt(java.lang.String encryptedPassword,
com.openexchange.session.Session session,
int accountId,
java.lang.String login,
java.lang.String server)
Decrypts specified encrypted password with given key.
|
static java.lang.String |
decrypt(java.lang.String encryptedPassword,
java.lang.String key)
Decrypts specified encrypted password with given key.
|
static java.lang.String |
encrypt(java.lang.String password,
java.security.Key key)
Encrypts specified password with given key.
|
static java.lang.String |
encrypt(java.lang.String password,
java.lang.String key)
Encrypts specified password with given key.
|
static java.security.Key |
generateRandomKey()
Create a key for use in the cipher code
|
static java.security.Key |
generateSecretKey(java.lang.String key)
Generates a secret key from specified key string.
|
public static final com.openexchange.secret.SecretEncryptionStrategy<com.openexchange.mailaccount.internal.GenericProperty> STRATEGY
public static java.lang.String encrypt(java.lang.String password,
java.lang.String key)
throws java.security.GeneralSecurityException
password - The passwordkey - The keyjava.security.GeneralSecurityException - If password encryption failspublic static java.lang.String decrypt(java.lang.String encryptedPassword,
com.openexchange.session.Session session,
int accountId,
java.lang.String login,
java.lang.String server)
throws com.openexchange.exception.OXException
encryptedPassword - The Base64 encoded encrypted passwordsession - The sessionjava.security.GeneralSecurityException - If password decryption failscom.openexchange.exception.OXExceptionpublic static java.lang.String decrypt(java.lang.String encryptedPassword,
java.lang.String key)
throws java.security.GeneralSecurityException
encryptedPassword - The Base64 encoded encrypted passwordkey - The keyjava.security.GeneralSecurityException - If password decryption failspublic static java.lang.String encrypt(java.lang.String password,
java.security.Key key)
throws java.security.GeneralSecurityException
password - The password to encryptkey - The keyjava.security.GeneralSecurityException - If password encryption failspublic static java.lang.String decrypt(java.lang.String encryptedPassword,
java.security.Key key)
throws java.security.GeneralSecurityException
encryptedPassword - The Base64 encoded encrypted passwordkey - The keyjava.security.GeneralSecurityException - If password decryption failspublic static java.security.Key generateRandomKey()
throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmExceptionpublic static java.security.Key generateSecretKey(java.lang.String key)
throws java.security.GeneralSecurityException
key - The key stringjava.security.GeneralSecurityException - If generating secret key fails