SAML 2.0 artifact bits plus tests
authorScott Cantor <cantor.2@osu.edu>
Tue, 1 Aug 2006 18:15:11 +0000 (18:15 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 1 Aug 2006 18:15:11 +0000 (18:15 +0000)
15 files changed:
saml/Makefile.am
saml/SAMLArtifact.cpp
saml/saml.vcproj
saml/saml1/core/SAMLArtifactType0001.h
saml/saml1/core/SAMLArtifactType0002.h
saml/saml2/core/SAML2Artifact.h [new file with mode: 0644]
saml/saml2/core/SAML2ArtifactType0004.h [new file with mode: 0644]
saml/saml2/core/impl/SAML2Artifact.cpp [new file with mode: 0644]
saml/saml2/core/impl/SAML2ArtifactType0004.cpp [new file with mode: 0644]
samltest/Makefile.am
samltest/SAMLArtifactCreationTest.h [new file with mode: 0644]
samltest/SAMLArtifactType0001Test.h [new file with mode: 0644]
samltest/SAMLArtifactType0002Test.h [new file with mode: 0644]
samltest/SAMLArtifactType0004Test.h [new file with mode: 0644]
samltest/samltest.vcproj

index 97ea7b1..31abc1a 100644 (file)
@@ -42,7 +42,9 @@ saml1coreinclude_HEADERS = \
 
 saml2coreinclude_HEADERS = \
        saml2/core/Assertions.h \
 
 saml2coreinclude_HEADERS = \
        saml2/core/Assertions.h \
-       saml2/core/Protocols.h 
+       saml2/core/Protocols.h \
+       saml2/core/SAML2Artifact.h \ 
+       saml2/core/SAML2ArtifactType0004.h
 
 saml2mdinclude_HEADERS = \
        saml2/metadata/Metadata.h
 
 saml2mdinclude_HEADERS = \
        saml2/metadata/Metadata.h
@@ -53,7 +55,7 @@ noinst_HEADERS = \
        internal.h
 
 libsaml_la_SOURCES = \
        internal.h
 
 libsaml_la_SOURCES = \
-       SAMLArtifact.h \
+       SAMLArtifact.cpp \
        SAMLConfig.cpp \
        encryption/EncryptedKeyResolver.cpp \
        saml1/core/impl/AssertionsImpl.cpp \
        SAMLConfig.cpp \
        encryption/EncryptedKeyResolver.cpp \
        saml1/core/impl/AssertionsImpl.cpp \
@@ -66,6 +68,8 @@ libsaml_la_SOURCES = \
        saml2/core/impl/Assertions20SchemaValidators.cpp \
        saml2/core/impl/Protocols20Impl.cpp \
        saml2/core/impl/Protocols20SchemaValidators.cpp \
        saml2/core/impl/Assertions20SchemaValidators.cpp \
        saml2/core/impl/Protocols20Impl.cpp \
        saml2/core/impl/Protocols20SchemaValidators.cpp \
+       saml2/core/impl/SAML2Artifact.cpp \
+       saml2/core/impl/SAML2ArtifactType0004.cpp \
        saml2/metadata/impl/BlacklistMetadataFilter.cpp \
        saml2/metadata/impl/FilesystemMetadataProvider.cpp \
        saml2/metadata/impl/MetadataImpl.cpp \
        saml2/metadata/impl/BlacklistMetadataFilter.cpp \
        saml2/metadata/impl/FilesystemMetadataProvider.cpp \
        saml2/metadata/impl/MetadataImpl.cpp \
index 1f1bead..5c8d0fe 100644 (file)
@@ -36,7 +36,7 @@ namespace opensaml {
     };
 
     namespace saml2p {
     };
 
     namespace saml2p {
-        //SAML_DLLLOCAL PluginManager<SAMLArtifact,const char*>::Factory SAMLArtifactType0004Factory; 
+        SAML_DLLLOCAL PluginManager<SAMLArtifact,const char*>::Factory SAML2ArtifactType0004Factory; 
     };
 };
 
     };
 };
 
@@ -50,8 +50,8 @@ void SAML_API opensaml::registerSAMLArtifacts()
     conf.SAMLArtifactManager.registerFactory(typecode, saml1p::SAMLArtifactType0001Factory);
     typecode[1]=(char)0x2;
     conf.SAMLArtifactManager.registerFactory(typecode, saml1p::SAMLArtifactType0002Factory);
     conf.SAMLArtifactManager.registerFactory(typecode, saml1p::SAMLArtifactType0001Factory);
     typecode[1]=(char)0x2;
     conf.SAMLArtifactManager.registerFactory(typecode, saml1p::SAMLArtifactType0002Factory);
-    //typecode[1]=(char)0x4;
-    //conf.SAMLArtifactManager.registerFactory(typecode, saml2p::SAMLArtifactType0004Factory);
+    typecode[1]=(char)0x4;
+    conf.SAMLArtifactManager.registerFactory(typecode, saml2p::SAML2ArtifactType0004Factory);
 }
 
 const unsigned int SAMLArtifact::TYPECODE_LENGTH = 2;
 }
 
 const unsigned int SAMLArtifact::TYPECODE_LENGTH = 2;
index 80c81c0..58ba323 100644 (file)
                                                        RelativePath=".\saml2\core\impl\Protocols20SchemaValidators.cpp"\r
                                                        >\r
                                                </File>\r
                                                        RelativePath=".\saml2\core\impl\Protocols20SchemaValidators.cpp"\r
                                                        >\r
                                                </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml2\core\impl\SAML2Artifact.cpp"\r
+                                                       >\r
+                                               </File>\r
+                                               <File\r
+                                                       RelativePath=".\saml2\core\impl\SAML2ArtifactType0004.cpp"\r
+                                                       >\r
+                                               </File>\r
                                        </Filter>\r
                                </Filter>\r
                                <Filter\r
                                        </Filter>\r
                                </Filter>\r
                                <Filter\r
                                                RelativePath=".\saml2\core\Protocols.h"\r
                                                >\r
                                        </File>\r
                                                RelativePath=".\saml2\core\Protocols.h"\r
                                                >\r
                                        </File>\r
+                                       <File\r
+                                               RelativePath=".\saml2\core\SAML2Artifact.h"\r
+                                               >\r
+                                       </File>\r
+                                       <File\r
+                                               RelativePath=".\saml2\core\SAML2ArtifactType0004.h"\r
+                                               >\r
+                                       </File>\r
                                </Filter>\r
                                <Filter\r
                                        Name="metadata"\r
                                </Filter>\r
                                <Filter\r
                                        Name="metadata"\r
index f7fd284..d61020c 100644 (file)
@@ -78,7 +78,7 @@ namespace opensaml {
             static const unsigned int HANDLE_LENGTH;\r
     \r
         protected:\r
             static const unsigned int HANDLE_LENGTH;\r
     \r
         protected:\r
-            SAMLArtifactType0001(const SAMLArtifact& src) : SAMLArtifact(src) {}\r
+            SAMLArtifactType0001(const SAMLArtifactType0001& src) : SAMLArtifact(src) {}\r
         };\r
         \r
     };\r
         };\r
         \r
     };\r
index ffcbd78..c9cb7c7 100644 (file)
@@ -75,7 +75,7 @@ namespace opensaml {
             static const unsigned int HANDLE_LENGTH;\r
     \r
         protected:\r
             static const unsigned int HANDLE_LENGTH;\r
     \r
         protected:\r
-            SAMLArtifactType0002(const SAMLArtifact& src) : SAMLArtifact(src) {}\r
+            SAMLArtifactType0002(const SAMLArtifactType0002& src) : SAMLArtifact(src) {}\r
         };\r
         \r
     };\r
         };\r
         \r
     };\r
diff --git a/saml/saml2/core/SAML2Artifact.h b/saml/saml2/core/SAML2Artifact.h
new file mode 100644 (file)
index 0000000..eb14aa2
--- /dev/null
@@ -0,0 +1,61 @@
+/*\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/saml2/core/SAML2Artifact.h\r
+ * \r
+ * Base class for SAML 2.0 artifacts\r
+ */\r
+\r
+#ifndef __saml2_artifact_h__\r
+#define __saml2_artifact_h__\r
+\r
+#include <saml/SAMLArtifact.h>\r
+\r
+namespace opensaml {\r
+    namespace saml2p {\r
+        \r
+        /**\r
+         * Base class for SAML 2.0 artifacts\r
+         */\r
+        class SAML_API SAML2Artifact : public SAMLArtifact\r
+        {\r
+            SAML2Artifact& operator=(const SAML2Artifact& src);\r
+        public:\r
+            virtual ~SAML2Artifact() {}\r
+            \r
+            /**\r
+             * Returns the endpoint index of the artifact.\r
+             * \r
+             * @return endpoint index\r
+             */\r
+            virtual int getEndpointIndex() const;\r
+            \r
+            /** Length of endpoint index */            \r
+            static const unsigned int INDEX_LENGTH;\r
+\r
+        protected:\r
+            SAML2Artifact() {}\r
+\r
+            SAML2Artifact(const char* s) : SAMLArtifact(s) {}\r
+    \r
+            SAML2Artifact(const SAML2Artifact& src) : SAMLArtifact(src) {}\r
+        };\r
+        \r
+    };\r
+};\r
+\r
+#endif /* __saml2_artifact_h__ */\r
diff --git a/saml/saml2/core/SAML2ArtifactType0004.h b/saml/saml2/core/SAML2ArtifactType0004.h
new file mode 100644 (file)
index 0000000..7a0375c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\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/saml2/core/SAML2ArtifactType0004.h\r
+ * \r
+ * Type 0x0004 SAML 2.0 artifact class\r
+ */\r
+\r
+#ifndef __saml_artifacttype0004_h__\r
+#define __saml_artifacttype0004_h__\r
+\r
+#include <saml/saml2/core/SAML2Artifact.h>\r
+\r
+namespace opensaml {\r
+    namespace saml2p {\r
+        \r
+        /**\r
+         * Type 0x0004 SAML 2.0 artifact class\r
+         */\r
+        class SAML_API SAML2ArtifactType0004 : public SAML2Artifact\r
+        {\r
+            SAML2ArtifactType0004& operator=(const SAML2ArtifactType0004& src);\r
+        public:\r
+            /**\r
+             * Decodes a base64-encoded type 0x0004 artifact\r
+             * \r
+             * @param s NULL-terminated base64-encoded string \r
+             */        \r
+            SAML2ArtifactType0004(const char* s);\r
+\r
+            /**\r
+             * Constructs an artifact with the specified source ID and index, but a random message handle.\r
+             * \r
+             * @param sourceid  SOURCEID_LENGTH bytes of binary data\r
+             * @param index     endpoint index\r
+             */        \r
+            SAML2ArtifactType0004(const std::string& sourceid, int index);\r
+\r
+            /**\r
+             * Constructs an artifact with the specified source ID and assertion handle.\r
+             * \r
+             * @param sourceid  SOURCEID_LENGTH bytes of binary data\r
+             * @param index     endpoint index\r
+             * @param handle    HANDLE_LENGTH bytes of binary data \r
+             */        \r
+            SAML2ArtifactType0004(const std::string& sourceid, int index, const std::string& handle);\r
+    \r
+            virtual ~SAML2ArtifactType0004() {}\r
+            \r
+            virtual SAML2ArtifactType0004* clone() const {\r
+                return new SAML2ArtifactType0004(*this);\r
+            }\r
+            \r
+            virtual std::string getSource() const {\r
+                return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH, SOURCEID_LENGTH);    // bytes 5-24\r
+            }\r
+            \r
+            virtual std::string getMessageHandle() const {\r
+                return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH + SOURCEID_LENGTH, HANDLE_LENGTH);    // bytes 25-44\r
+            }\r
+\r
+            /** Length of source ID */            \r
+            static const unsigned int SOURCEID_LENGTH;\r
+\r
+            /** Length of message handle */            \r
+            static const unsigned int HANDLE_LENGTH;\r
+    \r
+        protected:\r
+            SAML2ArtifactType0004(const SAML2ArtifactType0004& src) : SAML2Artifact(src) {}\r
+        };\r
+        \r
+    };\r
+};\r
+\r
+#endif /* __saml_artifacttype0004_h__ */\r
diff --git a/saml/saml2/core/impl/SAML2Artifact.cpp b/saml/saml2/core/impl/SAML2Artifact.cpp
new file mode 100644 (file)
index 0000000..dcbd0f2
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  Copyright 2001-2006 Internet2
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * SAML2Artifact.cpp
+ * 
+ * Base class for SAML 2.0 artifacts 
+ */
+
+#include "internal.h"
+#include "saml2/core/SAML2Artifact.h"
+
+using namespace opensaml::saml2p;
+
+const unsigned int SAML2Artifact::INDEX_LENGTH = 2;
+
+int SAML2Artifact::getEndpointIndex() const
+{
+    int index=0;
+    if (m_raw.size()>=TYPECODE_LENGTH+INDEX_LENGTH) {
+        index = (16 * static_cast<int>(m_raw[TYPECODE_LENGTH])) + static_cast<int>(m_raw[TYPECODE_LENGTH+1]); 
+    }
+    return index;
+}
diff --git a/saml/saml2/core/impl/SAML2ArtifactType0004.cpp b/saml/saml2/core/impl/SAML2ArtifactType0004.cpp
new file mode 100644 (file)
index 0000000..22e6362
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ *  Copyright 2001-2006 Internet2
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * SAML2ArtifactType0004.cpp
+ * 
+ * Type 0x0004 SAML 2.0 artifact class 
+ */
+
+#include "internal.h"
+#include "saml2/core/SAML2ArtifactType0004.h"
+
+using namespace opensaml::saml2p;
+using namespace opensaml;
+using namespace xmltooling;
+using namespace std;
+
+namespace opensaml {
+    namespace saml2p {
+        SAMLArtifact* SAML_DLLLOCAL SAML2ArtifactType0004Factory(const char* const & s)
+        {
+            return new SAML2ArtifactType0004(s);
+        }
+    }
+};
+
+const unsigned int SAML2ArtifactType0004::SOURCEID_LENGTH = 20;
+const unsigned int SAML2ArtifactType0004::HANDLE_LENGTH = 20;
+
+SAML2ArtifactType0004::SAML2ArtifactType0004(const char* s) : SAML2Artifact(s)
+{
+    // The base class does the work, we just do the checking.
+    if (m_raw.size() != TYPECODE_LENGTH + INDEX_LENGTH + SOURCEID_LENGTH + HANDLE_LENGTH)
+        throw ArtifactException("Type 0x0004 artifact is of incorrect length.");
+    else if (m_raw[0] != 0x0 || m_raw[1] != 0x4)
+        throw ArtifactException(
+            string("Type 0x0004 artifact given an artifact of invalid type (") + toHex(getTypeCode()) + ")."
+            );
+}
+
+SAML2ArtifactType0004::SAML2ArtifactType0004(const string& sourceid, int index)
+{
+    if (sourceid.size()!=SOURCEID_LENGTH)
+        throw ArtifactException("Type 0x0004 artifact sourceid of incorrect length.");
+    if (index < 0 || index > (1 << 16)-1)
+        throw ArtifactException("Type 0x0004 artifact index is invalid.");
+    m_raw+=(char)0x0;
+    m_raw+=(char)0x4;
+    m_raw+=(char)(index / 256);
+    m_raw+=(char)(index % 256);
+    m_raw.append(sourceid,0,SOURCEID_LENGTH);
+    char buf[HANDLE_LENGTH];
+    SAMLConfig::getConfig().generateRandomBytes(buf,HANDLE_LENGTH);
+    for (int i=0; i<HANDLE_LENGTH; i++)
+        m_raw+=buf[i];
+}
+
+SAML2ArtifactType0004::SAML2ArtifactType0004(const string& sourceid, int index, const string& handle)
+{
+    if (sourceid.size()!=SOURCEID_LENGTH)
+        throw ArtifactException("Type 0x0004 artifact sourceid of incorrect length.");
+    if (index < 0 || index > (1 << 16)-1)
+        throw ArtifactException("Type 0x0004 artifact index is invalid.");
+    if (handle.size()!=HANDLE_LENGTH)
+        throw ArtifactException("Type 0x0004 artifact message handle of incorrect length.");
+    m_raw+=(char)0x0;
+    m_raw+=(char)0x4;
+    m_raw+=(char)(index / 256);
+    m_raw+=(char)(index % 256);
+    m_raw.append(sourceid,0,SOURCEID_LENGTH);
+    m_raw.append(handle,0,HANDLE_LENGTH);
+}
index f5de16d..0c83dbe 100644 (file)
@@ -9,6 +9,10 @@ endif
 
 samltest_h = \
     samltest.h \
 
 samltest_h = \
     samltest.h \
+    SAMLArtifactCreationTest.h \
+    SAMLArtifactType0001Test.h \
+    SAMLArtifactType0002Test.h \
+    SAMLArtifactType0004Test.h \
     signature/SAML1AssertionTest.h \
     signature/SAML1RequestTest.h \
     signature/SAML1ResponseTest.h \
     signature/SAML1AssertionTest.h \
     signature/SAML1RequestTest.h \
     signature/SAML1ResponseTest.h \
diff --git a/samltest/SAMLArtifactCreationTest.h b/samltest/SAMLArtifactCreationTest.h
new file mode 100644 (file)
index 0000000..104e7b1
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ *  Copyright 2001-2005 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
+#include "internal.h"\r
+#include <saml/saml1/core/SAMLArtifactType0001.h>\r
+#include <saml/saml1/core/SAMLArtifactType0002.h>\r
+#include <saml/saml2/core/SAML2ArtifactType0004.h>\r
+\r
+using namespace opensaml::saml1p;\r
+using namespace opensaml::saml2p;\r
+using namespace opensaml;\r
+using namespace std;\r
+\r
+class SAMLArtifactCreationTest : public CxxTest::TestSuite\r
+{\r
+public:\r
+    string providerIdStr;\r
+    string handle;\r
+    void setUp() {\r
+        if (handle.empty()) {\r
+            providerIdStr = "https://idp.org/SAML";\r
+            SAMLConfig::getConfig().generateRandomBytes(handle,SAMLArtifactType0001::HANDLE_LENGTH);\r
+        }\r
+    }\r
+    void testSAMLArtifactType0001(void) {\r
+        SAMLConfig& conf=SAMLConfig::getConfig();\r
+        string sourceId;\r
+        conf.generateRandomBytes(sourceId,SAMLArtifactType0001::SOURCEID_LENGTH);\r
+        SAMLArtifactType0001 artifact1(sourceId,handle);\r
+        //printResults(artifact1);\r
+\r
+        SAMLArtifactType0001 artifact2(conf.hashSHA1(providerIdStr.c_str()),handle);\r
+        //printResults(artifact2,providerIdStr.c_str());\r
+    }\r
+\r
+    void testSAMLArtifactType0002(void) {\r
+        SAMLArtifactType0002 artifact(providerIdStr,handle);\r
+        //printResults(artifact,providerIdStr.c_str());\r
+    }\r
+\r
+    void testSAMLArtifactType0004(void) {\r
+        SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle);\r
+        //printResults(artifact,providerIdStr.c_str());\r
+    }\r
+\r
+    void printResults(SAMLArtifact& artifact, const char* str=NULL) {\r
+        // print heading:\r
+        cout << "Artifact Type " << SAMLArtifact::toHex(artifact.getTypeCode());\r
+        cout << " (size = " << artifact.getBytes().size() << ")" << endl;\r
+    \r
+        // print URI:\r
+        if (str) { \r
+          cout << "URI:     " << str << endl; \r
+        }\r
+        else {\r
+          cout << "URI:     NONE" << endl; \r
+        }\r
+    \r
+        // print hex-encoded artifact:\r
+        cout << "Hex:     " << SAMLArtifact::toHex(artifact.getBytes()) << endl;\r
+    \r
+        // print base64-encoded artifact:\r
+        cout << "Base64:  " << artifact.encode() << endl;\r
+    \r
+        // print ruler:\r
+        cout <<  "         ----------------------------------------------------------------------" << endl;\r
+        cout <<  "         1234567890123456789012345678901234567890123456789012345678901234567890" << endl;\r
+        cout <<  "                  1         2         3         4         5         6         7" << endl;\r
+        cout <<  "         ----------------------------------------------------------------------" << endl;\r
+    }\r
+};\r
diff --git a/samltest/SAMLArtifactType0001Test.h b/samltest/SAMLArtifactType0001Test.h
new file mode 100644 (file)
index 0000000..48c8754
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ *  Copyright 2001-2005 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
+#include "internal.h"\r
+#include <saml/saml1/core/SAMLArtifactType0001.h>\r
+\r
+using namespace opensaml::saml1p;\r
+using namespace opensaml;\r
+using namespace std;\r
+\r
+class SAMLArtifactType0001Test : public CxxTest::TestSuite\r
+{\r
+public:\r
+    string providerIdStr;\r
+\r
+    void setUp() {\r
+        providerIdStr = "https://idp.org/SAML";\r
+    }\r
+    \r
+    void testSAMLArtifactType0001(void) {\r
+        string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str());\r
+        auto_ptr<SAMLArtifactType0001> artifact(new SAMLArtifactType0001(sourceId));\r
+        auto_ptr<SAMLArtifact> tempArtifact(SAMLArtifact::parse(artifact->encode().c_str()));\r
+        \r
+        TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource());\r
+        TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle());\r
+        \r
+        TS_ASSERT_THROWS(auto_ptr<SAMLArtifact> bogus1(new SAMLArtifactType0001(sourceId + sourceId)), ArtifactException);\r
+        TS_ASSERT_THROWS(auto_ptr<SAMLArtifact> bogus2(new SAMLArtifactType0001(sourceId, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException);\r
+    }\r
+};\r
diff --git a/samltest/SAMLArtifactType0002Test.h b/samltest/SAMLArtifactType0002Test.h
new file mode 100644 (file)
index 0000000..8556105
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ *  Copyright 2001-2005 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
+#include "internal.h"\r
+#include <saml/saml1/core/SAMLArtifactType0002.h>\r
+\r
+using namespace opensaml::saml1p;\r
+using namespace opensaml;\r
+using namespace std;\r
+\r
+class SAMLArtifactType0002Test : public CxxTest::TestSuite\r
+{\r
+public:\r
+    string providerIdStr;\r
+\r
+    void setUp() {\r
+        providerIdStr = "https://idp.org/SAML";\r
+    }\r
+    \r
+    void testSAMLArtifactType0002(void) {\r
+        auto_ptr<SAMLArtifactType0002> artifact(new SAMLArtifactType0002(providerIdStr));\r
+        auto_ptr<SAMLArtifact> tempArtifact(SAMLArtifact::parse(artifact->encode().c_str()));\r
+        \r
+        TS_ASSERT_SAME_DATA(artifact->getSource().c_str(),tempArtifact->getSource().c_str(),artifact->getSource().length());\r
+        TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle());\r
+\r
+        TS_ASSERT_THROWS(auto_ptr<SAMLArtifact> bogus1(new SAMLArtifactType0002(providerIdStr, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException);\r
+    }\r
+};\r
diff --git a/samltest/SAMLArtifactType0004Test.h b/samltest/SAMLArtifactType0004Test.h
new file mode 100644 (file)
index 0000000..e2f57d0
--- /dev/null
@@ -0,0 +1,45 @@
+/*\r
+ *  Copyright 2001-2005 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
+#include "internal.h"\r
+#include <saml/saml2/core/SAML2ArtifactType0004.h>\r
+\r
+using namespace opensaml::saml2p;\r
+using namespace opensaml;\r
+using namespace std;\r
+\r
+class SAMLArtifactType0004Test : public CxxTest::TestSuite\r
+{\r
+public:\r
+    string providerIdStr;\r
+\r
+    void setUp() {\r
+        providerIdStr = "https://idp.org/SAML";\r
+    }\r
+    \r
+    void testSAMLArtifactType0004(void) {\r
+        string sourceId = SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str());\r
+        auto_ptr<SAML2ArtifactType0004> artifact(new SAML2ArtifactType0004(sourceId,666));\r
+        auto_ptr<SAML2Artifact> tempArtifact(dynamic_cast<SAML2Artifact*>(SAMLArtifact::parse(artifact->encode().c_str())));\r
+        \r
+        TS_ASSERT_EQUALS(artifact->getSource(),tempArtifact->getSource());\r
+        TS_ASSERT_EQUALS(artifact->getEndpointIndex(),tempArtifact->getEndpointIndex());\r
+        TS_ASSERT_EQUALS(artifact->getMessageHandle(),tempArtifact->getMessageHandle());\r
+        \r
+        TS_ASSERT_THROWS(auto_ptr<SAML2Artifact> bogus1(new SAML2ArtifactType0004(sourceId, 100000)), ArtifactException);\r
+        TS_ASSERT_THROWS(auto_ptr<SAML2Artifact> bogus2(new SAML2ArtifactType0004(sourceId, 666, artifact->getMessageHandle() + artifact->getMessageHandle())), ArtifactException);\r
+    }\r
+};\r
index 0771976..e3eb662 100644 (file)
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
+                               RelativePath=".\SAMLArtifactCreationTest.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SAMLArtifactType0001Test.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SAMLArtifactType0002Test.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SAMLArtifactType0004Test.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\samltest.cpp"\r
                                >\r
                        </File>\r
                                RelativePath=".\samltest.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\SAMLArtifactCreationTest.h"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SAMLArtifactType0001Test.h"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SAMLArtifactType0002Test.h"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SAMLArtifactType0004Test.h"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                               Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\samltest.h"\r
                                >\r
                                <FileConfiguration\r
                                RelativePath=".\samltest.h"\r
                                >\r
                                <FileConfiguration\r