diff --git a/jasypt-maven-plugin/pom.xml b/jasypt-maven-plugin/pom.xml index 43c2d1f..52c91ff 100644 --- a/jasypt-maven-plugin/pom.xml +++ b/jasypt-maven-plugin/pom.xml @@ -5,7 +5,7 @@ jasypt-spring-boot-parent com.github.ulisesbocchio - 3.0.6-SNAPSHOT + 3.1.0-SNAPSHOT jasypt-maven-plugin diff --git a/jasypt-spring-boot-starter/pom.xml b/jasypt-spring-boot-starter/pom.xml index 91159e7..a046c10 100644 --- a/jasypt-spring-boot-starter/pom.xml +++ b/jasypt-spring-boot-starter/pom.xml @@ -4,7 +4,7 @@ com.github.ulisesbocchio jasypt-spring-boot-parent - 3.0.6-SNAPSHOT + 3.1.0-SNAPSHOT jasypt-spring-boot-starter @@ -30,6 +30,7 @@ org.springframework.security spring-security-rsa + 1.1.5 test @@ -50,7 +51,7 @@ uk.org.webcompere system-stubs-jupiter - 2.0.1 + 2.1.7 test diff --git a/jasypt-spring-boot-starter/src/test/java/com/ulisesbocchio/jasyptspringbootstarter/resolver/DefaultPropertyResolverTest.java b/jasypt-spring-boot-starter/src/test/java/com/ulisesbocchio/jasyptspringbootstarter/resolver/DefaultPropertyResolverTest.java index d858494..59583cf 100644 --- a/jasypt-spring-boot-starter/src/test/java/com/ulisesbocchio/jasyptspringbootstarter/resolver/DefaultPropertyResolverTest.java +++ b/jasypt-spring-boot-starter/src/test/java/com/ulisesbocchio/jasyptspringbootstarter/resolver/DefaultPropertyResolverTest.java @@ -73,6 +73,7 @@ default boolean hasError(ClientHttpResponse response) throws IOException { } @Override + @SuppressWarnings("removal") default void handleError(ClientHttpResponse response) throws IOException { // Do nothing by default } diff --git a/jasypt-spring-boot/pom.xml b/jasypt-spring-boot/pom.xml index 13d2bf5..356e869 100644 --- a/jasypt-spring-boot/pom.xml +++ b/jasypt-spring-boot/pom.xml @@ -5,7 +5,7 @@ com.github.ulisesbocchio jasypt-spring-boot-parent - 3.0.6-SNAPSHOT + 3.1.0-SNAPSHOT jasypt-spring-boot diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/EncryptablePropertySource.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/EncryptablePropertySource.java index 71a6b6a..8049857 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/EncryptablePropertySource.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/EncryptablePropertySource.java @@ -7,6 +7,8 @@ /** *

EncryptablePropertySource interface.

* + * @param delegate. + * * @author Ulises Bocchio * @version $Id: $Id */ diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/InterceptionMode.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/InterceptionMode.java index 324747c..460280c 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/InterceptionMode.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/InterceptionMode.java @@ -7,6 +7,12 @@ * @version $Id: $Id */ public enum InterceptionMode { + /** + * Wrapper. + */ WRAPPER, + /** + * Proxy. + */ PROXY } diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EnableEncryptableProperties.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EnableEncryptableProperties.java index 7790e2d..4fee1b8 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EnableEncryptableProperties.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EnableEncryptableProperties.java @@ -18,7 +18,7 @@ /** *

Annotation that enables Jasypt for properties decryption by annotating {@link org.springframework.context.annotation.Configuration} classes. * Only one occurrence of this annotation is needed.

- *

+ *

 

*

This works well in conjunction with the {@link org.springframework.context.annotation.PropertySource} annotation. * For instance:

*
@@ -35,7 +35,7 @@
  * not only the ones defined with the {@link org.springframework.context.annotation.PropertySource} annotation, but also
  * all system properties, command line properties, and those auto-magically picked up from application.properties and application.yml
  * if they exist.

- *

+ *

 

*

This Configuration class basically registers a {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor} that wraps all {@link org.springframework.core.env.PropertySource} defined in the {@link org.springframework.core.env.Environment} * with {@link com.ulisesbocchio.jasyptspringboot.wrapper.EncryptablePropertySourceWrapper} and defines a default {@link org.jasypt.encryption.StringEncryptor} for decrypting properties * that can be configured through the same properties it wraps.

diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySource.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySource.java index 5021ab4..7086d0e 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySource.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySource.java @@ -22,6 +22,8 @@ * will be generated based on the description of the underlying * resource. * + * @return name. + * * @see org.springframework.core.env.PropertySource#getName() * @see org.springframework.core.io.Resource#getDescription() */ @@ -38,6 +40,8 @@ * examples. *

Each location will be added to the enclosing {@code Environment} as its own * property source, and in the order declared. + * + * @return value. */ String[] value(); @@ -46,6 +50,8 @@ * ignored. *

{@code true} is appropriate if the properties file is completely optional. * Default is {@code false}. + * + * @return whether to ignore not found resource. */ boolean ignoreResourceNotFound() default false; diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySources.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySources.java index b701807..02771fe 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySources.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/annotation/EncryptablePropertySources.java @@ -24,5 +24,11 @@ @Retention(RetentionPolicy.RUNTIME) @Import(EncryptablePropertySourceConfiguration.class) public @interface EncryptablePropertySources { + + /** + * EncryptablePropertySource. + * + * @return value. + */ EncryptablePropertySource[] value(); } diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/aop/EncryptablePropertySourceMethodInterceptor.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/aop/EncryptablePropertySourceMethodInterceptor.java index 0824946..df20b71 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/aop/EncryptablePropertySourceMethodInterceptor.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/aop/EncryptablePropertySourceMethodInterceptor.java @@ -10,6 +10,8 @@ /** *

EncryptablePropertySourceMethodInterceptor class.

* + * @param propertySource delegate. + * * @author Ulises Bocchio * @version $Id: $Id */ diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/caching/CachingDelegateEncryptablePropertySource.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/caching/CachingDelegateEncryptablePropertySource.java index 2d97140..75c81c7 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/caching/CachingDelegateEncryptablePropertySource.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/caching/CachingDelegateEncryptablePropertySource.java @@ -16,6 +16,8 @@ /** *

CachingDelegateEncryptablePropertySource class.

* + * @param propertySource delegate. + * * @author Sergio.U.Bocchio * @version $Id: $Id */ diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesBeanFactoryPostProcessor.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesBeanFactoryPostProcessor.java index 97c0e21..1c3d1ab 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesBeanFactoryPostProcessor.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesBeanFactoryPostProcessor.java @@ -15,7 +15,7 @@ * with {@link com.ulisesbocchio.jasyptspringboot.wrapper.EncryptablePropertySourceWrapper} and defines a default {@link * EncryptablePropertyResolver} for decrypting properties * that can be configured through the same properties it wraps.

- *

+ *

 

*

It takes the lowest precedence so it does not interfere with Spring Boot's own post processors

* * @author Ulises Bocchio diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesConfiguration.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesConfiguration.java index 88973c4..bacdb50 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesConfiguration.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/configuration/EnableEncryptablePropertiesConfiguration.java @@ -20,6 +20,7 @@ * bean of type {@link org.jasypt.encryption.StringEncryptor} is present in the Application Context, thus allowing for custom definition if required.

*

The default {@link org.jasypt.encryption.StringEncryptor} can be configured through the following properties:

* + * * * * diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/PooledStringEncryptor.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/PooledStringEncryptor.java index a47e364..33c279f 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/PooledStringEncryptor.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/PooledStringEncryptor.java @@ -55,9 +55,17 @@ public String decrypt(String encryptedMessage) { return robin(e -> e.decrypt(encryptedMessage)); } + /** + * ThreadSafeStringEncryptor. + */ public static class ThreadSafeStringEncryptor implements StringEncryptor { private final StringEncryptor delegate; + /** + * ThreadSafeStringEncryptor. + * + * @param delegate encryptor. + */ public ThreadSafeStringEncryptor(StringEncryptor delegate) { this.delegate = delegate; } diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMByteEncryptor.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMByteEncryptor.java index 6e04573..0724269 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMByteEncryptor.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMByteEncryptor.java @@ -122,7 +122,7 @@ public static String generateBase64EncodedSecretKey() { /** *

getAESKeyFromPassword.

* - * @param password an array of {@link char} objects + * @param password an array of char objects * @param saltGenerator a {@link org.jasypt.salt.SaltGenerator} object * @param iterations a int * @param algorithm a {@link java.lang.String} object diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMConfig.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMConfig.java index 8c4d300..42a7f1d 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMConfig.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/encryptor/SimpleGCMConfig.java @@ -61,7 +61,7 @@ public Resource loadSecretKeyResource() { /** *

getSecretKeyPasswordChars.

* - * @return an array of {@link char} objects + * @return an array of char objects */ public char[] getSecretKeyPasswordChars() { return secretKeyPassword.toCharArray(); diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/AsymmetricCryptography.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/AsymmetricCryptography.java index 5515d36..e0ac5db 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/AsymmetricCryptography.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/AsymmetricCryptography.java @@ -26,6 +26,8 @@ public class AsymmetricCryptography { private static final String PUBLIC_KEY_HEADER = "-----BEGIN PUBLIC KEY-----"; private static final String PRIVATE_KEY_FOOTER = "-----END PRIVATE KEY-----"; private static final String PUBLIC_KEY_FOOTER = "-----END PUBLIC KEY-----"; + private static final String KEYFACTORY_RSA = "RSA"; + private static final String CIPHER_RSA = "RSA"; private final ResourceLoader resourceLoader; /** @@ -77,7 +79,7 @@ public PrivateKey getPrivateKey(Resource resource, KeyFormat format) { keyBytes = decodePem(keyBytes, PRIVATE_KEY_HEADER, PRIVATE_KEY_FOOTER); } PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); + KeyFactory kf = KeyFactory.getInstance(KEYFACTORY_RSA); return kf.generatePrivate(spec); } @@ -107,20 +109,20 @@ public PublicKey getPublicKey(Resource resource, KeyFormat format) { keyBytes = decodePem(keyBytes, PUBLIC_KEY_HEADER, PUBLIC_KEY_FOOTER); } X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); + KeyFactory kf = KeyFactory.getInstance(KEYFACTORY_RSA); return kf.generatePublic(spec); } /** *

encrypt.

* - * @param msg an array of {@link byte} objects + * @param msg an array of byte objects * @param key a {@link java.security.PublicKey} object - * @return an array of {@link byte} objects + * @return an array of byte objects */ @SneakyThrows public byte[] encrypt(byte[] msg, PublicKey key) { - final Cipher cipher = Cipher.getInstance("RSA"); + final Cipher cipher = Cipher.getInstance(CIPHER_RSA); cipher.init(Cipher.ENCRYPT_MODE, key); return cipher.doFinal(msg); } @@ -128,19 +130,28 @@ public byte[] encrypt(byte[] msg, PublicKey key) { /** *

decrypt.

* - * @param msg an array of {@link byte} objects + * @param msg an array of byte objects * @param key a {@link java.security.PrivateKey} object - * @return an array of {@link byte} objects + * @return an array of byte objects */ @SneakyThrows public byte[] decrypt(byte[] msg, PrivateKey key) { - final Cipher cipher = Cipher.getInstance("RSA"); + final Cipher cipher = Cipher.getInstance(CIPHER_RSA); cipher.init(Cipher.DECRYPT_MODE, key); return cipher.doFinal(msg); } + /** + * Key format. + */ public enum KeyFormat { + /** + * DER format. + */ DER, + /** + * PEM format. + */ PEM; } } diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Iterables.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Iterables.java index 804ae08..f22fad0 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Iterables.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Iterables.java @@ -52,6 +52,12 @@ static public IterableDecorator filter(Iterable source, Predicate(source, Function.identity(), filter); } + /** + * IterableDecorator. + * + * @param u. + * @param t. + */ public static class IterableDecorator implements Iterable { private final Function transform; private final Predicate filter; @@ -76,6 +82,13 @@ public static class IteratorDecorator implements Iterator { private final Predicate filter; private T next = null; + /** + * IteratorDecorator. + * + * @param source source + * @param transform transform + * @param filter filter + */ public IteratorDecorator(Iterator source, Function transform, Predicate filter) { this.source = source; this.transform = transform; @@ -97,12 +110,10 @@ public T next() { } private void maybeFetchNext() { - if (next == null) { - if (source.hasNext()) { - U val = source.next(); - if (filter.test(val)) { - next = transform.apply(val); - } + if (next == null && source.hasNext()) { + U val = source.next(); + if (filter.test(val)) { + next = transform.apply(val); } } } diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Singleton.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Singleton.java index ac4fe63..59a45af 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Singleton.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/util/Singleton.java @@ -10,6 +10,8 @@ * has been initialized or not, but after initialization the instance supplier is changed to avoid extra logic * execution. * + * @param supplier. + * * @author Sergio.U.Bocchio * @version $Id: $Id */ diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptableEnumerablePropertySourceWrapper.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptableEnumerablePropertySourceWrapper.java index c25fcc5..538e0e6 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptableEnumerablePropertySourceWrapper.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptableEnumerablePropertySourceWrapper.java @@ -10,6 +10,8 @@ /** *

EncryptableEnumerablePropertySourceWrapper class.

* + * @param encryptableDelegate. + * * @author Ulises Bocchio * @version $Id: $Id */ diff --git a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptablePropertySourceWrapper.java b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptablePropertySourceWrapper.java index 6383fd0..e50693b 100644 --- a/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptablePropertySourceWrapper.java +++ b/jasypt-spring-boot/src/main/java/com/ulisesbocchio/jasyptspringboot/wrapper/EncryptablePropertySourceWrapper.java @@ -13,6 +13,8 @@ * property is encrypted or not using the Jasypt convention of surrounding encrypted values with "ENC()".

*

When an encrypted property is detected, it is decrypted using the provided {@link org.jasypt.encryption.StringEncryptor}

* + * @param encryptableDelegate. + * * @author Ulises Bocchio * @version $Id: $Id */ diff --git a/pom.xml b/pom.xml index 37be680..31d9fcb 100644 --- a/pom.xml +++ b/pom.xml @@ -5,18 +5,18 @@ com.github.ulisesbocchio jasypt-spring-boot-parent pom - 3.0.6-SNAPSHOT + 3.1.0-SNAPSHOT Jasypt Spring Boot Parent Jasypt Spring Boot Parent https://github.com/ulisesbocchio/jasypt-spring-boot UTF-8 - 1.8 - 2.7.6 - 2021.0.5 + 11 + 3.4.4 + 2024.0.1 1.9.3 - 3.10.1 + 3.14.0 1.19.0 @@ -81,12 +81,12 @@ org.apache.maven.plugins maven-site-plugin - 4.0.0-M4 + 4.0.0-M16 org.apache.maven.plugins maven-release-plugin - 3.0.0-M7 + 3.1.1 true false @@ -104,12 +104,19 @@ ${java.version} ${java.version} + + + org.projectlombok + lombok + 1.18.38 + + org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 + 3.5.3 @@ -123,7 +130,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.2.7 true @@ -145,7 +152,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.1 attach-sources @@ -158,7 +165,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.11.2 attach-javadocs @@ -171,6 +178,26 @@ + + + org.owasp + dependency-check-maven + 12.1.1 + + + package + + check + + + + + 6 + ALL + + + +
Table of Defaults
KeyRequiredDefault Value