From 4bc07b8c5169ecf62bc45f78d5017b99023b5df7 Mon Sep 17 00:00:00 2001 From: Manousos Mathioudakis Date: Wed, 24 Mar 2021 16:44:16 +0200 Subject: [PATCH] Add javadoc at constructors. Closes gh-9361 Signed-off-by: Manousos Mathioudakis --- .../crypto/encrypt/AesBytesEncryptor.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crypto/src/main/java/org/springframework/security/crypto/encrypt/AesBytesEncryptor.java b/crypto/src/main/java/org/springframework/security/crypto/encrypt/AesBytesEncryptor.java index d8f2fc12b63..12a88ab4203 100644 --- a/crypto/src/main/java/org/springframework/security/crypto/encrypt/AesBytesEncryptor.java +++ b/crypto/src/main/java/org/springframework/security/crypto/encrypt/AesBytesEncryptor.java @@ -52,14 +52,40 @@ public final class AesBytesEncryptor implements BytesEncryptor { private static final String AES_GCM_ALGORITHM = "AES/GCM/NoPadding"; + /** + * Constructs an encryptor that uses AES encryption. Example: + * AesBytesEncryptor encryptor = new AesBytesEncryptor(yourPassword, 5c0744940b5c369b); + * + * @param password the password value + * @param salt the hex-encoded salt value + */ public AesBytesEncryptor(String password, CharSequence salt) { this(password, salt, null); } + /** + * Constructs an encryptor that uses AES encryption. Example: + * AesBytesEncryptor encryptor = + * new AesBytesEncryptor(yourPassword, 5c0744940b5c369b, KeyGenerators.secureRandom(16)); + * + * @param password the password value + * @param salt the hex-encoded salt value + * @param ivGenerator the generator used to generate the initialization vector + */ public AesBytesEncryptor(String password, CharSequence salt, BytesKeyGenerator ivGenerator) { this(password, salt, ivGenerator, CipherAlgorithm.CBC); } + /** + * Constructs an encryptor that uses AES encryption. Example: + * AesBytesEncryptor encryptor = + * new AesBytesEncryptor(yourPassword, 5c0744940b5c369b, KeyGenerators.secureRandom(16), CipherAlgorithm.GCM); + * + * @param password the password value + * @param salt the hex-encoded salt value + * @param ivGenerator the generator used to generate the initialization vector + * @param alg the {@link CipherAlgorithm} to be used + */ public AesBytesEncryptor(String password, CharSequence salt, BytesKeyGenerator ivGenerator, CipherAlgorithm alg) { this(CipherUtils.newSecretKey("PBKDF2WithHmacSHA1", new PBEKeySpec(password.toCharArray(), Hex.decode(salt), 1024, 256)), ivGenerator, alg);