1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_ucb.hxx"
24 
25 #include <SerfCallbacks.hxx>
26 
27 #include <SerfSession.hxx>
28 #include <SerfRequestProcessor.hxx>
29 
30 using namespace http_dav_ucp;
31 
32 extern "C" apr_status_t Serf_ConnectSetup( apr_socket_t *skt,
33                                            serf_bucket_t **read_bkt,
34                                            serf_bucket_t **write_bkt,
35                                            void *setup_baton,
36                                            apr_pool_t *pool )
37 {
38     SerfSession* pSerfSession = static_cast< SerfSession* >( setup_baton );
39     return pSerfSession->setupSerfConnection( skt,
40                                               read_bkt,
41                                               write_bkt,
42                                               pool );
43 }
44 
45 extern "C" apr_status_t Serf_Credentials( char **username,
46                                           char **password,
47                                           serf_request_t *request,
48                                           void *baton,
49                                           int code,
50                                           const char *authn_type,
51                                           const char *realm,
52                                           apr_pool_t *pool )
53 {
54     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( baton );
55     return pReqProc->provideSerfCredentials( username,
56                                              password,
57                                              request,
58                                              code,
59                                              authn_type,
60                                              realm,
61                                              pool );
62 }
63 
64 extern "C" apr_status_t Serf_CertificateChainValidation(
65     void* pSerfSession,
66     int nFailures,
67     const char** pCertificateChainBase64Encoded,
68     int nCertificateChainLength)
69 {
70     return static_cast<SerfSession*>(pSerfSession)
71         ->verifySerfCertificateChain(nFailures, pCertificateChainBase64Encoded, nCertificateChainLength);
72 }
73 
74 extern "C" apr_status_t Serf_SetupRequest( serf_request_t *request,
75                                            void *setup_baton,
76                                            serf_bucket_t **req_bkt,
77                                            serf_response_acceptor_t *acceptor,
78                                            void **acceptor_baton,
79                                            serf_response_handler_t *handler,
80                                            void **handler_baton,
81                                            apr_pool_t * pool )
82 {
83     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( setup_baton );
84     return pReqProc->setupSerfRequest( request,
85                                        req_bkt,
86                                        acceptor,
87                                        acceptor_baton,
88                                        handler,
89                                        handler_baton,
90                                        pool );
91 }
92 
93 extern "C" serf_bucket_t* Serf_AcceptResponse( serf_request_t *request,
94                                                serf_bucket_t *stream,
95                                                void *acceptor_baton,
96                                                apr_pool_t *pool )
97 {
98     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( acceptor_baton );
99     return pReqProc->acceptSerfResponse( request,
100                                          stream,
101                                          pool );
102 }
103 
104 extern "C" apr_status_t Serf_HandleResponse( serf_request_t *request,
105                                              serf_bucket_t *response,
106                                              void *handler_baton,
107                                              apr_pool_t *pool )
108 {
109     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( handler_baton );
110     return pReqProc->handleSerfResponse( request,
111                                          response,
112                                          pool );
113 }
114 
115