1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util;
17
18 import org.jasypt.util.text.BasicTextEncryptor;
19 import org.jasypt.util.text.StrongTextEncryptor;
20 import org.jasypt.util.text.TextEncryptor;
21
22 public class EncUtils {
23
24
25
26
27 public static final TextEncryptor getTextEncryptor(String password) {
28 return getTextEncryptor(EncryptionStrength.BASIC, password);
29 }
30
31
32
33
34 public static final TextEncryptor getTextEncryptor(EncryptionStrength strength, String password) {
35 switch (strength) {
36 case BASIC:
37 BasicTextEncryptor basic = new BasicTextEncryptor();
38 basic.setPassword(password);
39 return basic;
40 case STRONG:
41 StrongTextEncryptor strong = new StrongTextEncryptor();
42 strong.setPassword(password);
43 return strong;
44 default:
45 throw new IllegalArgumentException("Encryption strength [" + strength + "] is unknown");
46 }
47 }
48 }