forked from Ericsson/ecchronos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TLSConfig.java
227 lines (187 loc) · 6.21 KB
/
TLSConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*
* Copyright 2020 Telefonaktiebolaget LM Ericsson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ericsson.bss.cassandra.ecchronos.application.config;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
@SuppressWarnings({"checkstyle:membername", "checkstyle:methodname"})
public class TLSConfig
{
private static final int HASH_SEED = 31;
private boolean enabled;
private String keystore;
private String keystore_password;
private String truststore;
private String truststore_password;
private String certificate;
private String certificate_private_key;
private String trust_certificate;
private String protocol;
private String algorithm;
private String store_type;
private String[] cipher_suites;
private boolean require_endpoint_verification;
public final boolean isEnabled()
{
return enabled;
}
public final void setEnabled(final boolean isEnabled)
{
this.enabled = isEnabled;
}
public final String getKeystore()
{
return keystore;
}
public final void setKeystore(final String aKeystore)
{
this.keystore = aKeystore;
}
public final String getKeystore_password()
{
return keystore_password;
}
public final void setKeystore_password(final String keystorePassword)
{
this.keystore_password = keystorePassword;
}
public final String getTruststore()
{
return truststore;
}
public final void setTruststore(final String aTruststore)
{
this.truststore = aTruststore;
}
public final String getTruststore_password()
{
return truststore_password;
}
public final void setTruststore_password(final String truststorePassword)
{
this.truststore_password = truststorePassword;
}
public final Optional<String> getCertificate()
{
return Optional.ofNullable(certificate);
}
public final void setCertificate(final String aCertificate)
{
this.certificate = aCertificate;
}
public final Optional<String> getCertificatePrivateKey()
{
return Optional.ofNullable(certificate_private_key);
}
public final void setCertificate_private_key(final String certificatePrivateKey)
{
this.certificate_private_key = certificatePrivateKey;
}
public final Optional<String> getTrustCertificate()
{
return Optional.ofNullable(trust_certificate);
}
public final void setTrust_certificate(final String trustCertificate)
{
this.trust_certificate = trustCertificate;
}
public final String getProtocol()
{
return protocol;
}
public final String[] getProtocols()
{
return protocol.split(",");
}
public final void setProtocol(final String aProtocol)
{
this.protocol = aProtocol;
}
public final Optional<String[]> getCipher_suites()
{
if (cipher_suites == null)
{
return Optional.empty();
}
return Optional.of(Arrays.copyOf(cipher_suites, cipher_suites.length));
}
public final void setCipher_suites(final String cipherSuites)
{
this.cipher_suites = transformCiphers(cipherSuites);
}
public final Optional<String> getAlgorithm()
{
return Optional.ofNullable(algorithm);
}
public final void setAlgorithm(final String theAlgorithm)
{
this.algorithm = theAlgorithm;
}
public final String getStore_type()
{
return store_type;
}
public final void setStore_type(final String storeType)
{
this.store_type = storeType;
}
public final boolean requiresEndpointVerification()
{
return require_endpoint_verification;
}
public final void setRequire_endpoint_verification(final boolean requireEndpointVerification)
{
this.require_endpoint_verification = requireEndpointVerification;
}
private static String[] transformCiphers(final String cipherSuites)
{
return cipherSuites == null ? null : cipherSuites.split(",");
}
@Override
public final boolean equals(final Object o)
{
if (this == o)
{
return true;
}
if (o == null || getClass() != o.getClass())
{
return false;
}
TLSConfig tlsConfig = (TLSConfig) o;
return enabled == tlsConfig.enabled
&& require_endpoint_verification == tlsConfig.require_endpoint_verification
&& Objects.equals(keystore, tlsConfig.keystore)
&& Objects.equals(keystore_password, tlsConfig.keystore_password)
&& Objects.equals(truststore, tlsConfig.truststore)
&& Objects.equals(truststore_password, tlsConfig.truststore_password)
&& Objects.equals(certificate, tlsConfig.certificate)
&& Objects.equals(certificate_private_key, tlsConfig.certificate_private_key)
&& Objects.equals(trust_certificate, tlsConfig.trust_certificate)
&& Objects.equals(protocol, tlsConfig.protocol)
&& Objects.equals(algorithm, tlsConfig.algorithm)
&& Objects.equals(store_type, tlsConfig.store_type)
&& Arrays.equals(cipher_suites, tlsConfig.cipher_suites);
}
@Override
public final int hashCode()
{
int result = Objects.hash(enabled, keystore, keystore_password, truststore, truststore_password, certificate,
certificate_private_key, trust_certificate, protocol, algorithm, store_type,
require_endpoint_verification);
result = HASH_SEED * result + Arrays.hashCode(cipher_suites);
return result;
}
}