Suppress dll-interface warnings.
[shibboleth/cpp-opensaml.git] / saml / binding / ArtifactMap.h
1 /*
2  *  Copyright 2001-2010 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/binding/ArtifactMap.h
19  * 
20  * Helper class for SAMLArtifact mapping and retrieval.
21  */
22
23 #ifndef __saml_artmap_h__
24 #define __saml_artmap_h__
25
26 #include <saml/base.h>
27
28 #include <string>
29 #include <xercesc/dom/DOM.hpp>
30
31 namespace xmltooling {
32     class XMLTOOL_API StorageService;
33     class XMLTOOL_API XMLObject;
34 };
35
36 namespace opensaml {
37
38     class SAML_API SAMLArtifact;
39     class SAML_DLLLOCAL ArtifactMappings;
40     
41 #if defined (_MSC_VER)
42     #pragma warning( push )
43     #pragma warning( disable : 4251 )
44 #endif
45
46     /**
47      * Helper class for SAMLArtifact mapping and retrieval.
48      */
49     class SAML_API ArtifactMap
50     {
51         MAKE_NONCOPYABLE(ArtifactMap);
52     public:
53         
54         /**
55          * Creates a map on top of a particular storage service context, or in-memory.
56          * 
57          * @param storage       pointer to a StorageService, or nullptr to keep map in memory
58          * @param context       optional label for storage context
59          * @param artifactTTL   time to live in seconds, determines how long artifact remains valid
60          */
61         ArtifactMap(xmltooling::StorageService* storage=nullptr, const char* context=nullptr, unsigned int artifactTTL=180);
62
63         /**
64          * Creates a map on top of a particular storage service context, or in-memory.
65          * 
66          * @param e         root of a DOM with optional XML attributes for context and artifactTTL
67          * @param storage   pointer to a StorageService, or nullptr to keep map in memory
68          */
69         ArtifactMap(const xercesc::DOMElement* e, xmltooling::StorageService* storage=nullptr);
70
71         virtual ~ArtifactMap();
72         
73         /**
74          * Associates XML content with an artifact and optionally a specific relying party.
75          * Specifying no relying party means that the first attempt to resolve the artifact
76          * will succeed. The XML content cannot have a parent object, and any existing references
77          * to the content will be invalidated.
78          * 
79          * @param content       the XML content to map to an artifact
80          * @param artifact      the artifact representing the XML content
81          * @param relyingParty  entityID of the party authorized to resolve the artifact
82          * @return the generated artifact
83          */
84         virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=nullptr);
85         
86         /**
87          * Retrieves the XML content represented by the artifact. The identity of the
88          * relying party can be supplied, if known. If the wrong party tries to resolve
89          * an artifact, an exception will be thrown and the mapping will be removed.
90          * The caller is responsible for freeing the XML content returned.
91          * 
92          * @param artifact      the artifact representing the XML content
93          * @param relyingParty  entityID of the party trying to resolve the artifact
94          * @return the XML content
95          */
96         virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=nullptr);
97
98         /**
99          * Retrieves the relying party to whom the artifact was issued.
100          *
101          * @param artifact  the artifact to check
102          * @return  entityID of the party to whom the artifact was issued, if any
103          */
104         virtual std::string getRelyingParty(const SAMLArtifact* artifact);
105
106     private:
107         xmltooling::StorageService* m_storage;
108         std::string m_context;
109         ArtifactMappings* m_mappings;
110         unsigned int m_artifactTTL;
111     };
112
113 #if defined (_MSC_VER)
114     #pragma warning( pop )
115 #endif
116
117 };
118
119 #endif /* __saml_artmap_h__ */