2 * Copyright 2001-2005 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include "internal.h"
\r
18 #include <saml/SAMLConfig.h>
\r
19 #include <saml/saml1/binding/SAMLArtifactType0001.h>
\r
20 #include <saml/saml1/binding/SAMLArtifactType0002.h>
\r
21 #include <saml/saml2/binding/SAML2ArtifactType0004.h>
\r
23 using namespace opensaml::saml1p;
\r
24 using namespace opensaml::saml2p;
\r
25 using namespace opensaml;
\r
26 using namespace std;
\r
28 class SAMLArtifactCreationTest : public CxxTest::TestSuite
\r
31 string providerIdStr;
\r
34 if (handle.empty()) {
\r
35 providerIdStr = "https://idp.org/SAML";
\r
36 SAMLConfig::getConfig().generateRandomBytes(handle,SAMLArtifactType0001::HANDLE_LENGTH);
\r
39 void testSAMLArtifactType0001(void) {
\r
40 SAMLConfig& conf=SAMLConfig::getConfig();
\r
42 conf.generateRandomBytes(sourceId,SAMLArtifactType0001::SOURCEID_LENGTH);
\r
43 SAMLArtifactType0001 artifact1(sourceId,handle);
\r
44 //printResults(artifact1);
\r
46 SAMLArtifactType0001 artifact2(conf.hashSHA1(providerIdStr.c_str()),handle);
\r
47 //printResults(artifact2,providerIdStr.c_str());
\r
50 void testSAMLArtifactType0002(void) {
\r
51 SAMLArtifactType0002 artifact(providerIdStr,handle);
\r
52 //printResults(artifact,providerIdStr.c_str());
\r
55 void testSAMLArtifactType0004(void) {
\r
56 SAML2ArtifactType0004 artifact(SAMLConfig::getConfig().hashSHA1(providerIdStr.c_str()),666,handle);
\r
57 //printResults(artifact,providerIdStr.c_str());
\r
60 void printResults(SAMLArtifact& artifact, const char* str=NULL) {
\r
62 cout << "Artifact Type " << SAMLArtifact::toHex(artifact.getTypeCode());
\r
63 cout << " (size = " << artifact.getBytes().size() << ")" << endl;
\r
67 cout << "URI: " << str << endl;
\r
70 cout << "URI: NONE" << endl;
\r
73 // print hex-encoded artifact:
\r
74 cout << "Hex: " << SAMLArtifact::toHex(artifact.getBytes()) << endl;
\r
76 // print base64-encoded artifact:
\r
77 cout << "Base64: " << artifact.encode() << endl;
\r
80 cout << " ----------------------------------------------------------------------" << endl;
\r
81 cout << " 1234567890123456789012345678901234567890123456789012345678901234567890" << endl;
\r
82 cout << " 1 2 3 4 5 6 7" << endl;
\r
83 cout << " ----------------------------------------------------------------------" << endl;
\r