MessageEncoder, ArtifactMap, and SAML 1.x encoder classes.
[shibboleth/opensaml2.git] / saml / binding / ArtifactMap.h
diff --git a/saml/binding/ArtifactMap.h b/saml/binding/ArtifactMap.h
new file mode 100644 (file)
index 0000000..7f57f88
--- /dev/null
@@ -0,0 +1,88 @@
+/*\r
+ *  Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * @file saml/binding/ArtifactMap.h\r
+ * \r
+ * Helper class for SAMLArtifact mapping and retrieval.\r
+ */\r
+\r
+#ifndef __saml_artmap_h__\r
+#define __saml_artmap_h__\r
+\r
+#include <saml/base.h>\r
+#include <xmltooling/XMLObject.h>\r
+#include <xmltooling/util/StorageService.h>\r
+#include <xmltooling/util/Threads.h>\r
+\r
+namespace opensaml {\r
+\r
+    class SAML_API SAMLArtifact;\r
+    class SAML_DLLLOCAL ArtifactMappings;\r
+    \r
+    /**\r
+     * Helper class for SAMLArtifact mapping and retrieval.\r
+     */\r
+    class SAML_API ArtifactMap\r
+    {\r
+        MAKE_NONCOPYABLE(ArtifactMap);\r
+    public:\r
+        \r
+        /**\r
+         * Creates a map on top of a particular storage service context, or in-memory.\r
+         * \r
+         * @param storage       pointer to a StorageService, or NULL to keep map in memory\r
+         * @param context       optional label for storage context\r
+         * @param artifactTTL   time to live value, determines how long artifact remains valid\r
+         */\r
+        ArtifactMap(xmltooling::StorageService* storage=NULL, const char* context=NULL, int artifactTTL=180);\r
+\r
+        virtual ~ArtifactMap();\r
+        \r
+        /**\r
+         * Associates XML content with an artifact and optionally a specific relying party.\r
+         * Specifying no relying party means that the first attempt to resolve the artifact\r
+         * will succeed. The XML content cannot have a parent object, and any existing references\r
+         * to the content will be invalidated.\r
+         * \r
+         * @param content       the XML content to map to an artifact\r
+         * @param artifact      the artifact representing the XML content\r
+         * @param relyingParty  entityID of the party authorized to resolve the artifact\r
+         * @return the generated artifact\r
+         */\r
+        virtual void storeContent(xmltooling::XMLObject* content, const SAMLArtifact* artifact, const char* relyingParty=NULL);\r
+        \r
+        /**\r
+         * Retrieves the XML content represented by the artifact. The identity of the\r
+         * relying party can be supplied, if known. If the wrong party tries to resolve\r
+         * an artifact, an exception will be thrown and the mapping will be removed.\r
+         * The caller is responsible for freeing the XML content returned.\r
+         * \r
+         * @param artifact      the artifact representing the XML content\r
+         * @param relyingParty  entityID of the party trying to resolve the artifact\r
+         * @return the XML content\r
+         */\r
+        virtual xmltooling::XMLObject* retrieveContent(const SAMLArtifact* artifact, const char* relyingParty=NULL);\r
+\r
+    private:\r
+        xmltooling::StorageService* m_storage;\r
+        std::string m_context;\r
+        ArtifactMappings* m_mappings;\r
+        int m_artifactTTL;\r
+    };\r
+};\r
+\r
+#endif /* __saml_artmap_h__ */\r