1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.wa.bootstrap;
20
21 import org.apache.syncope.wa.bootstrap.mapping.AttrReleaseMapper;
22 import org.apache.syncope.wa.bootstrap.mapping.AttrRepoPropertySourceMapper;
23 import org.apache.syncope.wa.bootstrap.mapping.AuthModulePropertySourceMapper;
24 import org.apache.syncope.wa.bootstrap.mapping.DefaultAttrReleaseMapper;
25 import org.apereo.cas.configuration.support.CasConfigurationJasyptCipherExecutor;
26 import org.apereo.cas.util.crypto.CipherExecutor;
27 import org.springframework.beans.factory.annotation.Qualifier;
28 import org.springframework.beans.factory.annotation.Value;
29 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
30 import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
31 import org.springframework.context.annotation.Bean;
32 import org.springframework.context.annotation.Configuration;
33 import org.springframework.context.annotation.PropertySource;
34 import org.springframework.core.env.Environment;
35
36 @Configuration(proxyBeanMethods = false)
37 @PropertySource("classpath:wa.properties")
38 @PropertySource(value = "file:${syncope.conf.dir}/wa.properties", ignoreResourceNotFound = true)
39 public class WABootstrapConfiguration {
40
41 @Configuration(proxyBeanMethods = false)
42 public static class WAClientConfiguration {
43
44 @Value("${wa.anonymousUser}")
45 private String anonymousUser;
46
47 @Value("${wa.anonymousKey}")
48 private String anonymousKey;
49
50 @Value("${wa.useGZIPCompression:true}")
51 private boolean useGZIPCompression;
52
53 @Value("${service.discovery.address}")
54 private String serviceDiscoveryAddress;
55
56 @Bean
57 public WARestClient waRestClient() {
58 return new WARestClient(anonymousUser, anonymousKey, useGZIPCompression, serviceDiscoveryAddress);
59 }
60 }
61
62 @Configuration(proxyBeanMethods = false)
63 public static class PropertySourceConfiguration {
64
65 @ConditionalOnMissingBean(name = "waConfigurationCipher")
66 @Bean
67 public CipherExecutor<String, String> waConfigurationCipher(final Environment environment) {
68 return new CasConfigurationJasyptCipherExecutor(environment);
69 }
70
71 @ConditionalOnMissingBean
72 @Bean
73 public AuthModulePropertySourceMapper authModulePropertySourceMapper(final WARestClient waRestClient) {
74 return new AuthModulePropertySourceMapper(waRestClient);
75 }
76
77 @ConditionalOnMissingBean
78 @Bean
79 public AttrRepoPropertySourceMapper attrRepoPropertySourceMapper(final WARestClient waRestClient) {
80 return new AttrRepoPropertySourceMapper(waRestClient);
81 }
82
83 @ConditionalOnMissingBean
84 @Bean
85 public AttrReleaseMapper attrReleaseMapper() {
86 return new DefaultAttrReleaseMapper();
87 }
88
89 @Bean
90 public PropertySourceLocator configPropertySourceLocator(
91 @Qualifier("waConfigurationCipher")
92 final CipherExecutor<String, String> waConfigurationCipher,
93 final WARestClient waRestClient,
94 final AuthModulePropertySourceMapper authModulePropertySourceMapper,
95 final AttrRepoPropertySourceMapper attrRepoPropertySourceMapper,
96 final AttrReleaseMapper attrReleaseMapper) {
97
98 return new WAPropertySourceLocator(
99 waRestClient,
100 authModulePropertySourceMapper,
101 attrRepoPropertySourceMapper,
102 attrReleaseMapper,
103 waConfigurationCipher);
104 }
105 }
106 }