Major revamp of credential and trust handling code, PKIX engine still needs work.
[shibboleth/cpp-opensaml.git] / saml / saml2 / binding / SAML2SOAPClient.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 saml/saml2/binding/SAML2SOAPClient.h
19  * 
20  * Specialized SOAPClient for SAML 2.0 SOAP binding.
21  */
22
23 #ifndef __saml2_soap11client_h__
24 #define __saml2_soap11client_h__
25
26 #include <saml/binding/SOAPClient.h>
27
28 namespace opensaml {
29
30     namespace saml2p {
31         
32         class SAML_API RequestAbstractType;
33         class SAML_API StatusResponseType;
34         class SAML_API Status;
35
36         /**
37          * Specialized SOAPClient for SAML 2.0 SOAP binding.
38          */
39         class SAML_API SAML2SOAPClient
40         {
41         public:
42             /**
43              * Constructor
44              * 
45              * @param soaper    reference to SOAPClient object to use for call
46              */
47             SAML2SOAPClient(SOAPClient& soaper) : m_soaper(soaper), m_correlate(NULL) {
48             }
49             
50             virtual ~SAML2SOAPClient() {
51                 XMLString::release(&m_correlate);
52             }
53     
54             /**
55              * Specialized method for sending SAML 2.0 requests. The SOAP layer will be
56              * constructed automatically.
57              * 
58              * <p>The request will be freed by the client object regardless of the outcome.
59              * 
60              * @param request   SAML request to send
61              * @param peer      peer to send message to, expressed in metadata criteria terms
62              * @param endpoint  URL of endpoint to recieve message
63              */
64             virtual void sendSAML(RequestAbstractType* request, saml2md::MetadataCredentialCriteria& peer, const char* endpoint);
65             
66             /**
67              * Specialized method for receiving SAML 2.0 responses. The SOAP layer will be
68              * evaluated automatically, and the attached policy will be applied to the Response.
69              * 
70              * <p>The caller is responsible for freeing the response.
71              * 
72              * @return SAML 2.0 response, after SecurityPolicy has been applied
73              */
74             virtual StatusResponseType* receiveSAML();
75
76         protected:
77             /**
78              * Handling of SAML errors.
79              * 
80              * @param status SAML Status received by client
81              * @return true iff the error should be treated as a fatal error
82              */
83             virtual bool handleError(const Status& status);
84
85             /** SOAP client object */
86             SOAPClient& m_soaper;
87
88         private:
89             XMLCh* m_correlate;
90         };
91         
92     };
93 };
94
95 #endif /* __saml2_soap11client_h__ */