Reducing header overuse, non-inlining selected methods (CPPOST-35).
[shibboleth/cpp-opensaml.git] / saml / saml1 / binding / SAML1SOAPClient.h
1 /*
2  *  Copyright 2001-2009 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/saml1/binding/SAML1SOAPClient.h
19  * 
20  * Client class for SAML 1.x SOAP binding.
21  */
22
23 #ifndef __saml1_soap11client_h__
24 #define __saml1_soap11client_h__
25
26 #include <saml/base.h>
27
28 namespace opensaml {
29
30     class SAML_API SOAPClient;
31
32     namespace saml2md {
33         class SAML_API MetadataCredentialCriteria;
34     };
35
36     namespace saml1p {
37         
38         class SAML_API Request;
39         class SAML_API Response;
40         class SAML_API Status;
41
42         /**
43          *  Client class for SAML 1.x SOAP binding.
44          */
45         class SAML_API SAML1SOAPClient
46         {
47         public:
48             /**
49              * Constructor
50              * 
51              * @param soaper            reference to SOAPClient object to use for call
52              * @param fatalSAMLErrors   true iff a non-successful SAML Status code should be fatal
53              */
54             SAML1SOAPClient(SOAPClient& soaper, bool fatalSAMLErrors=true) : m_soaper(soaper), m_fatal(fatalSAMLErrors), m_correlate(NULL) {
55             }
56             
57             virtual ~SAML1SOAPClient() {
58                 xercesc::XMLString::release(&m_correlate);
59             }
60     
61             /**
62              * Specialized method for sending SAML 1.x requests. The SOAP layer will be
63              * constructed automatically.
64              * 
65              * <p>The request will be freed by the client object regardless of the outcome.
66              * 
67              * @param request   SAML request to send
68              * @param from      identity of sending application
69              * @param to        peer to send message to, expressed in metadata criteria terms
70              * @param endpoint  URL of endpoint to recieve message
71              */
72             virtual void sendSAML(Request* request, const char* from, saml2md::MetadataCredentialCriteria& to, const char* endpoint);
73             
74             /**
75              * Specialized method for receiving SAML 1.x responses. The SOAP layer will be
76              * evaluated automatically, and the attached policy will be applied to the Response.
77              * 
78              * <p>The caller is responsible for freeing the Response.
79              * 
80              * @return SAML 1.x Response, after SecurityPolicy has been applied
81              */
82             virtual Response* receiveSAML();
83
84         protected:
85             /**
86              * Handling of SAML errors.
87              * 
88              * @param status SAML Status received by client
89              * @return true iff the error should be treated as a fatal error
90              */
91             virtual bool handleError(const Status& status);
92
93             /** SOAP client object. */
94             SOAPClient& m_soaper;
95
96             /** Flag controlling default error handler. */
97             bool m_fatal;
98
99         private:
100             XMLCh* m_correlate;
101         };
102         
103     };
104 };
105
106 #endif /* __saml1_soap11client_h__ */