Glue SOAP client to SP config, expand policy settings.
[shibboleth/sp.git] / shibsp / binding / SOAPClient.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file shibsp/binding/SOAPClient.h
19  * 
20  * Specialized SOAPClient for SP environment.
21  */
22
23 #ifndef __shibsp_soap11client_h__
24 #define __shibsp_soap11client_h__
25
26 #include <shibsp/Application.h>
27 #include <saml/binding/SOAPClient.h>
28
29 namespace shibsp {
30
31     /**
32      * Specialized SOAPClient for SP environment.
33      */
34     class SHIBSP_API SOAPClient : public opensaml::SOAPClient
35     {
36     public:
37         /**
38          * Creates a SOAP client instance for an Application to use.
39          * 
40          * @param application   reference to Application
41          * @param policy        reference to (empty) SecurityPolicy to apply
42          */
43         SOAPClient(const Application& application, opensaml::SecurityPolicy& policy);
44         
45         virtual ~SOAPClient() {
46             if (m_credResolver)
47                 m_credResolver->unlock();
48         }
49
50         /**
51          * Override handles message signing for SAML payloads.
52          * 
53          * @param env       SOAP envelope to send
54          * @param peer      peer to send message to, expressed in TrustEngine terms
55          * @param endpoint  URL of endpoint to recieve message
56          */
57         void send(const soap11::Envelope& env, const xmltooling::KeyInfoSource& peer, const char* endpoint);
58
59         void reset();
60
61     protected:
62         /**
63          * Override prepares transport by applying policy settings from Application.
64          * 
65          * @param transport reference to transport layer
66          */
67         void prepareTransport(const xmltooling::SOAPTransport& transport);
68
69         /** Application supplied to client. */
70         const Application& m_app;
71
72         /** Properties associated with the Application's security policy. */
73         const PropertySet* m_settings;
74
75         /** CredentialUse properties, set after transport prep. */
76         const PropertySet* m_credUse;
77
78         /** Locked CredentialResolver for transport, set after transport prep. */
79         xmlsignature::CredentialResolver* m_credResolver;
80     };
81
82 };
83
84 #endif /* __shibsp_soap11client_h__ */