Copied over mapping and filtering schemas.
[shibboleth/sp.git] / shibsp / attribute / ScopedAttributeDecoder.cpp
index 312f3d4..464f482 100644 (file)
@@ -36,23 +36,34 @@ using namespace log4cpp;
 using namespace std;\r
 \r
 namespace shibsp {\r
+    static const XMLCh Scope[] =            UNICODE_LITERAL_5(S,c,o,p,e);\r
+    static const XMLCh scopeDelimeter[] =   UNICODE_LITERAL_14(s,c,o,p,e,D,e,l,i,m,e,t,e,r);\r
+\r
     class SHIBSP_DLLLOCAL ScopedAttributeDecoder : virtual public AttributeDecoder\r
     {\r
     public:\r
-        ScopedAttributeDecoder(const DOMElement* e) {}\r
+        ScopedAttributeDecoder(const DOMElement* e) : AttributeDecoder(e), m_delimeter('@') {\r
+            if (e) {\r
+                if (e->hasAttributeNS(NULL,scopeDelimeter)) {\r
+                    auto_ptr_char d(e->getAttributeNS(NULL,scopeDelimeter));\r
+                    m_delimeter = *(d.get());\r
+                }\r
+            }\r
+        }\r
         ~ScopedAttributeDecoder() {}\r
 \r
         shibsp::Attribute* decode(\r
             const char* id, const XMLObject* xmlObject, const char* assertingParty=NULL, const char* relyingParty=NULL\r
             ) const;\r
+\r
+    private:\r
+        char m_delimeter;\r
     };\r
 \r
     AttributeDecoder* SHIBSP_DLLLOCAL ScopedAttributeDecoderFactory(const DOMElement* const & e)\r
     {\r
         return new ScopedAttributeDecoder(e);\r
     }\r
-\r
-    static const XMLCh Scope[] = UNICODE_LITERAL_5(S,c,o,p,e);\r
 };\r
 \r
 shibsp::Attribute* ScopedAttributeDecoder::decode(\r
@@ -64,6 +75,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode(
     const XMLCh* xmlscope;\r
     QName scopeqname(NULL,Scope);\r
     auto_ptr<ScopedAttribute> scoped(new ScopedAttribute(id));\r
+    scoped->setCaseSensitive(m_caseSensitive);\r
     vector< pair<string,string> >& dest = scoped->getValues();\r
     vector<XMLObject*>::const_iterator v,stop;\r
 \r
@@ -109,7 +121,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode(
                         delete[] scope;\r
                     }\r
                     else {\r
-                        scope = strchr(val, '@');\r
+                        scope = strchr(val, m_delimeter);\r
                         if (scope) {\r
                             *scope++ = 0;\r
                             if (*scope)\r
@@ -158,8 +170,8 @@ shibsp::Attribute* ScopedAttributeDecoder::decode(
         }\r
     }\r
 \r
-    if (val && *val && *val!='@') {\r
-        scope = strchr(val, '@');\r
+    if (val && *val && *val!=m_delimeter) {\r
+        scope = strchr(val, m_delimeter);\r
         if (scope) {\r
             *scope++ = 0;\r
             if (*scope)\r
@@ -168,7 +180,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode(
                 log.warn("ignoring NameID with no scope");\r
         }\r
         else {\r
-            log.warn("ignoring NameID with no scope delimiter (@)");\r
+            log.warn("ignoring NameID with no scope delimiter (%c)", m_delimeter);\r
         }\r
     }\r
     else {\r