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 cc61165ee7fc75b5f5fc607b9c2a89fa0bd64add Author: Colm O hEigeartaigh <cohei...@apache.org> AuthorDate: Thu Apr 11 13:07:12 2019 +0100 Adding support for client authentication --- .../java/org/apache/camel/coap/CoAPComponent.java | 3 +- .../java/org/apache/camel/coap/CoAPEndpoint.java | 38 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) 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 13f0c9b..1a17d94 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 @@ -98,7 +98,8 @@ public class CoAPComponent extends UriEndpointComponent implements RestConsumerF throw new IllegalStateException("Error in configuring TLS", e); } - builder.setClientAuthenticationRequired(false); //TODO + builder.setClientAuthenticationRequired(endpoint.isClientAuthenticationRequired()); + builder.setClientAuthenticationWanted(endpoint.isClientAuthenticationWanted()); if (endpoint.getConfiguredCipherSuites() != null) { builder.setSupportedCipherSuites(endpoint.getConfiguredCipherSuites()); 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 2a3c0ad..e0a0b7e 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 @@ -35,6 +35,7 @@ import org.apache.camel.impl.DefaultEndpoint; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; +import org.apache.camel.util.jsse.ClientAuthentication; import org.apache.camel.util.jsse.KeyStoreParameters; import org.eclipse.californium.core.CoapServer; @@ -70,6 +71,8 @@ public class CoAPEndpoint extends DefaultEndpoint { private String cipherSuites; private String[] configuredCipherSuites; + + private String clientAuthentication; private CoAPComponent component; @@ -232,6 +235,35 @@ public class CoAPEndpoint extends DefaultEndpoint { return configuredCipherSuites; } + + /** + * Gets the configuration options for server-side client-authentication requirements. The value is + * either null or one of NONE, WANT, REQUIRE. + */ + public String getClientAuthentication() { + return clientAuthentication; + } + + /** + * 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; + } + + public boolean isClientAuthenticationRequired() { + return clientAuthentication != null + && ClientAuthentication.valueOf(clientAuthentication) == ClientAuthentication.REQUIRE; + } + + public boolean isClientAuthenticationWanted() { + return clientAuthentication != null + && ClientAuthentication.valueOf(clientAuthentication) == ClientAuthentication.WANT; + } + public Certificate[] getTrustedCerts() throws KeyStoreException { Enumeration<String> aliases = truststore.aliases(); List<Certificate> trustCerts = new ArrayList<>(); @@ -245,4 +277,10 @@ public class CoAPEndpoint extends DefaultEndpoint { return trustCerts.toArray(new Certificate[0]); } + + /* + public DTLSConnector createDTLSConnector() { + + } + */ }