Bump header file dependencies in specfile
[shibboleth/cpp-sp.git] / shibsp / Application.cpp
index 2fc42f3..cf48efa 100644 (file)
@@ -63,27 +63,32 @@ const char* Application::getId() const
 pair<string,const char*> Application::getCookieNameProps(const char* prefix, time_t* lifetime) const
 {
     static const char* defProps="; path=/; HttpOnly";
+    static const char* sslProps="; path=/; secure; HttpOnly";
 
     if (lifetime)
         *lifetime = 0;
-    const PropertySet* props=getPropertySet("Sessions");
+    if (!prefix)
+        prefix = "";
+    const PropertySet* props = getPropertySet("Sessions");
     if (props) {
         if (lifetime) {
             pair<bool,unsigned int> lt = props->getUnsignedInt("cookieLifetime");
             if (lt.first)
                 *lifetime = lt.second;
         }
-        pair<bool,const char*> p=props->getString("cookieProps");
-        if (!p.first)
-            p.second=defProps;
-        pair<bool,const char*> p2=props->getString("cookieName");
+        pair<bool,const char*> p = props->getString("cookieProps");
+        if (!p.first || !strcmp(p.second, "http"))
+            p.second = defProps;
+        else if (!strcmp(p.second, "https"))
+            p.second = sslProps;
+        pair<bool,const char*> p2 = props->getString("cookieName");
         if (p2.first)
-            return make_pair(string(prefix) + p2.second,p.second);
-        return make_pair(string(prefix) + getHash(),p.second);
+            return make_pair(string(prefix) + p2.second, p.second);
+        return make_pair(string(prefix) + getHash(), p.second);
     }
 
     // Shouldn't happen, but just in case..
-    return pair<string,const char*>(prefix,defProps);
+    return pair<string,const char*>(prefix, defProps);
 }
 
 void Application::clearHeader(SPRequest& request, const char* rawname, const char* cginame) const
@@ -110,7 +115,7 @@ void Application::clearAttributeHeaders(SPRequest& request) const
                 &SPRequest::clearHeader,
                 boost::ref(request),
                 boost::bind(&string::c_str, boost::bind(&pair<string,string>::first, _1)),
-                boost::bind(&string::c_str, boost::bind(&pair<string,string>::first, _1))
+                boost::bind(&string::c_str, boost::bind(&pair<string,string>::second, _1))
                 )
             );
         return;
@@ -129,7 +134,7 @@ void Application::clearAttributeHeaders(SPRequest& request) const
             out = getServiceProvider().getListenerService()->send(in);
             if (out.islist()) {
                 DDF header = out.first();
-                while (header.isstring()) {
+                while (header.name() && header.isstring()) {
                     m_unsetHeaders.push_back(pair<string,string>(header.name(),header.string()));
                     header = out.next();
                 }
@@ -149,7 +154,7 @@ void Application::clearAttributeHeaders(SPRequest& request) const
             &SPRequest::clearHeader,
             boost::ref(request),
             boost::bind(&string::c_str, boost::bind(&pair<string,string>::first, _1)),
-            boost::bind(&string::c_str, boost::bind(&pair<string,string>::first, _1))
+            boost::bind(&string::c_str, boost::bind(&pair<string,string>::second, _1))
             )
         );
 }