X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fbinding%2Fimpl%2FSAMLArtifact.cpp;h=755089e4c9ef175b6ad428e8937c455fbe89fca7;hb=c072b75e6f6e05e24a1c35b952008b38d0d375c1;hp=c28ef5bf3bc3d3e892b96b216865a8b70bed5bb2;hpb=71425c1586a07281fdddd2fc2faa60d97d7f1df8;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/binding/impl/SAMLArtifact.cpp b/saml/binding/impl/SAMLArtifact.cpp index c28ef5b..755089e 100644 --- a/saml/binding/impl/SAMLArtifact.cpp +++ b/saml/binding/impl/SAMLArtifact.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,15 @@ /** * SAMLArtifact.cpp * - * Base class for SAML 1.x and 2.0 artifacts + * Base class for SAML 1.x and 2.0 artifacts. */ #include "internal.h" #include "binding/SAMLArtifact.h" #include +#include +#include using namespace opensaml; using namespace xmltooling; @@ -31,12 +33,12 @@ using namespace std; namespace opensaml { namespace saml1p { - SAML_DLLLOCAL PluginManager::Factory SAMLArtifactType0001Factory; - SAML_DLLLOCAL PluginManager::Factory SAMLArtifactType0002Factory; + SAML_DLLLOCAL PluginManager::Factory SAMLArtifactType0001Factory; + SAML_DLLLOCAL PluginManager::Factory SAMLArtifactType0002Factory; }; namespace saml2p { - SAML_DLLLOCAL PluginManager::Factory SAML2ArtifactType0004Factory; + SAML_DLLLOCAL PluginManager::Factory SAML2ArtifactType0004Factory; }; }; @@ -61,23 +63,46 @@ const unsigned int SAMLArtifact::TYPECODE_LENGTH = 2; SAMLArtifact::SAMLArtifact(const char* s) { - unsigned int len=0; + xsecsize_t len=0; XMLByte* decoded=Base64::decode(reinterpret_cast(s),&len); if (!decoded) throw ArtifactException("Unable to decode base64 artifact."); XMLByte* ptr=decoded; while (len--) m_raw+= *ptr++; +#ifdef OPENSAML_XERCESC_HAS_XMLBYTE_RELEASE XMLString::release(&decoded); +#else + XMLString::release((char**)&decoded); +#endif +} + +string SAMLArtifact::getBytes() const +{ + return m_raw; +} + +string SAMLArtifact::getTypeCode() const +{ + return m_raw.substr(0,TYPECODE_LENGTH); +} + +string SAMLArtifact::getRemainingArtifact() const +{ + return m_raw.substr(TYPECODE_LENGTH); } string SAMLArtifact::encode() const { - unsigned int len=0; + xsecsize_t len=0; XMLByte* out=Base64::encode(reinterpret_cast(m_raw.data()),m_raw.size(),&len); if (out) { string ret(reinterpret_cast(out),len); +#ifdef OPENSAML_XERCESC_HAS_XMLBYTE_RELEASE XMLString::release(&out); +#else + XMLString::release((char**)&out); +#endif return ret; } return string(); @@ -86,7 +111,7 @@ string SAMLArtifact::encode() const SAMLArtifact* SAMLArtifact::parse(const char* s) { // Decode and extract the type code first. - unsigned int len=0; + xsecsize_t len=0; XMLByte* decoded=Base64::decode(reinterpret_cast(s),&len); if (!decoded) throw ArtifactException("Artifact parser unable to decode base64-encoded artifact."); @@ -94,11 +119,21 @@ SAMLArtifact* SAMLArtifact::parse(const char* s) string type; type+= decoded[0]; type+= decoded[1]; +#ifdef OPENSAML_XERCESC_HAS_XMLBYTE_RELEASE XMLString::release(&decoded); +#else + XMLString::release((char**)&decoded); +#endif return SAMLConfig::getConfig().SAMLArtifactManager.newPlugin(type,s); } +SAMLArtifact* SAMLArtifact::parse(const XMLCh* s) +{ + auto_ptr_char temp(s); + return parse(temp.get()); +} + 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'};