1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.properties.spring;
17
18 import java.util.Properties;
19
20 import org.kuali.common.util.PropertyUtils;
21 import org.kuali.common.util.enc.EncContext;
22 import org.kuali.common.util.project.model.Project;
23 import org.kuali.common.util.project.spring.AutowiredProjectConfig;
24 import org.kuali.common.util.properties.DefaultPropertiesService;
25 import org.kuali.common.util.properties.PropertiesService;
26 import org.kuali.common.util.property.ImmutableProperties;
27 import org.kuali.common.util.property.processor.JasyptDecryptingProcessor;
28 import org.kuali.common.util.property.processor.OverridingProcessor;
29 import org.kuali.common.util.property.processor.ProcessorsProcessor;
30 import org.kuali.common.util.property.processor.PropertyProcessor;
31 import org.kuali.common.util.property.processor.ResolvingProcessor;
32 import org.kuali.common.util.spring.env.BasicEnvironmentService;
33 import org.kuali.common.util.spring.env.EnvironmentService;
34 import org.kuali.common.util.spring.service.SpringServiceConfig;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.context.annotation.Bean;
37 import org.springframework.context.annotation.Configuration;
38 import org.springframework.context.annotation.Import;
39
40
41
42
43 @Deprecated
44 @Configuration
45 @Import({ SpringServiceConfig.class, AutowiredProjectConfig.class })
46 public class DefaultPropertiesServiceConfig implements PropertiesServiceConfig {
47
48 @Autowired
49 Project project;
50
51 @Autowired
52 EnvironmentService env;
53
54 @Override
55 @Bean
56 public PropertiesService propertiesService() {
57 Properties overrides = getOverrides(project);
58 PropertyProcessor processor = getPostProcessor(overrides);
59 return new DefaultPropertiesService(overrides, processor);
60 }
61
62 private Properties getOverrides(Project project) {
63
64 Properties global = PropertyUtils.getGlobalProperties();
65
66
67 return ImmutableProperties.copyOf(PropertyUtils.combine(project.getProperties(), global));
68 }
69
70 private PropertyProcessor getPostProcessor(Properties overrides) {
71 EnvironmentService env = new BasicEnvironmentService(overrides);
72 EncContext context = EncContext.builder(env).removeSystemProperties(false).build();
73 PropertyProcessor override = new OverridingProcessor(overrides);
74 PropertyProcessor decrypt = new JasyptDecryptingProcessor(context.getTextEncryptor());
75 PropertyProcessor resolver = new ResolvingProcessor();
76 return new ProcessorsProcessor(override, decrypt, resolver);
77 }
78
79 }