1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property.processor;
17
18 import java.util.List;
19 import java.util.Properties;
20
21 import org.jasypt.util.text.TextEncryptor;
22 import org.kuali.common.util.Mode;
23 import org.kuali.common.util.PropertyUtils;
24 import org.kuali.common.util.property.Constants;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28
29
30
31 @Deprecated
32 public class EndsWithEncryptProcessor extends DecryptProcessor {
33
34 private static final Logger logger = LoggerFactory.getLogger(EndsWithEncryptProcessor.class);
35
36 String suffix = Constants.DEFAULT_ENCRYPTED_SUFFIX;
37 boolean removeUnencryptedProperties = true;
38 Mode propertyOverwriteMode = Constants.DEFAULT_PROPERTY_OVERWRITE_MODE;
39
40 public EndsWithEncryptProcessor() {
41 this(null);
42 }
43
44 public EndsWithEncryptProcessor(TextEncryptor encryptor) {
45 super(encryptor);
46 }
47
48 @Override
49 public void process(Properties properties) {
50 List<String> keys = PropertyUtils.getSortedKeys(properties);
51 for (String key : keys) {
52 String decryptedValue = properties.getProperty(key);
53 String encryptedValue = encryptor.encrypt(decryptedValue);
54 String newKey = key + suffix;
55 PropertyUtils.addOrOverrideProperty(properties, newKey, encryptedValue, propertyOverwriteMode);
56 if (removeUnencryptedProperties) {
57 logger.debug("Removing {}", key);
58 properties.remove(key);
59 }
60 }
61 }
62
63 public String getSuffix() {
64 return suffix;
65 }
66
67 public void setSuffix(String suffix) {
68 this.suffix = suffix;
69 }
70
71 public boolean isRemoveUnencryptedProperties() {
72 return removeUnencryptedProperties;
73 }
74
75 public void setRemoveUnencryptedProperties(boolean removeUnencryptedProperties) {
76 this.removeUnencryptedProperties = removeUnencryptedProperties;
77 }
78
79 public Mode getPropertyOverwriteMode() {
80 return propertyOverwriteMode;
81 }
82
83 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
84 this.propertyOverwriteMode = propertyOverwriteMode;
85 }
86
87 }