[cpp-sp] branch main updated: Add new sources to project and provide a Windows time parser.

Scott Cantor cantor.2 at osu.edu
Thu Oct 23 16:54:18 UTC 2025


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

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

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

The following commit(s) were added to refs/heads/main by this push:
     new ad5b97a0 Add new sources to project and provide a Windows time parser.
ad5b97a0 is described below

commit ad5b97a07894c4c136eb264e866104408110dfbe
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Oct 23 12:54:08 2025 -0400

    Add new sources to project and provide a Windows time parser.
---
 Projects/vc22/Tests.vcxproj          |  1 +
 Projects/vc22/Tests.vcxproj.filters  |  5 ++++-
 Projects/vc22/shibsp.vcxproj         |  1 +
 Projects/vc22/shibsp.vcxproj.filters |  3 +++
 shibsp/util/Misc.cpp                 | 26 +++++++++++++++++++++-----
 5 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/Projects/vc22/Tests.vcxproj b/Projects/vc22/Tests.vcxproj
index 4fa3de5e..d76b361d 100644
--- a/Projects/vc22/Tests.vcxproj
+++ b/Projects/vc22/Tests.vcxproj
@@ -41,6 +41,7 @@
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">_CRT_SECURE_NO_WARNINGS=1;SHIBSP_LITE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <ClCompile Include="..\..\tests\util\BoostPropertySetTests.cpp" />
+    <ClCompile Include="..\..\tests\util\ISOParserTests.cpp" />
     <ClCompile Include="..\..\tests\util\PropertyTreeTests.cpp" />
     <ClCompile Include="..\..\tests\util\ReloadableXMLFileTests.cpp" />
   </ItemGroup>
diff --git a/Projects/vc22/Tests.vcxproj.filters b/Projects/vc22/Tests.vcxproj.filters
index bf118c5e..d582cbf1 100644
--- a/Projects/vc22/Tests.vcxproj.filters
+++ b/Projects/vc22/Tests.vcxproj.filters
@@ -99,6 +99,9 @@
     <ClCompile Include="..\..\tests\attribute\impl\DefaultAttributeConfigurationTests.cpp">
       <Filter>Source Files\attribute\impl</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\tests\util\ISOParserTests.cpp">
+      <Filter>Source Files\util</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\tests\data\console-agent.ini">
@@ -282,4 +285,4 @@
       <Filter>Data\attribute\impl</Filter>
     </None>
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/Projects/vc22/shibsp.vcxproj b/Projects/vc22/shibsp.vcxproj
index e482f03a..35889131 100644
--- a/Projects/vc22/shibsp.vcxproj
+++ b/Projects/vc22/shibsp.vcxproj
@@ -113,6 +113,7 @@
     <ClCompile Include="..\..\shibsp\impl\AgentConfig.cpp" />
     <ClCompile Include="..\..\shibsp\impl\ChainingAccessControl.cpp" />
     <ClCompile Include="..\..\shibsp\impl\DefaultAgent.cpp" />
+    <ClCompile Include="..\..\shibsp\impl\TimeAccessControl.cpp" />
     <ClCompile Include="..\..\shibsp\impl\XMLAccessControl.cpp" />
     <ClCompile Include="..\..\shibsp\impl\XMLRequestMapper.cpp" />
     <ClCompile Include="..\..\shibsp\io\impl\CookieManager.cpp" />
diff --git a/Projects/vc22/shibsp.vcxproj.filters b/Projects/vc22/shibsp.vcxproj.filters
index 12998717..00cb30ea 100644
--- a/Projects/vc22/shibsp.vcxproj.filters
+++ b/Projects/vc22/shibsp.vcxproj.filters
@@ -389,6 +389,9 @@
     <ClCompile Include="..\..\shibsp\csprng\impl\csprng.cpp">
       <Filter>Source Files\Impl</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\shibsp\impl\TimeAccessControl.cpp">
+      <Filter>Source Files\Impl</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\shibsp\shibsp.rc">
diff --git a/shibsp/util/Misc.cpp b/shibsp/util/Misc.cpp
index 2cebe3dc..9d605e72 100644
--- a/shibsp/util/Misc.cpp
+++ b/shibsp/util/Misc.cpp
@@ -24,7 +24,10 @@
 
 #include <ctime>
 #include <set>
-#include <sstream>
+#ifdef WIN32
+# include <iomanip>
+# include <sstream>
+#endif
 #include <vector>
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
@@ -82,7 +85,7 @@ time_t shibsp::parseISODuration(const string& s)
             regexp::regex_search(s, match, notime_parser);
         }
     }
-    catch (const regexp::regex_error& e) {
+    catch (const regexp::regex_error&) {
         return -1;
     }
 
@@ -92,7 +95,7 @@ time_t shibsp::parseISODuration(const string& s)
 
     vector<double> vec = {0,0,0,0,0,0}; // years, months, days, hours, minutes, seconds
 
-    for (size_t i = 1; i < match.size(); ++i) {
+    for (regexp::smatch::size_type i = 1; i < match.size(); ++i) {
 
         if (match[i].matched) {
             string str = match[i];
@@ -100,7 +103,7 @@ time_t shibsp::parseISODuration(const string& s)
             try {
                 vec[i-1] = boost::lexical_cast<long>(str);
             }
-            catch (const boost::bad_lexical_cast& e) {
+            catch (const boost::bad_lexical_cast&) {
                 return 0;
             }
         }
@@ -118,12 +121,25 @@ time_t shibsp::parseISODuration(const string& s)
 
 time_t shibsp::parseISODateTime(const string& s)
 {
-    tm tmStruct = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr};
+    tm tmStruct;
+    memset(&tmStruct, 0, sizeof(tm));
+
+#ifdef WIN32
+    istringstream in(s);
+    in >> get_time(&tmStruct, "%Y-%m-%dT%TZ");
+    // This is finicky but does seem to detect critical errors, including the
+    // absence of the 'Z' literal, which doesn't set fail but does set eof.
+    if (in.fail() || in.eof()) {
+        return -1;
+    }
+    return _mkgmtime64(&tmStruct);
+#else
     char* ret = strptime(s.c_str(), "%Y-%m-%dT%TZ", &tmStruct);
     if (!ret || *ret) {
         return -1;
     }
     return timegm(&tmStruct);
+#endif
 }
 
 bool FileSupport::exists(const char* path)

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


More information about the commits mailing list