From commits-return-12522-archive-asf-public=cust-asf.ponee.io@syncope.apache.org Tue Nov 13 09:33:11 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6FF35180676 for ; Tue, 13 Nov 2018 09:33:10 +0100 (CET) Received: (qmail 16942 invoked by uid 500); 13 Nov 2018 08:33:09 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 16894 invoked by uid 99); 13 Nov 2018 08:33:09 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Nov 2018 08:33:09 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id A9B13852C3; Tue, 13 Nov 2018 08:33:08 +0000 (UTC) Date: Tue, 13 Nov 2018 08:33:08 +0000 To: "commits@syncope.apache.org" Subject: [syncope] branch 2_1_X updated: [SYNCOPE-1396] Configuration option for TLSClientParameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154209798861.6114.16206640025863722906@gitbox.apache.org> From: ilgrosso@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: syncope X-Git-Refname: refs/heads/2_1_X X-Git-Reftype: branch X-Git-Oldrev: b9779f3c38626444750852328bd5a8a7ed511937 X-Git-Newrev: 480a0e78c02757c9d91cffd71cf8b8b9cbcc6a51 X-Git-Rev: 480a0e78c02757c9d91cffd71cf8b8b9cbcc6a51 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch 2_1_X in repository https://gitbox.apache.org/repos/asf/syncope.git The following commit(s) were added to refs/heads/2_1_X by this push: new 480a0e7 [SYNCOPE-1396] Configuration option for TLSClientParameters 480a0e7 is described below commit 480a0e78c02757c9d91cffd71cf8b8b9cbcc6a51 Author: Francesco Chicchiriccò AuthorDate: Tue Nov 13 09:28:51 2018 +0100 [SYNCOPE-1396] Configuration option for TLSClientParameters --- .../org/apache/syncope/client/lib/SyncopeClient.java | 12 +++++++++++- .../syncope/client/lib/SyncopeClientFactoryBean.java | 19 ++++++++++++++++++- .../workingwithapachesyncope/restfulservices.adoc | 10 +++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java index 466b266..26bc71b 100644 --- a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java +++ b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java @@ -32,12 +32,14 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.commons.lang3.tuple.Pair; +import org.apache.cxf.configuration.jsse.TLSClientParameters; import org.apache.cxf.jaxrs.client.Client; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.transport.common.gzip.GZIPInInterceptor; import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor; +import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transport.http.URLConnectionHTTPConduit; import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder; @@ -70,12 +72,15 @@ public class SyncopeClient { private final boolean useCompression; + private final TLSClientParameters tlsClientParameters; + public SyncopeClient( final MediaType mediaType, final JAXRSClientFactoryBean restClientFactory, final RestClientExceptionMapper exceptionMapper, final AuthenticationHandler handler, - final boolean useCompression) { + final boolean useCompression, + final TLSClientParameters tlsClientParameters) { this.mediaType = mediaType; this.restClientFactory = restClientFactory; @@ -83,6 +88,7 @@ public class SyncopeClient { this.restClientFactory.setHeaders(new HashMap<>()); } this.exceptionMapper = exceptionMapper; + this.tlsClientParameters = tlsClientParameters; init(handler); this.useCompression = useCompression; } @@ -247,6 +253,10 @@ public class SyncopeClient { config.getInInterceptors().add(new GZIPInInterceptor()); config.getOutInterceptors().add(new GZIPOutInterceptor()); } + if (tlsClientParameters != null) { + HTTPConduit httpConduit = (HTTPConduit) config.getConduit(); + httpConduit.setTlsClientParameters(tlsClientParameters); + } return serviceInstance; } diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java index 90105d0..f055f83 100644 --- a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java +++ b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java @@ -29,6 +29,7 @@ import java.util.Map; import javax.ws.rs.core.MediaType; import javax.xml.bind.Marshaller; import org.apache.commons.lang3.StringUtils; +import org.apache.cxf.configuration.jsse.TLSClientParameters; import org.apache.cxf.feature.Feature; import org.apache.cxf.ext.logging.LoggingFeature; import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; @@ -83,6 +84,8 @@ public class SyncopeClientFactoryBean { private boolean useCompression; + private TLSClientParameters tlsClientParameters; + private JAXRSClientFactoryBean restClientFactoryBean; protected JacksonJaxbJsonProvider defaultJsonProvider() { @@ -226,6 +229,19 @@ public class SyncopeClientFactoryBean { return useCompression; } + /** + * Sets the client TLS configuration. + * + * @param tlsClientParameters client TLS configuration + */ + public void setTlsClientParameters(final TLSClientParameters tlsClientParameters) { + this.tlsClientParameters = tlsClientParameters; + } + + public TLSClientParameters getTlsClientParameters() { + return tlsClientParameters; + } + public JAXRSClientFactoryBean getRestClientFactoryBean() { return restClientFactoryBean == null ? defaultRestClientFactoryBean() @@ -285,6 +301,7 @@ public class SyncopeClientFactoryBean { getRestClientFactoryBean(), getExceptionMapper(), handler, - useCompression); + useCompression, + tlsClientParameters); } } diff --git a/src/main/asciidoc/reference-guide/workingwithapachesyncope/restfulservices.adoc b/src/main/asciidoc/reference-guide/workingwithapachesyncope/restfulservices.adoc index 2b6ce6b..2bc57d8 100644 --- a/src/main/asciidoc/reference-guide/workingwithapachesyncope/restfulservices.adoc +++ b/src/main/asciidoc/reference-guide/workingwithapachesyncope/restfulservices.adoc @@ -550,17 +550,21 @@ SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean(). ---- You might also select a specific <> - other than `Master`, choose to exchange XML payloads - rather -than JSON (default), or to select -https://en.wikipedia.org/wiki/HTTP_compression[HTTP compression^] (more options in the +than JSON (default), to select +https://en.wikipedia.org/wiki/HTTP_compression[HTTP compression^] or to set the +https://cxf.apache.org/javadoc/latest/org/apache/cxf/configuration/jsse/TLSClientParameters.html[TLS client configuration^] +(more options in the http://syncope.apache.org/apidocs/2.1/org/apache/syncope/client/lib/SyncopeClientFactoryBean.html[Javadoc^]): [source,java] ---- +TLSClientParameters tlsClientParameters = ...; SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean(). setAddress("http://localhost:9080/syncope/rest/"). setDomain("Two"). setContentType(SyncopeClientFactoryBean.ContentType.XML). - setUseCompression(true); + setUseCompression(true). + setTlsClientParameters(tlsClientParameters); ---- At this point an instance of `SyncopeClient` can be obtained by passing the login credentials via: