573f3f1f6c3775c291d73cd83e7a9b50676232c0
[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/security/SecurityPolicy.h>
27 #include <saml/binding/SOAPClient.h>
28 #include <xmltooling/security/CredentialResolver.h>
29
30 namespace shibsp {
31
32     class SHIBSP_API PropertySet;
33
34     /**
35      * Specialized SOAPClient for SP environment.
36      */
37     class SHIBSP_API SOAPClient : public opensaml::SOAPClient
38     {
39     public:
40         /**
41          * Creates a SOAP client instance for an Application to use.
42          * 
43          * @param policy        reference to SP-SecurityPolicy to apply
44          */
45         SOAPClient(SecurityPolicy& policy);
46         
47         virtual ~SOAPClient() {
48             if (m_credResolver)
49                 m_credResolver->unlock();
50         }
51
52         /**
53          * Override handles message signing for SAML payloads.
54          * 
55          * @param env       SOAP envelope to send
56          * @param from      identity of sending application
57          * @param to        peer to send message to, expressed in metadata terms
58          * @param endpoint  URL of endpoint to recieve message
59          */
60         void send(const soap11::Envelope& env, const char* from, opensaml::saml2md::MetadataCredentialCriteria& to, const char* endpoint);
61
62         void reset();
63
64     protected:
65         /**
66          * Override prepares transport by applying policy settings from Application.
67          * 
68          * @param transport reference to transport layer
69          */
70         void prepareTransport(xmltooling::SOAPTransport& transport);
71
72         /** Application supplied to client. */
73         const Application& m_app;
74
75         /** Properties associated with the Application's security policy. */
76         const PropertySet* m_settings;
77
78         /** RelyingParty properties, set after transport prep. */
79         const PropertySet* m_relyingParty;
80
81         /** Locked CredentialResolver for transport, set after transport prep. */
82         xmltooling::CredentialResolver* m_credResolver;
83     };
84
85 };
86
87 #endif /* __shibsp_soap11client_h__ */