2 * Copyright 2001-2007 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file saml/binding/ArtifactMap.h
20 * Helper class for SAMLArtifact mapping and retrieval.
23 #ifndef __saml_artmap_h__
24 #define __saml_artmap_h__
26 #include <saml/base.h>
27 #include <xmltooling/XMLObject.h>
28 #include <xmltooling/util/StorageService.h>
29 #include <xmltooling/util/Threads.h>
33 class SAML_API SAMLArtifact;
34 class SAML_DLLLOCAL ArtifactMappings;
37 * Helper class for SAMLArtifact mapping and retrieval.
39 class SAML_API ArtifactMap
41 MAKE_NONCOPYABLE(ArtifactMap);
45 * Creates a map on top of a particular storage service context, or in-memory.
47 * @param storage pointer to a StorageService, or NULL to keep map in memory
48 * @param context optional label for storage context
49 * @param artifactTTL time to live value, determines how long artifact remains valid
51 ArtifactMap(xmltooling::StorageService* storage=NULL, const char* context=NULL, int artifactTTL=180);
53 virtual ~ArtifactMap();
56 * Associates XML content with an artifact and optionally a specific relying party.
57 * Specifying no relying party means that the first attempt to resolve the artifact
58 * will succeed. The XML content cannot have a parent object, and any existing references
59 * to the content will be invalidated.
61 * @param content the XML content to map to an artifact
62 * @param artifact the artifact representing the XML content
63 * @param relyingParty entityID of the party authorized to resolve the artifact
64 * @return the generated artifact
66 virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=NULL);
69 * Retrieves the XML content represented by the artifact. The identity of the
70 * relying party can be supplied, if known. If the wrong party tries to resolve
71 * an artifact, an exception will be thrown and the mapping will be removed.
72 * The caller is responsible for freeing the XML content returned.
74 * @param artifact the artifact representing the XML content
75 * @param relyingParty entityID of the party trying to resolve the artifact
76 * @return the XML content
78 virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=NULL);
81 xmltooling::StorageService* m_storage;
82 std::string m_context;
83 ArtifactMappings* m_mappings;
88 #endif /* __saml_artmap_h__ */