https://issues.shibboleth.net/jira/browse/SSPCPP-472
authorscantor <scantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Fri, 6 Jul 2012 21:39:44 +0000 (21:39 +0000)
committerscantor <scantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Fri, 6 Jul 2012 21:39:44 +0000 (21:39 +0000)
git-svn-id: https://svn.shibboleth.net/cpp-sp/branches/REL_2@3724 cb58f699-b61c-0410-a6fe-9272a202ed29

plugins/TemplateAttributeResolver.cpp
plugins/TransformAttributeResolver.cpp
shibsp/attribute/ExtensibleAttribute.cpp
shibsp/attribute/NameIDAttribute.cpp

index f809cd9..124e8a4 100644 (file)
@@ -213,6 +213,7 @@ void TemplateAttributeResolver::resolveAttributes(ResolutionContext& ctx) const
         if (start != string::npos && start < m_template.length())
             processed += m_template.substr(start, i);    // append rest of string
 
+        trim(processed);
         if (processed.empty())
             dest->getValues().pop_back();
     }
index 1856d3e..6b4bf7b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <algorithm>
 #include <boost/shared_ptr.hpp>
+#include <boost/algorithm/string/trim.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <shibsp/exceptions.h>
 #include <shibsp/SessionCache.h>
@@ -232,10 +233,12 @@ void TransformAttributeResolver::resolveAttributes(ResolutionContext& ctx) const
                         if (dest) {
                             // Modify in place.
                             dest->getValues()[i] = narrow.get();
+                            trim(dest->getValues()[i]);
                         }
                         else {
                             // Add to new object.
                             destwrapper->getValues().push_back(narrow.get());
+                            trim(destwrapper->getValues().back());
                         }
                     }
                 }
index 41a38a5..2d4fe54 100644 (file)
@@ -29,6 +29,8 @@
 #include "attribute/ExtensibleAttribute.h"
 #include "util/SPConstants.h"
 
+#include <boost/algorithm/string/trim.hpp>
+
 using namespace shibsp;
 using namespace xmltooling;
 using namespace std;
@@ -103,20 +105,20 @@ const vector<string>& ExtensibleAttribute::getSerializedValues() const
                 string& processed = m_serialized.back();
 
                 string::size_type i=0,start=0;
-                while (start!=string::npos && start<msg.length() && (i=msg.find("$",start))!=string::npos) {
+                while (start != string::npos && start < msg.length() && (i = msg.find("$",start)) != string::npos) {
                     if (i>start)
-                        processed += msg.substr(start,i-start); // append everything in between
-                    start=i+1;                                  // move start to the beginning of the token name
-                    i=msg.find_first_not_of(legal,start);       // find token delimiter
-                    if (i==start) {                             // append a non legal character
-                       processed+=msg[start++];
+                        processed += msg.substr(start, i-start);    // append everything in between
+                    start = i+1;                                    // move start to the beginning of the token name
+                    i = msg.find_first_not_of(legal, start);        // find token delimiter
+                    if (i == start) {                               // append a non legal character
+                       processed += msg[start++];
                        continue;
                     }
                     
-                    string tag = msg.substr(start,(i==string::npos) ? i : i-start);
+                    string tag = msg.substr(start, (i==string::npos) ? i : i-start);
                     if (tag == "_string" && val.string()) {
                         processed += val.string();
-                        start=i;
+                        start = i;
                     }
                     else {
                         DDF child = val.getmember(tag.c_str());
@@ -124,11 +126,12 @@ const vector<string>& ExtensibleAttribute::getSerializedValues() const
                             processed += child.string();
                         else if (child.isstruct() && child["_string"].string())
                             processed += child["_string"].string();
-                        start=i;
+                        start = i;
                     }
                 }
-                if (start!=string::npos && start<msg.length())
+                if (start != string::npos && start < msg.length())
                     processed += msg.substr(start,i);    // append rest of string
+                boost::trim(processed);
 
                 val = m_obj.first().next();
             }
index 9f15c1e..fbdb2c9 100644 (file)
@@ -29,6 +29,7 @@
 #include "attribute/NameIDAttribute.h"
 #include "remoting/ListenerService.h"
 
+#include <boost/algorithm/string/trim.hpp>
 #include <xmltooling/exceptions.h>
 #include <xmltooling/security/SecurityHelper.h>
 
@@ -139,16 +140,19 @@ const vector<string>& NameIDAttribute::getSerializedValues() const
                 );
             if (m_hashAlg.empty()) {
                 m_serialized.push_back(e.what());
+                boost::trim(m_serialized.back());
             }
             else {
+                string trimmed(e.what());
+                boost::trim(trimmed);
 #ifndef SHIBSP_LITE
-                m_serialized.push_back(SecurityHelper::doHash(m_hashAlg.c_str(), e.what(), strlen(e.what())));
+                m_serialized.push_back(SecurityHelper::doHash(m_hashAlg.c_str(), trimmed.c_str(), strlen(e.what())));
 #else
                 try {
                     DDF out, in("hash");
                     DDFJanitor jin(in), jout(out);
                     in.addmember("alg").string(m_hashAlg.c_str());
-                    in.addmember("data").unsafe_string(e.what());
+                    in.addmember("data").unsafe_string(trimmed.c_str());
                     out = SPConfig::getConfig().getServiceProvider()->getListenerService()->send(in);
                     if (out.isstring() && out.string())
                         m_serialized.push_back(out.string());