This is an automated email from the ASF dual-hosted git repository.
mmoayyed pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/3_0_X by this push:
new 30a254aaf8 SYNCOPE-1765: allow WA properties to be decrypted (#476)
30a254aaf8 is described below
commit 30a254aaf85c2c2bdfdd26bec4af84d6f643fe4e
Author: Misagh Moayyed <[email protected]>
AuthorDate: Fri Jun 16 17:59:01 2023 +0400
SYNCOPE-1765: allow WA properties to be decrypted (#476)
---
.../syncope/wa/bootstrap/WABootstrapConfiguration.java | 15 ++++++++++++++-
.../syncope/wa/bootstrap/WAPropertySourceLocator.java | 12 ++++++++++--
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git
a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
index 2215b28130..f470e9a778 100644
---
a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
+++
b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WABootstrapConfiguration.java
@@ -18,12 +18,16 @@
*/
package org.apache.syncope.wa.bootstrap;
+import
org.apereo.cas.configuration.support.CasConfigurationJasyptCipherExecutor;
+import org.apereo.cas.util.crypto.CipherExecutor;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
@Configuration(proxyBeanMethods = false)
@PropertySource("classpath:wa.properties")
@@ -54,6 +58,12 @@ public class WABootstrapConfiguration {
@Configuration(proxyBeanMethods = false)
public static class PropertySourceConfiguration {
+ @Bean
+ @ConditionalOnMissingBean(name = "waConfigurationCipher")
+ public CipherExecutor<String, String> waConfigurationCipher(final
Environment environment) {
+ return new CasConfigurationJasyptCipherExecutor(environment);
+ }
+
@ConditionalOnMissingBean
@Bean
public AuthModulePropertySourceMapper
authModulePropertySourceMapper(final WARestClient waRestClient) {
@@ -68,12 +78,15 @@ public class WABootstrapConfiguration {
@Bean
public PropertySourceLocator configPropertySourceLocator(
+ @Qualifier("waConfigurationCipher")
+ final CipherExecutor<String, String> waConfigurationCipher,
final WARestClient waRestClient,
final AuthModulePropertySourceMapper
authModulePropertySourceMapper,
final AttrRepoPropertySourceMapper
attrRepoPropertySourceMapper) {
return new WAPropertySourceLocator(
- waRestClient, authModulePropertySourceMapper,
attrRepoPropertySourceMapper);
+ waRestClient, authModulePropertySourceMapper,
+ attrRepoPropertySourceMapper, waConfigurationCipher);
}
}
}
diff --git
a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WAPropertySourceLocator.java
b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WAPropertySourceLocator.java
index 1257a57897..21b8ff3c2f 100644
---
a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WAPropertySourceLocator.java
+++
b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/WAPropertySourceLocator.java
@@ -22,12 +22,14 @@ import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.rest.api.service.AttrRepoService;
import org.apache.syncope.common.rest.api.service.AuthModuleService;
import org.apache.syncope.common.rest.api.service.wa.WAConfigService;
+import org.apereo.cas.util.crypto.CipherExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
@@ -47,14 +49,18 @@ public class WAPropertySourceLocator implements
PropertySourceLocator {
protected final AttrRepoPropertySourceMapper attrRepoPropertySourceMapper;
+ protected final CipherExecutor<String, String> configurationCipher;
+
public WAPropertySourceLocator(
final WARestClient waRestClient,
final AuthModulePropertySourceMapper
authModulePropertySourceMapper,
- final AttrRepoPropertySourceMapper attrRepoPropertySourceMapper) {
+ final AttrRepoPropertySourceMapper attrRepoPropertySourceMapper,
+ final CipherExecutor<String, String> configurationCipher) {
this.waRestClient = waRestClient;
this.authModulePropertySourceMapper = authModulePropertySourceMapper;
this.attrRepoPropertySourceMapper = attrRepoPropertySourceMapper;
+ this.configurationCipher = configurationCipher;
}
protected Map<String, Object> index(final Map<String, Object> map, final
Map<String, Integer> prefixes) {
@@ -107,6 +113,8 @@ public class WAPropertySourceLocator implements
PropertySourceLocator {
attr.getSchema(),
attr.getValues().stream().collect(Collectors.joining(","))));
LOG.debug("Collected WA properties: {}", properties);
- return new MapPropertySource(getClass().getName(), properties);
+ Map<String, Object> decodedProperties =
configurationCipher.decode(properties, ArrayUtils.EMPTY_OBJECT_ARRAY);
+ LOG.debug("Decoded WA properties: {}", decodedProperties);
+ return new MapPropertySource(getClass().getName(), decodedProperties);
}
}