public class StandardTlsConfiguration extends Object implements TlsConfiguration
SSLContext
s.Modifier and Type | Field and Description |
---|---|
private String |
keyPassword |
private String |
keystorePassword |
private String |
keystorePath |
private KeystoreType |
keystoreType |
private static org.slf4j.Logger |
logger |
private static String |
MASKED_PASSWORD_LOG |
private static String |
NULL_LOG |
private String |
protocol |
private static String |
TLS_PROTOCOL_VERSION |
private String |
truststorePassword |
private String |
truststorePath |
private KeystoreType |
truststoreType |
JAVA_11_MAX_SUPPORTED_TLS_PROTOCOL_VERSION, JAVA_11_SUPPORTED_TLS_PROTOCOL_VERSIONS, JAVA_8_MAX_SUPPORTED_TLS_PROTOCOL_VERSION, JAVA_8_SUPPORTED_TLS_PROTOCOL_VERSIONS, LEGACY_TLS_PROTOCOL_VERSIONS, SSL_PROTOCOL, TLS_1_0_PROTOCOL, TLS_1_1_PROTOCOL, TLS_1_2_PROTOCOL, TLS_PROTOCOL
Constructor and Description |
---|
StandardTlsConfiguration()
Default constructor present for testing and completeness.
|
StandardTlsConfiguration(String keystorePath,
String keystorePassword,
KeystoreType keystoreType,
String truststorePath,
String truststorePassword,
KeystoreType truststoreType)
Instantiates a container object with the given configuration values.
|
StandardTlsConfiguration(String keystorePath,
String keystorePassword,
String keyPassword,
KeystoreType keystoreType,
String truststorePath,
String truststorePassword,
KeystoreType truststoreType)
Instantiates a container object with the given configuration values.
|
StandardTlsConfiguration(String keystorePath,
String keystorePassword,
String keyPassword,
KeystoreType keystoreType,
String truststorePath,
String truststorePassword,
KeystoreType truststoreType,
String protocol)
Instantiates a container object with the given configuration values.
|
StandardTlsConfiguration(String keystorePath,
String keystorePassword,
String keyPassword,
String keystoreType,
String truststorePath,
String truststorePassword,
String truststoreType)
Instantiates a container object with the given configuration values.
|
StandardTlsConfiguration(String keystorePath,
String keystorePassword,
String keyPassword,
String keystoreType,
String truststorePath,
String truststorePassword,
String truststoreType,
String protocol)
Instantiates a container object with the given configuration values.
|
StandardTlsConfiguration(TlsConfiguration other)
Instantiates a container object with a deep copy of the given configuration values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static StandardTlsConfiguration |
fromNiFiProperties(NiFiProperties niFiProperties)
Returns a
TlsConfiguration instantiated from the relevant NiFiProperties properties. |
static StandardTlsConfiguration |
fromNiFiPropertiesTruststoreOnly(NiFiProperties niFiProperties)
Returns a
TlsConfiguration instantiated
from the relevant NiFiProperties properties for the truststore
only. |
String[] |
getEnabledProtocols()
Get Enabled TLS Protocols translates SSL to legacy protocols and TLS to current protocols or returns configured protocol
|
String |
getFunctionalKeyPassword()
Returns the "working" key password -- if the key password is populated, it is returned; otherwise the
getKeystorePassword() is returned. |
String |
getFunctionalKeyPasswordForLogging()
Returns
"********" if the functional key password is populated, "null" if not. |
String |
getKeyPassword() |
String |
getKeyPasswordForLogging()
Returns
"********" if the key password is populated, "null" if not. |
String |
getKeystorePassword() |
String |
getKeystorePasswordForLogging()
Returns
"********" if the keystore password is populated, "null" if not. |
String |
getKeystorePath() |
String[] |
getKeystorePropertiesForLogging()
Returns a
String[] containing the keystore properties for logging. |
KeystoreType |
getKeystoreType() |
String |
getProtocol() |
String |
getTruststorePassword() |
String |
getTruststorePasswordForLogging()
Returns
"********" if the truststore password is populated, "null" if not. |
String |
getTruststorePath() |
String[] |
getTruststorePropertiesForLogging()
Returns a
String[] containing the truststore properties for logging. |
KeystoreType |
getTruststoreType() |
int |
hashCode() |
boolean |
isAnyKeystorePopulated()
Returns
true if any of the keystore properties is populated, indicating that the caller expects a valid keystore to be generated. |
private boolean |
isAnyPopulated(String path,
String password,
KeystoreType type) |
boolean |
isAnyTruststorePopulated()
Returns
true if any of the truststore properties is populated, indicating that the caller expects a valid truststore to be generated. |
boolean |
isKeystorePopulated()
Returns
true if the necessary properties are populated to instantiate a keystore. |
boolean |
isKeystoreValid()
Returns
true if the necessary properties are populated and the keystore can be successfully instantiated (i.e. |
private boolean |
isStorePopulated(String path,
String password,
KeystoreType type,
String label) |
private boolean |
isStoreValid(String path,
String password,
KeystoreType type,
String label) |
boolean |
isTruststorePopulated()
Returns
true if the necessary properties are populated to instantiate a truststore. |
boolean |
isTruststoreValid()
Returns
true if the necessary properties are populated and the truststore can be successfully instantiated (i.e. |
private static String |
maskPasswordForLog(String password) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getCurrentSupportedTlsProtocolVersions, getHighestCurrentSupportedTlsProtocolVersion, getJavaVersion, isEmpty, parseJavaVersion
private static final org.slf4j.Logger logger
private static final String TLS_PROTOCOL_VERSION
private static final String MASKED_PASSWORD_LOG
private static final String NULL_LOG
private final String keystorePath
private final String keystorePassword
private final String keyPassword
private final KeystoreType keystoreType
private final String truststorePath
private final String truststorePassword
private final KeystoreType truststoreType
private final String protocol
public StandardTlsConfiguration()
public StandardTlsConfiguration(String keystorePath, String keystorePassword, KeystoreType keystoreType, String truststorePath, String truststorePassword, KeystoreType truststoreType)
keystorePath
- the keystore pathkeystorePassword
- the keystore passwordkeystoreType
- the keystore typetruststorePath
- the truststore pathtruststorePassword
- the truststore passwordtruststoreType
- the truststore typepublic StandardTlsConfiguration(String keystorePath, String keystorePassword, String keyPassword, KeystoreType keystoreType, String truststorePath, String truststorePassword, KeystoreType truststoreType)
keystorePath
- the keystore pathkeystorePassword
- the keystore passwordkeyPassword
- the key passwordkeystoreType
- the keystore typetruststorePath
- the truststore pathtruststorePassword
- the truststore passwordtruststoreType
- the truststore typepublic StandardTlsConfiguration(String keystorePath, String keystorePassword, String keyPassword, String keystoreType, String truststorePath, String truststorePassword, String truststoreType)
keystorePath
- the keystore pathkeystorePassword
- the keystore passwordkeyPassword
- the key passwordkeystoreType
- the keystore type as a StringtruststorePath
- the truststore pathtruststorePassword
- the truststore passwordtruststoreType
- the truststore type as a Stringpublic StandardTlsConfiguration(String keystorePath, String keystorePassword, String keyPassword, String keystoreType, String truststorePath, String truststorePassword, String truststoreType, String protocol)
keystorePath
- the keystore pathkeystorePassword
- the keystore passwordkeyPassword
- the (optional) key password -- if null
, the keystore password is assumed the same for the individual keykeystoreType
- the keystore type as a StringtruststorePath
- the truststore pathtruststorePassword
- the truststore passwordtruststoreType
- the truststore type as a Stringprotocol
- the TLS protocol version stringpublic StandardTlsConfiguration(String keystorePath, String keystorePassword, String keyPassword, KeystoreType keystoreType, String truststorePath, String truststorePassword, KeystoreType truststoreType, String protocol)
keystorePath
- the keystore pathkeystorePassword
- the keystore passwordkeyPassword
- the (optional) key password -- if null
, the keystore password is assumed the same for the individual keykeystoreType
- the keystore typetruststorePath
- the truststore pathtruststorePassword
- the truststore passwordtruststoreType
- the truststore typeprotocol
- the TLS protocol version stringpublic StandardTlsConfiguration(TlsConfiguration other)
other
- the configuration to copypublic static StandardTlsConfiguration fromNiFiProperties(NiFiProperties niFiProperties)
TlsConfiguration
instantiated from the relevant NiFiProperties
properties.niFiProperties
- the NiFi propertiespublic static StandardTlsConfiguration fromNiFiPropertiesTruststoreOnly(NiFiProperties niFiProperties)
TlsConfiguration
instantiated
from the relevant NiFiProperties
properties for the truststore
only. No keystore properties are read or used.niFiProperties
- the NiFi propertiespublic String getKeystorePath()
getKeystorePath
in interface TlsConfiguration
public String getKeystorePassword()
getKeystorePassword
in interface TlsConfiguration
public String getKeystorePasswordForLogging()
"********"
if the keystore password is populated, "null"
if not.getKeystorePasswordForLogging
in interface TlsConfiguration
public String getKeyPassword()
getKeyPassword
in interface TlsConfiguration
public String getKeyPasswordForLogging()
"********"
if the key password is populated, "null"
if not.getKeyPasswordForLogging
in interface TlsConfiguration
public String getFunctionalKeyPassword()
getKeystorePassword()
is returned.getFunctionalKeyPassword
in interface TlsConfiguration
public String getFunctionalKeyPasswordForLogging()
"********"
if the functional key password is populated, "null"
if not.getFunctionalKeyPasswordForLogging
in interface TlsConfiguration
public KeystoreType getKeystoreType()
getKeystoreType
in interface TlsConfiguration
public String getTruststorePath()
getTruststorePath
in interface TlsConfiguration
public String getTruststorePassword()
getTruststorePassword
in interface TlsConfiguration
public String getTruststorePasswordForLogging()
"********"
if the truststore password is populated, "null"
if not.getTruststorePasswordForLogging
in interface TlsConfiguration
public KeystoreType getTruststoreType()
getTruststoreType
in interface TlsConfiguration
public String getProtocol()
getProtocol
in interface TlsConfiguration
public boolean isKeystorePopulated()
true
if the necessary properties are populated to instantiate a keystore. This does not validate the values (see isKeystoreValid()
).isKeystorePopulated
in interface TlsConfiguration
public boolean isAnyKeystorePopulated()
true
if any of the keystore properties is populated, indicating that the caller expects a valid keystore to be generated.isAnyKeystorePopulated
in interface TlsConfiguration
public boolean isKeystoreValid()
true
if the necessary properties are populated and the keystore can be successfully instantiated (i.e. the path is valid and the password(s) are correct).isKeystoreValid
in interface TlsConfiguration
public boolean isTruststorePopulated()
true
if the necessary properties are populated to instantiate a truststore. This does not validate the values (see isTruststoreValid()
).isTruststorePopulated
in interface TlsConfiguration
public boolean isAnyTruststorePopulated()
true
if any of the truststore properties is populated, indicating that the caller expects a valid truststore to be generated.isAnyTruststorePopulated
in interface TlsConfiguration
public boolean isTruststoreValid()
true
if the necessary properties are populated and the truststore can be successfully instantiated (i.e. the path is valid and the password is correct).isTruststoreValid
in interface TlsConfiguration
public String[] getKeystorePropertiesForLogging()
String[]
containing the keystore properties for logging. The order is
getKeystorePath()
, getKeystorePasswordForLogging()
,
getFunctionalKeyPasswordForLogging()
, getKeystoreType()
(using the type or "null").getKeystorePropertiesForLogging
in interface TlsConfiguration
public String[] getTruststorePropertiesForLogging()
String[]
containing the truststore properties for logging. The order is
getTruststorePath()
, getTruststorePasswordForLogging()
,
getTruststoreType()
(using the type or "null").getTruststorePropertiesForLogging
in interface TlsConfiguration
public String[] getEnabledProtocols()
getEnabledProtocols
in interface TlsConfiguration
private boolean isAnyPopulated(String path, String password, KeystoreType type)
private boolean isStorePopulated(String path, String password, KeystoreType type, String label)
private boolean isStoreValid(String path, String password, KeystoreType type, String label)
Copyright © 2021 Apache NiFi Project. All rights reserved.