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>
33 #include <xercesc/dom/DOM.hpp>
35 namespace xmltooling {
36 class XMLTOOL_API StorageService;
37 class XMLTOOL_API XMLObject;
42 class SAML_API SAMLArtifact;
43 class SAML_DLLLOCAL ArtifactMappings;
45 #if defined (_MSC_VER)
46 #pragma warning( push )
47 #pragma warning( disable : 4251 )
51 * Helper class for SAMLArtifact mapping and retrieval.
53 class SAML_API ArtifactMap
55 MAKE_NONCOPYABLE(ArtifactMap);
59 * Creates a map on top of a particular storage service context, or in-memory.
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
65 ArtifactMap(xmltooling::StorageService* storage=nullptr, const char* context=nullptr, unsigned int artifactTTL=180);
68 * Creates a map on top of a particular storage service context, or in-memory.
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
73 ArtifactMap(const xercesc::DOMElement* e, xmltooling::StorageService* storage=nullptr);
75 virtual ~ArtifactMap();
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.
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
88 virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=nullptr);
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.
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
100 virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=nullptr);
103 * Retrieves the relying party to whom the artifact was issued.
105 * @param artifact the artifact to check
106 * @return entityID of the party to whom the artifact was issued, if any
108 virtual std::string getRelyingParty(const SAMLArtifact* artifact);
111 xmltooling::StorageService* m_storage;
112 std::string m_context;
113 std::auto_ptr<ArtifactMappings> m_mappings;
114 unsigned int m_artifactTTL;
117 #if defined (_MSC_VER)
118 #pragma warning( pop )
123 #endif /* __saml_artmap_h__ */