Boost related changes
[shibboleth/cpp-opensaml.git] / saml / binding / ArtifactMap.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file saml/binding/ArtifactMap.h
23  * 
24  * Helper class for SAMLArtifact mapping and retrieval.
25  */
26
27 #ifndef __saml_artmap_h__
28 #define __saml_artmap_h__
29
30 #include <saml/base.h>
31
32 #include <string>
33 #include <xercesc/dom/DOM.hpp>
34
35 namespace xmltooling {
36     class XMLTOOL_API StorageService;
37     class XMLTOOL_API XMLObject;
38 };
39
40 namespace opensaml {
41
42     class SAML_API SAMLArtifact;
43     class SAML_DLLLOCAL ArtifactMappings;
44     
45 #if defined (_MSC_VER)
46     #pragma warning( push )
47     #pragma warning( disable : 4251 )
48 #endif
49
50     /**
51      * Helper class for SAMLArtifact mapping and retrieval.
52      */
53     class SAML_API ArtifactMap
54     {
55         MAKE_NONCOPYABLE(ArtifactMap);
56     public:
57         
58         /**
59          * Creates a map on top of a particular storage service context, or in-memory.
60          * 
61          * @param storage       pointer to a StorageService, or nullptr to keep map in memory
62          * @param context       optional label for storage context
63          * @param artifactTTL   time to live in seconds, determines how long artifact remains valid
64          */
65         ArtifactMap(xmltooling::StorageService* storage=nullptr, const char* context=nullptr, unsigned int artifactTTL=180);
66
67         /**
68          * Creates a map on top of a particular storage service context, or in-memory.
69          * 
70          * @param e         root of a DOM with optional XML attributes for context and artifactTTL
71          * @param storage   pointer to a StorageService, or nullptr to keep map in memory
72          */
73         ArtifactMap(const xercesc::DOMElement* e, xmltooling::StorageService* storage=nullptr);
74
75         virtual ~ArtifactMap();
76         
77         /**
78          * Associates XML content with an artifact and optionally a specific relying party.
79          * Specifying no relying party means that the first attempt to resolve the artifact
80          * will succeed. The XML content cannot have a parent object, and any existing references
81          * to the content will be invalidated.
82          * 
83          * @param content       the XML content to map to an artifact
84          * @param artifact      the artifact representing the XML content
85          * @param relyingParty  entityID of the party authorized to resolve the artifact
86          * @return the generated artifact
87          */
88         virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=nullptr);
89         
90         /**
91          * Retrieves the XML content represented by the artifact. The identity of the
92          * relying party can be supplied, if known. If the wrong party tries to resolve
93          * an artifact, an exception will be thrown and the mapping will be removed.
94          * The caller is responsible for freeing the XML content returned.
95          * 
96          * @param artifact      the artifact representing the XML content
97          * @param relyingParty  entityID of the party trying to resolve the artifact
98          * @return the XML content
99          */
100         virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=nullptr);
101
102         /**
103          * Retrieves the relying party to whom the artifact was issued.
104          *
105          * @param artifact  the artifact to check
106          * @return  entityID of the party to whom the artifact was issued, if any
107          */
108         virtual std::string getRelyingParty(const SAMLArtifact* artifact);
109
110     private:
111         xmltooling::StorageService* m_storage;
112         std::string m_context;
113         std::auto_ptr<ArtifactMappings> m_mappings;
114         unsigned int m_artifactTTL;
115     };
116
117 #if defined (_MSC_VER)
118     #pragma warning( pop )
119 #endif
120
121 };
122
123 #endif /* __saml_artmap_h__ */