https://issues.shibboleth.net/jira/browse/SSPCPP-209
authorScott Cantor <cantor.2@osu.edu>
Tue, 2 Jun 2009 21:05:42 +0000 (21:05 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 2 Jun 2009 21:05:42 +0000 (21:05 +0000)
shibsp/attribute/NameIDAttributeDecoder.cpp
shibsp/attribute/NameIDFromScopedAttributeDecoder.cpp

index aa257e1..38ad01c 100644 (file)
@@ -35,11 +35,17 @@ using namespace std;
 \r
 namespace shibsp {\r
     static const XMLCh formatter[] = UNICODE_LITERAL_9(f,o,r,m,a,t,t,e,r);\r
+    static const XMLCh defaultQualifiers[] = UNICODE_LITERAL_17(d,e,f,a,u,l,t,Q,u,a,l,i,f,i,e,r,s);\r
 \r
     class SHIBSP_DLLLOCAL NameIDAttributeDecoder : virtual public AttributeDecoder\r
     {\r
     public:\r
-        NameIDAttributeDecoder(const DOMElement* e) : AttributeDecoder(e), m_formatter(e ? e->getAttributeNS(NULL,formatter) : NULL) {}\r
+        NameIDAttributeDecoder(const DOMElement* e)\r
+                : AttributeDecoder(e), m_formatter(e ? e->getAttributeNS(NULL, formatter) : NULL), m_defaultQualifiers(false) {\r
+            const XMLCh* flag = e ? e->getAttributeNS(NULL, defaultQualifiers) : NULL;\r
+            if (flag && (*flag == chLatin_t || *flag == chDigit_1))\r
+                m_defaultQualifiers = true;\r
+        }\r
         ~NameIDAttributeDecoder() {}\r
 \r
         shibsp::Attribute* decode(\r
@@ -54,6 +60,7 @@ namespace shibsp {
             const NameIdentifier* n, vector<NameIDAttribute::Value>& dest, const char* assertingParty, const char* relyingParty\r
             ) const;\r
         auto_ptr_char m_formatter;\r
+        bool m_defaultQualifiers;\r
     };\r
 \r
     AttributeDecoder* SHIBSP_DLLLOCAL NameIDAttributeDecoderFactory(const DOMElement* const & e)\r
@@ -181,14 +188,14 @@ void NameIDAttributeDecoder::extract(
         str = toUTF8(n->getNameQualifier());\r
         if (str && *str)\r
             val.m_NameQualifier = str;\r
-        else if (assertingParty)\r
+        else if (m_defaultQualifiers && assertingParty)\r
             val.m_NameQualifier = assertingParty;\r
         delete[] str;\r
 \r
         str = toUTF8(n->getSPNameQualifier());\r
         if (str && *str)\r
             val.m_SPNameQualifier = str;\r
-        else if (relyingParty)\r
+        else if (m_defaultQualifiers && relyingParty)\r
             val.m_SPNameQualifier = relyingParty;\r
         delete[] str;\r
 \r
@@ -218,11 +225,11 @@ void NameIDAttributeDecoder::extract(
         str = toUTF8(n->getNameQualifier());\r
         if (str && *str)\r
             val.m_NameQualifier = str;\r
-        else if (assertingParty)\r
+        else if (m_defaultQualifiers && assertingParty)\r
             val.m_NameQualifier = assertingParty;\r
         delete[] str;\r
 \r
-        if (relyingParty)\r
+        if (m_defaultQualifiers && relyingParty)\r
             val.m_SPNameQualifier = relyingParty;\r
     }\r
 }\r
index 5711419..611bd5f 100644 (file)
@@ -34,20 +34,28 @@ using namespace xmltooling;
 using namespace std;
 
 namespace shibsp {
-    static XMLCh format[] =                 UNICODE_LITERAL_6(f,o,r,m,a,t);
-    static XMLCh formatter[] =              UNICODE_LITERAL_9(f,o,r,m,a,t,t,e,r);
+    static const XMLCh defaultQualifiers[] =UNICODE_LITERAL_17(d,e,f,a,u,l,t,Q,u,a,l,i,f,i,e,r,s);
+    static const XMLCh format[] =           UNICODE_LITERAL_6(f,o,r,m,a,t);
+    static const XMLCh formatter[] =        UNICODE_LITERAL_9(f,o,r,m,a,t,t,e,r);
     static const XMLCh Scope[] =            UNICODE_LITERAL_5(S,c,o,p,e);
     static const XMLCh scopeDelimeter[] =   UNICODE_LITERAL_14(s,c,o,p,e,D,e,l,i,m,e,t,e,r);
 
     class SHIBSP_DLLLOCAL NameIDFromScopedAttributeDecoder : virtual public AttributeDecoder
     {
     public:
-        NameIDFromScopedAttributeDecoder(const DOMElement* e) : AttributeDecoder(e), m_delimeter('@'),
-                m_format(e ? e->getAttributeNS(NULL,format) : NULL), m_formatter(e ? e->getAttributeNS(NULL,formatter) : NULL) {
+        NameIDFromScopedAttributeDecoder(const DOMElement* e)
+            : AttributeDecoder(e),
+                m_delimeter('@'),
+                m_format(e ? e->getAttributeNS(NULL,format) : NULL),
+                m_formatter(e ? e->getAttributeNS(NULL,formatter) : NULL),
+                m_defaultQualifiers(false) {
             if (e && e->hasAttributeNS(NULL,scopeDelimeter)) {
                 auto_ptr_char d(e->getAttributeNS(NULL,scopeDelimeter));
                 m_delimeter = *(d.get());
             }
+            const XMLCh* flag = e ? e->getAttributeNS(NULL, defaultQualifiers) : NULL;
+            if (flag && (*flag == chLatin_t || *flag == chDigit_1))
+                m_defaultQualifiers = true;
         }
         ~NameIDFromScopedAttributeDecoder() {}
 
@@ -59,6 +67,7 @@ namespace shibsp {
         char m_delimeter;
         auto_ptr_char m_format;
         auto_ptr_char m_formatter;
+        bool m_defaultQualifiers;
     };
 
     AttributeDecoder* SHIBSP_DLLLOCAL NameIDFromScopedAttributeDecoderFactory(const DOMElement* const & e)
@@ -135,9 +144,9 @@ shibsp::Attribute* NameIDFromScopedAttributeDecoder::decode(
                     destval.m_Name = val;
                     if (m_format.get() && *m_format.get())
                         destval.m_Format = m_format.get();
-                    if (assertingParty)
+                    if (m_defaultQualifiers && assertingParty)
                         destval.m_NameQualifier = assertingParty;
-                    if (relyingParty)
+                    if (m_defaultQualifiers && relyingParty)
                         destval.m_SPNameQualifier = relyingParty;
                 }
                 else {