Bump lib version.
[shibboleth/cpp-opensaml.git] / saml / exceptions.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/exceptions.h
19  * 
20  * Exception classes
21  */
22  
23 #ifndef __saml_exceptions_h__
24 #define __saml_exceptions_h__
25
26 #include <saml/base.h>
27 #include <xmltooling/exceptions.h>
28
29 namespace opensaml {
30     
31     namespace saml2p {
32         class SAML_API Status;
33     };
34     namespace saml2md {
35         class SAML_API EntityDescriptor;
36         class SAML_API RoleDescriptor;
37     };
38     
39     DECL_XMLTOOLING_EXCEPTION(SecurityPolicyException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions in security policy processing);
40     DECL_XMLTOOLING_EXCEPTION(BindingException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions in SAML binding processing);
41     DECL_XMLTOOLING_EXCEPTION(ProfileException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::ValidationException,Exceptions in SAML profile processing);
42     DECL_XMLTOOLING_EXCEPTION(FatalProfileException,SAML_EXCEPTIONAPI(SAML_API),opensaml,ProfileException,Fatal exceptions in SAML profile processing);
43     DECL_XMLTOOLING_EXCEPTION(RetryableProfileException,SAML_EXCEPTIONAPI(SAML_API),opensaml,ProfileException,Non-fatal exceptions in SAML profile processing);
44
45     /**
46      * Attaches metadata-derived information as exception properties and optionally
47      * rethrows the object. The following named properties are attached, when possible:
48      * 
49      *  <dl>
50      *  <dt>entityID</dt>       <dd>The unique ID of the entity</dd>
51      *  <dt>errorURL</dt>       <dd>The error support URL of a random role</dd>
52      *  <dt>contactName</dt>    <dd>A formatted support or technical contact name</dd>
53      *  <dt>contactEmail</dt>   <dd>A contact email address</dd>
54      *  <dt>statusCode</dt>     <dd>Top-level status code from Status object</dd>
55      *  <dt>statusCode2</dt>    <dd>Second-level status code from Status object</dd>
56      *  <dt>statusMessage</dt>  <dd>StatusMessage from Status object</dd>
57      *  </dl>
58      * 
59      * @param e         pointer to exception object
60      * @param entity    pointer to entity
61      * @param status    pointer to Status from message 
62      * @param rethrow   true iff the exception should be rethrown
63      */
64     void SAML_API annotateException(
65         xmltooling::XMLToolingException* e,
66         const saml2md::EntityDescriptor* entity,
67         const saml2p::Status* status=NULL,
68         bool rethrow=true
69         );
70     
71     /**
72      * Attaches metadata-derived information as exception properties and optionally
73      * rethrows the object. The following named properties are attached, when possible:
74      * 
75      *  <dl>
76      *  <dt>entityID</dt>       <dd>The unique ID of the entity</dd>
77      *  <dt>errorURL</dt>       <dd>The error support URL of the role</dd>
78      *  <dt>contactName</dt>    <dd>A formatted support or technical contact name</dd>
79      *  <dt>contactEmail</dt>   <dd>A contact email address</dd>
80      *  <dt>statusCode</dt>     <dd>Top-level status code from Status object</dd>
81      *  <dt>statusCode2</dt>    <dd>Second-level status code from Status object</dd>
82      *  </dl>
83      * 
84      * @param e         pointer to exception object
85      * @param entity    pointer to role
86      * @param status    pointer to Status from message 
87      * @param rethrow   true iff the exception should be rethrown
88      */
89     void SAML_API annotateException(
90         xmltooling::XMLToolingException* e,
91         const saml2md::RoleDescriptor* role,
92         const saml2p::Status* status=NULL,
93         bool rethrow=true
94         );
95 };
96
97 #endif /* __saml_exceptions_h__ */