MessageEncoder, ArtifactMap, and SAML 1.x encoder classes.
[shibboleth/cpp-opensaml.git] / saml / binding / ArtifactMap.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /**\r
18  * @file saml/binding/ArtifactMap.h\r
19  * \r
20  * Helper class for SAMLArtifact mapping and retrieval.\r
21  */\r
22 \r
23 #ifndef __saml_artmap_h__\r
24 #define __saml_artmap_h__\r
25 \r
26 #include <saml/base.h>\r
27 #include <xmltooling/XMLObject.h>\r
28 #include <xmltooling/util/StorageService.h>\r
29 #include <xmltooling/util/Threads.h>\r
30 \r
31 namespace opensaml {\r
32 \r
33     class SAML_API SAMLArtifact;\r
34     class SAML_DLLLOCAL ArtifactMappings;\r
35     \r
36     /**\r
37      * Helper class for SAMLArtifact mapping and retrieval.\r
38      */\r
39     class SAML_API ArtifactMap\r
40     {\r
41         MAKE_NONCOPYABLE(ArtifactMap);\r
42     public:\r
43         \r
44         /**\r
45          * Creates a map on top of a particular storage service context, or in-memory.\r
46          * \r
47          * @param storage       pointer to a StorageService, or NULL to keep map in memory\r
48          * @param context       optional label for storage context\r
49          * @param artifactTTL   time to live value, determines how long artifact remains valid\r
50          */\r
51         ArtifactMap(xmltooling::StorageService* storage=NULL, const char* context=NULL, int artifactTTL=180);\r
52 \r
53         virtual ~ArtifactMap();\r
54         \r
55         /**\r
56          * Associates XML content with an artifact and optionally a specific relying party.\r
57          * Specifying no relying party means that the first attempt to resolve the artifact\r
58          * will succeed. The XML content cannot have a parent object, and any existing references\r
59          * to the content will be invalidated.\r
60          * \r
61          * @param content       the XML content to map to an artifact\r
62          * @param artifact      the artifact representing the XML content\r
63          * @param relyingParty  entityID of the party authorized to resolve the artifact\r
64          * @return the generated artifact\r
65          */\r
66         virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=NULL);\r
67         \r
68         /**\r
69          * Retrieves the XML content represented by the artifact. The identity of the\r
70          * relying party can be supplied, if known. If the wrong party tries to resolve\r
71          * an artifact, an exception will be thrown and the mapping will be removed.\r
72          * The caller is responsible for freeing the XML content returned.\r
73          * \r
74          * @param artifact      the artifact representing the XML content\r
75          * @param relyingParty  entityID of the party trying to resolve the artifact\r
76          * @return the XML content\r
77          */\r
78         virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=NULL);\r
79 \r
80     private:\r
81         xmltooling::StorageService* m_storage;\r
82         std::string m_context;\r
83         ArtifactMappings* m_mappings;\r
84         int m_artifactTTL;\r
85     };\r
86 };\r
87 \r
88 #endif /* __saml_artmap_h__ */\r