Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A63F118EBF for ; Thu, 7 Jan 2016 13:36:15 +0000 (UTC) Received: (qmail 91157 invoked by uid 500); 7 Jan 2016 13:36:15 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 91110 invoked by uid 500); 7 Jan 2016 13:36:15 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 91099 invoked by uid 99); 7 Jan 2016 13:36:15 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jan 2016 13:36:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id AAB9318050E for ; Thu, 7 Jan 2016 13:36:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.247 X-Spam-Level: * X-Spam-Status: No, score=1.247 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id DhrIsseCyv6y for ; Thu, 7 Jan 2016 13:36:07 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id C6695439F6 for ; Thu, 7 Jan 2016 13:36:06 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 4E92CE00AF for ; Thu, 7 Jan 2016 13:36:06 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id F080F3A07DF for ; Thu, 7 Jan 2016 13:36:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1723539 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemi... Date: Thu, 07 Jan 2016 13:36:05 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160107133605.F080F3A07DF@svn01-us-west.apache.org> Author: fmui Date: Thu Jan 7 13:36:05 2016 New Revision: 1723539 URL: http://svn.apache.org/viewvc?rev=1723539&view=rev Log: CMIS-965: Web Services client: added session parameters to control temp files Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java?rev=1723539&r1=1723538&r2=1723539&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/SessionParameterMap.java Thu Jan 7 13:36:05 2016 @@ -172,6 +172,25 @@ public class SessionParameterMap extends } /** + * Sets the Web Service temp directory. + * + * @param tempDir + * path of the temp directory + * @param encrypt + * {@code true} if temp files should be encrypted, {@code false} + * otherwise + */ + public void setWebServicesMemoryTempDirectory(String tempDir, boolean encrypt) { + if (tempDir == null) { + remove(SessionParameter.WEBSERVICES_TEMP_DIRECTORY); + remove(SessionParameter.WEBSERVICES_TEMP_ENCRYPT); + } else { + put(SessionParameter.WEBSERVICES_TEMP_DIRECTORY, tempDir); + put(SessionParameter.WEBSERVICES_TEMP_ENCRYPT, encrypt); + } + } + + /** * Sets the Browser URL and sets the binding to Browser. * * @param url Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java?rev=1723539&r1=1723538&r2=1723539&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java Thu Jan 7 13:36:05 2016 @@ -22,6 +22,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSocketFactory; import javax.xml.namespace.QName; import javax.xml.ws.Binding; import javax.xml.ws.BindingProvider; @@ -29,10 +31,13 @@ import javax.xml.ws.soap.MTOMFeature; import javax.xml.ws.soap.SOAPBinding; import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper; +import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession; import org.apache.chemistry.opencmis.commons.SessionParameter; import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException; import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException; import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider; +import org.apache.cxf.Bus; +import org.apache.cxf.configuration.jsse.TLSClientParameters; import org.apache.cxf.endpoint.Client; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.headers.Header; @@ -48,6 +53,21 @@ import org.w3c.dom.Element; public class CXFPortProvider extends AbstractPortProvider { private static final Logger LOG = LoggerFactory.getLogger(CXFPortProvider.class); + private int contentThreshold; + private int responseThreshold; + + @Override + public void setSession(BindingSession session) { + super.setSession(session); + + contentThreshold = session.get(SessionParameter.WEBSERVICES_MEMORY_THRESHOLD, 4 * 1024 * 1024); + responseThreshold = session.get(SessionParameter.WEBSERVICES_REPSONSE_MEMORY_THRESHOLD, -1); + + if (responseThreshold > contentThreshold) { + contentThreshold = responseThreshold; + } + } + /** * Creates a port object. */ @@ -65,6 +85,31 @@ public class CXFPortProvider extends Abs Binding binding = portObject.getBinding(); ((SOAPBinding) binding).setMTOMEnabled(true); + Client client = ClientProxy.getClient(portObject); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + httpClientPolicy.setAllowChunking(true); + + // temp files and large stream handlding + Bus bus = client.getBus(); + + Object tempDir = getSession().get(SessionParameter.WEBSERVICES_TEMP_DIRECTORY); + if (tempDir != null) { + bus.setProperty("bus.io.CachedOutputStream.OutputDirectory", tempDir.toString()); + } + + if (serviceHolder.getService().handlesContent()) { + bus.setProperty("bus.io.CachedOutputStream.Threshold", String.valueOf(contentThreshold)); + } else if (responseThreshold > -1) { + bus.setProperty("bus.io.CachedOutputStream.Threshold", String.valueOf(responseThreshold)); + } + + bus.setProperty("bus.io.CachedOutputStream.MaxSize", "-1"); + + if (getSession().get(SessionParameter.WEBSERVICES_TEMP_ENCRYPT, false)) { + bus.setProperty("bus.io.CachedOutputStream.CipherTransformation", "AES/CTR/PKCS5Padding"); + } + // add SOAP and HTTP authentication headers AuthenticationProvider authProvider = CmisBindingsHelper.getAuthenticationProvider(getSession()); Map> httpHeaders = null; @@ -82,6 +127,20 @@ public class CXFPortProvider extends Abs String url = (serviceHolder.getEndpointUrl() != null ? serviceHolder.getEndpointUrl().toString() : serviceHolder.getServiceObject().getWSDLDocumentLocation().toString()); httpHeaders = authProvider.getHTTPHeaders(url); + + // SSL factory and hostname verifier + SSLSocketFactory sslSocketFactory = authProvider.getSSLSocketFactory(); + HostnameVerifier hostnameVerifier = authProvider.getHostnameVerifier(); + if (sslSocketFactory != null || hostnameVerifier != null) { + TLSClientParameters tlsCP = new TLSClientParameters(); + if (sslSocketFactory != null) { + tlsCP.setSSLSocketFactory(sslSocketFactory); + } + if (hostnameVerifier != null) { + tlsCP.setHostnameVerifier(hostnameVerifier); + } + http.setTlsClientParameters(tlsCP); + } } // set HTTP headers @@ -90,11 +149,6 @@ public class CXFPortProvider extends Abs // set endpoint URL setEndpointUrl(portObject, serviceHolder.getEndpointUrl()); - Client client = ClientProxy.getClient(portObject); - HTTPConduit http = (HTTPConduit) client.getConduit(); - HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); - httpClientPolicy.setAllowChunking(true); - // timeouts int connectTimeout = getSession().get(SessionParameter.CONNECT_TIMEOUT, -1); if (connectTimeout >= 0) { Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1723539&r1=1723538&r2=1723539&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java Thu Jan 7 13:36:05 2016 @@ -181,7 +181,7 @@ package org.apache.chemistry.opencmis.co * no * - * - * + * * {@link #USER_AGENT} * User agent header * AtomPub, Web Services, Browser @@ -509,6 +509,22 @@ package org.apache.chemistry.opencmis.co * (JAX-WS implementation default) * * + * {@link #WEBSERVICES_TEMP_DIRECTORY} + * Sets the path for temp files to an existing directory + * Web Services + * path to temp directory + * no + * (JAX-WS implementation default) + * + * + * {@link #WEBSERVICES_TEMP_ENCRYPT} + * Defines whether temp files should be encrypted or not + * Web Services + * "true", "false" + * no + * "false" + * + * * Browser Binding * * @@ -628,6 +644,9 @@ public final class SessionParameter { public static final String WEBSERVICES_MEMORY_THRESHOLD = "org.apache.chemistry.opencmis.binding.webservices.memoryThreshold"; public static final String WEBSERVICES_REPSONSE_MEMORY_THRESHOLD = "org.apache.chemistry.opencmis.binding.webservices.responseMemoryThreshold"; + public static final String WEBSERVICES_TEMP_DIRECTORY = "org.apache.chemistry.opencmis.binding.webservices.tempDirectory"; + public static final String WEBSERVICES_TEMP_ENCRYPT = "org.apache.chemistry.opencmis.binding.webservices.tempEncrypt"; + public static final String WEBSERVICES_PORT_PROVIDER_CLASS = "org.apache.chemistry.opencmis.binding.webservices.portprovider.classname"; public static final String WEBSERVICES_JAXWS_IMPL = "org.apache.chemistry.opencmis.binding.webservices.jaxws.impl"; Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java?rev=1723539&r1=1723538&r2=1723539&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java Thu Jan 7 13:36:05 2016 @@ -264,8 +264,12 @@ public class CmisWebServicesServlet exte Bus bus = getBus(); BusFactory.setDefaultBus(bus); - bus.setProperty("bus.io.CachedOutputStream.OutputDirectory", factory.getTempDirectory().getAbsolutePath()); - bus.setProperty("bus.io.CachedOutputStream.Threshold", String.valueOf(factory.getMemoryThreshold())); + if (factory.getTempDirectory() != null) { + bus.setProperty("bus.io.CachedOutputStream.OutputDirectory", factory.getTempDirectory().getAbsolutePath()); + } + if (factory.getMemoryThreshold() >= 0) { + bus.setProperty("bus.io.CachedOutputStream.Threshold", String.valueOf(factory.getMemoryThreshold())); + } bus.setProperty("bus.io.CachedOutputStream.MaxSize", "-1"); if (factory.encryptTempFiles()) { bus.setProperty("bus.io.CachedOutputStream.CipherTransformation", "AES/CTR/PKCS5Padding");