diff options
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav/SerfCallbacks.cxx | 5 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfCallbacks.hxx | 5 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx | 15 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx | 24 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx | 22 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx | 22 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx | 29 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfRequestProcessorImpl.hxx | 7 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfSession.cxx | 15 | ||||
-rw-r--r-- | ucb/source/ucp/webdav/SerfSession.hxx | 2 |
10 files changed, 83 insertions, 63 deletions
diff --git a/ucb/source/ucp/webdav/SerfCallbacks.cxx b/ucb/source/ucp/webdav/SerfCallbacks.cxx index c0aa58bf0e32..afa177a4913a 100644 --- a/ucb/source/ucp/webdav/SerfCallbacks.cxx +++ b/ucb/source/ucp/webdav/SerfCallbacks.cxx @@ -59,8 +59,9 @@ extern "C" apr_status_t Serf_Credentials( char **username, extern "C" apr_status_t Serf_CertificateChainValidation( void* pSerfSession, int nFailures, - const char** pCertificateChainBase64Encoded, - int nCertificateChainLength) + int nErrorCode, + const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded, + apr_size_t nCertificateChainLength) { return static_cast<SerfSession*>(pSerfSession) ->verifySerfCertificateChain(nFailures, pCertificateChainBase64Encoded, nCertificateChainLength); diff --git a/ucb/source/ucp/webdav/SerfCallbacks.hxx b/ucb/source/ucp/webdav/SerfCallbacks.hxx index 78b0d06e1fd7..1d8776fdabfc 100644 --- a/ucb/source/ucp/webdav/SerfCallbacks.hxx +++ b/ucb/source/ucp/webdav/SerfCallbacks.hxx @@ -41,8 +41,9 @@ extern "C" apr_status_t Serf_Credentials( char **username, extern "C" apr_status_t Serf_CertificateChainValidation( void* pSerfSession, int nFailures, - const char** pCertificateChainBase64Encoded, - int nCertificateChainLength); + int error_depth, + const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded, + apr_size_t nCertificateChainLength); extern "C" apr_status_t Serf_SetupRequest( serf_request_t *request, void *setup_baton, diff --git a/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx index 5bf1ce9f548e..4135e5d251dd 100644 --- a/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx +++ b/ucb/source/ucp/webdav/SerfPostReqProcImpl.cxx @@ -73,10 +73,6 @@ serf_bucket_t * SerfPostReqProcImpl::createSerfRequestBucket( serf_request_t * i if ( mpPostData != 0 && mnPostDataLen > 0 ) { body_bkt = SERF_BUCKET_SIMPLE_STRING_LEN( mpPostData, mnPostDataLen, pSerfBucketAlloc ); - if ( useChunkedEncoding() ) - { - body_bkt = serf_bucket_chunk_create( body_bkt, pSerfBucketAlloc ); - } } // create serf request @@ -91,16 +87,9 @@ serf_bucket_t * SerfPostReqProcImpl::createSerfRequestBucket( serf_request_t * i // general header fields provided by caller setRequestHeaders( hdrs_bkt ); + handleChunkedEncoding(req_bkt, mnPostDataLen); + // request specific header fields - if ( body_bkt != 0 ) - { - if ( useChunkedEncoding() ) - { - serf_bucket_headers_set( hdrs_bkt, "Transfer-Encoding", "chunked"); - } - serf_bucket_headers_set( hdrs_bkt, "Content-Length", - OUStringToOString( OUString::valueOf( (sal_Int32)mnPostDataLen ), RTL_TEXTENCODING_UTF8 ) ); - } if ( mpContentType != 0 ) { serf_bucket_headers_set( hdrs_bkt, "Content-Type", mpContentType ); diff --git a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx index 9cff1d7be13e..1d5d0f01abb5 100644 --- a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx +++ b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx @@ -147,23 +147,25 @@ serf_bucket_t * SerfPropFindReqProcImpl::createSerfRequestBucket( serf_request_t getPathStr(), body_bkt, pSerfBucketAlloc ); + handleChunkedEncoding(req_bkt, aBodyText.getLength()); // set request header fields serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt ); - // general header fields provided by caller - setRequestHeaders( hdrs_bkt ); - - // request specific header fields - serf_bucket_headers_set( hdrs_bkt, "Depth", mDepthStr ); - if ( body_bkt != 0 && aBodyText.getLength() > 0 ) + if (hdrs_bkt != NULL) { - if ( useChunkedEncoding() ) + // general header fields provided by caller + setRequestHeaders( hdrs_bkt ); + + // request specific header fields + serf_bucket_headers_set( hdrs_bkt, "Depth", mDepthStr ); + if (hdrs_bkt!=NULL && body_bkt != 0 && aBodyText.getLength() > 0 ) { - serf_bucket_headers_set( hdrs_bkt, "Transfer-Encoding", "chunked"); + serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" ); } - serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" ); - serf_bucket_headers_set( hdrs_bkt, "Content-Length", - OUStringToOString( OUString::valueOf( aBodyText.getLength() ), RTL_TEXTENCODING_UTF8 ) ); + } + else + { + OSL_ASSERT("Headers Bucket missing"); } return req_bkt; diff --git a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx index 809a81e12cdd..86a97aee971b 100644 --- a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx +++ b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx @@ -152,22 +152,24 @@ serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_ getPathStr(), body_bkt, pSerfBucketAlloc ) ; + handleChunkedEncoding(req_bkt, aBodyText.getLength()); // set request header fields serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt ); - // general header fields provided by caller - setRequestHeaders( hdrs_bkt ); - - // request specific header fields - if ( body_bkt != 0 && aBodyText.getLength() > 0 ) + if (hdrs_bkt != NULL) { - if ( useChunkedEncoding() ) + // general header fields provided by caller + setRequestHeaders( hdrs_bkt ); + + // request specific header fields + if ( body_bkt != 0 && aBodyText.getLength() > 0 ) { - serf_bucket_headers_set( hdrs_bkt, "Transfer-Encoding", "chunked"); + serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" ); } - serf_bucket_headers_set( hdrs_bkt, "Content-Type", "application/xml" ); - serf_bucket_headers_set( hdrs_bkt, "Content-Length", - OUStringToOString( OUString::valueOf( aBodyText.getLength() ), RTL_TEXTENCODING_UTF8 ) ); + } + else + { + OSL_ASSERT("Headers Bucket missing"); } return req_bkt; diff --git a/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx index e3617f9c57fd..e98ca265de2f 100644 --- a/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx +++ b/ucb/source/ucp/webdav/SerfPutReqProcImpl.cxx @@ -49,10 +49,6 @@ serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in if ( mpData != 0 && mnDataLen > 0 ) { body_bkt = SERF_BUCKET_SIMPLE_STRING_LEN( mpData, mnDataLen, pSerfBucketAlloc ); - if ( useChunkedEncoding() ) - { - body_bkt = serf_bucket_chunk_create( body_bkt, pSerfBucketAlloc ); - } } // create serf request @@ -61,23 +57,7 @@ serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in getPathStr(), body_bkt, serf_request_get_alloc( inSerfRequest ) ); - - // set request header fields - serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt ); - // general header fields provided by caller - setRequestHeaders( hdrs_bkt ); - - // request specific header fields - if ( body_bkt != 0 ) - { - if ( useChunkedEncoding() ) - { - serf_bucket_headers_set( hdrs_bkt, "Transfer-Encoding", "chunked"); - } - serf_bucket_headers_set( hdrs_bkt, "Content-Length", - OUStringToOString( OUString::valueOf( (sal_Int32)mnDataLen ), RTL_TEXTENCODING_UTF8 ) ); - } - + handleChunkedEncoding(req_bkt, mnDataLen); // set request header fields serf_bucket_t* hdrs_bkt = serf_bucket_request_get_headers( req_bkt ); diff --git a/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx b/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx index 49963ca09fce..801a920d74cc 100644 --- a/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx +++ b/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx @@ -20,6 +20,14 @@ #include "SerfRequestProcessorImpl.hxx" #include "webdavuseragent.hxx" +namespace +{ +// Define a magic value that is used by serf to reset chunked +// encoding. The value definition is not supported by serf, hence the +// definition here. +static const apr_int64_t SERF_UNKNOWN_LENGTH (-1); +} + namespace http_dav_ucp { @@ -50,6 +58,27 @@ bool SerfRequestProcessorImpl::useChunkedEncoding() const return mbUseChunkedEncoding; } + +void SerfRequestProcessorImpl::handleChunkedEncoding ( + serf_bucket_t* pRequestBucket, + apr_int64_t nLength) const +{ + if (pRequestBucket != NULL) + { + if (useChunkedEncoding()) + { + // Activate chunked encoding. + serf_bucket_request_set_CL(pRequestBucket, SERF_UNKNOWN_LENGTH); + } + else + { + // Deactivate chunked encoding by setting the length. + serf_bucket_request_set_CL(pRequestBucket, nLength); + } + } +} + + void SerfRequestProcessorImpl::setRequestHeaders( serf_bucket_t* inoutSerfHeaderBucket ) { bool bHasUserAgent( false ); diff --git a/ucb/source/ucp/webdav/SerfRequestProcessorImpl.hxx b/ucb/source/ucp/webdav/SerfRequestProcessorImpl.hxx index 1c1562151f76..8e004169c34c 100644 --- a/ucb/source/ucp/webdav/SerfRequestProcessorImpl.hxx +++ b/ucb/source/ucp/webdav/SerfRequestProcessorImpl.hxx @@ -47,6 +47,13 @@ public: void activateChunkedEncoding(); + /** Turn chunked encoding on or off, dependeing on the result of + useChunkedEncoding(). + */ + void handleChunkedEncoding ( + serf_bucket_t* pRequestBucket, + apr_int64_t nLength) const; + protected: void setRequestHeaders( serf_bucket_t* inoutSerfHeaderBucket ); diff --git a/ucb/source/ucp/webdav/SerfSession.cxx b/ucb/source/ucp/webdav/SerfSession.cxx index 4364a692c12c..0b56bd1c2592 100644 --- a/ucb/source/ucp/webdav/SerfSession.cxx +++ b/ucb/source/ucp/webdav/SerfSession.cxx @@ -269,6 +269,7 @@ apr_status_t SerfSession::setupSerfConnection( apr_socket_t * inAprSocket, */ serf_ssl_server_cert_chain_callback_set( serf_bucket_ssl_decrypt_context_get(tmpInputBkt), + NULL, Serf_CertificateChainValidation, this); serf_ssl_set_hostname( serf_bucket_ssl_decrypt_context_get( tmpInputBkt ), @@ -366,7 +367,7 @@ namespace { apr_status_t SerfSession::verifySerfCertificateChain ( int, - const char** pCertificateChainBase64Encoded, + const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded, int nCertificateChainLength) { // Check arguments. @@ -411,9 +412,13 @@ apr_status_t SerfSession::verifySerfCertificateChain ( } // Decode the server certificate. + const char* sBase64EncodedServerCertificate ( + serf_ssl_cert_export( + pCertificateChainBase64Encoded[0], + getAprPool())); uno::Reference< security::XCertificate > xServerCertificate( xSecurityEnv->createCertificateFromAscii( - OUString::createFromAscii(pCertificateChainBase64Encoded[0]))); + OUString::createFromAscii(sBase64EncodedServerCertificate))); if ( ! xServerCertificate.is()) return SERF_SSL_CERT_UNKNOWN_FAILURE; @@ -454,9 +459,13 @@ apr_status_t SerfSession::verifySerfCertificateChain ( std::vector< uno::Reference< security::XCertificate > > aChain; for (int nIndex=1; nIndex<nCertificateChainLength; ++nIndex) { + const char* sBase64EncodedCertificate ( + serf_ssl_cert_export( + pCertificateChainBase64Encoded[nIndex], + getAprPool())); uno::Reference< security::XCertificate > xCertificate( xSecurityEnv->createCertificateFromAscii( - OUString::createFromAscii(pCertificateChainBase64Encoded[nIndex]))); + OUString::createFromAscii(sBase64EncodedCertificate))); if ( ! xCertificate.is()) return SERF_SSL_CERT_UNKNOWN_FAILURE; aChain.push_back(xCertificate); diff --git a/ucb/source/ucp/webdav/SerfSession.hxx b/ucb/source/ucp/webdav/SerfSession.hxx index a84fcc1abeba..291c1858e6bf 100644 --- a/ucb/source/ucp/webdav/SerfSession.hxx +++ b/ucb/source/ucp/webdav/SerfSession.hxx @@ -96,7 +96,7 @@ public: apr_status_t verifySerfCertificateChain ( int nFailures, - const char** pCertificateChainBase64Encoded, + const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded, int nCertificateChainLength); serf_bucket_t* acceptSerfResponse( serf_request_t * inSerfRequest, |