<pathentry include="C:/cxxtest" kind="inc" path="" system="true"/>\r
<pathentry kind="out" path=""/>\r
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>\r
-<pathentry excluding="util/|saml1/|signature/|saml2/|encryption/|saml2/metadata/impl/" kind="src" path="saml"/>\r
+<pathentry excluding="util/|saml1/|signature/|saml2/|encryption/" kind="src" path="saml"/>\r
<pathentry excluding="impl/" kind="src" path="saml/saml1/core"/>\r
<pathentry kind="src" path="saml/saml1/core/impl"/>\r
+<pathentry excluding="impl/" kind="src" path="saml/saml1/profile"/>\r
+<pathentry kind="src" path="saml/saml1/profile/impl"/>\r
<pathentry excluding="impl/" kind="src" path="saml/saml2/core"/>\r
<pathentry kind="src" path="saml/saml2/core/impl"/>\r
<pathentry excluding="impl/" kind="src" path="saml/saml2/metadata"/>\r
base.h \
exceptions.h \
version.h \
+ SAMLArtifact.h \
SAMLConfig.h
encinclude_HEADERS = \
saml1coreinclude_HEADERS = \
saml1/core/Assertions.h \
- saml1/core/Protocols.h
+ saml1/core/Protocols.h \
+ saml1/core/SAMLArtifactType0001.h \
+ saml1/core/SAMLArtifactType0002.h
saml2coreinclude_HEADERS = \
saml2/core/Assertions.h \
internal.h
libsaml_la_SOURCES = \
+ SAMLArtifact.h \
SAMLConfig.cpp \
encryption/EncryptedKeyResolver.cpp \
saml1/core/impl/AssertionsImpl.cpp \
saml1/core/impl/AssertionsSchemaValidators.cpp \
saml1/core/impl/ProtocolsImpl.cpp \
saml1/core/impl/ProtocolsSchemaValidators.cpp \
+ saml1/core/impl/SAMLArtifactType0001.cpp \
+ saml1/core/impl/SAMLArtifactType0002.cpp \
saml2/core/impl/Assertions20Impl.cpp \
saml2/core/impl/Assertions20SchemaValidators.cpp \
saml2/core/impl/Protocols20Impl.cpp \
--- /dev/null
+/*
+ * 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.
+ */
+
+/**
+ * SAMLArtifact.cpp
+ *
+ * Base class for SAML 1.x and 2.0 artifacts
+ */
+
+#include "internal.h"
+#include "SAMLArtifact.h"
+
+#include <xercesc/util/Base64.hpp>
+
+using namespace opensaml;
+using namespace xmltooling;
+using namespace std;
+
+namespace opensaml {
+ namespace saml1p {
+ SAML_DLLLOCAL PluginManager<SAMLArtifact,const char*>::Factory SAMLArtifactType0001Factory;
+ SAML_DLLLOCAL PluginManager<SAMLArtifact,const char*>::Factory SAMLArtifactType0002Factory;
+ };
+
+ namespace saml2p {
+ //SAML_DLLLOCAL PluginManager<SAMLArtifact,const char*>::Factory SAMLArtifactType0004Factory;
+ };
+};
+
+void SAML_API opensaml::registerSAMLArtifacts()
+{
+ SAMLConfig& conf=SAMLConfig::getConfig();
+
+ string typecode;
+ typecode+=(char)0x0;
+ typecode+=(char)0x1;
+ 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);
+}
+
+const unsigned int SAMLArtifact::TYPECODE_LENGTH = 2;
+
+// Basic constructor just decodes the string and saves it off.
+// Subclasses will handle pulling it apart.
+
+SAMLArtifact::SAMLArtifact(const char* s)
+{
+ unsigned int len=0;
+ XMLByte* decoded=Base64::decode(reinterpret_cast<const XMLByte*>(s),&len);
+ if (!decoded)
+ throw ArtifactException("Unable to decode base64 artifact.");
+ XMLByte* ptr=decoded;
+ while (len--)
+ m_raw+= *ptr++;
+ XMLString::release(&decoded);
+}
+
+string SAMLArtifact::encode() const
+{
+ unsigned int len=0;
+ XMLByte* out=Base64::encode(reinterpret_cast<const XMLByte*>(m_raw.data()),m_raw.size(),&len);
+ if (out) {
+ string ret(reinterpret_cast<char*>(out),len);
+ XMLString::release(&out);
+ return ret;
+ }
+ return string();
+}
+
+SAMLArtifact* SAMLArtifact::parse(const char* s)
+{
+ // Decode and extract the type code first.
+ unsigned int len=0;
+ XMLByte* decoded=Base64::decode(reinterpret_cast<const XMLByte*>(s),&len);
+ if (!decoded)
+ throw ArtifactException("Artifact parser unable to decode base64-encoded artifact.");
+
+ string type;
+ type+= decoded[0];
+ type+= decoded[1];
+ XMLString::release(&decoded);
+
+ return SAMLConfig::getConfig().SAMLArtifactManager.newPlugin(type,s);
+}
+
+string SAMLArtifact::toHex(const string& s)
+{
+ static char DIGITS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+ string::size_type len = s.length();
+ string ret;
+
+ // two characters form the hex value.
+ for (string::size_type i=0; i < len; i++) {
+ ret+=(DIGITS[((unsigned char)(0xF0 & s[i])) >> 4 ]);
+ ret+=(DIGITS[0x0F & s[i]]);
+ }
+ return ret;
+}
--- /dev/null
+/*\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/SAMLArtifact.h\r
+ * \r
+ * Base class for SAML 1.x and 2.0 artifacts \r
+ */\r
+\r
+#ifndef __saml_artifact_h__\r
+#define __saml_artifact_h__\r
+\r
+#include <saml/base.h>\r
+\r
+#include <string>\r
+#include <xmltooling/unicode.h>\r
+\r
+namespace opensaml {\r
+\r
+ /**\r
+ * Base class for SAML 1.x and 2.0 artifacts.\r
+ */\r
+ class SAML_API SAMLArtifact\r
+ {\r
+ SAMLArtifact& operator=(const SAMLArtifact& src);\r
+ public:\r
+ virtual ~SAMLArtifact() {}\r
+\r
+ /**\r
+ * Returns artifact encoded into null-terminated base64 for transmission.\r
+ */\r
+ virtual std::string encode() const;\r
+ \r
+ /**\r
+ * Builds a duplicate, independent artifact of the same type.\r
+ * \r
+ * @return the new artifact\r
+ */\r
+ virtual SAMLArtifact* clone() const=0;\r
+ \r
+ /**\r
+ * Returns all of the raw binary data that makes up the artifact.\r
+ * The result is NOT null-terminated.\r
+ * \r
+ * @return the binary artifact data\r
+ */\r
+ virtual std::string getBytes() const {\r
+ return m_raw;\r
+ }\r
+\r
+ /**\r
+ * Returns the binary type code of the artifact.\r
+ * The result is NOT null-terminated.\r
+ * \r
+ * @return the binary type code\r
+ */\r
+ virtual std::string getTypeCode() const {\r
+ return m_raw.substr(0,TYPECODE_LENGTH);\r
+ }\r
+ \r
+ /**\r
+ * Returns the binary artifact data following the type code.\r
+ * The result is NOT null-terminated.\r
+ * \r
+ * @return the binary artifact data\r
+ */\r
+ virtual std::string getRemainingArtifact() const {\r
+ return m_raw.substr(TYPECODE_LENGTH);\r
+ }\r
+ \r
+ /**\r
+ * Returns the binary data that identifies the source of the artifact.\r
+ * The exact form this takes depends on the type.\r
+ * The result is NOT null-terminated.\r
+ * \r
+ * @return the binary source data\r
+ */\r
+ virtual std::string getSource() const=0;\r
+ \r
+ /**\r
+ * Returns the binary data that references the message (2.0) or assertion (1.x)\r
+ * The exact form this takes depends on the type.\r
+ * The result is NOT null-terminated.\r
+ * \r
+ * @return the binary reference data\r
+ */\r
+ virtual std::string getMessageHandle() const=0;\r
+\r
+ /** Length of type code */ \r
+ static const unsigned int TYPECODE_LENGTH;\r
+\r
+ /**\r
+ * Parses a base64-encoded null-terminated string into an artifact,\r
+ * if the type is known.\r
+ * \r
+ * @param s base64-encoded artifact\r
+ * @return the decoded artifact\r
+ */\r
+ static SAMLArtifact* parse(const char* s);\r
+ \r
+ /**\r
+ * Parses a base64-encoded null-terminated string into an artifact,\r
+ * if the type is known.\r
+ * \r
+ * @param s base64-encoded artifact\r
+ * @return the decoded artifact\r
+ */\r
+ static SAMLArtifact* parse(const XMLCh* s) {\r
+ xmltooling::auto_ptr_char temp(s);\r
+ return parse(temp.get());\r
+ }\r
+\r
+ /**\r
+ * Converts binary data to hex notation.\r
+ * \r
+ * @param s the bytes to convert\r
+ * @return the data in hex form, 2 characters per byte\r
+ */\r
+ static std::string toHex(const std::string& s);\r
+ \r
+ protected:\r
+ SAMLArtifact() {}\r
+\r
+ /**\r
+ * Decodes a base64-encoded artifact into its raw form.\r
+ * \r
+ * @param s NULL-terminated base64-encoded string \r
+ */ \r
+ SAMLArtifact(const char* s);\r
+\r
+ SAMLArtifact(const SAMLArtifact& src) : m_raw(src.m_raw) {}\r
+ \r
+ /** Raw binary data that makes up an artifact. */\r
+ std::string m_raw;\r
+ };\r
+\r
+ DECL_XMLTOOLING_EXCEPTION(ArtifactException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions related to artifact parsing);\r
+ \r
+ /**\r
+ * Registers SAMLArtifact subclasses into the runtime.\r
+ */\r
+ void SAML_API registerSAMLArtifacts();\r
+};\r
+\r
+#endif /* __saml_artifact_h__ */\r
* Library configuration
*/
-#define SAML_DECLARE_VALIDATORS
-
#include "internal.h"
#include "exceptions.h"
+#include "SAMLArtifact.h"
#include "SAMLConfig.h"
#include "saml1/core/Assertions.h"
#include "saml1/core/Protocols.h"
#include <log4cpp/Category.hh>
#include <xsec/enc/XSECCryptoException.hpp>
+#include <xsec/enc/XSECCryptoProvider.hpp>
#include <xsec/utils/XSECPlatformUtils.hpp>
+
using namespace opensaml;
using namespace xmlsignature;
using namespace xmltooling;
using namespace log4cpp;
using namespace std;
-//DECL_EXCEPTION_FACTORY(XMLParserException,xmltooling);
+DECL_EXCEPTION_FACTORY(ArtifactException,opensaml);
+DECL_EXCEPTION_FACTORY(MetadataFilterException,opensaml::saml2md);
namespace opensaml {
SAMLInternalConfig g_config;
XMLToolingConfig::getConfig().init();
log.debug("XMLTooling library initialized");
+ REGISTER_EXCEPTION_FACTORY(ArtifactException,opensaml);
+ REGISTER_EXCEPTION_FACTORY(MetadataFilterException,opensaml::saml2md);
+
+ registerSAMLArtifacts();
saml1::registerAssertionClasses();
saml1p::registerProtocolClasses();
saml2::registerAssertionClasses();
saml2::AssertionSchemaValidators.destroyValidators();
saml2md::MetadataSchemaValidators.destroyValidators();
+ SAMLArtifactManager.deregisterFactories();
MetadataFilterManager.deregisterFactories();
MetadataProviderManager.deregisterFactories();
hexform[33]=0;
return XMLString::transcode(hexform);
}
+
+string SAMLInternalConfig::hashSHA1(const char* s, bool toHex)
+{
+ static char DIGITS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+ auto_ptr<XSECCryptoHash> hasher(XSECPlatformUtils::g_cryptoProvider->hashSHA1());
+ if (hasher.get()) {
+ auto_ptr<char> dup(strdup(s));
+ unsigned char buf[21];
+ hasher->hash(reinterpret_cast<unsigned char*>(dup.get()),strlen(dup.get()));
+ if (hasher->finish(buf,20)==20) {
+ string ret;
+ if (toHex) {
+ for (unsigned int i=0; i<20; i++) {
+ ret+=(DIGITS[((unsigned char)(0xF0 & buf[i])) >> 4 ]);
+ ret+=(DIGITS[0x0F & buf[i]]);
+ }
+ }
+ else {
+ for (unsigned int i=0; i<20; i++) {
+ ret+=buf[i];
+ }
+ }
+ return ret;
+ }
+ }
+ throw XMLSecurityException("Unable to generate SHA-1 hash.");
+}
#include <saml/base.h>\r
\r
#include <xmltooling/PluginManager.h>\r
-#include <xmltooling/unicode.h>\r
#include <xmltooling/XMLToolingConfig.h>\r
\r
#include <string>\r
*/\r
namespace opensaml {\r
\r
+ class SAML_API SAMLArtifact;\r
+\r
namespace saml2md {\r
class SAML_API MetadataProvider;\r
class SAML_API MetadataFilter;\r
virtual XMLCh* generateIdentifier()=0;\r
\r
/**\r
+ * Generate the SHA-1 hash of a string\r
+ * \r
+ * @param s NULL-terminated string to hash\r
+ * @param toHex true iff the result should be encoded in hexadecimal form or left as raw bytes\r
+ * \r
+ * @return SHA-1 hash of the data\r
+ */\r
+ virtual std::string hashSHA1(const char* s, bool toHex=false)=0;\r
+ \r
+ /**\r
* Manages factories for MetadataProvider plugins.\r
*/\r
xmltooling::PluginManager<saml2md::MetadataProvider,const DOMElement*> MetadataProviderManager;\r
*/\r
xmltooling::PluginManager<saml2md::MetadataFilter,const DOMElement*> MetadataFilterManager;\r
\r
+ /**\r
+ * Manages factories for SAMLArtifact plugins.\r
+ */\r
+ xmltooling::PluginManager<SAMLArtifact,const char*> SAMLArtifactManager;\r
+\r
protected:\r
SAMLConfig() {}\r
};\r
void generateRandomBytes(void* buf, unsigned int len);
void generateRandomBytes(std::string& buf, unsigned int len);
XMLCh* generateIdentifier();
+ std::string hashSHA1(const char* data, bool toHex=false);
private:
};
/// @endcond
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
>\r
<File\r
+ RelativePath=".\SAMLArtifact.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\SAMLConfig.cpp"\r
>\r
</File>\r
RelativePath=".\saml1\core\impl\ProtocolsSchemaValidators.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\saml1\core\impl\SAMLArtifactType0001.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\saml1\core\impl\SAMLArtifactType0002.cpp"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ </Filter>\r
+ <Filter\r
+ Name="profile"\r
+ >\r
+ <Filter\r
+ Name="impl"\r
+ >\r
</Filter>\r
</Filter>\r
</Filter>\r
>\r
</File>\r
<File\r
+ RelativePath=".\SAMLArtifact.h"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\SAMLConfig.h"\r
>\r
</File>\r
RelativePath=".\saml1\core\Protocols.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\saml1\core\SAMLArtifactType0001.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\saml1\core\SAMLArtifactType0002.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="profile"\r
+ >\r
</Filter>\r
</Filter>\r
<Filter\r
--- /dev/null
+/*\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/saml1/core/SAMLArtifactType0001.h\r
+ * \r
+ * Type 0x0001 SAML 1.x artifact class\r
+ */\r
+\r
+#ifndef __saml_artifacttype0001_h__\r
+#define __saml_artifacttype0001_h__\r
+\r
+#include <saml/SAMLArtifact.h>\r
+\r
+namespace opensaml {\r
+ namespace saml1p {\r
+ \r
+ /**\r
+ * Type 0x0001 SAML 1.x artifact class\r
+ */\r
+ class SAML_API SAMLArtifactType0001 : public SAMLArtifact\r
+ {\r
+ SAMLArtifactType0001& operator=(const SAMLArtifactType0001& src);\r
+ public:\r
+ /**\r
+ * Decodes a base64-encoded type 0x0001 artifact\r
+ * \r
+ * @param s NULL-terminated base64-encoded string \r
+ */ \r
+ SAMLArtifactType0001(const char* s);\r
+\r
+ /**\r
+ * Constructs an artifact with the specified source ID, but a random assertion handle.\r
+ * \r
+ * @param sourceid SOURCEID_LENGTH bytes of binary data \r
+ */ \r
+ SAMLArtifactType0001(const std::string& sourceid);\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 handle HANDLE_LENGTH bytes of binary data \r
+ */ \r
+ SAMLArtifactType0001(const std::string& sourceid, const std::string& handle);\r
+ \r
+ virtual ~SAMLArtifactType0001() {}\r
+ \r
+ virtual SAMLArtifactType0001* clone() const {\r
+ return new SAMLArtifactType0001(*this);\r
+ }\r
+ \r
+ virtual std::string getSource() const {\r
+ return m_raw.substr(TYPECODE_LENGTH,SOURCEID_LENGTH); // bytes 3-22\r
+ }\r
+ \r
+ virtual std::string getMessageHandle() const {\r
+ return m_raw.substr(TYPECODE_LENGTH+SOURCEID_LENGTH, HANDLE_LENGTH); // bytes 23-42\r
+ }\r
+\r
+ /** Length of source ID */ \r
+ static const unsigned int SOURCEID_LENGTH;\r
+\r
+ /** Length of assertion handle */ \r
+ static const unsigned int HANDLE_LENGTH;\r
+ \r
+ protected:\r
+ SAMLArtifactType0001(const SAMLArtifact& src) : SAMLArtifact(src) {}\r
+ };\r
+ \r
+ };\r
+};\r
+\r
+#endif /* __saml_artifacttype0001_h__ */\r
--- /dev/null
+/*\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/saml1/core/SAMLArtifactType0002.h\r
+ * \r
+ * Type 0x0002 SAML 1.x artifact class\r
+ */\r
+\r
+#ifndef __saml_artifacttype0002_h__\r
+#define __saml_artifacttype0002_h__\r
+\r
+#include <saml/SAMLArtifact.h>\r
+\r
+namespace opensaml {\r
+ namespace saml1p {\r
+ \r
+ /**\r
+ * Type 0x0002 SAML 1.x artifact class\r
+ */\r
+ class SAML_API SAMLArtifactType0002 : public SAMLArtifact\r
+ {\r
+ SAMLArtifactType0002& operator=(const SAMLArtifactType0002& src);\r
+ public:\r
+ /**\r
+ * Decodes a base64-encoded type 0x0002 artifact\r
+ * \r
+ * @param s NULL-terminated base64-encoded string \r
+ */ \r
+ SAMLArtifactType0002(const char* s);\r
+\r
+ /**\r
+ * Constructs an artifact with the specified source URL, but a random assertion handle.\r
+ * \r
+ * @param sourceLocation source URL\r
+ */ \r
+ SAMLArtifactType0002(const std::string& sourceLocation);\r
+\r
+ /**\r
+ * Constructs an artifact with the specified source URL and assertion handle.\r
+ * \r
+ * @param sourceLocation source URL\r
+ * @param handle HANDLE_LENGTH bytes of binary data \r
+ */ \r
+ SAMLArtifactType0002(const std::string& sourceLocation, const std::string& handle);\r
+ \r
+ virtual ~SAMLArtifactType0002() {}\r
+ \r
+ virtual SAMLArtifactType0002* clone() const {\r
+ return new SAMLArtifactType0002(*this);\r
+ }\r
+ \r
+ virtual std::string getMessageHandle() const {\r
+ return m_raw.substr(TYPECODE_LENGTH, HANDLE_LENGTH); // bytes 3-22\r
+ }\r
+\r
+ virtual std::string getSource() const {\r
+ return m_raw.c_str() + TYPECODE_LENGTH + HANDLE_LENGTH; // bytes 23-terminating null\r
+ }\r
+ \r
+ /** Length of assertion handle */\r
+ static const unsigned int HANDLE_LENGTH;\r
+ \r
+ protected:\r
+ SAMLArtifactType0002(const SAMLArtifact& src) : SAMLArtifact(src) {}\r
+ };\r
+ \r
+ };\r
+};\r
+\r
+#endif /* __saml_artifacttype0002_h__ */\r
--- /dev/null
+/*
+ * 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.
+ */
+
+/**
+ * SAMLArtifactType0001.cpp
+ *
+ * Type 0x0001 SAML 1.x artifact class
+ */
+
+#include "internal.h"
+#include "saml1/core/SAMLArtifactType0001.h"
+
+using namespace opensaml::saml1p;
+using namespace opensaml;
+using namespace xmltooling;
+using namespace std;
+
+namespace opensaml {
+ namespace saml1p {
+ SAMLArtifact* SAML_DLLLOCAL SAMLArtifactType0001Factory(const char* const & s)
+ {
+ return new SAMLArtifactType0001(s);
+ }
+ }
+};
+
+const unsigned int SAMLArtifactType0001::SOURCEID_LENGTH = 20;
+const unsigned int SAMLArtifactType0001::HANDLE_LENGTH = 20;
+
+SAMLArtifactType0001::SAMLArtifactType0001(const char* s) : SAMLArtifact(s)
+{
+ // The base class does the work, we just do the checking.
+ if (m_raw.size() != TYPECODE_LENGTH + SOURCEID_LENGTH + HANDLE_LENGTH)
+ throw ArtifactException("Type 0x0001 artifact is of incorrect length.");
+ else if (m_raw[0] != 0x0 || m_raw[1] != 0x1)
+ throw ArtifactException(
+ string("Type 0x0001 artifact given an artifact of invalid type (") + toHex(getTypeCode()) + ")."
+ );
+}
+
+SAMLArtifactType0001::SAMLArtifactType0001(const string& sourceid)
+{
+ if (sourceid.size()!=SOURCEID_LENGTH)
+ throw ArtifactException("Type 0x0001 artifact sourceid of incorrect length.");
+ m_raw+=(char)0x0;
+ m_raw+=(char)0x1;
+ 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];
+}
+
+SAMLArtifactType0001::SAMLArtifactType0001(const string& sourceid, const string& handle)
+{
+ if (sourceid.size()!=SOURCEID_LENGTH)
+ throw ArtifactException("Type 0x0001 artifact sourceid of incorrect length.");
+ if (handle.size()!=HANDLE_LENGTH)
+ throw ArtifactException("Type 0x0001 artifact assertion handle of incorrect length.");
+ m_raw+=(char)0x0;
+ m_raw+=(char)0x1;
+ m_raw.append(sourceid,0,SOURCEID_LENGTH);
+ m_raw.append(handle,0,HANDLE_LENGTH);
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+/**
+ * SAMLArtifactType0002.cpp
+ *
+ * Type 0x0002 SAML 1.x artifact class
+ */
+
+#include "internal.h"
+#include "saml1/core/SAMLArtifactType0002.h"
+
+using namespace opensaml::saml1p;
+using namespace opensaml;
+using namespace xmltooling;
+using namespace std;
+
+namespace opensaml {
+ namespace saml1p {
+ SAMLArtifact* SAML_DLLLOCAL SAMLArtifactType0002Factory(const char* const & s)
+ {
+ return new SAMLArtifactType0002(s);
+ }
+ }
+};
+
+const unsigned int SAMLArtifactType0002::HANDLE_LENGTH = 20;
+
+SAMLArtifactType0002::SAMLArtifactType0002(const char* s) : SAMLArtifact(s)
+{
+ // The base class does the work, we just do the checking.
+ if (m_raw.size() <= TYPECODE_LENGTH + HANDLE_LENGTH)
+ throw ArtifactException("Type 0x0002 artifact given artifact of incorrect length.");
+ else if (m_raw[0] != 0x0 || m_raw[1] != 0x2)
+ throw ArtifactException(
+ string("Type 0x0002 artifact given artifact of invalid type (") + toHex(getTypeCode()) + ")."
+ );
+}
+
+SAMLArtifactType0002::SAMLArtifactType0002(const string& sourceLocation)
+{
+ if (sourceLocation.empty())
+ throw ArtifactException("Type 0x0002 artifact with empty source location.");
+ m_raw+=(char)0x0;
+ m_raw+=(char)0x2;
+ char buf[HANDLE_LENGTH];
+ SAMLConfig::getConfig().generateRandomBytes(buf,HANDLE_LENGTH);
+ for (int i=0; i<HANDLE_LENGTH; i++)
+ m_raw+=buf[i];
+ m_raw+=sourceLocation;
+}
+
+SAMLArtifactType0002::SAMLArtifactType0002(const string& sourceLocation, const string& handle)
+{
+ if (sourceLocation.empty())
+ throw ArtifactException("Type 0x0002 artifact with empty source location.");
+ if (handle.size()!=HANDLE_LENGTH)
+ throw ArtifactException("Type 0x0002 artifact with handle of incorrect length.");
+ m_raw+=(char)0x0;
+ m_raw+=(char)0x2;
+ m_raw.append(handle,0,HANDLE_LENGTH);
+ m_raw+=sourceLocation;
+}