[shibboleth-sp2] 26/82: SSPCPP-694 Code tidy

Etienne Dysli Metref edm-guest at moszumanska.debian.org
Thu Nov 16 08:16:21 UTC 2017


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

edm-guest pushed a commit to branch master
in repository shibboleth-sp2.

commit 154611e1ba74b90da70f3a700f33feaa88f0f43d
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date:   Thu May 25 16:41:45 2017 +0100

    SSPCPP-694 Code tidy
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-694
    
    Clean things up slighty.  Add a couple of todods and fix and bug (looking at the wrong
    field)
---
 iis7_shib/NativeRequest.cpp          | 22 +++++-----------------
 iis7_shib/ShibHttpModule.cpp         |  2 +-
 iis7_shib/headers/ShibHttpModule.hpp |  6 +++++-
 iis7_shib/headers/ShibUser.hpp       |  3 +++
 4 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/iis7_shib/NativeRequest.cpp b/iis7_shib/NativeRequest.cpp
index d5594ac..c40334e 100644
--- a/iis7_shib/NativeRequest.cpp
+++ b/iis7_shib/NativeRequest.cpp
@@ -27,7 +27,7 @@
 
 #include <shibsp/exceptions.h>
 
-#include <codecvt>
+#include <codecvt> // 16 bit to 8 bit chars
 #include "NativeRequest.hpp"
 #include "ShibHttpModule.hpp"
 #include "ShibUser.hpp"
@@ -166,9 +166,8 @@ void NativeRequest::setHeader(const char* name, const char* value)
 
 void NativeRequest::setRemoteUser(const char* user)
 {
-
     m_remoteUser = user;
-    if (m_useVariables) {
+    if (m_useHeaders) {
         HRESULT hr;
         if (user) {
             hr = m_request->SetHeader("REMOTE_USER", user, static_cast<USHORT>(strlen(user)), true);
@@ -181,18 +180,14 @@ void NativeRequest::setRemoteUser(const char* user)
         }
     }
     if (m_useVariables) {
+        // Setting the variable REMOTE_USER fails, so set the Principal if we are called appropriately.
+        // Getting REMOTE_USER goes via the Principal.
         auto_ptr_XMLCh widen(user);
         IAuthenticationProvider *auth = dynamic_cast<IAuthenticationProvider*>(m_event);
 
         if (auth) {
             auth->SetUser(new ShibUser(user));
         }
-
-/*            const HRESULT hr(m_ctx->SetServerVariable("REMOTE_USER", widen.get())); 
-            if (FAILED(hr)) {
-                throwError("setRemoteUser (Header)", hr);
-            }
-        }*/
     }
 }
 
@@ -346,18 +341,11 @@ const char* NativeRequest::getRequestBody() const
     if (m_gotBody) {
         return m_body.c_str();
     }
+    // TODO Not Thread safe?
     DWORD totalBytesLeft = m_request->GetRemainingEntityBytes();
     if (totalBytesLeft > 1024 * 1024) {
         throw opensaml::SecurityPolicyException("Size of request body exceeded 1M size limit.");
     }
-/*        else if (m_lpECB->cbTotalBytes > m_lpECB->cbAvailable) {
-        m_gotBody=true;
-        DWORD datalen=m_lpECB->cbTotalBytes;
-        if (m_lpECB->cbAvailable > 0) {
-        m_body.assign(reinterpret_cast<char*>(m_lpECB->lpbData), m_lpECB->cbAvailable);
-        datalen-=m_lpECB->cbAvailable;
-    }
-    */
     while (totalBytesLeft) {
         char buf[8192];
         DWORD bytesRead;
diff --git a/iis7_shib/ShibHttpModule.cpp b/iis7_shib/ShibHttpModule.cpp
index a74cb38..5131b2c 100644
--- a/iis7_shib/ShibHttpModule.cpp
+++ b/iis7_shib/ShibHttpModule.cpp
@@ -55,7 +55,7 @@ ShibHttpModule::DoFilter(
     _In_ IHttpEventProvider *  pProvider
 )
 {
-    IHttpRequest *req(pHttpContext->GetRequest());
+    const IHttpRequest *req(pHttpContext->GetRequest());
 
     string threadid("[");
     threadid += lexical_cast<string>(_getpid()) + "] native_shib";
diff --git a/iis7_shib/headers/ShibHttpModule.hpp b/iis7_shib/headers/ShibHttpModule.hpp
index ce4264d..5810c9f 100644
--- a/iis7_shib/headers/ShibHttpModule.hpp
+++ b/iis7_shib/headers/ShibHttpModule.hpp
@@ -29,24 +29,28 @@ public:
     ~ShibHttpModule()
     {};
 
+    // RQ_BEGIN_REQUEST
     REQUEST_NOTIFICATION_STATUS
         OnBeginRequest(
             _In_ IHttpContext *         pHttpContext,
             _In_ IHttpEventProvider *   pProvider
         );
+
+    // RQ_PRE_EXECUTE_REQUEST_HANDLER
     REQUEST_NOTIFICATION_STATUS
         OnPreExecuteRequestHandler(
             _In_ IHttpContext *         pHttpContext,
             _In_ IHttpEventProvider *   pProvider
         );
 
-    // RQ_AUTHENTICATE_REQUEST descriptor
+    // RQ_AUTHENTICATE_REQUEST
     REQUEST_NOTIFICATION_STATUS
         OnAuthenticateRequest(
             _In_ IHttpContext *             pHttpContext,
             _In_ IAuthenticationProvider *  pProvider
         );
 
+    // RQ_AUTHENTICATE_REQUEST
     REQUEST_NOTIFICATION_STATUS
         OnPostAuthenticateRequest(
             _In_ IHttpContext *             pHttpContext,
diff --git a/iis7_shib/headers/ShibUser.hpp b/iis7_shib/headers/ShibUser.hpp
index 5a63fcc..7e89a7a 100644
--- a/iis7_shib/headers/ShibUser.hpp
+++ b/iis7_shib/headers/ShibUser.hpp
@@ -22,6 +22,9 @@
 
 class ShibUser : public IHttpUser {
 
+    // An IHttpUser which allows us to supply REMOTE_USER.
+    // Also, a testbed for Roles Based AuthN.
+
 public:
     ShibUser(std::string username);
             

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git



More information about the Pkg-shibboleth-devel mailing list