Repository: wicket Updated Branches: refs/heads/5756-improve-crypt 748fba9b1 -> 02923b178
WICKET-5756 Allow to use custom ciphers when using SunJceCrypt class Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/02923b17 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/02923b17 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/02923b17 Branch: refs/heads/5756-improve-crypt Commit: 02923b178440987a51e9660e2cb03d6fb280621b Parents: 748fba9 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Tue Nov 18 15:58:52 2014 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Tue Nov 18 15:58:52 2014 +0200 ---------------------------------------------------------------------- .../org/apache/wicket/util/crypt/SunJceCrypt.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/02923b17/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java ---------------------------------------------------------------------- diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java index d1faf34..934f586 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java @@ -111,11 +111,23 @@ public class SunJceCrypt extends AbstractCrypt { SecretKey key = generateSecretKey(); AlgorithmParameterSpec spec = createParameterSpec(); - Cipher ciph = createCipher(cryptMethod, key, spec, mode); + Cipher ciph = createCipher(key, spec, mode); return ciph.doFinal(input); } - protected Cipher createCipher(String cryptMethod, SecretKey key, AlgorithmParameterSpec spec, int mode) throws GeneralSecurityException + /** + * Creates the {@link javax.crypto.Cipher} that will do the de-/encryption. + * + * @param key + * the secret key to use + * @param spec + * the parameters spec to use + * @param mode + * the mode ({@link javax.crypto.Cipher#ENCRYPT_MODE} or {@link javax.crypto.Cipher#DECRYPT_MODE}) + * @return the cipher that will do the de-/encryption + * @throws GeneralSecurityException + */ + protected Cipher createCipher(SecretKey key, AlgorithmParameterSpec spec, int mode) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(cryptMethod); cipher.init(mode, key, spec); @@ -127,7 +139,7 @@ public class SunJceCrypt extends AbstractCrypt * <p> * Note: if you don't provide your own encryption key, the implementation will use a default. Be * aware that this is potential security risk. Thus make sure you always provide your own one. - * + * * @return secretKey the security key generated * @throws NoSuchAlgorithmException * unable to find encryption algorithm specified
