From f96e7ab59bc10bef8a314b34e2871f2be2f604f1 Mon Sep 17 00:00:00 2001 From: John Blum Date: Mon, 28 May 2018 19:25:39 -0700 Subject: [PATCH] Rename trusted.keystore to test-trusted-keystore. --- .../autoconfigure/SslAutoConfiguration.java | 55 ++++++++---------- .../AutoConfiguredSslIntegrationTests.java | 4 +- .../test/resources/application-ssl.properties | 1 + ...trusted.keystore => test-trusted.keystore} | Bin 4 files changed, 27 insertions(+), 33 deletions(-) rename geode-spring-boot-starter/src/test/resources/{trusted.keystore => test-trusted.keystore} (100%) diff --git a/geode-spring-boot-starter/src/main/java/org/springframework/boot/data/geode/autoconfigure/SslAutoConfiguration.java b/geode-spring-boot-starter/src/main/java/org/springframework/boot/data/geode/autoconfigure/SslAutoConfiguration.java index fa401dd8..0ae0994b 100644 --- a/geode-spring-boot-starter/src/main/java/org/springframework/boot/data/geode/autoconfigure/SslAutoConfiguration.java +++ b/geode-spring-boot-starter/src/main/java/org/springframework/boot/data/geode/autoconfigure/SslAutoConfiguration.java @@ -148,45 +148,38 @@ public class SslAutoConfiguration { new File(new ClassPathResource(keystoreName).getURL().toURI())).getAbsolutePath()); */ - return locateKeyStoreInClassPath(environment).map(resource -> { + return locateKeyStoreInClassPath(environment) + .map(resource -> { - File trustedKeyStore = null; + File trustedKeyStore = null; - try { + try { - URL url = resource.getURL(); + URL url = resource.getURL(); - if (ResourceUtils.isFileURL(url)) { - trustedKeyStore = new File(url.toURI()); - } - else if (ResourceUtils.isJarURL(url)) { - trustedKeyStore = new File(CURRENT_WORKING_DIRECTORY, resolveTrustedKeystoreName(environment)); - FileCopyUtils.copy(url.openStream(), new FileOutputStream(trustedKeyStore)); - } - } - catch (IOException | URISyntaxException cause) { - - if (logger.isWarnEnabled()) { - - logger.warn("Trusted KeyStore {} found in Class Path but is not resolvable as a File: {}", - resource, cause.getMessage()); - - if (logger.isTraceEnabled()) { - logger.trace("Caused by:", cause); + if (ResourceUtils.isFileURL(url)) { + trustedKeyStore = new File(url.toURI()); + } + else if (ResourceUtils.isJarURL(url)) { + trustedKeyStore = new File(CURRENT_WORKING_DIRECTORY, resolveTrustedKeystoreName(environment)); + FileCopyUtils.copy(url.openStream(), new FileOutputStream(trustedKeyStore)); } } - } + catch (IOException | URISyntaxException cause) { - return trustedKeyStore; - }); + if (logger.isWarnEnabled()) { - /* - return locateKeyStoreInClassPath() - .map(it -> ObjectUtils.doOperationSafely(it::getURL)) - .map(url -> ObjectUtils.doOperationSafely(url::toURI)) - .map(uri -> ObjectUtils.doOperationSafely(() -> new File(uri))) - .filter(File::isFile); - */ + logger.warn("Trusted KeyStore {} found in Class Path but is not resolvable as a File: {}", + resource, cause.getMessage()); + + if (logger.isTraceEnabled()) { + logger.trace("Caused by:", cause); + } + } + } + + return trustedKeyStore; + }); } private static Optional locateKeyStoreInClassPath(Environment environment) { diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java index aa89d694..69343d35 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java @@ -84,7 +84,7 @@ import example.geode.cache.EchoCacheLoader; public class AutoConfiguredSslIntegrationTests extends ForkingClientServerIntegrationTestsSupport { private static final String GEMFIRE_LOG_LEVEL = "error"; - private static final String TRUSTED_KEYSTORE_FILENAME = "trusted.keystore"; + private static final String TRUSTED_KEYSTORE_FILENAME = "test-trusted.keystore"; @BeforeClass public static void startGemFireServer() throws IOException { @@ -216,9 +216,9 @@ public class AutoConfiguredSslIntegrationTests extends ForkingClientServerIntegr } } - @EnableSsl @CacheServerApplication(name = "AutoConfiguredSslIntegrationTests", logLevel = GEMFIRE_LOG_LEVEL) @PropertySource(name = "gemfire-ssl", value = "application-ssl.properties") + @EnableSsl static class GemFireServerConfiguration { public static void main(String[] args) { diff --git a/geode-spring-boot-starter/src/test/resources/application-ssl.properties b/geode-spring-boot-starter/src/test/resources/application-ssl.properties index 92a7b988..e3d7e0e2 100644 --- a/geode-spring-boot-starter/src/test/resources/application-ssl.properties +++ b/geode-spring-boot-starter/src/test/resources/application-ssl.properties @@ -1,4 +1,5 @@ # Spring Boot application.properties for testing Apache Geode/Pivotal GemFire SSL +spring.boot.data.gemfire.security.ssl.keystore.name=test-trusted.keystore spring.data.gemfire.security.ssl.keystore.password=s3cr3t spring.data.gemfire.security.ssl.truststore.password=s3cr3t diff --git a/geode-spring-boot-starter/src/test/resources/trusted.keystore b/geode-spring-boot-starter/src/test/resources/test-trusted.keystore similarity index 100% rename from geode-spring-boot-starter/src/test/resources/trusted.keystore rename to geode-spring-boot-starter/src/test/resources/test-trusted.keystore