[cpp-sp] 01/02: Windows Build: IIS7 module

Rod Widdowson rdw at steadingsoftware.com
Wed Jan 15 20:04:15 UTC 2025


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=5ad30d0768dadb5835fecbeebc133ade73fd4913

commit 5ad30d0768dadb5835fecbeebc133ade73fd4913
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Jan 15 20:03:00 2025 +0000

    Windows Build: IIS7 module
    
    Fix some low-hanging fruit causing compile issues
---
 iis7_shib/IIS7Request.cpp         | 22 +++++++++++-----------
 iis7_shib/ShibHttpModule.cpp      | 15 ++++++++-------
 iis7_shib/headers/IIS7Request.hpp |  1 +
 iis7_shib/headers/IIS7_shib.hpp   |  1 +
 iis7_shib/register.cpp            | 12 ++++++------
 5 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/iis7_shib/IIS7Request.cpp b/iis7_shib/IIS7Request.cpp
index 7fea5769..4385ff09 100644
--- a/iis7_shib/IIS7Request.cpp
+++ b/iis7_shib/IIS7Request.cpp
@@ -36,7 +36,7 @@ using namespace Config;
 
 IIS7Request::IIS7Request(IHttpContext *pHttpContext, IHttpEventProvider *pEventProvider, bool checkUser, const PropertySet& site)
     : AbstractSPRequest(SHIBSP_LOGCAT ".IIS"),
-        m_ctx(pHttpContext), m_request(pHttpContext->GetRequest()), m_response(pHttpContext->GetResponse()), m_site(site)
+        m_ctx(pHttpContext), m_request(pHttpContext->GetRequest()), m_response(pHttpContext->GetResponse()), m_site(site),
         m_firsttime(true), m_port(0), m_gotBody(false), m_event(pEventProvider)
 {
     DWORD len;
@@ -70,8 +70,8 @@ IIS7Request::IIS7Request(IHttpContext *pHttpContext, IHttpEventProvider *pEventP
     m_safeHeaderNames = site.getBool(ModuleConfig::SAFE_HEADER_NAMES_PROP_NAME, m_useHeaders);
     m_useVariables = site.getBool(ModuleConfig::USE_VARIABLES_PROP_NAME, ModuleConfig::USE_VARIABLES_PROP_DEFAULT);
 
-    string prop(site.getString(ModuleConfig::ROLE_ATTRIBUTES_PROP_NAME, "");
-    split_to_container(m_roleAttributeNames, prop);
+    string prop(site.getString(ModuleConfig::ROLE_ATTRIBUTES_PROP_NAME, ""));
+    split_to_container(m_roleAttributeNames, prop.c_str());
 
     bool normalizeRequest = site.getBool(ModuleConfig::NORMALIZE_REQUEST_PROP_NAME, true);
     unsigned int site_port = site.getUnsignedInt(ModuleConfig::SITE_PORT_PROP_NAME, 0);
@@ -114,8 +114,8 @@ IIS7Request::IIS7Request(IHttpContext *pHttpContext, IHttpEventProvider *pEventP
             if (site_name != m_hostname && site.m_aliases.find(m_hostname) == site.m_aliases.end()) {
                 vector<string> aliases;
                 string s = site.getString(ModuleConfig::SITE_ALIASES_PROP_NAME, "");
-                split_to_container(aliases, s);
-                if (aliases.find(m_hostname) == aliases.end()) {
+                split_to_container(aliases, s.c_str());
+                if (find(aliases.begin(), aliases.end(), m_hostname) == aliases.end()) {
                     m_hostname = site_name;
                 }
             }
@@ -163,7 +163,7 @@ void IIS7Request::setHeader(const char* name, const char* value)
         if (m_roleAttributeNames.find(name) != m_roleAttributeNames.end()) {
             const string str(value);
             boost::tokenizer<boost::escaped_list_separator<char>> tok(str, boost::escaped_list_separator<char>('\\', ';', '"'));
-            for (tokenizer<escaped_list_separator<char>>::iterator it = tok.begin(); it != tok.end(); ++it) {
+            for (boost::tokenizer<boost::escaped_list_separator<char>>::iterator it = tok.begin(); it != tok.end(); ++it) {
                 m_roles.insert(converter.from_bytes(*it));
             }
         }
@@ -215,7 +215,7 @@ void IIS7Request::clearHeader(const char* rawname, const char* cginame)
                 }
             }
         }
-        string unsetHeaderValue(g_Config->getAgent().getString(Agent::UNSET_HEADER_NAME_PROP_NAME, ""));
+        string unsetHeaderValue(g_Config->getAgent().getString(Agent::UNSET_HEADER_VALUE_PROP_NAME, ""));
         HRESULT hr = m_request->SetHeader(m_safeHeaderNames ? makeSafeHeader(rawname).c_str() : rawname,
             unsetHeaderValue.c_str(), static_cast<USHORT>(unsetHeaderValue.length()), TRUE);
         if (FAILED(hr)) {
@@ -296,7 +296,7 @@ long IIS7Request::getContentLength() const
     DWORD len;
     HRESULT hr = m_ctx->GetServerVariable("CONTENT_LENGTH", &length, &len);
     if (SUCCEEDED(hr)) {
-        return lexical_cast<int>(length);
+        return boost::lexical_cast<int>(length);
     }
     return 0;
 }
@@ -407,7 +407,7 @@ void IIS7Request::setResponseHeader(const char* name, const char* value, bool re
 
     size_t sz = value ? strlen(value) : 0;
     if (sz > USHRT_MAX) {
-        log(SPWarn, "Header value overflow");
+        log(Priority::SHIB_WARN, "Header value overflow");
         sz = USHRT_MAX;
     }
 
@@ -442,7 +442,7 @@ string IIS7Request::makeSafeHeader(const char* rawname) const
 
 void IIS7Request::logFatal(const string& operation, HRESULT hr) const
 {
-    string msg(operation + " failed: " + lexical_cast<string>(hr));
+    string msg(operation + " failed: " + boost::lexical_cast<string>(hr));
     log(Priority::SHIB_CRIT, msg.c_str());
     if (m_response) {
         m_response->SetStatus(static_cast<USHORT>(SHIBSP_HTTP_STATUS_ERROR), "Fatal Server Error", 0, hr);
@@ -452,6 +452,6 @@ void IIS7Request::logFatal(const string& operation, HRESULT hr) const
 void IIS7Request::throwError(const string& operation, HRESULT hr) const
 {
     logFatal(operation, hr);
-    string msg(operation + " failed: " + lexical_cast<string>(hr));
+    string msg(operation + " failed: " + boost::lexical_cast<string>(hr));
     throw IOException(msg.c_str());
 }
diff --git a/iis7_shib/ShibHttpModule.cpp b/iis7_shib/ShibHttpModule.cpp
index 887ef83f..50a102c5 100644
--- a/iis7_shib/ShibHttpModule.cpp
+++ b/iis7_shib/ShibHttpModule.cpp
@@ -20,11 +20,10 @@
 
 #include "IIS7_shib.hpp"
 
-#include "io/HTTPResponse.h"
+#include "shibsp/io/HTTPResponse.h"
 
 #include "ShibHttpModule.hpp"
 #include "IIS7Request.hpp"
-#include "IIS7_shib.hpp"
 
 #include <process.h>
 #include <winreg.h>
@@ -32,6 +31,8 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
 
+#include <codecvt>
+
 using namespace Config;
 using namespace std;
 
@@ -55,12 +56,12 @@ ShibHttpModule::DoHandler(
     // This saves us converting from 8 bit ascii up to 16 bit for the compare against something which was only in 16
     // bits to speed this path.  In V4 we can look at the local request
     const wstring url(pHttpContext->GetScriptName());
-    if (url.length() < handlerPrefix.length() || !starts_with(url, handlerPrefix))
+    if (url.length() < handlerPrefix.length() || !boost::starts_with(url, handlerPrefix))
         return RQ_NOTIFICATION_CONTINUE;
 
     IIS7Request handler(pHttpContext, pProvider, false, *site);
 
-    pair<bool, long> res = handler.getServiceProvider().doHandler(handler);
+    pair<bool, long> res = handler.getAgent().doHandler(handler);
 
     if (res.first) {
         return static_cast<REQUEST_NOTIFICATION_STATUS>(res.second);
@@ -83,7 +84,7 @@ ShibHttpModule::DoFilter(
 
     IIS7Request filter(pHttpContext, pProvider, true, *site);
 
-    pair<bool, long> res = filter.getServiceProvider().doAuthentication(filter, true);
+    pair<bool, long> res = filter.getAgent().doAuthentication(filter, true);
     if (res.first) {
         return static_cast<REQUEST_NOTIFICATION_STATUS>(res.second);
     }
@@ -95,12 +96,12 @@ ShibHttpModule::DoFilter(
             return RQ_NOTIFICATION_FINISH_REQUEST;
         }
     }
-    res = filter.getServiceProvider().doExport(filter);
+    res = filter.getAgent().doExport(filter);
     if (res.first) {
         return static_cast<REQUEST_NOTIFICATION_STATUS>(res.second);
     }
 
-    res = filter.getServiceProvider().doAuthorization(filter);
+    res = filter.getAgent().doAuthorization(filter);
     if (res.first) {
         return static_cast<REQUEST_NOTIFICATION_STATUS>(res.second);
     }
diff --git a/iis7_shib/headers/IIS7Request.hpp b/iis7_shib/headers/IIS7Request.hpp
index 6be45597..deb96573 100644
--- a/iis7_shib/headers/IIS7Request.hpp
+++ b/iis7_shib/headers/IIS7Request.hpp
@@ -75,6 +75,7 @@ protected:
     string getContentType() const;
     long getContentLength() const;
     string getRemoteUser() const;
+    string getAuthType() const;
     const char* getRequestBody() const;
     //
     // XMLTooing:: HTTPRequest
diff --git a/iis7_shib/headers/IIS7_shib.hpp b/iis7_shib/headers/IIS7_shib.hpp
index 22edaa04..53c2632c 100644
--- a/iis7_shib/headers/IIS7_shib.hpp
+++ b/iis7_shib/headers/IIS7_shib.hpp
@@ -33,6 +33,7 @@
 #include <shibsp/logging/Priority.h>
 #include <shibsp/platform/iis/ModuleConfig.h>
 #include <shibsp/util/PropertySet.h>
+#include <shibsp/logging/Category.h>
 
 //
 // Miscelanea
diff --git a/iis7_shib/register.cpp b/iis7_shib/register.cpp
index b9000e13..8908ab64 100644
--- a/iis7_shib/register.cpp
+++ b/iis7_shib/register.cpp
@@ -83,22 +83,22 @@ RegisterModule(
         return S_OK;
     }
 
+    Category& log = Category::getInstance(SHIBSP_LOGCAT ".IIS");
+
     g_Config = &AgentConfig::getConfig();
     if (!g_Config->init()) {
-        log.fatal("IIS module failed during library initialization, check log for detail");
+        log.crit("IIS module failed during library initialization, check log for detail");
         g_Config=nullptr;
         return E_FAIL;
     }
 
-    Category& log = Category::getInstance(SHIBSP_LOGCAT ".IIS");
-
     // Access implementation-specifics and create site mappings.
     const Agent& agent = g_Config->getAgent();
 
     try {
-        g_ModuleConfig.reset(iis::ModuleConfig::newNoduleConfig()));
+        g_ModuleConfig.reset(iis::ModuleConfig::newModuleConfig().get());
     } catch (const exception& ex) {
-        log.fatal("IIS module failed during module configuration installation: %s", ex.what());
+        log.crit("IIS module failed during module configuration installation: %s", ex.what());
         g_Config=nullptr;
         return E_FAIL;
     }
@@ -118,7 +118,7 @@ RegisterModule(
             }
             else {
                 _set_invalid_parameter_handler(old);
-                log.fatal("IIS module failed to generate a random anti-spoofing key");
+                log.crit("IIS module failed to generate a random anti-spoofing key");
                 g_Config->term();
                 g_Config = nullptr;
                 return E_FAIL;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list