[cpp-opensaml] branch master updated: Move zlib routines into xmltooling.
Scott Cantor
cantor.2 at osu.edu
Fri Feb 2 18:03:00 EST 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-opensaml.git;a=commit;h=046affa393b63d2e32b319355fd51a8b09b6449a
The following commit(s) were added to refs/heads/master by this push:
new 046affa Move zlib routines into xmltooling.
046affa is described below
commit 046affa393b63d2e32b319355fd51a8b09b6449a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Feb 2 18:02:54 2018 -0500
Move zlib routines into xmltooling.
---
Projects/vc15/saml/saml.vcxproj | 12 +-
Projects/vc15/saml/saml.vcxproj.filters | 6 -
configure.ac | 17 ---
saml/Makefile.am | 2 -
saml/saml2/binding/SAML2Redirect.h | 54 --------
saml/saml2/binding/impl/SAML2Redirect.cpp | 154 -----------------------
saml/saml2/binding/impl/SAML2RedirectDecoder.cpp | 4 +-
saml/saml2/binding/impl/SAML2RedirectEncoder.cpp | 4 +-
8 files changed, 9 insertions(+), 244 deletions(-)
diff --git a/Projects/vc15/saml/saml.vcxproj b/Projects/vc15/saml/saml.vcxproj
index a79af9f..295da05 100644
--- a/Projects/vc15/saml/saml.vcxproj
+++ b/Projects/vc15/saml/saml.vcxproj
@@ -111,7 +111,7 @@
<PreprocessorDefinitions>_UNICODE;UNICODE;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
- <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Configuration)\xmltooling3D.lib;xerces-c_3D.lib;xsec_2D.lib;log4shib1D.lib;zlib1d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Configuration)\xmltooling3D.lib;xerces-c_3D.lib;xsec_2D.lib;log4shib1D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<DataExecutionPrevention>
@@ -137,7 +137,7 @@
<PreprocessorDefinitions>_UNICODE;UNICODE;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
- <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Platform)\$(Configuration)\xmltooling3D.lib;xerces-c_3D.lib;xsec_2D.lib;log4shib1D.lib;zlib1d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Platform)\$(Configuration)\xmltooling3D.lib;xerces-c_3D.lib;xsec_2D.lib;log4shib1D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<DataExecutionPrevention>
@@ -154,7 +154,7 @@
<DisableSpecificWarnings>4275</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Configuration)\xmltooling3.lib;xerces-c_3.lib;xsec_2.lib;log4shib1.lib;zlib1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Configuration)\xmltooling3.lib;xerces-c_3.lib;xsec_2.lib;log4shib1.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -176,7 +176,7 @@
<DisableSpecificWarnings>4275</DisableSpecificWarnings>
</ClCompile>
<Link>
- <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Platform)\$(Configuration)\xmltooling3.lib;xerces-c_3.lib;xsec_2.lib;log4shib1.lib;zlib1.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>..\..\..\..\cpp-xmltooling\Build\vc15\$(Platform)\$(Configuration)\xmltooling3.lib;xerces-c_3.lib;xsec_2.lib;log4shib1.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -264,7 +264,6 @@
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2MessageDecoder.cpp" />
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2POSTDecoder.cpp" />
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2POSTEncoder.cpp" />
- <ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2Redirect.cpp" />
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2RedirectDecoder.cpp" />
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2RedirectEncoder.cpp" />
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2SOAPClient.cpp" />
@@ -329,7 +328,6 @@
<ClInclude Include="..\..\..\saml\saml2\binding\SAML2Artifact.h" />
<ClInclude Include="..\..\..\saml\saml2\binding\SAML2ArtifactType0004.h" />
<ClInclude Include="..\..\..\saml\saml2\binding\SAML2MessageDecoder.h" />
- <ClInclude Include="..\..\..\saml\saml2\binding\SAML2Redirect.h" />
<ClInclude Include="..\..\..\saml\saml2\binding\SAML2SOAPClient.h" />
<ClInclude Include="..\..\..\saml\saml2\profile\AssertionValidator.h" />
<ClInclude Include="..\..\..\saml\saml2\profile\BrowserSSOProfileValidator.h" />
@@ -352,4 +350,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/Projects/vc15/saml/saml.vcxproj.filters b/Projects/vc15/saml/saml.vcxproj.filters
index b2094e9..554e3c1 100644
--- a/Projects/vc15/saml/saml.vcxproj.filters
+++ b/Projects/vc15/saml/saml.vcxproj.filters
@@ -276,9 +276,6 @@
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2POSTEncoder.cpp">
<Filter>Source Files\saml2\binding\impl</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2Redirect.cpp">
- <Filter>Source Files\saml2\binding\impl</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\saml\saml2\binding\impl\SAML2RedirectDecoder.cpp">
<Filter>Source Files\saml2\binding\impl</Filter>
</ClCompile>
@@ -482,9 +479,6 @@
<ClInclude Include="..\..\..\saml\saml2\binding\SAML2MessageDecoder.h">
<Filter>Header Files\saml2\binding</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\saml\saml2\binding\SAML2Redirect.h">
- <Filter>Header Files\saml2\binding</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\saml\saml2\binding\SAML2SOAPClient.h">
<Filter>Header Files\saml2\binding</Filter>
</ClInclude>
diff --git a/configure.ac b/configure.ac
index e2d6a20..1456da5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,23 +82,6 @@ else
CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
fi
-# zlib settings
-AC_ARG_WITH(zlib,
- AS_HELP_STRING([--with-zlib=PATH],[where zlib is installed]),
- [
- if test -d "$withval" ; then
- CPPFLAGS="${CPPFLAGS} -I$withval/include"
- LDFLAGS="${LDFLAGS} -L$withval/lib"
- fi
- ]
-)
-
-AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([unable to find zlib header files]))
-AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[#include <zlib.h>]],
- [[zlibVersion()]])],,
- [AC_MSG_ERROR([unable to link with zlib])])
-
# OpenSSL settings
AC_ARG_WITH(openssl,
diff --git a/saml/Makefile.am b/saml/Makefile.am
index b464eb6..8c03b36 100644
--- a/saml/Makefile.am
+++ b/saml/Makefile.am
@@ -79,7 +79,6 @@ saml2bindinclude_HEADERS = \
saml2/binding/SAML2Artifact.h \
saml2/binding/SAML2ArtifactType0004.h \
saml2/binding/SAML2MessageDecoder.h \
- saml2/binding/SAML2Redirect.h \
saml2/binding/SAML2SOAPClient.h
saml2mdinclude_HEADERS = \
@@ -174,7 +173,6 @@ libsaml_la_SOURCES = \
saml2/binding/impl/SAML2MessageDecoder.cpp \
saml2/binding/impl/SAML2POSTDecoder.cpp \
saml2/binding/impl/SAML2POSTEncoder.cpp \
- saml2/binding/impl/SAML2Redirect.cpp \
saml2/binding/impl/SAML2RedirectDecoder.cpp \
saml2/binding/impl/SAML2RedirectEncoder.cpp \
saml2/binding/impl/SAML2SOAPDecoder.cpp \
diff --git a/saml/saml2/binding/SAML2Redirect.h b/saml/saml2/binding/SAML2Redirect.h
deleted file mode 100644
index 22eeeb9..0000000
--- a/saml/saml2/binding/SAML2Redirect.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * @file saml/saml2/binding/SAML2Redirect.h
- *
- * SAML 2.0 HTTP Redirect compression functionality
- */
-
-#include <saml/base.h>
-#include <iostream>
-
-namespace opensaml {
- namespace saml2p {
- /**
- * Deflates data in accordance with RFC1951. The caller must free the
- * resulting buffer using delete[]
- *
- * @param in the data to compress
- * @param in_len length of input data
- * @param out_len will contain the length of the resulting data
- * @return allocated buffer of out_len bytes containing deflated data
- */
- SAML_EXPORT char* deflate(char* in, unsigned int in_len, unsigned int* out_len);
-
- /**
- * Inflates data compressed in accordance with RFC1951 and sends the
- * results to an output stream.
- *
- * @param in the data to inflate
- * @param in_len length of input data
- * @param out reference to output stream to receive data
- * @return number of bytes written to stream
- */
- SAML_EXPORT unsigned int inflate(char* in, unsigned int in_len, std::ostream& out);
- };
-};
diff --git a/saml/saml2/binding/impl/SAML2Redirect.cpp b/saml/saml2/binding/impl/SAML2Redirect.cpp
deleted file mode 100644
index 7c2a4a5..0000000
--- a/saml/saml2/binding/impl/SAML2Redirect.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * Licensed to the University Corporation for Advanced Internet
- * Development, Inc. (UCAID) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * UCAID licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the
- * License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- */
-
-/**
- * @file saml/saml2/binding/SAML2Redirect.h
- *
- * SAML 2.0 HTTP Redirect compression functionality.
- */
-
-#include "internal.h"
-#include "saml2/binding/SAML2Redirect.h"
-
-#include <zlib.h>
-#include <xmltooling/logging.h>
-#include <xmltooling/util/NDC.h>
-
-using namespace xmltooling::logging;
-using namespace std;
-
-namespace {
- extern "C" {
- voidpf saml_zalloc(void* opaque, uInt items, uInt size)
- {
- return malloc(items*size);
- }
-
- void saml_zfree(void* opaque, voidpf addr)
- {
- free(addr);
- }
- };
-};
-
-char* opensaml::saml2p::deflate(char* in, unsigned int in_len, unsigned int* out_len)
-{
-#ifdef _DEBUG
- xmltooling::NDC ndc("deflate");
-#endif
- Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML2Redirect.zlib");
-
- z_stream z;
- memset(&z, 0, sizeof(z_stream));
-
- z.zalloc = saml_zalloc;
- z.zfree = saml_zfree;
- z.opaque = nullptr;
- z.next_in = (Bytef*)in;
- z.avail_in = in_len;
- *out_len = 0;
-
- int ret = deflateInit2(&z, 9, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY);
- if (ret != Z_OK) {
- log.error("zlib deflateInit2 failed with error code (%d)", ret);
- return nullptr;
- }
-
- int dlen = in_len + (in_len >> 8) + 12; /* orig_size * 1.001 + 12 */
- char* out = new char[dlen];
- z.next_out = (Bytef*)out;
- z.avail_out = dlen;
-
- ret = deflate(&z, Z_FINISH);
- if (ret != Z_STREAM_END) {
- deflateEnd(&z);
- log.error("zlib deflateInit2 failed with error code (%d)", ret);
- delete[] out;
- }
-
- *out_len = z.total_out;
- deflateEnd(&z);
- return out;
-}
-
-unsigned int opensaml::saml2p::inflate(char* in, unsigned int in_len, ostream& out)
-{
-#ifdef _DEBUG
- xmltooling::NDC ndc("inflate");
-#endif
- Category& log = Category::getInstance(SAML_LOGCAT ".MessageDecoder.SAML2Redirect.zlib");
-
- z_stream z;
- memset(&z, 0, sizeof(z_stream));
-
- z.zalloc = saml_zalloc;
- z.zfree = saml_zfree;
- z.opaque = nullptr;
- z.next_in = (Bytef*)in;
- z.avail_in = in_len;
-
- int dlen = in_len << 3; /* guess inflated size: orig_size * 8 */
- Byte* buf = new Byte[dlen];
- memset(buf, 0, dlen);
- z.next_out = buf;
- z.avail_out = dlen;
-
- int ret = inflateInit2(&z, -15);
- if (ret != Z_OK) {
- log.error("zlib inflateInit2 failed with error code (%d)", ret);
- delete[] buf;
- return 0;
- }
-
- size_t diff;
- int iter = 30;
- while (--iter) { /* Make sure we can never be caught in infinite loop */
- ret = inflate(&z, Z_SYNC_FLUSH);
- switch (ret) {
- case Z_STREAM_END:
- diff = z.next_out - buf;
- z.next_out = buf;
- while (diff--)
- out << *(z.next_out++);
- goto done;
-
- case Z_OK: /* avail_out should be 0 now. Time to dump the buffer. */
- diff = z.next_out - buf;
- z.next_out = buf;
- while (diff--)
- out << *(z.next_out++);
- memset(buf, 0, dlen);
- z.next_out = buf;
- z.avail_out = dlen;
- break;
-
- default:
- delete[] buf;
- inflateEnd(&z);
- log.error("zlib inflate failed with error code (%d)", ret);
- return 0;
- }
- }
-done:
- delete[] buf;
- int out_len = z.total_out;
- inflateEnd(&z);
- return out_len;
-}
diff --git a/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp b/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp
index c5259c1..e18c5a6 100644
--- a/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp
+++ b/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp
@@ -28,7 +28,6 @@
#include "exceptions.h"
#include "binding/SecurityPolicy.h"
#include "saml2/binding/SAML2MessageDecoder.h"
-#include "saml2/binding/SAML2Redirect.h"
#include "saml2/core/Protocols.h"
#include "saml2/metadata/Metadata.h"
#include "saml2/metadata/MetadataProvider.h"
@@ -39,6 +38,7 @@
#include <xmltooling/io/HTTPRequest.h>
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/ParserPool.h>
+#include <xmltooling/util/XMLHelper.h>
#include <xmltooling/validation/ValidatorSuite.h>
using namespace opensaml::saml2md;
@@ -111,7 +111,7 @@ XMLObject* SAML2RedirectDecoder::decode(
// Now we have to inflate it.
stringstream s;
- if (inflate(reinterpret_cast<char*>(decoded), x, s)==0) {
+ if (XMLHelper::inflate(reinterpret_cast<char*>(decoded), x, s)==0) {
XMLString::release((char**)&decoded);
throw BindingException("Unable to inflate Redirect binding message.");
}
diff --git a/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp b/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
index 6f5249d..3a56d3b 100644
--- a/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
+++ b/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp
@@ -27,7 +27,6 @@
#include "internal.h"
#include "exceptions.h"
#include "binding/MessageEncoder.h"
-#include "saml2/binding/SAML2Redirect.h"
#include "saml2/core/Protocols.h"
#include <fstream>
@@ -41,6 +40,7 @@
#include <xmltooling/signature/Signature.h>
#include <xmltooling/util/NDC.h>
#include <xmltooling/util/URLEncoder.h>
+#include <xmltooling/util/XMLHelper.h>
using namespace opensaml::saml2p;
using namespace opensaml::saml2md;
@@ -131,7 +131,7 @@ long SAML2RedirectEncoder::encode(
log.debug("marshalled message:\n%s", xmlbuf.c_str());
unsigned int len;
- char* deflated = deflate(const_cast<char*>(xmlbuf.c_str()), xmlbuf.length(), &len);
+ char* deflated = XMLHelper::deflate(const_cast<char*>(xmlbuf.c_str()), xmlbuf.length(), &len);
if (!deflated)
throw BindingException("Failed to deflate message.");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list