1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.net.ssl;
18
19 import java.util.Arrays;
20
21 import org.apache.logging.log4j.status.StatusLogger;
22
23
24
25
26 public class StoreConfiguration<T> {
27 protected static final StatusLogger LOGGER = StatusLogger.getLogger();
28
29 private String location;
30 private char[] password;
31
32 public StoreConfiguration(final String location, final char[] password) {
33 this.location = location;
34 this.password = password;
35 }
36
37
38
39
40 public void clearSecrets() {
41 this.location = null;
42 if (password != null) {
43 Arrays.fill(password, Character.MIN_VALUE);
44 this.password = null;
45 }
46 }
47
48
49
50
51 @Deprecated
52 public StoreConfiguration(final String location, final String password) {
53 this.location = location;
54 this.password = password == null ? null : password.toCharArray();
55 }
56
57 public String getLocation() {
58 return this.location;
59 }
60
61 public void setLocation(final String location) {
62 this.location = location;
63 }
64
65
66
67
68
69 @Deprecated
70 public String getPassword() {
71 return String.valueOf(this.password);
72 }
73
74 public char[] getPasswordAsCharArray() {
75 return this.password;
76 }
77
78 public void setPassword(final char[] password) {
79 this.password = password;
80 }
81
82
83
84
85
86 @Deprecated
87 public void setPassword(final String password) {
88 this.password = password == null ? null : password.toCharArray();
89 }
90
91
92
93
94 protected T load() throws StoreConfigurationException {
95 return null;
96 }
97
98 @Override
99 public int hashCode() {
100 final int prime = 31;
101 int result = 1;
102 result = prime * result + ((location == null) ? 0 : location.hashCode());
103 result = prime * result + Arrays.hashCode(password);
104 return result;
105 }
106
107 @Override
108 public boolean equals(final Object obj) {
109 if (this == obj) {
110 return true;
111 }
112 if (obj == null) {
113 return false;
114 }
115 if (getClass() != obj.getClass()) {
116 return false;
117 }
118 final StoreConfiguration<?> other = (StoreConfiguration<?>) obj;
119 if (location == null) {
120 if (other.location != null) {
121 return false;
122 }
123 } else if (!location.equals(other.location)) {
124 return false;
125 }
126 if (!Arrays.equals(password, other.password)) {
127 return false;
128 }
129 return true;
130 }
131 }