You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2015/02/10 17:54:28 UTC
[3/3] incubator-nifi git commit: NIFI-250: Fixed NPE in
StandardSSLContextService
NIFI-250: Fixed NPE in StandardSSLContextService
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/5390c762
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/5390c762
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/5390c762
Branch: refs/heads/NIFI-250
Commit: 5390c7626a99c076daf05d06118815f902ab7b51
Parents: c25a2ca
Author: Mark Payne <ma...@hotmail.com>
Authored: Tue Feb 10 11:54:17 2015 -0500
Committer: Mark Payne <ma...@hotmail.com>
Committed: Tue Feb 10 11:54:17 2015 -0500
----------------------------------------------------------------------
.../nifi/ssl/StandardSSLContextService.java | 37 ++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5390c762/nifi/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java
index 39bb5fb..34f1844 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java
@@ -94,6 +94,7 @@ public class StandardSSLContextService extends AbstractControllerService impleme
.build();
private static final List<PropertyDescriptor> properties;
+ private ConfigurationContext configContext;
static {
List<PropertyDescriptor> props = new ArrayList<>();
@@ -105,7 +106,6 @@ public class StandardSSLContextService extends AbstractControllerService impleme
props.add(TRUSTSTORE_TYPE);
properties = Collections.unmodifiableList(props);
}
- private ConfigurationContext configContext;
@OnEnabled
public void onConfigured(final ConfigurationContext context) throws InitializationException {
@@ -194,7 +194,7 @@ public class StandardSSLContextService extends AbstractControllerService impleme
if (results.isEmpty()) {
// verify that the filename, password, and type match
try {
- createSSLContext(ClientAuth.REQUIRED);
+ verifySslConfig(validationContext);
} catch (ProcessException e) {
results.add(new ValidationResult.Builder()
.subject(getClass().getSimpleName() + " : " + getIdentifier())
@@ -205,6 +205,39 @@ public class StandardSSLContextService extends AbstractControllerService impleme
}
return results;
}
+
+ private void verifySslConfig(final ValidationContext validationContext) throws ProcessException {
+ try {
+ final String keystoreFile = validationContext.getProperty(KEYSTORE).getValue();
+ if (keystoreFile == null) {
+ SslContextFactory.createTrustSslContext(
+ validationContext.getProperty(TRUSTSTORE).getValue(),
+ validationContext.getProperty(TRUSTSTORE_PASSWORD).getValue().toCharArray(),
+ validationContext.getProperty(TRUSTSTORE_TYPE).getValue());
+ return;
+ }
+ final String truststoreFile = validationContext.getProperty(TRUSTSTORE).getValue();
+ if (truststoreFile == null) {
+ SslContextFactory.createSslContext(
+ validationContext.getProperty(KEYSTORE).getValue(),
+ validationContext.getProperty(KEYSTORE_PASSWORD).getValue().toCharArray(),
+ validationContext.getProperty(KEYSTORE_TYPE).getValue());
+ return;
+ }
+
+ SslContextFactory.createSslContext(
+ validationContext.getProperty(KEYSTORE).getValue(),
+ validationContext.getProperty(KEYSTORE_PASSWORD).getValue().toCharArray(),
+ validationContext.getProperty(KEYSTORE_TYPE).getValue(),
+ validationContext.getProperty(TRUSTSTORE).getValue(),
+ validationContext.getProperty(TRUSTSTORE_PASSWORD).getValue().toCharArray(),
+ validationContext.getProperty(TRUSTSTORE_TYPE).getValue(),
+ org.apache.nifi.security.util.SslContextFactory.ClientAuth.REQUIRED);
+ } catch (final Exception e) {
+ throw new ProcessException(e);
+ }
+ }
+
@Override
public SSLContext createSSLContext(final ClientAuth clientAuth) throws ProcessException {