/
TlsConfiguration.java
769 lines (673 loc) · 26.8 KB
/
TlsConfiguration.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.api.security.tls;
import static org.mule.api.config.MuleProperties.SYSTEM_PROPERTY_PREFIX;
import org.mule.api.lifecycle.CreateException;
import org.mule.api.security.TlsDirectKeyStore;
import org.mule.api.security.TlsDirectTrustStore;
import org.mule.api.security.TlsIndirectKeyStore;
import org.mule.config.i18n.CoreMessages;
import org.mule.util.ArrayUtils;
import org.mule.util.FileUtils;
import org.mule.util.IOUtils;
import org.mule.util.SecurityUtils;
import org.mule.util.StringUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.Enumeration;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Support for configuring TLS/SSL connections.
* <p/>
* <h2>Introduction</h2>
* <p/>
* This class was introduced to centralise the work of TLS/SSL configuration. It is intended
* to be backwards compatible with earlier code (as much as possible) and so is perhaps more
* complex than would be necessary if starting from zero - the main source of confusion is the
* distinction between direct and indirect creation of sockets and stores.
* <p/>
* <h2>Configuration</h2>
* <p/>
* The documentation in this class is intended more for programmers than end uses. If you are
* configuring a connector the interfaces {@link org.mule.api.security.TlsIndirectTrustStore},
* {@link TlsDirectTrustStore},
* {@link TlsDirectKeyStore} and {@link TlsIndirectKeyStore} should provide guidance to individual
* properties. In addition you should check the documentation for the specific protocol / connector
* used and may also need to read the discussion on direct and indirect socket and store creation
* below (or, more simply, just use whichever key store interface your connector implements!).
* <p/>
* <h2>Programming</h2>
* <p/>
* This class is intended to be used as a delegate as we typically want to add security to an
* already existing connector (so we inherit from that connector, implement the appropriate
* interfaces from {@link org.mule.api.security.TlsIndirectTrustStore}, {@link TlsDirectTrustStore},
* {@link TlsDirectKeyStore} and {@link TlsIndirectKeyStore}, and then forward calls to the
* interfaces to an instance of this class).
* <p/>
* <p>For setting System properties (and reading them) use {@link TlsPropertiesMapper}. This
* can take a "namespace" which can then be used by {@link TlsPropertiesSocketFactory} to
* construct an appropriate socket factory. This approach (storing to properties and then
* retrieving that information later in a socket factory) lets us pass TLS/SSL configuration
* into libraries that are configured by specifying on the socket factory class.</p>
* <p/>
* <h2>Direct and Indirect Socket and Store Creation</h2>
* <p/>
* For the SSL transport, which historically defined parameters for many different secure
* transports, the configuration interfaces worked as follows:
* <p/>
* <dl>
* <dt>{@link TlsDirectTrustStore}</dt><dd>Used to generate trust store directly and indirectly
* for all TLS/SSL conections via System properties</dd>
* <dt>{@link TlsDirectKeyStore}</dt><dd>Used to generate key store directly</dd>
* <dt>{@link TlsIndirectKeyStore}</dt><dd>Used to generate key store indirectly for all
* TLS/SSL conections via System properties</dd>
* </dl>
* <p/>
* Historically, many other transports relied on the indirect configurations defined above.
* So they implemented {@link org.mule.api.security.TlsIndirectTrustStore}
* (a superclass of {@link TlsDirectTrustStore})
* and relied on {@link TlsIndirectKeyStore} from the SSL configuration. For continuity these
* interfaces continue to be used, even though
* the configurations are now typically (see individual connector/protocol documentation) specific
* to a protocol or connector. <em>Note - these interfaces are new, but the original code had
* those methods, used as described. The new interfaces only make things explicit.</em>
* <p/>
* <p><em>Note for programmers</em> One way to understand the above is to see that many
* protocols are handled by libraries that are configured by providing either properties or
* a socket factory. In both cases (the latter via {@link TlsPropertiesSocketFactory}) we
* continue to use properties and the "indirect" interface. Note also that the mapping
* in {@link TlsPropertiesMapper} correctly handles the asymmetry, so an initial call to
* {@link TlsConfiguration} uses the keystore defined via {@link TlsDirectKeyStore}, but
* when a {@link TlsConfiguration} is retrieved from System proerties using
* {@link TlsPropertiesMapper#readFromProperties(TlsConfiguration,java.util.Properties)}
* the "indirect" properties are supplied as "direct" values, meaning that the "indirect"
* socket factory can be retrieved from {@link #getKeyManagerFactory()}. It just works.</p>
*/
public final class TlsConfiguration
implements TlsDirectTrustStore, TlsDirectKeyStore, TlsIndirectKeyStore
{
public static final String DEFAULT_KEYSTORE = ".keystore";
public static final String DEFAULT_KEYSTORE_TYPE = KeyStore.getDefaultType();
public static final String DEFAULT_KEYMANAGER_ALGORITHM = KeyManagerFactory.getDefaultAlgorithm();
public static final String DEFAULT_SSL_TYPE = "TLSv1";
public static final String JSSE_NAMESPACE = "javax.net";
public static final String PROPERTIES_FILE_PATTERN = "tls-%s.conf";
public static final String DEFAULT_SECURITY_MODEL = "default";
public static final String FIPS_SECURITY_MODEL = "fips140-2";
public static final String DISABLE_SYSTEM_PROPERTIES_MAPPING_PROPERTY = SYSTEM_PROPERTY_PREFIX + "tls.disableSystemPropertiesMapping";
private Log logger = LogFactory.getLog(getClass());
private String sslType = DEFAULT_SSL_TYPE;
// this is the key store that is generated in-memory and available to connectors explicitly.
// it is local to the socket.
private String keyStoreName = DEFAULT_KEYSTORE; // was default in https but not ssl
private String keyAlias = null;
private String keyPassword = null;
private String keyStorePassword = null;
private String keystoreType = DEFAULT_KEYSTORE_TYPE;
private String keyManagerAlgorithm = DEFAULT_KEYMANAGER_ALGORITHM;
private KeyManagerFactory keyManagerFactory = null;
// this is the key store defined in system properties that is used implicitly.
// note that some transports use different namespaces within system properties,
// so this is typically global across a particular transport.
// it is also used as the trust store defined in system properties if no other trust
// store is given and explicitTrustStoreOnly is false
private String clientKeyStoreName = null;
private String clientKeyStorePassword = null;
private String clientKeyStoreType = DEFAULT_KEYSTORE_TYPE;
// this is the trust store used to construct sockets both explicitly
// and globally (if not set, see client key above) via the jvm defaults.
private String trustStoreName = null;
private String trustStorePassword = null;
private String trustStoreType = DEFAULT_KEYSTORE_TYPE;
private String trustManagerAlgorithm = DEFAULT_KEYMANAGER_ALGORITHM;
private TrustManagerFactory trustManagerFactory = null;
private boolean explicitTrustStoreOnly = false;
private boolean requireClientAuthentication = false;
private TlsProperties tlsProperties = new TlsProperties();
private boolean disableSystemPropertiesMapping = true;
/**
* Support for TLS connections with a given initial value for the key store
*
* @param keyStore initial value for the key store
*/
public TlsConfiguration(String keyStore)
{
this.keyStoreName = keyStore;
String disableSystemPropertiesMappingValue = System.getProperty(DISABLE_SYSTEM_PROPERTIES_MAPPING_PROPERTY);
if (disableSystemPropertiesMappingValue != null)
{
disableSystemPropertiesMapping = BooleanUtils.toBoolean(disableSystemPropertiesMappingValue);
}
}
// note - in what follows i'm using "raw" variables rather than accessors because
// i think the names are clearer. the API names for the accessors are historical
// and not a close fit to actual use (imho).
/**
* @param anon If the connection is anonymous then we don't care about client keys
* @param namespace Namespace to use for global properties (for JSSE use JSSE_NAMESPACE)
* @throws CreateException ON initialisation problems
*/
public void initialise(boolean anon, String namespace) throws CreateException
{
if (logger.isDebugEnabled())
{
logger.debug("initialising: anon " + anon);
}
validate(anon);
if (!anon)
{
initKeyManagerFactory();
}
initTrustManagerFactory();
if (logger.isDebugEnabled())
{
logger.debug("TLS system properties mapping is " + (disableSystemPropertiesMapping ? "disabled" : "enabled"));
}
if (null != namespace && !disableSystemPropertiesMapping)
{
new TlsPropertiesMapper(namespace).writeToProperties(System.getProperties(), this);
}
tlsProperties.load(String.format(PROPERTIES_FILE_PATTERN, SecurityUtils.getSecurityModel()));
}
private void validate(boolean anon) throws CreateException
{
if (!anon)
{
assertNotNull(getKeyStore(), "The KeyStore location cannot be null");
assertNotNull(getKeyPassword(), "The Key password cannot be null");
assertNotNull(getKeyStorePassword(), "The KeyStore password cannot be null");
assertNotNull(getKeyManagerAlgorithm(), "The Key Manager Algorithm cannot be null");
}
}
private void initKeyManagerFactory() throws CreateException
{
if (logger.isDebugEnabled())
{
logger.debug("initialising key manager factory from keystore data");
}
KeyStore tempKeyStore;
try
{
tempKeyStore = loadKeyStore();
checkKeyStoreContainsAlias(tempKeyStore);
}
catch (Exception e)
{
throw new CreateException(
CoreMessages.failedToLoad("KeyStore: " + keyStoreName), e, this);
}
try
{
keyManagerFactory = KeyManagerFactory.getInstance(getKeyManagerAlgorithm());
keyManagerFactory.init(tempKeyStore, keyPassword.toCharArray());
}
catch (Exception e)
{
throw new CreateException(CoreMessages.failedToLoad("Key Manager"), e, this);
}
}
protected KeyStore loadKeyStore() throws GeneralSecurityException, IOException
{
KeyStore tempKeyStore = KeyStore.getInstance(keystoreType);
InputStream is = IOUtils.getResourceAsStream(keyStoreName, getClass());
if (null == is)
{
throw new FileNotFoundException(
CoreMessages.cannotLoadFromClasspath("Keystore: " + keyStoreName).getMessage());
}
tempKeyStore.load(is, keyStorePassword.toCharArray());
return tempKeyStore;
}
protected void checkKeyStoreContainsAlias(KeyStore keyStore) throws KeyStoreException
{
if (StringUtils.isNotBlank(keyAlias))
{
boolean keyAliasFound = false;
Enumeration<String> aliases = keyStore.aliases();
while (aliases.hasMoreElements())
{
String alias = aliases.nextElement();
if (alias.equals(keyAlias))
{
// if alias is found all is valid but continue processing to strip out all
// other (unwanted) keys
keyAliasFound = true;
}
else
{
// if the current alias is not the one we are looking for, remove
// it from the keystore
keyStore.deleteEntry(alias);
}
}
// if the alias was not found, throw an exception
if (!keyAliasFound)
{
throw new IllegalStateException("Key with alias \"" + keyAlias + "\" was not found");
}
}
}
private void initTrustManagerFactory() throws CreateException
{
if (null != trustStoreName)
{
trustStorePassword = null == trustStorePassword ? "" : trustStorePassword;
KeyStore trustStore;
try
{
trustStore = KeyStore.getInstance(trustStoreType);
InputStream is = IOUtils.getResourceAsStream(trustStoreName, getClass());
if (null == is)
{
throw new FileNotFoundException(
"Failed to load truststore from classpath or local file: " + trustStoreName);
}
trustStore.load(is, trustStorePassword.toCharArray());
}
catch (Exception e)
{
throw new CreateException(
CoreMessages.failedToLoad("TrustStore: " + trustStoreName), e, this);
}
try
{
trustManagerFactory = TrustManagerFactory.getInstance(trustManagerAlgorithm);
trustManagerFactory.init(trustStore);
}
catch (Exception e)
{
throw new CreateException(
CoreMessages.failedToLoad("Trust Manager (" + trustManagerAlgorithm + ")"), e, this);
}
}
}
private static void assertNotNull(Object value, String message)
{
if (null == value)
{
throw new IllegalArgumentException(message);
}
}
private static String defaultForNull(String value, String deflt)
{
if (null == value)
{
return deflt;
}
else
{
return value;
}
}
public SSLSocketFactory getSocketFactory() throws NoSuchAlgorithmException, KeyManagementException
{
return new RestrictedSSLSocketFactory(getSslContext(), getEnabledCipherSuites(), getEnabledProtocols());
}
public SSLServerSocketFactory getServerSocketFactory()
throws NoSuchAlgorithmException, KeyManagementException
{
return new RestrictedSSLServerSocketFactory(getSslContext(), getEnabledCipherSuites(), getEnabledProtocols());
}
public String[] getEnabledCipherSuites()
{
return tlsProperties.getEnabledCipherSuites();
}
public String[] getEnabledProtocols()
{
return tlsProperties.getEnabledProtocols();
}
public SSLContext getSslContext() throws NoSuchAlgorithmException, KeyManagementException
{
TrustManager[] trustManagers =
null == getTrustManagerFactory() ? null : getTrustManagerFactory().getTrustManagers();
return getSslContext(trustManagers);
}
public SSLContext getSslContext(TrustManager[] trustManagers) throws NoSuchAlgorithmException, KeyManagementException
{
KeyManager[] keyManagers =
null == getKeyManagerFactory() ? null : getKeyManagerFactory().getKeyManagers();
SSLContext context = SSLContext.getInstance(getSslType());
// TODO - nice to have a configurable random number source set here
context.init(keyManagers, trustManagers, null);
return context;
}
public String getSslType()
{
return sslType;
}
public void setSslType(String sslType)
{
String[] enabledProtocols = tlsProperties.getEnabledProtocols();
if (enabledProtocols != null && !ArrayUtils.contains(enabledProtocols, sslType))
{
throw new IllegalArgumentException(String.format("Protocol %s is not allowed in current configuration", sslType));
}
this.sslType = sslType;
}
// access to the explicit key store variables
@Override
public String getKeyStore()
{
return keyStoreName;
}
@Override
public void setKeyStore(String name) throws IOException
{
keyStoreName = name;
if (null != keyStoreName)
{
keyStoreName = FileUtils.getResourcePath(keyStoreName, getClass());
if (logger.isDebugEnabled())
{
logger.debug("Normalised keyStore path to: " + keyStoreName);
}
}
}
@Override
public String getKeyPassword()
{
return keyPassword;
}
@Override
public void setKeyPassword(String keyPassword)
{
this.keyPassword = keyPassword;
}
@Override
public String getKeyStorePassword()
{
return keyStorePassword;
}
@Override
public void setKeyStorePassword(String storePassword)
{
this.keyStorePassword = storePassword;
}
@Override
public String getKeyStoreType()
{
return keystoreType;
}
@Override
public void setKeyStoreType(String keystoreType)
{
this.keystoreType = keystoreType;
}
@Override
public String getKeyManagerAlgorithm()
{
return keyManagerAlgorithm;
}
@Override
public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
{
this.keyManagerAlgorithm = keyManagerAlgorithm;
}
@Override
public KeyManagerFactory getKeyManagerFactory()
{
return keyManagerFactory;
}
// access to the implicit key store variables
@Override
public String getClientKeyStore()
{
return clientKeyStoreName;
}
@Override
public void setClientKeyStore(String name) throws IOException
{
clientKeyStoreName = name;
if (null != clientKeyStoreName)
{
clientKeyStoreName = FileUtils.getResourcePath(clientKeyStoreName, getClass());
if (logger.isDebugEnabled())
{
logger.debug("Normalised clientKeyStore path to: " + clientKeyStoreName);
}
}
}
@Override
public String getClientKeyStorePassword()
{
return clientKeyStorePassword;
}
@Override
public void setClientKeyStorePassword(String clientKeyStorePassword)
{
this.clientKeyStorePassword = clientKeyStorePassword;
}
@Override
public void setClientKeyStoreType(String clientKeyStoreType)
{
this.clientKeyStoreType = clientKeyStoreType;
}
@Override
public String getClientKeyStoreType()
{
return clientKeyStoreType;
}
// access to trust store variables
@Override
public String getTrustStore()
{
return trustStoreName;
}
@Override
public void setTrustStore(String name) throws IOException
{
trustStoreName = name;
if (null != trustStoreName)
{
trustStoreName = FileUtils.getResourcePath(trustStoreName, getClass());
if (logger.isDebugEnabled())
{
logger.debug("Normalised trustStore path to: " + trustStoreName);
}
}
}
@Override
public String getTrustStorePassword()
{
return trustStorePassword;
}
@Override
public void setTrustStorePassword(String trustStorePassword)
{
this.trustStorePassword = trustStorePassword;
}
@Override
public String getTrustStoreType()
{
return trustStoreType;
}
@Override
public void setTrustStoreType(String trustStoreType)
{
this.trustStoreType = trustStoreType;
}
@Override
public String getTrustManagerAlgorithm()
{
return trustManagerAlgorithm;
}
@Override
public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
{
this.trustManagerAlgorithm = defaultForNull(trustManagerAlgorithm, DEFAULT_KEYMANAGER_ALGORITHM);
}
@Override
public TrustManagerFactory getTrustManagerFactory()
{
return trustManagerFactory;
}
@Override
public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory)
{
this.trustManagerFactory = trustManagerFactory;
}
@Override
public boolean isExplicitTrustStoreOnly()
{
return explicitTrustStoreOnly;
}
@Override
public void setExplicitTrustStoreOnly(boolean explicitTrustStoreOnly)
{
this.explicitTrustStoreOnly = explicitTrustStoreOnly;
}
@Override
public boolean isRequireClientAuthentication()
{
return requireClientAuthentication;
}
@Override
public void setRequireClientAuthentication(boolean requireClientAuthentication)
{
this.requireClientAuthentication = requireClientAuthentication;
}
@Override
public String getKeyAlias()
{
return keyAlias;
}
@Override
public void setKeyAlias(String keyAlias)
{
this.keyAlias = keyAlias;
}
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof TlsConfiguration))
{
return false;
}
TlsConfiguration that = (TlsConfiguration) o;
if (explicitTrustStoreOnly != that.explicitTrustStoreOnly)
{
return false;
}
if (requireClientAuthentication != that.requireClientAuthentication)
{
return false;
}
if (clientKeyStoreName != null ? !clientKeyStoreName.equals(that.clientKeyStoreName) : that.clientKeyStoreName != null)
{
return false;
}
if (clientKeyStorePassword != null ? !clientKeyStorePassword.equals(that.clientKeyStorePassword) : that.clientKeyStorePassword != null)
{
return false;
}
if (clientKeyStoreType != null ? !clientKeyStoreType.equals(that.clientKeyStoreType) : that.clientKeyStoreType != null)
{
return false;
}
if (keyAlias != null ? !keyAlias.equals(that.keyAlias) : that.keyAlias != null)
{
return false;
}
if (keyManagerAlgorithm != null ? !keyManagerAlgorithm.equals(that.keyManagerAlgorithm) : that.keyManagerAlgorithm != null)
{
return false;
}
if (keyManagerFactory != null ? !keyManagerFactory.equals(that.keyManagerFactory) : that.keyManagerFactory != null)
{
return false;
}
if (keyPassword != null ? !keyPassword.equals(that.keyPassword) : that.keyPassword != null)
{
return false;
}
if (keyStoreName != null ? !keyStoreName.equals(that.keyStoreName) : that.keyStoreName != null)
{
return false;
}
if (keyStorePassword != null ? !keyStorePassword.equals(that.keyStorePassword) : that.keyStorePassword != null)
{
return false;
}
if (keystoreType != null ? !keystoreType.equals(that.keystoreType) : that.keystoreType != null)
{
return false;
}
if (sslType != null ? !sslType.equals(that.sslType) : that.sslType != null)
{
return false;
}
if (tlsProperties != null ? !tlsProperties.equals(that.tlsProperties) : that.tlsProperties != null)
{
return false;
}
if (trustManagerAlgorithm != null ? !trustManagerAlgorithm.equals(that.trustManagerAlgorithm) : that.trustManagerAlgorithm != null)
{
return false;
}
if (trustManagerFactory != null ? !trustManagerFactory.equals(that.trustManagerFactory) : that.trustManagerFactory != null)
{
return false;
}
if (trustStoreName != null ? !trustStoreName.equals(that.trustStoreName) : that.trustStoreName != null)
{
return false;
}
if (trustStorePassword != null ? !trustStorePassword.equals(that.trustStorePassword) : that.trustStorePassword != null)
{
return false;
}
if (trustStoreType != null ? !trustStoreType.equals(that.trustStoreType) : that.trustStoreType != null)
{
return false;
}
return true;
}
@Override
public int hashCode()
{
int result = sslType != null ? sslType.hashCode() : 0;
int hashcodePrimeNumber = 31;
result = hashcodePrimeNumber * result + (keyStoreName != null ? keyStoreName.hashCode() : 0);
result = hashcodePrimeNumber * result + (keyAlias != null ? keyAlias.hashCode() : 0);
result = hashcodePrimeNumber * result + (keyPassword != null ? keyPassword.hashCode() : 0);
result = hashcodePrimeNumber * result + (keyStorePassword != null ? keyStorePassword.hashCode() : 0);
result = hashcodePrimeNumber * result + (keystoreType != null ? keystoreType.hashCode() : 0);
result = hashcodePrimeNumber * result + (keyManagerAlgorithm != null ? keyManagerAlgorithm.hashCode() : 0);
result = hashcodePrimeNumber * result + (keyManagerFactory != null ? keyManagerFactory.hashCode() : 0);
result = hashcodePrimeNumber * result + (clientKeyStoreName != null ? clientKeyStoreName.hashCode() : 0);
result = hashcodePrimeNumber * result + (clientKeyStorePassword != null ? clientKeyStorePassword.hashCode() : 0);
result = hashcodePrimeNumber * result + (clientKeyStoreType != null ? clientKeyStoreType.hashCode() : 0);
result = hashcodePrimeNumber * result + (trustStoreName != null ? trustStoreName.hashCode() : 0);
result = hashcodePrimeNumber * result + (trustStorePassword != null ? trustStorePassword.hashCode() : 0);
result = hashcodePrimeNumber * result + (trustStoreType != null ? trustStoreType.hashCode() : 0);
result = hashcodePrimeNumber * result + (trustManagerAlgorithm != null ? trustManagerAlgorithm.hashCode() : 0);
result = hashcodePrimeNumber * result + (trustManagerFactory != null ? trustManagerFactory.hashCode() : 0);
result = hashcodePrimeNumber * result + (explicitTrustStoreOnly ? 1 : 0);
result = hashcodePrimeNumber * result + (requireClientAuthentication ? 1 : 0);
result = hashcodePrimeNumber * result + (tlsProperties != null ? tlsProperties.hashCode() : 0);
return result;
}
}