This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
forked from Ericsson/ecchronos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TLSConfig.java
230 lines (192 loc) · 6.03 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
228
229
230
/*
* 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;
public class TLSConfig
{
private boolean enabled;
private String keystore;
private String keystore_password;
private String truststore;
private String truststore_password;
private String certificate;
private String certificate_key;
private String certificate_authorities;
private String protocol;
private String algorithm;
private String store_type;
private String[] cipher_suites;
private boolean require_endpoint_verification;
public boolean isEnabled()
{
return enabled;
}
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
}
public String getKeystore()
{
return keystore;
}
public void setKeystore(String keystore)
{
this.keystore = keystore;
}
public String getKeystorePassword()
{
return keystore_password;
}
public void setKeystore_password(String keystore_password)
{
this.keystore_password = keystore_password;
}
public String getTruststore()
{
return truststore;
}
public void setTruststore(String truststore)
{
this.truststore = truststore;
}
public String getTruststorePassword()
{
return truststore_password;
}
public void setTruststore_password(String truststore_password)
{
this.truststore_password = truststore_password;
}
public Optional<String> getCertificate()
{
if (this.certificate == null)
{
return Optional.empty();
}
return Optional.of(certificate);
}
public void setCertificate(String certificate)
{
this.certificate = certificate;
}
public Optional<String> getCertificate_key()
{
if (this.certificate_key == null)
{
return Optional.empty();
}
return Optional.of(certificate_key);
}
public void setCertificate_key(String certificate_key)
{
this.certificate_key = certificate_key;
}
public Optional<String> getCertificate_authorities()
{
if (this.certificate_authorities == null)
{
return Optional.empty();
}
return Optional.of(certificate_authorities);
}
public void setCertificate_authorities(String certificate_authorities)
{
this.certificate_authorities = certificate_authorities;
}
public String getProtocol()
{
return protocol;
}
public String[] getProtocols()
{
return protocol.split(",");
}
public void setProtocol(String protocol)
{
this.protocol = protocol;
}
public Optional<String[]> getCipherSuites()
{
if (cipher_suites == null)
{
return Optional.empty();
}
return Optional.of(Arrays.copyOf(cipher_suites, cipher_suites.length));
}
public void setCipher_suites(String cipher_suites)
{
this.cipher_suites = transformCiphers(cipher_suites);
}
public Optional<String> getAlgorithm()
{
return Optional.ofNullable(algorithm);
}
public void setAlgorithm(String algorithm)
{
this.algorithm = algorithm;
}
public String getStoreType()
{
return store_type;
}
public void setStore_type(String store_type)
{
this.store_type = store_type;
}
public boolean requiresEndpointVerification()
{
return require_endpoint_verification;
}
public void setRequire_endpoint_verification(boolean require_endpoint_verification)
{
this.require_endpoint_verification = require_endpoint_verification;
}
private static String[] transformCiphers(String cipher_suites)
{
return cipher_suites == null ? null : cipher_suites.split(",");
}
@Override
public boolean equals(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_key, tlsConfig.certificate_key) &&
Objects.equals(certificate_authorities, tlsConfig.certificate_authorities) &&
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 int hashCode()
{
int result = Objects.hash(enabled, keystore, keystore_password, truststore, truststore_password, certificate,
certificate_key, certificate_authorities, protocol, algorithm, store_type, require_endpoint_verification);
result = 31 * result + Arrays.hashCode(cipher_suites);
return result;
}
}