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