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.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @file saml/binding/ArtifactMap.h
24 * Helper class for SAMLArtifact mapping and retrieval.
27 #ifndef __saml_artmap_h__
28 #define __saml_artmap_h__
30 #include <saml/base.h>
34 #include <xercesc/dom/DOM.hpp>
36 namespace xmltooling {
37 class XMLTOOL_API StorageService;
38 class XMLTOOL_API XMLObject;
43 class SAML_API SAMLArtifact;
44 class SAML_DLLLOCAL ArtifactMappings;
46 #if defined (_MSC_VER)
47 #pragma warning( push )
48 #pragma warning( disable : 4251 )
52 * Helper class for SAMLArtifact mapping and retrieval.
54 class SAML_API ArtifactMap
56 MAKE_NONCOPYABLE(ArtifactMap);
60 * Creates a map on top of a particular storage service context, or in-memory.
62 * @param storage pointer to a StorageService, or nullptr to keep map in memory
63 * @param context optional label for storage context
64 * @param artifactTTL time to live in seconds, determines how long artifact remains valid
66 ArtifactMap(xmltooling::StorageService* storage=nullptr, const char* context=nullptr, unsigned int artifactTTL=180);
69 * Creates a map on top of a particular storage service context, or in-memory.
71 * @param e root of a DOM with optional XML attributes for context and artifactTTL
72 * @param storage pointer to a StorageService, or nullptr to keep map in memory
74 ArtifactMap(const xercesc::DOMElement* e, xmltooling::StorageService* storage=nullptr);
76 virtual ~ArtifactMap();
79 * Associates XML content with an artifact and optionally a specific relying party.
80 * Specifying no relying party means that the first attempt to resolve the artifact
81 * will succeed. The XML content cannot have a parent object, and any existing references
82 * to the content will be invalidated.
84 * @param content the XML content to map to an artifact
85 * @param artifact the artifact representing the XML content
86 * @param relyingParty entityID of the party authorized to resolve the artifact
87 * @return the generated artifact
89 virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=nullptr);
92 * Retrieves the XML content represented by the artifact. The identity of the
93 * relying party can be supplied, if known. If the wrong party tries to resolve
94 * an artifact, an exception will be thrown and the mapping will be removed.
95 * The caller is responsible for freeing the XML content returned.
97 * @param artifact the artifact representing the XML content
98 * @param relyingParty entityID of the party trying to resolve the artifact
99 * @return the XML content
101 virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=nullptr);
104 * Retrieves the relying party to whom the artifact was issued.
106 * @param artifact the artifact to check
107 * @return entityID of the party to whom the artifact was issued, if any
109 virtual std::string getRelyingParty(const SAMLArtifact* artifact);
112 xmltooling::StorageService* m_storage;
113 std::string m_context;
114 std::auto_ptr<ArtifactMappings> m_mappings;
115 unsigned int m_artifactTTL;
118 #if defined (_MSC_VER)
119 #pragma warning( pop )
124 #endif /* __saml_artmap_h__ */