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_CertificationValidation( void *data,
65                                                       int failures,
66                                                       const serf_ssl_certificate_t *cert )
67 {
68     SerfSession* pSerfSession = static_cast< SerfSession* >( data );
69     return pSerfSession->verifySerfCertificate( failures,
70                                                 cert );
71 }
72 
73 extern "C" apr_status_t Serf_SetupRequest( serf_request_t *request,
74                                            void *setup_baton,
75                                            serf_bucket_t **req_bkt,
76                                            serf_response_acceptor_t *acceptor,
77                                            void **acceptor_baton,
78                                            serf_response_handler_t *handler,
79                                            void **handler_baton,
80                                            apr_pool_t * pool )
81 {
82     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( setup_baton );
83     return pReqProc->setupSerfRequest( request,
84                                        req_bkt,
85                                        acceptor,
86                                        acceptor_baton,
87                                        handler,
88                                        handler_baton,
89                                        pool );
90 }
91 
92 extern "C" serf_bucket_t* Serf_AcceptResponse( serf_request_t *request,
93                                                serf_bucket_t *stream,
94                                                void *acceptor_baton,
95                                                apr_pool_t *pool )
96 {
97     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( acceptor_baton );
98     return pReqProc->acceptSerfResponse( request,
99                                          stream,
100                                          pool );
101 }
102 
103 extern "C" apr_status_t Serf_HandleResponse( serf_request_t *request,
104                                              serf_bucket_t *response,
105                                              void *handler_baton,
106                                              apr_pool_t *pool )
107 {
108     SerfRequestProcessor* pReqProc = static_cast< SerfRequestProcessor* >( handler_baton );
109     return pReqProc->handleSerfResponse( request,
110                                          response,
111                                          pool );
112 }
113 
114