@Tags(value={"ssl","secure","certificate","keystore","truststore","jks","p12","pkcs12","pkcs","tls"}) @CapabilityDescription(value="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
| Modifier and Type | Class and Description |
|---|---|
static class |
StandardSSLContextService.KeystoreValidationGroup |
SSLContextService.ClientAuth| Modifier and Type | Field and Description |
|---|---|
protected ConfigurationContext |
configContext |
private static DeprecationLogger |
deprecationLogger |
private boolean |
isValidated |
(package private) static PropertyDescriptor |
KEY_PASSWORD |
static PropertyDescriptor |
KEYSTORE |
static PropertyDescriptor |
KEYSTORE_PASSWORD |
static PropertyDescriptor |
KEYSTORE_TYPE |
private static List<PropertyDescriptor> |
properties |
static PropertyDescriptor |
SSL_ALGORITHM |
static PropertyDescriptor |
TRUSTSTORE |
static PropertyDescriptor |
TRUSTSTORE_PASSWORD |
static PropertyDescriptor |
TRUSTSTORE_TYPE |
private static int |
VALIDATION_CACHE_EXPIRATION |
private int |
validationCacheCount |
| Constructor and Description |
|---|
StandardSSLContextService() |
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getConfigurationContext, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabledequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitinitialize, isStatefulgetIdentifier, getPropertyDescriptor, getPropertyDescriptors, validatepublic static final PropertyDescriptor TRUSTSTORE
public static final PropertyDescriptor TRUSTSTORE_TYPE
public static final PropertyDescriptor TRUSTSTORE_PASSWORD
public static final PropertyDescriptor KEYSTORE
public static final PropertyDescriptor KEYSTORE_TYPE
public static final PropertyDescriptor KEYSTORE_PASSWORD
static final PropertyDescriptor KEY_PASSWORD
public static final PropertyDescriptor SSL_ALGORITHM
private static final DeprecationLogger deprecationLogger
private static final List<PropertyDescriptor> properties
protected ConfigurationContext configContext
private boolean isValidated
private static final int VALIDATION_CACHE_EXPIRATION
private int validationCacheCount
@OnEnabled public void onConfigured(ConfigurationContext context) throws InitializationException
InitializationExceptionpublic void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponentprivate Map<PropertyDescriptor,String> evaluateProperties(PropertyContext context)
private void resetValidationCache()
protected int getValidationCacheExpiration()
public TlsConfiguration createTlsConfiguration()
TlsConfiguration configured with the current properties of the controller
service. This is useful for transferring the TLS configuration values between services.createTlsConfiguration in interface SSLContextServicepublic SSLContext createContext()
SSLContext 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.createContext in interface SSLContextServiceSSLContext initialized using configured properties@Deprecated public SSLContext createSSLContext(ClientAuth clientAuth) throws ProcessException
createContext() method should be used insteadSSLContext from the populated configuration values. This method is deprecated
due to the Client Authentication policy not being applicable when initializing the SSLContextcreateSSLContext in interface SSLContextServiceclientAuth - the desired level of client authenticationProcessException - if there is a problem configuring the context@Deprecated public SSLContext createSSLContext(SSLContextService.ClientAuth clientAuth) throws ProcessException
createContext() method should be used insteadSSLContext from the populated configuration values. This method is deprecated
due to the use of the deprecated ClientAuth enum
createContext() method is preferred.createSSLContext in interface SSLContextServiceclientAuth - the desired level of client authenticationProcessException - if there is a problem configuring the contextpublic X509TrustManager createTrustManager()
createTrustManager in interface SSLContextServiceX509TrustManager initialized using configured propertiespublic String getTrustStoreFile()
getTrustStoreFile in interface SSLContextServicepublic String getTrustStoreType()
getTrustStoreType in interface SSLContextServicepublic String getTrustStorePassword()
getTrustStorePassword in interface SSLContextServicepublic boolean isTrustStoreConfigured()
isTrustStoreConfigured in interface SSLContextServicepublic String getKeyStoreFile()
getKeyStoreFile in interface SSLContextServicepublic String getKeyStoreType()
getKeyStoreType in interface SSLContextServicepublic String getKeyStorePassword()
getKeyStorePassword in interface SSLContextServicepublic String getKeyPassword()
getKeyPassword in interface SSLContextServicepublic boolean isKeyStoreConfigured()
isKeyStoreConfigured in interface SSLContextServicepublic String getSslAlgorithm()
getSslAlgorithm in interface SSLContextServiceprivate static Collection<ValidationResult> validateStore(Map<PropertyDescriptor,String> properties, StandardSSLContextService.KeystoreValidationGroup keyStoreOrTrustStore)
ValidationResults for the provided
keystore/truststore properties. Called during
customValidate(ValidationContext).properties - the map of component propertieskeyStoreOrTrustStore - an enum StandardSSLContextService.KeystoreValidationGroup indicating keystore or truststore because logic is differentprivate static boolean keystorePropertiesEmpty(Map<PropertyDescriptor,String> properties)
private static boolean truststorePropertiesEmpty(Map<PropertyDescriptor,String> properties)
private static int countNulls(Object... objects)
null objects in the parameters. Used for keystore/truststore validation.objects - a variable array of objects, some of which can be nullprivate static List<ValidationResult> validateKeystore(Map<PropertyDescriptor,String> properties)
ValidationResults 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.properties - the component propertiesprivate static List<ValidationResult> validateTruststore(Map<PropertyDescriptor,String> properties)
ValidationResults 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.properties - the component propertiesprivate static List<ValidationResult> validateTruststoreFile(String filename, String password, String type)
ValidationResults when validating an actual truststore file on disk. Verifies the
file permissions and existence, and attempts to open the file given the provided password.filename - the path of the file on diskpassword - the file passwordtype - the truststore typeprivate static List<ValidationResult> validateKeystoreFile(String filename, String password, String keyPassword, String type)
ValidationResults 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.filename - the path of the file on diskpassword - the file passwordkeyPassword - the (optional) key-specific passwordtype - the keystore typepublic String toString()
toString in class AbstractConfigurableComponentprivate static AllowableValue[] getProtocolAllowableValues()
Copyright © 2024 Apache NiFi Project. All rights reserved.