Package org.apache.nifi.ssl
Class StandardSSLContextService
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.controller.AbstractControllerService
org.apache.nifi.ssl.StandardSSLContextService
- All Implemented Interfaces:
ConfigurableComponent
,ControllerService
,SSLContextService
- Direct Known Subclasses:
StandardRestrictedSSLContextService
@Tags({"ssl","secure","certificate","keystore","truststore","jks","p12","pkcs12","pkcs","tls"})
@CapabilityDescription("Standard implementation of the SSLContextService. Provides the ability to configure keystore and/or truststore properties once and reuse that configuration throughout the application. This service can be used to communicate with both legacy and modern systems. If you only need to communicate with non-legacy systems, then the StandardRestrictedSSLContextService is recommended as it only allows a specific set of SSL protocols to be chosen.")
public class StandardSSLContextService
extends AbstractControllerService
implements SSLContextService
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConfigurationContext
private boolean
(package private) static final PropertyDescriptor
static final PropertyDescriptor
static final PropertyDescriptor
static final PropertyDescriptor
private static final List
<PropertyDescriptor> static final PropertyDescriptor
static final String
static final String
static final PropertyDescriptor
static final PropertyDescriptor
static final PropertyDescriptor
private static final int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
countNulls
(Object... objects) Returns the count ofnull
objects in the parameters.Create and initializeSSLContext
using configured properties.Returns aTlsConfiguration
configured with the current properties of the controller service.Create X.509 Trust Manager using configured propertiesprotected Collection
<ValidationResult> customValidate
(ValidationContext validationContext) private Map
<PropertyDescriptor, String> evaluateProperties
(PropertyContext context) private static AllowableValue[]
protected List
<PropertyDescriptor> protected int
boolean
boolean
private static boolean
keystorePropertiesEmpty
(Map<PropertyDescriptor, String> properties) void
onConfigured
(ConfigurationContext context) void
onPropertyModified
(PropertyDescriptor descriptor, String oldValue, String newValue) private void
toString()
private static boolean
truststorePropertiesEmpty
(Map<PropertyDescriptor, String> properties) private static List
<ValidationResult> validateKeystore
(Map<PropertyDescriptor, String> properties) Returns a list ofValidationResult
s for keystore validity checking.private static List
<ValidationResult> validateKeystoreFile
(String filename, String password, String keyPassword, String type) Returns a list ofValidationResult
s when validating an actual keystore file on disk.private static Collection
<ValidationResult> validateStore
(Map<PropertyDescriptor, String> properties, StandardSSLContextService.KeystoreValidationGroup keyStoreOrTrustStore) Returns a list ofValidationResult
s for the provided keystore/truststore properties.private static List
<ValidationResult> validateTruststore
(Map<PropertyDescriptor, String> properties) Returns a list ofValidationResult
s for truststore validity checking.private static List
<ValidationResult> validateTruststoreFile
(String filename, String password, String type) Returns a list ofValidationResult
s when validating an actual truststore file on disk.Methods inherited from class org.apache.nifi.controller.AbstractControllerService
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getConfigurationContext, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabled
Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.nifi.components.ConfigurableComponent
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, validate
Methods inherited from interface org.apache.nifi.controller.ControllerService
initialize, isStateful, migrateProperties
-
Field Details
-
TLS_PROTOCOL
- See Also:
-
SSL_PROTOCOL
- See Also:
-
TRUSTSTORE
-
TRUSTSTORE_TYPE
-
TRUSTSTORE_PASSWORD
-
KEYSTORE
-
KEYSTORE_TYPE
-
KEYSTORE_PASSWORD
-
KEY_PASSWORD
-
SSL_ALGORITHM
-
properties
-
configContext
-
isValidated
private boolean isValidated -
VALIDATION_CACHE_EXPIRATION
private static final int VALIDATION_CACHE_EXPIRATION- See Also:
-
validationCacheCount
private int validationCacheCount
-
-
Constructor Details
-
StandardSSLContextService
public StandardSSLContextService()
-
-
Method Details
-
onConfigured
- Throws:
InitializationException
-
onPropertyModified
- Specified by:
onPropertyModified
in interfaceConfigurableComponent
- Overrides:
onPropertyModified
in classAbstractConfigurableComponent
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptors
in classAbstractConfigurableComponent
-
customValidate
- Overrides:
customValidate
in classAbstractConfigurableComponent
-
evaluateProperties
-
resetValidationCache
private void resetValidationCache() -
getValidationCacheExpiration
protected int getValidationCacheExpiration() -
createTlsConfiguration
Returns aTlsConfiguration
configured with the current properties of the controller service. This is useful for transferring the TLS configuration values between services.- Specified by:
createTlsConfiguration
in interfaceSSLContextService
- Returns:
- the populated TlsConfiguration
-
createContext
Create and initializeSSLContext
using configured properties. This method is preferred over deprecated methods due to not requiring a client authentication policy. Invokes createTlsConfiguration() to prepare properties for processing.- Specified by:
createContext
in interfaceSSLContextService
- Returns:
SSLContext
initialized using configured properties
-
createTrustManager
Create X.509 Trust Manager using configured properties- Specified by:
createTrustManager
in interfaceSSLContextService
- Returns:
X509TrustManager
initialized using configured properties
-
getTrustStoreFile
- Specified by:
getTrustStoreFile
in interfaceSSLContextService
-
getTrustStoreType
- Specified by:
getTrustStoreType
in interfaceSSLContextService
-
getTrustStorePassword
- Specified by:
getTrustStorePassword
in interfaceSSLContextService
-
isTrustStoreConfigured
public boolean isTrustStoreConfigured()- Specified by:
isTrustStoreConfigured
in interfaceSSLContextService
-
getKeyStoreFile
- Specified by:
getKeyStoreFile
in interfaceSSLContextService
-
getKeyStoreType
- Specified by:
getKeyStoreType
in interfaceSSLContextService
-
getKeyStorePassword
- Specified by:
getKeyStorePassword
in interfaceSSLContextService
-
getKeyPassword
- Specified by:
getKeyPassword
in interfaceSSLContextService
-
isKeyStoreConfigured
public boolean isKeyStoreConfigured()- Specified by:
isKeyStoreConfigured
in interfaceSSLContextService
-
getSslAlgorithm
- Specified by:
getSslAlgorithm
in interfaceSSLContextService
-
validateStore
private static Collection<ValidationResult> validateStore(Map<PropertyDescriptor, String> properties, StandardSSLContextService.KeystoreValidationGroup keyStoreOrTrustStore) Returns a list ofValidationResult
s for the provided keystore/truststore properties. Called duringcustomValidate(ValidationContext)
.- Parameters:
properties
- the map of component propertieskeyStoreOrTrustStore
- an enumStandardSSLContextService.KeystoreValidationGroup
indicating keystore or truststore because logic is different- Returns:
- the list of validation results (empty means valid)
-
keystorePropertiesEmpty
-
truststorePropertiesEmpty
-
countNulls
Returns the count ofnull
objects in the parameters. Used for keystore/truststore validation.- Parameters:
objects
- a variable array of objects, some of which can be null- Returns:
- the count of provided objects which were null
-
validateKeystore
Returns a list ofValidationResult
s for keystore validity checking. Ensures none or all of the properties are populated; if populated, validates the keystore file on disk and password as well.- Parameters:
properties
- the component properties- Returns:
- the list of validation results (empty is valid)
-
validateTruststore
Returns a list ofValidationResult
s for truststore validity checking. Ensures none of the properties are populated or at least filename and type are populated; if populated, validates the truststore file on disk and password as well.- Parameters:
properties
- the component properties- Returns:
- the list of validation results (empty is valid)
-
validateTruststoreFile
private static List<ValidationResult> validateTruststoreFile(String filename, String password, String type) Returns a list ofValidationResult
s when validating an actual truststore file on disk. Verifies the file permissions and existence, and attempts to open the file given the provided password.- Parameters:
filename
- the path of the file on diskpassword
- the file passwordtype
- the truststore type- Returns:
- the list of validation results (empty is valid)
-
validateKeystoreFile
private static List<ValidationResult> validateKeystoreFile(String filename, String password, String keyPassword, String type) Returns a list ofValidationResult
s when validating an actual keystore file on disk. Verifies the file permissions and existence, and attempts to open the file given the provided (keystore or key) password.- Parameters:
filename
- the path of the file on diskpassword
- the file passwordkeyPassword
- the (optional) key-specific passwordtype
- the keystore type- Returns:
- the list of validation results (empty is valid)
-
toString
- Overrides:
toString
in classAbstractConfigurableComponent
-
getProtocolAllowableValues
-