This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch camel-2.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1adf51742a051e6d241059eb7a2d1c79d5aeb520 Author: Colm O hEigeartaigh <cohei...@apache.org> AuthorDate: Mon Apr 29 12:53:58 2019 +0100 Removing some whitespace --- .../camel-coap/src/main/docs/coap-component.adoc | 5 +- .../java/org/apache/camel/coap/CoAPComponent.java | 4 +- .../java/org/apache/camel/coap/CoAPEndpoint.java | 59 +++++++++++----------- .../java/org/apache/camel/coap/CoAPProducer.java | 2 +- .../apache/camel/coap/CoAPComponentTLSTest.java | 2 +- .../camel/coap/CoAPRestComponentTLSTest.java | 12 ++--- 6 files changed, 40 insertions(+), 44 deletions(-) diff --git a/components/camel-coap/src/main/docs/coap-component.adoc b/components/camel-coap/src/main/docs/coap-component.adoc index c86e853..3cb957b 100644 --- a/components/camel-coap/src/main/docs/coap-component.adoc +++ b/components/camel-coap/src/main/docs/coap-component.adoc @@ -37,10 +37,7 @@ The CoAP endpoint is configured using URI syntax: ---- coap:uri ---- -Alternatively, if TLS is being used: ----- -coaps:uri ----- + with the following path and query parameters: ==== Path Parameters (1 parameters): diff --git a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java index bf1f515..bfa450c 100644 --- a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java +++ b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPComponent.java @@ -68,7 +68,7 @@ public class CoAPComponent extends UriEndpointComponent implements RestConsumerF NetworkConfig config = NetworkConfig.createStandardWithoutFile(); InetSocketAddress address = new InetSocketAddress(port); coapBuilder.setNetworkConfig(config); - + // Configure TLS if (CoAPEndpoint.enableTLS(endpoint.getUri())) { DTLSConnector connector = endpoint.createDTLSConnector(address, false); @@ -79,7 +79,7 @@ public class CoAPComponent extends UriEndpointComponent implements RestConsumerF server = new CoapServer(); server.addEndpoint(coapBuilder.build()); - + servers.put(port, server); if (this.isStarted()) { server.start(); diff --git a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java index 8d5d394..6d5e32c 100644 --- a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java +++ b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPEndpoint.java @@ -55,16 +55,16 @@ public class CoAPEndpoint extends DefaultEndpoint { private URI uri; @UriParam(label = "consumer") private String coapMethodRestrict; - + @UriParam private KeyStoreParameters keyStoreParameters; - + @UriParam private KeyStore keystore; - + @UriParam private KeyStoreParameters trustStoreParameters; - + @UriParam private KeyStore truststore; @@ -82,17 +82,17 @@ public class CoAPEndpoint extends DefaultEndpoint { @UriParam private String alias; - + @UriParam(label = "security", javaType = "java.lang.String", secret = true) private char[] password; - + @UriParam private String cipherSuites; - + private String[] configuredCipherSuites; - + private String clientAuthentication; - + private CoAPComponent component; public CoAPEndpoint(String uri, CoAPComponent component) { @@ -142,9 +142,9 @@ public class CoAPEndpoint extends DefaultEndpoint { public CoapServer getCoapServer() { return component.getServer(getUri().getPort(), this); } - + /** - * The KeyStoreParameters object to use with TLS to configure the keystore. Alternatively, a "keystore" + * The KeyStoreParameters object to use with TLS to configure the keystore. Alternatively, a "keystore" * parameter can be directly configured instead. An alias and password should also be configured on the route definition. */ public KeyStoreParameters getKeyStoreParameters() { @@ -157,9 +157,9 @@ public class CoAPEndpoint extends DefaultEndpoint { this.keystore = keyStoreParameters.createKeyStore(); } } - + /** - * The KeyStoreParameters object to use with TLS to configure the truststore. Alternatively, a "truststore" + * The KeyStoreParameters object to use with TLS to configure the truststore. Alternatively, a "truststore" * object can be directly configured instead. All certificates in the truststore are used to establish trust. */ public KeyStoreParameters getTrustStoreParameters() { @@ -172,7 +172,7 @@ public class CoAPEndpoint extends DefaultEndpoint { this.truststore = trustStoreParameters.createKeyStore(); } } - + /** * Gets the TLS key store. Alternatively, a KeyStoreParameters object can be configured instead. * An alias and password should also be configured on the route definition. @@ -188,7 +188,7 @@ public class CoAPEndpoint extends DefaultEndpoint { public void setKeystore(KeyStore keystore) { this.keystore = keystore; } - + /** * Gets the TLS trust store. Alternatively, a "trustStoreParameters" object can be configured instead. * All certificates in the truststore are used to establish trust. @@ -204,7 +204,7 @@ public class CoAPEndpoint extends DefaultEndpoint { public void setTruststore(KeyStore truststore) { this.truststore = truststore; } - + /** * Gets the alias used to query the KeyStore for the private key and certificate. */ @@ -288,7 +288,7 @@ public class CoAPEndpoint extends DefaultEndpoint { public void setPassword(char[] password) { this.password = password; } - + /** * Gets the cipherSuites String. This is a comma separated String of ciphersuites to configure. */ @@ -305,12 +305,11 @@ public class CoAPEndpoint extends DefaultEndpoint { configuredCipherSuites = cipherSuites.split(","); } } - + private String[] getConfiguredCipherSuites() { return configuredCipherSuites; } - - + /** * Gets the configuration options for server-side client-authentication requirements. The value is * either null or one of NONE, WANT, REQUIRE. @@ -322,23 +321,23 @@ public class CoAPEndpoint extends DefaultEndpoint { /** * Sets the configuration options for server-side client-authentication requirements. * The value must be one of NONE, WANT, REQUIRE. - * + * * @param value the desired configuration options or {@code null} to use the defaults */ public void setClientAuthentication(String clientAuthentication) { this.clientAuthentication = clientAuthentication; } - + private boolean isClientAuthenticationRequired() { - return clientAuthentication != null + return clientAuthentication != null && ClientAuthentication.valueOf(clientAuthentication) == ClientAuthentication.REQUIRE; } - + private boolean isClientAuthenticationWanted() { - return clientAuthentication != null + return clientAuthentication != null && ClientAuthentication.valueOf(clientAuthentication) == ClientAuthentication.WANT; } - + private Certificate[] getTrustedCerts() throws KeyStoreException { if (truststore != null) { Enumeration<String> aliases = truststore.aliases(); @@ -356,7 +355,7 @@ public class CoAPEndpoint extends DefaultEndpoint { return new Certificate[0]; } - + public static boolean enableTLS(URI uri) { return "coaps".equals(uri.getScheme()); } @@ -368,7 +367,7 @@ public class CoAPEndpoint extends DefaultEndpoint { if (trustedRpkStore == null && getTruststore() == null && pskStore == null) { throw new IllegalStateException("A truststore must be configured to use TLS"); } - + builder.setClientOnly(); } else { if (privateKey == null && getKeystore() == null && pskStore == null) { @@ -387,7 +386,7 @@ public class CoAPEndpoint extends DefaultEndpoint { && (getTruststore() == null && publicKey == null)) { throw new IllegalStateException("A truststore must be configured to support TLS client authentication"); } - + builder.setAddress(address); builder.setClientAuthenticationRequired(isClientAuthenticationRequired()); builder.setClientAuthenticationWanted(isClientAuthenticationWanted()); @@ -396,7 +395,7 @@ public class CoAPEndpoint extends DefaultEndpoint { try { // Configure the identity if the keystore or privateKey parameter is specified if (getKeystore() != null) { - PrivateKey privateKey = + PrivateKey privateKey = (PrivateKey)getKeystore().getKey(getAlias(), getPassword()); builder.setIdentity(privateKey, getKeystore().getCertificateChain(getAlias())); } else if (privateKey != null) { diff --git a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java index 46c8f60..5441481 100644 --- a/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java +++ b/components/camel-coap/src/main/java/org/apache/camel/coap/CoAPProducer.java @@ -93,7 +93,7 @@ public class CoAPProducer extends DefaultProducer { uri = endpoint.getUri(); } client = new CoapClient(uri); - + // Configure TLS if (CoAPEndpoint.enableTLS((uri))) { DTLSConnector connector = endpoint.createDTLSConnector(null, true); diff --git a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTest.java b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTest.java index 815a392..aadd2a78 100644 --- a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTest.java +++ b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPComponentTLSTest.java @@ -110,7 +110,7 @@ public class CoAPComponentTLSTest extends CamelTestSupport { sendBodyAndHeader("direct:failedclientauth", "Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); assertMockEndpointsSatisfied(); } - + @Test public void testCipherSuites() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); diff --git a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTLSTest.java b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTLSTest.java index a185c02..e911081 100644 --- a/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTLSTest.java +++ b/components/camel-coap/src/test/java/org/apache/camel/coap/CoAPRestComponentTLSTest.java @@ -34,7 +34,7 @@ public class CoAPRestComponentTLSTest extends CamelTestSupport { @Produce(uri = "direct:start") protected ProducerTemplate sender; - + @Test public void testPOST() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); @@ -44,7 +44,7 @@ public class CoAPRestComponentTLSTest extends CamelTestSupport { sender.sendBodyAndHeader("Camel CoAP", CoAPConstants.COAP_METHOD, "POST"); assertMockEndpointsSatisfied(); } - + @Test public void testGET() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); @@ -62,7 +62,7 @@ public class CoAPRestComponentTLSTest extends CamelTestSupport { KeyStoreParameters keystoreParameters = new KeyStoreParameters(); keystoreParameters.setResource("service.jks"); keystoreParameters.setPassword("security"); - + KeyStoreParameters truststoreParameters = new KeyStoreParameters(); truststoreParameters.setResource("truststore.jks"); truststoreParameters.setPassword("storepass"); @@ -75,7 +75,7 @@ public class CoAPRestComponentTLSTest extends CamelTestSupport { @Override protected RouteBuilder createRouteBuilder() throws Exception { - + return new RouteBuilder() { @Override public void configure() throws Exception { @@ -83,7 +83,7 @@ public class CoAPRestComponentTLSTest extends CamelTestSupport { .endpointProperty("keyStoreParameters", "#keystoreParameters") .endpointProperty("alias", "service") .endpointProperty("password", "security"); - + rest("/TestResource") .get().to("direct:get1") .post().to("direct:post1"); @@ -99,7 +99,7 @@ public class CoAPRestComponentTLSTest extends CamelTestSupport { exchange.getOut().setBody("Hello " + exchange.getIn().getBody(String.class)); } }); - + from("direct:start") .toF("coaps://localhost:%d/TestResource?trustStoreParameters=#truststoreParameters", PORT) .to("mock:result");