Adding case sensitivity flag to AAP rules.
authorScott Cantor <cantor.2@osu.edu>
Thu, 22 Jul 2004 17:29:02 +0000 (17:29 +0000)
committerScott Cantor <cantor.2@osu.edu>
Thu, 22 Jul 2004 17:29:02 +0000 (17:29 +0000)
shib/Makefile.am
shib/shib.h
xmlproviders/XML.cpp
xmlproviders/XMLAAP.cpp
xmlproviders/internal.h

index bb1a6d3..5bdf8ad 100644 (file)
@@ -20,7 +20,7 @@ libshib_la_SOURCES = \
 
 # this is different from the project version
 # http://sources.redhat.com/autobook/autobook/autobook_91.html
-libshib_la_LDFLAGS = -version-info 5:0:0
+libshib_la_LDFLAGS = -version-info 6:0:0
 
 install-exec-hook:
        for la in $(lib_LTLIBRARIES) ; do rm -f $(DESTDIR)$(libdir)/$$la ; done
index 20c2b7e..3a32d5c 100644 (file)
@@ -293,6 +293,7 @@ namespace shibboleth
         virtual const char* getFactory() const=0;
         virtual const char* getAlias() const=0;
         virtual const char* getHeader() const=0;
+        virtual bool getCaseSensitive() const=0;
         virtual void apply(const IProvider* originSite, saml::SAMLAttribute& attribute) const=0;
         virtual ~IAttributeRule() {}
     };
index b3de64f..8bbf9f1 100644 (file)
@@ -259,6 +259,11 @@ const XMLCh XML::Literals::AttributeRule[] =
   chLatin_R, chLatin_u, chLatin_l, chLatin_e, chNull
 };
 
+const XMLCh XML::Literals::CaseSensitive[] =
+{ chLatin_C, chLatin_a, chLatin_s, chLatin_e,
+  chLatin_S, chLatin_e, chLatin_n, chLatin_s, chLatin_i, chLatin_t, chLatin_i, chLatin_v, chLatin_e, chNull
+};
+
 const XMLCh XML::Literals::Factory[]=
 { chLatin_F, chLatin_a, chLatin_c, chLatin_t, chLatin_o, chLatin_r, chLatin_y, chNull };
 
index 40bd3fa..7702abf 100644 (file)
@@ -88,6 +88,7 @@ namespace {
             const char* getFactory() const { return m_factory.get(); }
             const char* getAlias() const { return m_alias.get(); }
             const char* getHeader() const { return m_header.get(); }
+            bool getCaseSensitive() const { return m_caseSensitive; }
             void apply(const IProvider* originSite, SAMLAttribute& attribute) const;
     
             enum value_type { literal, regexp, xpath };
@@ -97,6 +98,7 @@ namespace {
             auto_ptr_char m_factory;
             auto_ptr_char m_alias;
             auto_ptr_char m_header;
+            bool m_caseSensitive;
             
             value_type toValueType(const DOMElement* e);
             bool scopeCheck(const IProvider* originSite, const DOMElement* e) const;
@@ -247,13 +249,14 @@ XMLAAPImpl::AttributeRule::AttributeRule(const DOMElement* e) :
     m_header(e->hasAttributeNS(NULL,SHIB_L(Header)) ? e->getAttributeNS(NULL,SHIB_L(Header)) : NULL)
     
 {
-    static const XMLCh wTrue[] = {chLatin_t, chLatin_r, chLatin_u, chLatin_e, chNull};
-
     m_name=e->getAttributeNS(NULL,SHIB_L(Name));
     m_namespace=e->getAttributeNS(NULL,SHIB_L(Namespace));
     if (!m_namespace || !*m_namespace)
         m_namespace=Constants::SHIB_ATTRIBUTE_NAMESPACE_URI;
     
+    const XMLCh* caseSensitive=e->getAttributeNS(NULL,SHIB_L(CaseSensitive));
+    m_caseSensitive=(!caseSensitive || !*caseSensitive || *caseSensitive==chDigit_1 || *caseSensitive==chLatin_t);
+    
     // Check for an AnySite rule.
     DOMNode* anysite = e->getFirstChild();
     while (anysite && anysite->getNodeType()!=DOMNode::ELEMENT_NODE)
@@ -273,7 +276,7 @@ XMLAAPImpl::AttributeRule::AttributeRule(const DOMElement* e) :
             if (valnode && valnode->getNodeType()==DOMNode::TEXT_NODE)
             {
                 const XMLCh* accept=se->getAttributeNS(NULL,SHIB_L(Accept));
-                if (!accept || !*accept || *accept==chDigit_1 || !XMLString::compareString(accept,wTrue))
+                if (!accept || !*accept || *accept==chDigit_1 || *accept==chLatin_t)
                     m_anySiteRule.scopeAccepts.push_back(pair<value_type,const XMLCh*>(toValueType(se),valnode->getNodeValue()));
                 else
                     m_anySiteRule.scopeDenials.push_back(pair<value_type,const XMLCh*>(toValueType(se),valnode->getNodeValue()));
@@ -323,7 +326,7 @@ XMLAAPImpl::AttributeRule::AttributeRule(const DOMElement* e) :
             if (valnode && valnode->getNodeType()==DOMNode::TEXT_NODE)
             {
                 const XMLCh* accept=se->getAttributeNS(NULL,SHIB_L(Accept));
-                if (!accept || *accept==chDigit_1 || !XMLString::compareString(accept,wTrue))
+                if (!accept || !*accept || *accept==chDigit_1 || *accept==chLatin_t)
                     srule.scopeAccepts.push_back(pair<value_type,const XMLCh*>(toValueType(se),valnode->getNodeValue()));
                 else
                     srule.scopeDenials.push_back(pair<value_type,const XMLCh*>(toValueType(se),valnode->getNodeValue()));
@@ -584,16 +587,27 @@ bool XMLAAPImpl::AttributeRule::accept(const IProvider* originSite, const DOMEle
         return scopeCheck(originSite,e);
     }
 
-    for (i=srule->second.valueRules.begin(); bSimple && i!=srule->second.valueRules.end(); i++)
-    {
-        if ((i->first==literal && !XMLString::compareString(i->second,n->getNodeValue())) ||
-            (i->first==regexp && match(i->second,n->getNodeValue())))
-        {
-            log.debug("matching site, value match");
-            return scopeCheck(originSite,e);
+    for (i=srule->second.valueRules.begin(); bSimple && i!=srule->second.valueRules.end(); i++) {
+        switch (i->first) {
+            case literal:
+                if ((m_caseSensitive && !XMLString::compareString(i->second,n->getNodeValue())) ||
+                    (!m_caseSensitive && !XMLString::compareIString(i->second,n->getNodeValue()))) {
+                    log.debug("matching site, value match");
+                    return scopeCheck(originSite,e);
+                }
+                break;
+            
+            case regexp:
+                if (match(i->second,n->getNodeValue())) {
+                    log.debug("matching site, value match");
+                    return scopeCheck(originSite,e);
+                }
+                break;
+            
+            case xpath:
+                log.warn("implementation does not support XPath value rules");
+                break;
         }
-        else if (i->first==xpath)
-            log.warn("implementation does not support XPath value rules");
     }
 
     if (log.isWarnEnabled())
index 3686346..f1c71bf 100644 (file)
@@ -169,6 +169,7 @@ public:
         static const XMLCh AnyValue[];
         static const XMLCh AttributeAcceptancePolicy[];
         static const XMLCh AttributeRule[];
+        static const XMLCh CaseSensitive[];
         static const XMLCh Factory[];
         static const XMLCh Header[];
         static const XMLCh Namespace[];