SANTUARIO-277 - Remove old custom URI resolvers, add setBaseURI to abstract interface.
git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-cpp/trunk@1819345 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/Projects/VC15.0/xsec/xsec_lib/xsec_lib.vcxproj b/Projects/VC15.0/xsec/xsec_lib/xsec_lib.vcxproj
index 5295671..c9ab0b4 100644
--- a/Projects/VC15.0/xsec/xsec_lib/xsec_lib.vcxproj
+++ b/Projects/VC15.0/xsec/xsec_lib/xsec_lib.vcxproj
@@ -534,8 +534,6 @@
</ClCompile>
<ClCompile Include="..\..\..\..\xsec\utils\XSECTXFMInputSource.cpp" />
<ClCompile Include="..\..\..\..\xsec\utils\XSECXPathNodeList.cpp" />
- <ClCompile Include="..\..\..\..\xsec\utils\winutils\XSECBinHTTPURIInputStream.cpp" />
- <ClCompile Include="..\..\..\..\xsec\utils\winutils\XSECURIResolverGenericWin32.cpp" />
<ClCompile Include="..\..\..\..\xsec\framework\XSECAlgorithmMapper.cpp" />
<ClCompile Include="..\..\..\..\xsec\framework\XSECEnv.cpp" />
<ClCompile Include="..\..\..\..\xsec\framework\XSECError.cpp" />
@@ -666,8 +664,6 @@
</ClInclude>
<ClInclude Include="..\..\..\..\xsec\utils\XSECTXFMInputSource.hpp" />
<ClInclude Include="..\..\..\..\xsec\utils\XSECXPathNodeList.hpp" />
- <ClInclude Include="..\..\..\..\xsec\utils\winutils\XSECBinHTTPURIInputStream.hpp" />
- <ClInclude Include="..\..\..\..\xsec\utils\winutils\XSECURIResolverGenericWin32.hpp" />
<ClInclude Include="..\..\..\..\xsec\framework\XSECAlgorithmHandler.hpp" />
<ClInclude Include="..\..\..\..\xsec\framework\XSECAlgorithmMapper.hpp" />
<ClInclude Include="..\..\..\..\xsec\framework\XSECDefs.hpp" />
diff --git a/xsec/Makefile.am b/xsec/Makefile.am
index 90ef343..d13701a 100644
--- a/xsec/Makefile.am
+++ b/xsec/Makefile.am
@@ -268,10 +268,6 @@
utils/XSECBinTXFMInputStream.hpp \
utils/XSECPlatformUtils.hpp
-unixutilsinclude_HEADERS = \
- utils/unixutils/XSECURIResolverGenericUnix.hpp \
- utils/unixutils/XSECBinHTTPURIInputStream.hpp
-
xencinclude_HEADERS = \
xenc/XENCEncryptionMethod.hpp \
xenc/XENCEncryptedType.hpp \
@@ -458,8 +454,6 @@
# make. Cygwin compiles use the UNIX utilities, not windows
utils_sources = \
- utils/unixutils/XSECURIResolverGenericUnix.cpp \
- utils/unixutils/XSECBinHTTPURIInputStream.cpp \
utils/XSECAlgorithmSupport.cpp \
utils/XSECBinTXFMInputStream.cpp \
utils/XSECXPathNodeList.cpp \
@@ -612,11 +606,7 @@
for la in $(lib_LTLIBRARIES) ; do rm -f $(DESTDIR)$(libdir)/$$la ; done
EXTRA_DIST = \
- utils/winutils/XSECURIResolverGenericWin32.cpp \
utils/winutils/XSECSOAPRequestorSimpleWin32.cpp \
- utils/winutils/XSECBinHTTPURIInputStream.cpp \
- utils/winutils/XSECURIResolverGenericWin32.hpp \
- utils/winutils/XSECBinHTTPURIInputStream.hpp \
enc/WinCAPI/WinCAPICryptoProvider.cpp \
enc/WinCAPI/WinCAPICryptoKeyHMAC.hpp \
enc/WinCAPI/WinCAPICryptoHash.cpp \
diff --git a/xsec/framework/XSECURIResolver.hpp b/xsec/framework/XSECURIResolver.hpp
index 62675d1..f198753 100644
--- a/xsec/framework/XSECURIResolver.hpp
+++ b/xsec/framework/XSECURIResolver.hpp
@@ -88,8 +88,15 @@
* @returns The octet stream corresponding to the URI.
*/
- virtual XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream *
- resolveURI(const XMLCh * uri) = 0;
+ virtual XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream*
+ resolveURI(const XMLCh* uri) = 0;
+
+ /**
+ * \brief Set the base URI for relative URIs.
+ *
+ */
+
+ virtual void setBaseURI(const XMLCh* uri) = 0;
/**
* \brief Clone the resolver to be installed in a new object.
@@ -100,7 +107,7 @@
*
*/
- virtual XSECURIResolver * clone(void) = 0;
+ virtual XSECURIResolver* clone() = 0;
//@}
diff --git a/xsec/tools/checksig/checksig.cpp b/xsec/tools/checksig/checksig.cpp
index 65961a8..4f59881 100644
--- a/xsec/tools/checksig/checksig.cpp
+++ b/xsec/tools/checksig/checksig.cpp
@@ -40,14 +40,6 @@
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/enc/XSECKeyInfoResolverDefault.hpp>
-// ugly :<
-
-#if defined(_WIN32)
-# include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
-#else
-# include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
-#endif
-
// General
#include <memory.h>
@@ -427,13 +419,6 @@
useAnonymousResolver == true ||
useInteropResolver == true) {
-#if defined(_WIN32)
- XSECURIResolverGenericWin32
-#else
- XSECURIResolverGenericUnix
-#endif
- theResolver;
-
AnonymousResolver theAnonymousResolver;
// Map out base path of the file
@@ -480,29 +465,19 @@
#endif
if (useAnonymousResolver == true) {
- // AnonymousResolver takes precedence
- theAnonymousResolver.setBaseURI(baseURIXMLCh);
sig->setURIResolver(&theAnonymousResolver);
}
- else if (useXSECURIResolver == true) {
- theResolver.setBaseURI(baseURIXMLCh);
- sig->setURIResolver(&theResolver);
- }
+ sig->getURIResolver()->setBaseURI(baseURIXMLCh);
#if defined (XSEC_HAVE_OPENSSL)
if (useInteropResolver == true) {
-
InteropResolver ires(&(baseURIXMLCh[8]));
sig->setKeyInfoResolver(&ires);
-
}
#endif
XSEC_RELEASE_XMLCH(baseURIXMLCh);
-
}
-
-
bool result;
try {
diff --git a/xsec/tools/cipher/cipher.cpp b/xsec/tools/cipher/cipher.cpp
index 92131ca..1a8a5f2 100644
--- a/xsec/tools/cipher/cipher.cpp
+++ b/xsec/tools/cipher/cipher.cpp
@@ -42,14 +42,6 @@
#include "XencInteropResolver.hpp"
-// ugly :<
-
-#if defined(_WIN32)
-# include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
-#else
-# include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
-#endif
-
// General
#include <memory.h>
diff --git a/xsec/tools/templatesign/templatesign.cpp b/xsec/tools/templatesign/templatesign.cpp
index 60c6de3..1dcedc2 100644
--- a/xsec/tools/templatesign/templatesign.cpp
+++ b/xsec/tools/templatesign/templatesign.cpp
@@ -37,15 +37,10 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/framework/XSECException.hpp>
+#include <xsec/framework/XSECURIResolver.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
-#if defined(_WIN32)
-# include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
-#else
-# include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
-#endif
-
#if defined (XSEC_HAVE_OPENSSL)
# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyEC.hpp>
@@ -592,7 +587,7 @@
#if defined (XSEC_HAVE_OPENSSL)
- // Initialise OpenSSL
+ // Initialize OpenSSL
ERR_load_crypto_strings();
BIO * bio_err;
@@ -694,7 +689,7 @@
// Create the XSEC OpenSSL interface
key = new OpenSSLCryptoKeyDSA(pkey);
}
-# if defined(XSEC_OPENSSL_HAVE_EC)
+#if defined(XSEC_OPENSSL_HAVE_EC)
else if (_stricmp(argv[paramCount], "--eckey") == 0 || _stricmp(argv[paramCount], "-e") == 0) {
// Check type is correct
@@ -707,7 +702,7 @@
// Create the XSEC OpenSSL interface
key = new OpenSSLCryptoKeyEC(pkey);
}
-# endif
+#endif
else {
if (EVP_PKEY_id(pkey) != EVP_PKEY_RSA) {
cerr << "RSA Key requested, but OpenSSL loaded something else\n";
@@ -1118,13 +1113,6 @@
XSECProvider * prov = new XSECProvider;
DSIGSignature * sig = prov->newSignatureFromDOM(theDOM, sigNode);
-
- // Use the internal URI resolver
-#if defined(_WIN32)
- XSECURIResolverGenericWin32* theResolver = new XSECURIResolverGenericWin32();
-#else
- XSECURIResolverGenericUnix* theResolver = new XSECURIResolverGenericUnix();
-#endif
// Map out base path of the file
char * filename=argv[argc-1];
@@ -1163,8 +1151,7 @@
// The last "\\" must prefix the filename
baseURI[lastSlash + 1] = '\0';
- theResolver->setBaseURI(MAKE_UNICODE_STRING(baseURI));
- sig->setURIResolver(theResolver);
+ sig->getURIResolver()->setBaseURI(MAKE_UNICODE_STRING(baseURI));
#if XSEC_HAVE_GETCWD_DYN
free(path);
free(baseURI);
@@ -1343,7 +1330,6 @@
prov->releaseSignature(sig);
delete parser;
delete prov;
- delete theResolver;
XSECPlatformUtils::Terminate();
#ifdef XSEC_HAVE_XALAN
diff --git a/xsec/tools/txfmout/txfmout.cpp b/xsec/tools/txfmout/txfmout.cpp
index 94734c2..edc840f 100644
--- a/xsec/tools/txfmout/txfmout.cpp
+++ b/xsec/tools/txfmout/txfmout.cpp
@@ -37,16 +37,11 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/dsig/DSIGReference.hpp>
#include <xsec/framework/XSECException.hpp>
+#include <xsec/framework/XSECURIResolver.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/utils/XSECBinTXFMInputStream.hpp>
-#if defined(_WIN32)
-#include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
-#else
-#include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
-#endif
-
// General
#include <memory.h>
@@ -490,13 +485,6 @@
DSIGSignature * sig = prov.newSignatureFromDOM(theDOM, sigNode);
sig->registerIdAttributeName(MAKE_UNICODE_STRING("ID"));
-#if defined(_WIN32)
- XSECURIResolverGenericWin32
-#else
- XSECURIResolverGenericUnix
-#endif
- theResolver;
-
// Map out base path of the file
#if XSEC_HAVE_GETCWD_DYN
char *path = getcwd(NULL, 0);
@@ -525,12 +513,11 @@
// The last "\\" must prefix the filename
baseURI[lastSlash + 1] = '\0';
- theResolver.setBaseURI(MAKE_UNICODE_STRING(baseURI));
+ sig->getURIResolver()->setBaseURI(MAKE_UNICODE_STRING(baseURI));
#if XSEC_HAVE_GETCWD_DYN
free(path);
free(baseURI);
#endif
- sig->setURIResolver(&theResolver);
try {
diff --git a/xsec/utils/unixutils/XSECBinHTTPURIInputStream.cpp b/xsec/utils/unixutils/XSECBinHTTPURIInputStream.cpp
deleted file mode 100644
index 7bc6579..0000000
--- a/xsec/utils/unixutils/XSECBinHTTPURIInputStream.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECBinHTTPURIInputStream := Re-implementation of Xerces BinHTTPInputStream
- * Allows us to modify and create an input
- * stream that follows re-directs which is
- * necessary to fully support XML-DSIG interop
- * tests
- *
- * Author(s): Berin Lautenbach
- *
- * $Id$
- *
- * $Log$
- * Revision 1.8 2005/02/03 13:55:08 milan
- * Apache licence fix.
- *
- * Revision 1.7 2004/02/08 10:50:22 blautenb
- * Update to Apache 2.0 license
- *
- * Revision 1.6 2003/09/11 11:29:12 blautenb
- * Fix Xerces namespace usage in *NIX build
- *
- * Revision 1.5 2003/07/05 10:30:37 blautenb
- * Copyright update
- *
- * Revision 1.4 2003/05/19 12:31:00 blautenb
- * Cleaned up constants so can compile under INTEL compiler
- *
- * Revision 1.3 2003/03/23 09:49:49 blautenb
- * Silly mistype in ==
- *
- * Revision 1.2 2003/03/15 22:41:46 blautenb
- * Add 301 (permanently moved) support
- *
- * Revision 1.1 2003/02/12 11:21:03 blautenb
- * UNIX generic URI resolver
- *
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <errno.h>
-#include <limits.h>
-
-#include <xsec/framework/XSECError.hpp>
-#include <xsec/utils/unixutils/XSECBinHTTPURIInputStream.hpp>
-
-#include "../../utils/XSECAutoPtr.hpp"
-
-#include <xercesc/util/XMLNetAccessor.hpp>
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/XMLExceptMsgs.hpp>
-#include <xercesc/util/Janitor.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
-
-XERCES_CPP_NAMESPACE_USE
-
-int XSECBinHTTPURIInputStream::getSocketHandle(const XMLUri& urlSource) {
-
- //
- // Pull all of the parts of the URL out of th urlSource object, and transcode them
- // and transcode them back to ASCII.
- //
- const XMLCh* hostName = urlSource.getHost();
- XSECAutoPtrChar hostNameAsCharStar(hostName);
-
- const XMLCh* path = urlSource.getPath();
- XSECAutoPtrChar pathAsCharStar(path);
-
- const XMLCh* fragment = urlSource.getFragment();
- XSECAutoPtrChar fragmentAsCharStar(fragment);
-
- const XMLCh* query = urlSource.getQueryString();
- XSECAutoPtrChar queryAsCharStar(query);
-
- unsigned short portNumber = (unsigned short) urlSource.getPort();
- if (portNumber == USHRT_MAX)
- portNumber = 80;
-
- //
- // Set up a socket.
- //
- struct hostent* hostEntPtr = 0;
- struct sockaddr_in sa;
-
-
- if ((hostEntPtr = gethostbyname(hostNameAsCharStar.get())) == NULL)
- {
- unsigned long numAddress = inet_addr(hostNameAsCharStar.get());
- if (numAddress == 0)
- {
- ThrowXML(NetAccessorException,
- XMLExcepts::NetAcc_TargetResolution);
- }
- if ((hostEntPtr =
- gethostbyaddr((char *) &numAddress,
- sizeof(unsigned long), AF_INET)) == NULL)
- {
- ThrowXML(NetAccessorException,
- XMLExcepts::NetAcc_TargetResolution);
- }
- }
-
- memcpy((void *) &sa.sin_addr,
- (const void *) hostEntPtr->h_addr, hostEntPtr->h_length);
- sa.sin_family = hostEntPtr->h_addrtype;
- sa.sin_port = htons(portNumber);
-
- int s = socket(hostEntPtr->h_addrtype, SOCK_STREAM, 0);
- if (s < 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error creating socket");
-
- }
-
- if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error connecting to end server");
- }
-
- // The port is open and ready to go.
- // Build up the http GET command to send to the server.
- // To do: We should really support http 1.1. This implementation
- // is weak.
- strcpy(fBuffer, "GET ");
- strcat(fBuffer, pathAsCharStar.get());
-
- if (queryAsCharStar.get() != 0)
- {
- size_t n = strlen(fBuffer);
- fBuffer[n] = XERCES_CPP_NAMESPACE_QUALIFIER chQuestion;
- fBuffer[n+1] = XERCES_CPP_NAMESPACE_QUALIFIER chNull;
- strcat(fBuffer, queryAsCharStar.get());
- }
-
- if (fragmentAsCharStar.get() != 0)
- {
- strcat(fBuffer, fragmentAsCharStar.get());
- }
- strcat(fBuffer, " HTTP/1.0\r\n");
-
-
- strcat(fBuffer, "Host: ");
- strcat(fBuffer, hostNameAsCharStar.get());
- if (portNumber != 80)
- {
- int i = strlen(fBuffer);
- sprintf(fBuffer+i, ":%d", portNumber);
- // _itoa(portNumber, fBuffer+i, 10);
- }
- strcat(fBuffer, "\r\n\r\n");
-
- // Send the http request
- int lent = strlen(fBuffer);
- int aLent = 0;
- if ((aLent = write(s, (void *) fBuffer, lent)) != lent)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error writing to socket");
- }
-
- //
- // get the response, check the http header for errors from the server.
- //
- aLent = read(s, (void *)fBuffer, sizeof(fBuffer)-1);
- if (aLent <= 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- fBufferEnd = fBuffer+aLent;
- *fBufferEnd = 0;
-
- // Find the break between the returned http header and any data.
- // (Delimited by a blank line)
- // Hang on to any data for use by the first read from this BinHTTPURLInputStream.
- //
- fBufferPos = strstr(fBuffer, "\r\n\r\n");
- if (fBufferPos != 0)
- {
- fBufferPos += 4;
- *(fBufferPos-2) = 0;
- }
- else
- {
- fBufferPos = strstr(fBuffer, "\n\n");
- if (fBufferPos != 0)
- {
- fBufferPos += 2;
- *(fBufferPos-1) = 0;
- }
- else
- fBufferPos = fBufferEnd;
- }
-
- // Make sure the header includes an HTTP 200 OK response.
- //
- char *p = strstr(fBuffer, "HTTP");
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- p = strchr(p, ' ');
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- int httpResponse = atoi(p);
-
- if (httpResponse == 302 || httpResponse == 301) {
- //Once grows, should use a switch
- char redirectBuf[256];
- int q;
-
- // Find the "Location:" string
- p = strstr(p, "Location:");
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
- p = strchr(p, ' ');
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- // Now read
- p++;
- for (q=0; q < 255 && p[q] != '\r' && p[q] !='\n'; ++q)
- redirectBuf[q] = p[q];
-
- redirectBuf[q] = '\0';
-
- // Try to find this location
- XSECAutoPtrXMLCh redirectBufTrans(redirectBuf);
-
- return getSocketHandle(XMLUri(redirectBufTrans.get()));
- }
-
- else if (httpResponse != 200)
- {
- // Most likely a 404 Not Found error.
- // Should recognize and handle the forwarding responses.
- //
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Unknown HTTP Response");
- }
-
- return s;
-}
-
-
-XSECBinHTTPURIInputStream::XSECBinHTTPURIInputStream(const XMLUri& urlSource)
- : fSocket(0)
- , fBytesProcessed(0)
-{
-
- fSocket = getSocketHandle(urlSource);
-
-}
-
-
-
-XSECBinHTTPURIInputStream::~XSECBinHTTPURIInputStream()
-{
- shutdown(fSocket, 2);
- close(fSocket);
-}
-
-
-XMLSize_t XSECBinHTTPURIInputStream::readBytes(XMLByte* const toFill
- , const XMLSize_t maxToRead)
-{
- XMLSize_t len = fBufferEnd - fBufferPos;
- if (len > 0)
- {
- // If there's any data left over in the buffer into which we first
- // read from the server (to get the http header), return that.
- if (len > maxToRead)
- len = maxToRead;
- memcpy(toFill, fBufferPos, len);
- fBufferPos += len;
- }
- else
- {
- // There was no data in the local buffer.
- // Read some from the socket, straight into our caller's buffer.
- //
- len = read(fSocket, (void *) toFill, maxToRead);
- if (len == UINT_MAX)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reading from Socket");
- }
- }
-
- fBytesProcessed += len;
- return len;
-}
-
-const XMLCh* XSECBinHTTPURIInputStream::getContentType() const {
- return NULL;
-}
diff --git a/xsec/utils/unixutils/XSECBinHTTPURIInputStream.hpp b/xsec/utils/unixutils/XSECBinHTTPURIInputStream.hpp
deleted file mode 100644
index 4139c32..0000000
--- a/xsec/utils/unixutils/XSECBinHTTPURIInputStream.hpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECBinHTTPURIInputStream := Re-implementation of Xerces BinHTTPInputStream
- * Allows us to modify and create an input
- * stream that follows re-directs which is
- * necessary to fully support XML-DSIG interop
- * tests
- *
- * Author(s): Berin Lautenbach
- *
- * $Id$
- *
- * $Log$
- * Revision 1.5 2005/02/03 13:55:08 milan
- * Apache licence fix.
- *
- * Revision 1.4 2004/02/08 10:50:22 blautenb
- * Update to Apache 2.0 license
- *
- * Revision 1.3 2003/09/11 11:29:12 blautenb
- * Fix Xerces namespace usage in *NIX build
- *
- * Revision 1.2 2003/07/05 10:30:38 blautenb
- * Copyright update
- *
- * Revision 1.1 2003/02/12 11:21:03 blautenb
- * UNIX generic URI resolver
- *
- *
- */
-
-#ifndef UNIXXSECBINHTTPURIINPUTSTREAM_HEADER
-#define UNIXXSECBINHTTPURIINPUTSTREAM_HEADER
-
-#include <xsec/framework/XSECDefs.hpp>
-
-#include <xercesc/util/XMLUri.hpp>
-#include <xercesc/util/XMLExceptMsgs.hpp>
-#include <xercesc/util/BinInputStream.hpp>
-
-//
-// This class implements the BinInputStream interface specified by the XML
-// parser.
-//
-
-class XSEC_EXPORT XSECBinHTTPURIInputStream : public XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream
-{
-public :
- XSECBinHTTPURIInputStream(const XERCES_CPP_NAMESPACE_QUALIFIER XMLUri& urlSource);
- ~XSECBinHTTPURIInputStream();
-
- XMLFilePos curPos() const;
- XMLSize_t readBytes
- (
- XMLByte* const toFill
- , const XMLSize_t maxToRead
- );
-
- const XMLCh* getContentType() const;
-
-private :
- // -----------------------------------------------------------------------
- // Private data members
- //
- // fSocket
- // The socket representing the connection to the remote file.
- // fBytesProcessed
- // Its a rolling count of the number of bytes processed off this
- // input stream.
- // fBuffer
- // Holds the http header, plus the first part of the actual
- // data. Filled at the time the stream is opened, data goes
- // out to user in response to readBytes().
- // fBufferPos, fBufferEnd
- // Pointers into fBuffer, showing start and end+1 of content
- // that readBytes must return.
- // -----------------------------------------------------------------------
-
- int getSocketHandle(const XERCES_CPP_NAMESPACE_QUALIFIER XMLUri& urlSource);
-
- int fSocket;
- XMLSize_t fBytesProcessed;
- char fBuffer[4000];
- char * fBufferEnd;
- char * fBufferPos;
-
-};
-
-
-inline XMLFilePos XSECBinHTTPURIInputStream::curPos() const
-{
- return fBytesProcessed;
-}
-
-
-#endif // UNIXXSECBINHTTPURIINPUTSTREAM_HEADER
diff --git a/xsec/utils/unixutils/XSECURIResolverGenericUnix.cpp b/xsec/utils/unixutils/XSECURIResolverGenericUnix.cpp
deleted file mode 100644
index 514516b..0000000
--- a/xsec/utils/unixutils/XSECURIResolverGenericUnix.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECURIResolverGenericUnix := A URI Resolver that will work "out of
- * the box" with UNIX. Re-implements
- * much Xerces code, but allows us to
- * handle HTTP redirects as is required by
- * the DSIG Standard
- *
- * Author(s): Berin Lautenbach
- *
- * $Id$
- *
- * $Log$
- * Revision 1.11 2005/02/03 13:55:08 milan
- * Apache licence fix.
- *
- * Revision 1.10 2004/10/10 07:00:34 blautenb
- * Compile with Xerces 2.1
- *
- * Revision 1.9 2004/02/21 08:26:54 blautenb
- * Use XMLString::release rather than delete[] for all Xerces strings
- *
- * Revision 1.8 2004/02/08 10:50:22 blautenb
- * Update to Apache 2.0 license
- *
- * Revision 1.7 2004/02/03 11:00:03 blautenb
- * Add Space handling to UNIX URL handling
- *
- * Revision 1.6 2004/01/26 00:29:48 blautenb
- * Check for Xerces new way of handling NULL hostnames in URIs
- *
- * Revision 1.5 2003/09/11 11:29:12 blautenb
- * Fix Xerces namespace usage in *NIX build
- *
- * Revision 1.4 2003/07/05 10:30:38 blautenb
- * Copyright update
- *
- * Revision 1.3 2003/05/10 07:23:36 blautenb
- * Updates to support anonymous references
- *
- * Revision 1.2 2003/02/20 10:35:10 blautenb
- * Fix for broken Xerces XMLUri
- *
- * Revision 1.1 2003/02/12 11:21:03 blautenb
- * UNIX generic URI resolver
- *
- *
- */
-
-#include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
-
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xercesc/util/XMLUri.hpp>
-#include <xercesc/util/XMLUni.hpp>
-#include <xercesc/util/Janitor.hpp>
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/BinFileInputStream.hpp>
-
-XERCES_CPP_NAMESPACE_USE
-
-#include <xsec/framework/XSECError.hpp>
-#include <xsec/utils/XSECDOMUtils.hpp>
-#include <xsec/utils/unixutils/XSECBinHTTPURIInputStream.hpp>
-
-#include "../../utils/XSECAutoPtr.hpp"
-
-static const XMLCh gFileScheme[] = {
-
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_f,
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_i,
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_l,
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_e,
- XERCES_CPP_NAMESPACE_QUALIFIER chNull
-
-};
-
-static const XMLCh gHttpScheme[] = {
-
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_h,
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_t,
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_t,
- XERCES_CPP_NAMESPACE_QUALIFIER chLatin_p,
- XERCES_CPP_NAMESPACE_QUALIFIER chNull
-
-};
-
-
-#if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR < 3
-
-
-static const XMLCh DOTDOT_SLASH[] = {
-
- XERCES_CPP_NAMESPACE_QUALIFIER chPeriod,
- XERCES_CPP_NAMESPACE_QUALIFIER chPeriod,
- XERCES_CPP_NAMESPACE_QUALIFIER chForwardSlash,
- XERCES_CPP_NAMESPACE_QUALIFIER chNull
-
-};
-
-#endif
-
-
-
-XSECURIResolverGenericUnix::XSECURIResolverGenericUnix() :
-mp_baseURI(NULL) {
-
-};
-
-XSECURIResolverGenericUnix::~XSECURIResolverGenericUnix() {
-
- if (mp_baseURI != NULL)
- XSEC_RELEASE_XMLCH(mp_baseURI);
-
-}
-
-// -----------------------------------------------------------------------
-// Resolve a URI that is passed in
-// -----------------------------------------------------------------------
-
-BinInputStream * XSECURIResolverGenericUnix::resolveURI(const XMLCh * uri) {
-
- XSEC_USING_XERCES(BinInputStream);
- XSEC_USING_XERCES(XMLUri);
- XSEC_USING_XERCES(XMLUni);
- XSEC_USING_XERCES(Janitor);
- XSEC_USING_XERCES(BinFileInputStream);
-
- XMLUri * xmluri;
-
- if (uri == NULL) {
- throw XSECException(XSECException::ErrorOpeningURI,
- "XSECURIResolverGenericUnix - anonymous references not supported in default URI Resolvers");
- }
-
- // Create the appropriate XMLUri objects
-
- if (mp_baseURI != NULL) {
- XMLUri * turi;
-
-#if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR < 3
-
- // XMLUri relative paths are broken, so we need to strip out ".."
- XSECAutoPtrXMLCh b(mp_baseURI);
- XSECAutoPtrXMLCh r(uri);
-
- int index = 0;
- while (XMLString::startsWith(&(r.get()[index]), DOTDOT_SLASH)) {
-
- // Strip the last segment of the base
-
- int lastIndex = XMLString::lastIndexOf(b.get(), XERCES_CPP_NAMESPACE_QUALIFIER chForwardSlash);
- if (lastIndex > 0)
- const_cast<XMLCh*>(b.get())[lastIndex] = 0;
-
- index += 3;
-
- }
-
- XSECnew(turi, XMLUri(b.get()));
- Janitor<XMLUri> j_turi(turi);
- XSECnew(xmluri, XMLUri(turi, &(r.get()[index])));
-
-#else
- XSECnew(turi, XMLUri(mp_baseURI));
- Janitor<XMLUri> j_turi(turi);
-
- XSECnew(xmluri, XMLUri(turi, uri));
-#endif
-
- }
- else {
- XSECnew(xmluri, XMLUri(uri));
- }
-
- Janitor<XMLUri> j_xmluri(xmluri);
-
- // Determine what kind of URI this is and how to handle it.
-
- if (!XMLString::compareIString(xmluri->getScheme(), gFileScheme)) {
-
- // This is a file. We only really understand if this is localhost
- // XMLUri has already cleaned of escape characters (%xx)
-
- if (xmluri->getHost() == NULL || xmluri->getHost()[0] == chNull ||
- !XMLString::compareIString(xmluri->getHost(), XMLUni::fgLocalHostString)) {
-
- // Clean hex escapes
- XMLCh * realPath = cleanURIEscapes(xmluri->getPath());
-
- // Localhost
-
- BinFileInputStream* retStrm = new BinFileInputStream(realPath);
- XSEC_RELEASE_XMLCH(realPath);
-
- if (!retStrm->getIsOpen())
- {
- delete retStrm;
- return 0;
- }
- return retStrm;
-
- }
-
- else {
-
- throw XSECException(XSECException::ErrorOpeningURI,
- "XSECURIResolverGenericUnix - unable to open non-localhost file");
-
- }
-
- }
-
- // Is the scheme a HTTP?
- if (!XMLString::compareIString(xmluri->getScheme(), gHttpScheme)) {
-
- // Pass straight to our local XSECBinHTTPUriInputStream
- XSECBinHTTPURIInputStream *ret;
-
- XSECnew(ret, XSECBinHTTPURIInputStream(*xmluri));
-
- return ret;
-
- }
-
- throw XSECException(XSECException::ErrorOpeningURI,
- "XSECURIResolverGenericUnix - unknown URI scheme");
-
-}
-
-// -----------------------------------------------------------------------
-// Clone me
-// -----------------------------------------------------------------------
-
-
-XSECURIResolver * XSECURIResolverGenericUnix::clone(void) {
-
- XSECURIResolverGenericUnix * ret;
-
- ret = new XSECURIResolverGenericUnix();
-
- if (this->mp_baseURI != NULL)
- ret->mp_baseURI = XMLString::replicate(this->mp_baseURI);
- else
- ret->mp_baseURI = NULL;
-
- return ret;
-
-}
-
-// -----------------------------------------------------------------------
-// Set a base URI to map any incoming files against
-// -----------------------------------------------------------------------
-
-void XSECURIResolverGenericUnix::setBaseURI(const XMLCh * uri) {
-
- if (mp_baseURI != NULL)
- XSEC_RELEASE_XMLCH(mp_baseURI);
-
- mp_baseURI = XMLString::replicate(uri);
-
-}
diff --git a/xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp b/xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp
deleted file mode 100644
index de8b728..0000000
--- a/xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECURIResolverGenericWin32 := A URI Resolver that will work "out of
- * the box" with UNIX. Re-implements
- * much Xerces code, but allows us to
- * handle HTTP redirects as is required by
- * the DSIG Standard
- *
- * Author(s): Berin Lautenbach
- *
- * $Id$
- *
- * $Log$
- * Revision 1.5 2005/02/03 13:55:08 milan
- * Apache licence fix.
- *
- * Revision 1.4 2004/02/08 10:50:22 blautenb
- * Update to Apache 2.0 license
- *
- * Revision 1.3 2003/09/11 11:29:12 blautenb
- * Fix Xerces namespace usage in *NIX build
- *
- * Revision 1.2 2003/07/05 10:30:38 blautenb
- * Copyright update
- *
- * Revision 1.1 2003/02/12 11:21:04 blautenb
- * UNIX generic URI resolver
- *
- *
- */
-
-#ifndef XSECURIRESOLVERGENERICUNIX_INCLUDE
-#define XSECURIRESOLVERGENERICUNIX_INCLUDE
-
-#include <xsec/framework/XSECDefs.hpp>
-#include <xsec/framework/XSECURIResolver.hpp>
-
-#include <xercesc/util/XMLString.hpp>
-
-/**
- * @ingroup pubsig
- */
-/*\@{*/
-
-/**
- * @brief Generic UNIX URI Resolver.
- *
- * The XML Digital Signature standard makes heavy use of URIs to
- * identify information to be referenced and signed.
- *
- * This class implements the XSECURIResolver for UNIX, re-using
- * much of the Xerces code.
- *
- * @todo Implement a "pluggable" URI resolver that allows developers
- * to plug in different classes for different schemes
- */
-
-class XSEC_EXPORT XSECURIResolverGenericUnix : public XSECURIResolver {
-
-public:
-
- /** @name Constructors and Destructors */
- //@{
-
- XSECURIResolverGenericUnix();
- virtual ~XSECURIResolverGenericUnix();
-
- //@}
-
- /** @name Interface Methods */
- //@{
-
- /**
- * \brief Create a BYTE_STREAM from a URI.
- *
- * The resolver is required to take the input URI and
- * dereference it to an actual stream of octets.
- *
- * The octets are provided back to the library using
- * the Xerces BinInputStream class.
- *
- * @note The returned stream is "owned" by the caller, which
- * will delete it when processing is complete.
- * @param uri The string containing the URI to be de-referenced.
- * @returns The octet stream corresponding to the URI.
- */
-
- virtual XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream *
- resolveURI(const XMLCh * uri);
-
- /**
- * \brief Clone the resolver to be installed in a new object.
- *
- * When URIResolvers are passed into signatures and other
- * objects, they are cloned and control of the original object
- * is left with the caller.
- *
- */
-
- virtual XSECURIResolver * clone(void);
-
- //@}
-
- /** @name Class specific functions */
- //@{
-
- /**
- * \brief Set the base URI for relative URIs.
- *
- */
-
- void setBaseURI(const XMLCh * uri);
-
- //@}
-
-private:
-
- XMLCh * mp_baseURI;
-
-
-};
-
-
-#endif /* XSECURIRESOLVERGENERICUNIX_INCLUDE */
diff --git a/xsec/utils/winutils/XSECBinHTTPURIInputStream.cpp b/xsec/utils/winutils/XSECBinHTTPURIInputStream.cpp
deleted file mode 100644
index b822b46..0000000
--- a/xsec/utils/winutils/XSECBinHTTPURIInputStream.cpp
+++ /dev/null
@@ -1,596 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECBinHTTPURIInputStream := Re-implementation of the Xerces
- * BinHTTPURLInputStream. Allows us to make
- * some small changes to support the requirements
- * of XMLDSIG (notably re-directs)
- *
- * NOTE: Much code taken from Xerces, and the cross platform interfacing is
- * no-where near as nice.
- *
- * $Id$
- *
- */
-
-#include <xsec/utils/winutils/XSECBinHTTPURIInputStream.hpp>
-
-#define _WINSOCKAPI_
-
-#define INCL_WINSOCK_API_TYPEDEFS 1
-#include <winsock2.h>
-#include <windows.h>
-#include <tchar.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-
-#include <xercesc/util/PlatformUtils.hpp>
-#include <xercesc/util/XMLNetAccessor.hpp>
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/XMLExceptMsgs.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
-
-XERCES_CPP_NAMESPACE_USE
-
-#include <xsec/utils/winutils/XSECBinHTTPURIInputStream.hpp>
-#include <xsec/framework/XSECError.hpp>
-
-#include "../../utils/XSECAutoPtr.hpp"
-
-static HMODULE gWinsockLib = NULL;
-static LPFN_GETHOSTBYNAME gWSgethostbyname = NULL;
-static LPFN_INET_ADDR gWSinet_addr = NULL;
-static LPFN_GETHOSTBYADDR gWSgethostbyaddr = NULL;
-static LPFN_HTONS gWShtons = NULL;
-static LPFN_SOCKET gWSsocket = NULL;
-static LPFN_CONNECT gWSconnect = NULL;
-static LPFN_SEND gWSsend = NULL;
-static LPFN_RECV gWSrecv = NULL;
-static LPFN_SHUTDOWN gWSshutdown = NULL;
-static LPFN_CLOSESOCKET gWSclosesocket = NULL;
-static LPFN_WSACLEANUP gWSACleanup = NULL;
-
-bool XSECBinHTTPURIInputStream::fInitialized = false;
-XMLMutex* XSECBinHTTPURIInputStream::fInitMutex = 0;
-
-// Ported from Xerces 2.x, now missing on 3.x, so I'm inlining it.
-static void* compareAndSwap(void** toFill, const void* const newValue, const void* const toCompare) {
-#if defined _WIN64
- return ::InterlockedCompareExchangePointer(toFill, (void*)newValue, (void*)toCompare);
-#else
- void* result;
- __asm
- {
- mov eax, toCompare;
- mov ebx, newValue;
- mov ecx, toFill
- lock cmpxchg [ecx], ebx;
- mov result, eax;
- }
- return result;
-#endif
-}
-
-void XSECBinHTTPURIInputStream::Initialize() {
- //
- // Initialize the WinSock library here.
- //
- WORD wVersionRequested;
- WSADATA wsaData;
-
- LPFN_WSASTARTUP startup = NULL;
- if(gWinsockLib == NULL) {
- gWinsockLib = LoadLibrary(_T("WSOCK32"));
- if(gWinsockLib == NULL) {
- ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed);
- }
- else {
- startup = (LPFN_WSASTARTUP) GetProcAddress(gWinsockLib,"WSAStartup");
- gWSACleanup = (LPFN_WSACLEANUP) GetProcAddress(gWinsockLib,"WSACleanup");
- gWSgethostbyname = (LPFN_GETHOSTBYNAME) GetProcAddress(gWinsockLib,"gethostbyname");
- gWSinet_addr = (LPFN_INET_ADDR) GetProcAddress(gWinsockLib,"inet_addr");
- gWSgethostbyaddr = (LPFN_GETHOSTBYADDR) GetProcAddress(gWinsockLib,"gethostbyaddr");
- gWShtons = (LPFN_HTONS) GetProcAddress(gWinsockLib,"htons");
- gWSsocket = (LPFN_SOCKET) GetProcAddress(gWinsockLib,"socket");
- gWSconnect = (LPFN_CONNECT) GetProcAddress(gWinsockLib,"connect");
- gWSsend = (LPFN_SEND) GetProcAddress(gWinsockLib,"send");
- gWSrecv = (LPFN_RECV) GetProcAddress(gWinsockLib,"recv");
- gWSshutdown = (LPFN_SHUTDOWN) GetProcAddress(gWinsockLib,"shutdown");
- gWSclosesocket = (LPFN_CLOSESOCKET) GetProcAddress(gWinsockLib,"closesocket");
-
- if(startup == NULL ||
- gWSACleanup == NULL ||
- gWSgethostbyname == NULL ||
- gWSinet_addr == NULL ||
- gWSgethostbyaddr == NULL ||
- gWShtons == NULL ||
- gWSsocket == NULL ||
- gWSconnect == NULL ||
- gWSsend == NULL ||
- gWSrecv == NULL ||
- gWSshutdown == NULL ||
- gWSclosesocket == NULL)
- {
- gWSACleanup = NULL;
- Cleanup();
- ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed);
- }
- }
- }
- wVersionRequested = MAKEWORD( 2, 2 );
- int err = (*startup)(wVersionRequested, &wsaData);
- if (err != 0)
- {
- // Call WSAGetLastError() to get the last error.
- ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed);
- }
- fInitialized = true;
-}
-
-void XSECBinHTTPURIInputStream::Cleanup() {
- if(fInitialized)
- {
- if(gWSACleanup) (*gWSACleanup)();
- gWSACleanup = NULL;
- FreeLibrary(gWinsockLib);
- gWinsockLib = NULL;
- gWSgethostbyname = NULL;
- gWSinet_addr = NULL;
- gWSgethostbyaddr = NULL;
- gWShtons = NULL;
- gWSsocket = NULL;
- gWSconnect = NULL;
- gWSsend = NULL;
- gWSrecv = NULL;
- gWSshutdown = NULL;
- gWSclosesocket = NULL;
-
- fInitialized = false;
- delete fInitMutex;
- fInitMutex = 0;
- }
-}
-
-
-hostent* XSECBinHTTPURIInputStream::gethostbyname(const char* name)
-{
- return (*gWSgethostbyname)(name);
-}
-
-unsigned long XSECBinHTTPURIInputStream::inet_addr(const char* cp)
-{
- return (*gWSinet_addr)(cp);
-}
-
-hostent* XSECBinHTTPURIInputStream::gethostbyaddr(const char* addr,int len,int type)
-{
- return (*gWSgethostbyaddr)(addr,len,type);
-}
-
-unsigned short XSECBinHTTPURIInputStream::htons(unsigned short hostshort)
-{
- return (*gWShtons)(hostshort);
-}
-
-unsigned short XSECBinHTTPURIInputStream::socket(int af,int type,int protocol)
-{
- return (unsigned short) (*gWSsocket)(af,type,protocol);
-}
-
-int XSECBinHTTPURIInputStream::connect(unsigned short s,const sockaddr* name,int namelen)
-{
- return (*gWSconnect)(s,name,namelen);
-}
-
-int XSECBinHTTPURIInputStream::send(unsigned short s,const char* buf,int len,int flags)
-{
- return (*gWSsend)(s,buf,len,flags);
-}
-
-int XSECBinHTTPURIInputStream::recv(unsigned short s,char* buf,int len,int flags)
-{
- return (*gWSrecv)(s,buf,len,flags);
-}
-
-int XSECBinHTTPURIInputStream::shutdown(unsigned int s,int how)
-{
- return (*gWSshutdown)(s,how);
-}
-
-int XSECBinHTTPURIInputStream::closesocket(unsigned int socket)
-{
- return (*gWSclosesocket)(socket);
-}
-
-unsigned int XSECBinHTTPURIInputStream::getSocketHandle(const XMLUri& urlSource) {
-
- //
- // Pull all of the parts of the URL out of th urlSource object, and transcode them
- // and transcode them back to ASCII.
- //
- const XMLCh* hostName = urlSource.getHost();
- XSECAutoPtrChar hostNameAsCharStar(hostName);
-
- const XMLCh* path = urlSource.getPath();
- XSECAutoPtrChar pathAsCharStar(path);
-
- const XMLCh* fragment = urlSource.getFragment();
- XSECAutoPtrChar fragmentAsCharStar(fragment);
-
- const XMLCh* query = urlSource.getQueryString();
- XSECAutoPtrChar queryAsCharStar(query);
-
- unsigned short portNumber = (unsigned short) urlSource.getPort();
-
- // If no number is set, go with port 80
- if (portNumber == USHRT_MAX)
- portNumber = 80;
-
- //
- // Set up a socket.
- //
- struct hostent* hostEntPtr = 0;
- struct sockaddr_in sa;
-
-
- if ((hostEntPtr = gethostbyname(hostNameAsCharStar.get())) == NULL)
- {
- unsigned long numAddress = inet_addr(hostNameAsCharStar.get());
- if (numAddress == INADDR_NONE)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported resolving IP address");
- }
- if ((hostEntPtr =
- gethostbyaddr((const char *) &numAddress,
- sizeof(unsigned long), AF_INET)) == NULL)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported resolving IP address");
- }
- }
-
- memcpy((void *) &sa.sin_addr,
- (const void *) hostEntPtr->h_addr, hostEntPtr->h_length);
- sa.sin_family = hostEntPtr->h_addrtype;
- sa.sin_port = htons(portNumber);
-
- SOCKET s = socket(hostEntPtr->h_addrtype, SOCK_STREAM, 0);
- if (s == INVALID_SOCKET)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported creating socket");
- }
-
- if (connect((unsigned short) s, (struct sockaddr *) &sa, sizeof(sa)) == SOCKET_ERROR)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported connecting to socket");
- }
-
-
- // Set a flag so we know that the headers have not been read yet.
- bool fHeaderRead = false;
-
- // The port is open and ready to go.
- // Build up the http GET command to send to the server.
- // To do: We should really support http 1.1. This implementation
- // is weak.
-
- safeBuffer request("GET ");
- request.sbStrcatIn(pathAsCharStar.get());
-
- if (queryAsCharStar.get() != 0)
- {
- // Tack on a ? before the fragment
- request.sbStrcatIn("?");
- request.sbStrcatIn(queryAsCharStar.get());
- }
-
- if (fragmentAsCharStar.get() != 0)
- {
- request.sbStrcatIn(fragmentAsCharStar.get());
- }
- request.sbStrcatIn(" HTTP/1.0\r\n");
-
-
- request.sbStrcatIn("Host: ");
- request.sbStrcatIn(hostNameAsCharStar.get());
- if (portNumber != 80)
- {
- char portNumberStr[34];
- request.sbStrcatIn(":");
- _itoa(portNumber, portNumberStr, 10);
- request.sbStrcatIn(portNumberStr);
- }
- request.sbStrcatIn("\r\n\r\n");
-
- // Send the http request
- int lent = (int)request.sbStrlen();
- int aLent = 0;
- if ((aLent = send((unsigned short)s, (const char *) request.rawBuffer(), lent, 0)) != lent)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported writing to socket");
- }
-
-
-#if 0
-
- memset(fBuffer, 0, sizeof(fBuffer));
-
- strcpy(fBuffer, "GET ");
- strcat(fBuffer, pathAsCharStar.get());
-
- if (queryAsCharStar.get() != 0)
- {
- // Tack on a ? before the fragment
- strcat(fBuffer,"?");
- strcat(fBuffer, queryAsCharStar.get());
- }
-
- if (fragmentAsCharStar.get() != 0)
- {
- strcat(fBuffer, fragmentAsCharStar.get());
- }
- strcat(fBuffer, " HTTP/1.0\r\n");
-
-
- strcat(fBuffer, "Host: ");
- strcat(fBuffer, hostNameAsCharStar.get());
- if (portNumber != 80)
- {
- strcat(fBuffer, ":");
- int i = (int) strlen(fBuffer);
- _itoa(portNumber, fBuffer+i, 10);
- }
- strcat(fBuffer, "\r\n\r\n");
-
- // Send the http request
- int lent = (int) strlen(fBuffer);
- int aLent = 0;
- if ((aLent = send((unsigned short) s, fBuffer, lent, 0)) != lent)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported writing to socket");
- }
-
-#endif
- //
- // get the response, check the http header for errors from the server.
- //
- memset(fBuffer, 0, sizeof(fBuffer));
- aLent = recv((unsigned short) s, fBuffer, sizeof(fBuffer)-1, 0);
- if (aLent == SOCKET_ERROR || aLent == 0)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- fBufferEnd = fBuffer+aLent;
- *fBufferEnd = 0;
-
- do {
- // Find the break between the returned http header and any data.
- // (Delimited by a blank line)
- // Hang on to any data for use by the first read from this XSECBinHTTPURIInputStream.
- //
- fBufferPos = strstr(fBuffer, "\r\n\r\n");
- if (fBufferPos != 0)
- {
- fBufferPos += 4;
- *(fBufferPos-2) = 0;
- fHeaderRead = true;
- }
- else
- {
- fBufferPos = strstr(fBuffer, "\n\n");
- if (fBufferPos != 0)
- {
- fBufferPos += 2;
- *(fBufferPos-1) = 0;
- fHeaderRead = true;
- }
- else
- {
- //
- // Header is not yet read, do another recv() to get more data...
- aLent = (unsigned int) recv((unsigned short) s, fBufferEnd, ((int) sizeof(fBuffer) - 1) - (int) (fBufferEnd - fBuffer), 0);
- if (aLent == SOCKET_ERROR || aLent == 0)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
- fBufferEnd = fBufferEnd + aLent;
- *fBufferEnd = 0;
- }
- }
- } while(fHeaderRead == false);
-
- // Make sure the header includes an HTTP 200 OK response.
- //
- char *p = strstr(fBuffer, "HTTP");
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- p = strchr(p, ' ');
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- int httpResponse = atoi(p);
-
- // Check for redirect or permanently moved
- if (httpResponse == 302 || httpResponse == 301)
- {
- //Once grows, should use a switch
- char redirectBuf[256];
- int q;
-
- // Find the "Location:" string
- p = strstr(p, "Location:");
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
- p = strchr(p, ' ');
- if (p == 0)
- {
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
-
- // Now read
- p++;
- for (q=0; q < 255 && p[q] != '\r' && p[q] !='\n' && p[q] != '\0'; ++q)
- redirectBuf[q] = p[q];
-
- redirectBuf[q] = '\0';
-
- // Try to find this location
- XSECAutoPtrXMLCh redirectBufTrans(redirectBuf);
-
- return getSocketHandle(XMLUri(redirectBufTrans.get()));
- }
- else if (httpResponse != 200)
- {
- // Most likely a 404 Not Found error.
- // Should recognize and handle the forwarding responses.
- //
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Unknown HTTP response received");
- }
-
- return (unsigned int) s;
-}
-
-
-XSECBinHTTPURIInputStream::XSECBinHTTPURIInputStream(const XMLUri& urlSource)
- : fSocketHandle(0)
- , fBytesProcessed(0)
-{
- if(!fInitialized)
- {
- if (!fInitMutex)
- {
- XMLMutex* tmpMutex = new XMLMutex;
- if (compareAndSwap((void**)&fInitMutex, tmpMutex, 0))
- {
- // Someone beat us to it, so let's clean up ours
- delete tmpMutex;
- }
- }
- XMLMutexLock lock(fInitMutex);
- if (!fInitialized)
- {
- Initialize();
- }
- }
-
- fSocketHandle = getSocketHandle(urlSource);
-
-}
-
-void XSECBinHTTPURIInputStream::ExternalInitialize(void) {
-
- if(!fInitialized)
- {
- if (!fInitMutex)
- {
- XMLMutex* tmpMutex = new XMLMutex;
- if (compareAndSwap((void**)&fInitMutex, tmpMutex, 0))
- {
- // Someone beat us to it, so let's clean up ours
- delete tmpMutex;
- }
- }
- XMLMutexLock lock(fInitMutex);
- if (!fInitialized)
- {
- Initialize();
- }
- }
-}
-
-
-XSECBinHTTPURIInputStream::~XSECBinHTTPURIInputStream()
-{
- shutdown(fSocketHandle, SD_BOTH);
- closesocket(fSocketHandle);
-}
-
-
-//
-// readBytes
-//
-XMLSize_t XSECBinHTTPURIInputStream::readBytes(XMLByte* const toFill
- , const XMLSize_t maxToRead)
-{
-
- XMLSize_t len = (XMLSize_t) (fBufferEnd - fBufferPos);
- if (len > 0)
- {
- // If there's any data left over in the buffer into which we first
- // read from the server (to get the http header), return that.
- if (len > maxToRead)
- len = maxToRead;
- memcpy(toFill, fBufferPos, len);
- fBufferPos += len;
- }
- else
- {
- // There was no data in the local buffer.
- // Read some from the socket, straight into our caller's buffer.
- //
- len = recv(fSocketHandle, (char *) toFill, maxToRead, 0);
- if (len == SOCKET_ERROR)
- {
- // Call WSAGetLastError() to get the error number.
- throw XSECException(XSECException::HTTPURIInputStreamError,
- "Error reported reading socket");
- }
- }
-
- fBytesProcessed += len;
- return len;
-}
-
-const XMLCh* XSECBinHTTPURIInputStream::getContentType() const {
- return NULL;
-}
diff --git a/xsec/utils/winutils/XSECBinHTTPURIInputStream.hpp b/xsec/utils/winutils/XSECBinHTTPURIInputStream.hpp
deleted file mode 100644
index fd46f7b..0000000
--- a/xsec/utils/winutils/XSECBinHTTPURIInputStream.hpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECBinHTTPURIInputStream := Re-implementation of the Xerces
- * BinHTTPURLInputStream. Allows us to make
- * some small changes to support the requirements
- * of XMLDSIG (notably re-directs)
- *
- * NOTE: Much code taken from Xerces, and the cross platform interfacing is
- * no-where near as nice.
- *
- * Author(s): Berin Lautenbach
- *
- * $Id$
- *
- * $Log$
- * Revision 1.7 2005/02/03 13:56:22 milan
- * Apache licence fix.
- *
- * Revision 1.6 2004/04/21 10:14:49 blautenb
- * Clean windows build with overarching SimpleSOAPRequestor
- *
- * Revision 1.5 2004/04/16 12:07:23 blautenb
- * Skeleton code for XKMS MessageFactory
- *
- * Revision 1.4 2004/02/08 10:25:40 blautenb
- * Convert to Apache 2.0 license
- *
- * Revision 1.3 2003/09/11 11:11:05 blautenb
- * Cleaned up usage of Xerces namespace - no longer inject into global namespace in headers
- *
- * Revision 1.2 2003/07/05 10:30:38 blautenb
- * Copyright update
- *
- * Revision 1.1 2003/02/12 09:45:29 blautenb
- * Win32 Re-implementation of Xerces URIResolver to support re-directs
- *
- *
- */
-
-
-#ifndef XSECBINHTTPURIINPUTSTREAM_HEADER
-#define XSECBINHTTPURIINPUTSTREAM_HEADER
-
-#include <xsec/framework/XSECDefs.hpp>
-
-#include <xercesc/util/XMLUri.hpp>
-#include <xercesc/util/XMLExceptMsgs.hpp>
-#include <xercesc/util/BinInputStream.hpp>
-#include <xercesc/util/Mutexes.hpp>
-
-//
-// This class implements the BinInputStream interface specified by the XML
-// parser.
-//
-
-struct hostent;
-struct sockaddr;
-
-class XSECSOAPRequestorSimple;
-
-class XSEC_EXPORT XSECBinHTTPURIInputStream : public XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream
-{
-public :
-
- XSECBinHTTPURIInputStream(const XERCES_CPP_NAMESPACE_QUALIFIER XMLUri& urlSource);
- ~XSECBinHTTPURIInputStream();
-
- XMLFilePos curPos() const;
- XMLSize_t readBytes(XMLByte* const toFill, const XMLSize_t maxToRead);
-
- const XMLCh* getContentType() const;
-
- static void Cleanup();
-
- friend class XSECSOAPRequestorSimple;
-
-protected:
-
- /*
- * These are called by other classes that use the loaded DLL
- *
- * Actually - this is cheating of the worst kind, but it
- * provides a quick way to make these calls available outside the library
- */
-
- static void ExternalInitialize(void);
-
- static hostent* gethostbyname(const char* name);
- static unsigned long inet_addr(const char* cp);
- static hostent* gethostbyaddr(const char* addr,int len,int type);
- static unsigned short htons(unsigned short hostshort);
- static unsigned short socket(int af,int type,int protocol);
- static int connect(unsigned short s,const sockaddr* name,int namelen);
- static int send(unsigned short s,const char* buf,int len,int flags);
- static int recv(unsigned short s,char* buf,int len,int flags);
- static int shutdown(unsigned int s,int how);
- static int closesocket(unsigned int socket);
-
-
-private :
- // -----------------------------------------------------------------------
- // Private data members
- //
- // fSocketHandle
- // The socket representing the connection to the remote file.
- // We deliberately did not define the type to be SOCKET, so as to
- // avoid bringing in any Windows header into this file.
- // fBytesProcessed
- // Its a rolling count of the number of bytes processed off this
- // input stream.
- // fBuffer
- // Holds the http header, plus the first part of the actual
- // data. Filled at the time the stream is opened, data goes
- // out to user in response to readBytes().
- // fBufferPos, fBufferEnd
- // Pointers into fBuffer, showing start and end+1 of content
- // that readBytes must return.
- // -----------------------------------------------------------------------
-
- unsigned int fSocketHandle;
- XMLSize_t fBytesProcessed;
- char fBuffer[4000];
- char * fBufferEnd;
- char * fBufferPos;
- static bool fInitialized;
- static XERCES_CPP_NAMESPACE_QUALIFIER XMLMutex* fInitMutex;
-
- static void Initialize();
- unsigned int getSocketHandle(const XERCES_CPP_NAMESPACE_QUALIFIER XMLUri& urlSource);
-
-};
-
-
-inline XMLFilePos XSECBinHTTPURIInputStream::curPos() const
-{
- return fBytesProcessed;
-}
-
-
-#endif // XSECBINHTTPURIINPUTSTREAM_HEADER
diff --git a/xsec/utils/winutils/XSECURIResolverGenericWin32.cpp b/xsec/utils/winutils/XSECURIResolverGenericWin32.cpp
deleted file mode 100644
index 87eec62..0000000
--- a/xsec/utils/winutils/XSECURIResolverGenericWin32.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECURIResolverGenericWin32 := A URI Resolver that will work "out of
- * the box" with Windows. Re-implements
- * much Xerces code, but allows us to
- * handle HTTP redirects as is required by
- * the DSIG Standard
- *
- * Author(s): Berin Lautenbach
- *
- * $Id$
- *
- * $Log$
- * Revision 1.12 2005/05/29 00:06:55 blautenb
- * Update localhost check to include an empty hostname - reported by Vincent Finn <vincent.finn@automsoft.com> on security-dev@xml 27/5/2005
- *
- * Revision 1.11 2005/02/03 13:56:22 milan
- * Apache licence fix.
- *
- * Revision 1.10 2004/02/21 08:26:54 blautenb
- * Use XMLString::release rather than delete[] for all Xerces strings
- *
- * Revision 1.9 2004/02/08 10:25:40 blautenb
- * Convert to Apache 2.0 license
- *
- * Revision 1.8 2004/01/26 00:16:04 blautenb
- * Remove escapes from URI before retrieving a path on the file system
- *
- * Revision 1.7 2003/09/11 11:11:05 blautenb
- * Cleaned up usage of Xerces namespace - no longer inject into global namespace in headers
- *
- * Revision 1.6 2003/07/28 12:52:46 blautenb
- * Fixed a bug with DEBUG_NEW when compiling with Xalan 1.6
- *
- * Revision 1.5 2003/07/05 10:30:38 blautenb
- * Copyright update
- *
- * Revision 1.4 2003/05/22 11:42:06 blautenb
- * Updates so Windows version will compile with Xerces 2.3
- *
- * Revision 1.3 2003/05/10 07:23:36 blautenb
- * Updates to support anonymous references
- *
- * Revision 1.2 2003/02/17 11:21:45 blautenb
- * Work around for Xerces XMLUri bug
- *
- * Revision 1.1 2003/02/12 09:45:29 blautenb
- * Win32 Re-implementation of Xerces URIResolver to support re-directs
- *
- *
- */
-
-#include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
-
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xercesc/util/XMLUri.hpp>
-#include <xercesc/util/XMLUni.hpp>
-#include <xercesc/util/Janitor.hpp>
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/BinFileInputStream.hpp>
-
-XERCES_CPP_NAMESPACE_USE
-
-#include <xsec/framework/XSECError.hpp>
-#include <xsec/utils/winutils/XSECBinHTTPURIInputStream.hpp>
-#include <xsec/utils/XSECDOMUtils.hpp>
-
-#include "../../utils/XSECAutoPtr.hpp"
-
-static const XMLCh gFileScheme[] = {
-
- chLatin_f,
- chLatin_i,
- chLatin_l,
- chLatin_e,
- chNull
-
-};
-
-static const XMLCh gHttpScheme[] = {
-
- chLatin_h,
- chLatin_t,
- chLatin_t,
- chLatin_p,
- chNull
-
-};
-
-#if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR < 3
-
-
-static const XMLCh DOTDOT_SLASH[] = {
-
- chPeriod,
- chPeriod,
- chForwardSlash,
- chNull
-
-};
-
-#endif
-
-XSECURIResolverGenericWin32::XSECURIResolverGenericWin32() :
-mp_baseURI(NULL) {
-
-};
-
-
-XSECURIResolverGenericWin32::~XSECURIResolverGenericWin32() {
-
- if (mp_baseURI != NULL)
- XSEC_RELEASE_XMLCH(mp_baseURI);
-
-}
-
-// -----------------------------------------------------------------------
-// Resolve a URI that is passed in
-// -----------------------------------------------------------------------
-
-BinInputStream * XSECURIResolverGenericWin32::resolveURI(const XMLCh * uri) {
-
- XSEC_USING_XERCES(BinInputStream);
- XSEC_USING_XERCES(XMLUri);
- XSEC_USING_XERCES(XMLUni);
- XSEC_USING_XERCES(Janitor);
- XSEC_USING_XERCES(BinFileInputStream);
-
- XMLUri * xmluri;
-
- if (uri == NULL) {
- throw XSECException(XSECException::ErrorOpeningURI,
- "XSECURIResolverGenericWin32 - anonymous references not supported in default URI Resolvers");
- }
-
- // Create the appropriate XMLUri objects
- if (mp_baseURI != NULL) {
- XMLUri* turi = new XMLUri(mp_baseURI);
- Janitor<XMLUri> j_turi(turi);
-
- xmluri = new XMLUri(turi, uri);
- }
- else {
- xmluri = new XMLUri(uri);
- }
-
- Janitor<XMLUri> j_xmluri(xmluri);
-
- // Determine what kind of URI this is and how to handle it.
-
- if (!XMLString::compareIString(xmluri->getScheme(), gFileScheme)) {
-
- // This is a file. We only really understand if this is localhost
-
- if (xmluri->getHost() == NULL || xmluri->getHost()[0] == chNull ||
- !XMLString::compareIString(xmluri->getHost(), XMLUni::fgLocalHostString) ||
- !XMLString::compareIString(xmluri->getHost(), XMLUni::fgEmptyString)) {
-
- // Clean hex escapes
- XMLCh * realPath = cleanURIEscapes(xmluri->getPath());
-
- // Localhost
-
- BinFileInputStream* retStrm = new BinFileInputStream(realPath);
- XSEC_RELEASE_XMLCH(realPath);
-
- if (!retStrm->getIsOpen())
- {
- delete retStrm;
- return 0;
- }
- return retStrm;
-
- }
-
- else {
-
- throw XSECException(XSECException::ErrorOpeningURI,
- "XSECURIResolverGenericWin32 - unable to open non-localhost file");
-
- }
-
- }
-
- // Is the scheme a HTTP?
- if (!XMLString::compareIString(xmluri->getScheme(), gHttpScheme)) {
-
- // Pass straight to our local XSECBinHTTPUriInputStream
- XSECBinHTTPURIInputStream *ret;
-
- ret = new XSECBinHTTPURIInputStream(*xmluri);
-
- return ret;
-
- }
-
- throw XSECException(XSECException::ErrorOpeningURI,
- "XSECURIResolverGenericWin32 - unknown URI scheme");
-
-}
-
-// -----------------------------------------------------------------------
-// Clone me
-// -----------------------------------------------------------------------
-
-
-XSECURIResolver * XSECURIResolverGenericWin32::clone(void) {
-
- XSECURIResolverGenericWin32 * ret;
-
- ret = new XSECURIResolverGenericWin32();
-
- if (this->mp_baseURI != NULL)
- ret->mp_baseURI = XMLString::replicate(this->mp_baseURI);
- else
- ret->mp_baseURI = NULL;
-
- return ret;
-
-}
-
-// -----------------------------------------------------------------------
-// Set a base URI to map any incoming files against
-// -----------------------------------------------------------------------
-
-void XSECURIResolverGenericWin32::setBaseURI(const XMLCh * uri) {
-
- if (mp_baseURI != NULL)
- XSEC_RELEASE_XMLCH(mp_baseURI);
-
- mp_baseURI = XMLString::replicate(uri);
-
-}
diff --git a/xsec/utils/winutils/XSECURIResolverGenericWin32.hpp b/xsec/utils/winutils/XSECURIResolverGenericWin32.hpp
deleted file mode 100644
index 25ecfcf..0000000
--- a/xsec/utils/winutils/XSECURIResolverGenericWin32.hpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.
- */
-
-/*
- * XSEC
- *
- * XSECURIResolverGenericWin32 := A URI Resolver that will work "out of
- * the box" with Windows. Re-implements
- * much Xerces code, but allows us to
- * handle HTTP redirects as is required by
- * the DSIG Standard
- *
- * $Id$
- *
- * $Log$
- * Revision 1.6 2005/02/03 13:56:22 milan
- * Apache licence fix.
- *
- * Revision 1.5 2004/02/08 10:25:40 blautenb
- * Convert to Apache 2.0 license
- *
- * Revision 1.4 2003/09/11 11:11:05 blautenb
- * Cleaned up usage of Xerces namespace - no longer inject into global namespace in headers
- *
- * Revision 1.3 2003/07/05 10:30:38 blautenb
- * Copyright update
- *
- * Revision 1.2 2003/02/13 10:19:43 blautenb
- * Updated Xerces exceptions to Xsec exception
- *
- * Revision 1.1 2003/02/12 09:45:29 blautenb
- * Win32 Re-implementation of Xerces URIResolver to support re-directs
- *
- *
- */
-
-#ifndef XSECURIRESOLVERGENERICWIN32_INCLUDE
-#define XSECURIRESOLVERGENERICWIN32_INCLUDE
-
-#include <xsec/framework/XSECDefs.hpp>
-#include <xsec/framework/XSECURIResolver.hpp>
-
-#include <xercesc/util/XMLString.hpp>
-
-#include <map>
-
-
-/**
- * @ingroup pubsig
- */
-/*\@{*/
-
-/**
- * @brief Generic Windows URI Resolver.
- *
- * The XML Digital Signature standard makes heavy use of URIs to
- * identify information to be referenced and signed.
- *
- * This class implements the XSECURIResolver for Windows32, re-using
- * much of the Xerces code.
- *
- * @todo Re-implement using the Windows Internet API
- */
-
-class XSEC_EXPORT XSECURIResolverGenericWin32 : public XSECURIResolver {
-
-public:
-
- /** @name Constructors and Destructors */
- //@{
-
- XSECURIResolverGenericWin32();
- virtual ~XSECURIResolverGenericWin32();
-
- //@}
-
- /** @name Interface Methods */
- //@{
-
- /**
- * \brief Create a BYTE_STREAM from a URI.
- *
- * The resolver is required to take the input URI and
- * dereference it to an actual stream of octets.
- *
- * The octets are provided back to the library using
- * the Xerces BinInputStream class.
- *
- * @note The returned stream is "owned" by the caller, which
- * will delete it when processing is complete.
- * @param uri The string containing the URI to be de-referenced.
- * @returns The octet stream corresponding to the URI.
- */
-
- virtual XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream * resolveURI(const XMLCh * uri);
-
- /**
- * \brief Clone the resolver to be installed in a new object.
- *
- * When URIResolvers are passed into signatures and other
- * objects, they are cloned and control of the original object
- * is left with the caller.
- *
- */
-
- virtual XSECURIResolver * clone(void);
-
- //@}
-
- /** @name Class specific functions */
- //@{
-
- /**
- * \brief Set the base URI for relative URIs.
- *
- */
-
- void setBaseURI(const XMLCh * uri);
-
- //@}
-
-private:
-
- XMLCh * mp_baseURI;
-
-
-};
-
-
-#endif /* XSECURIRESOLVERGENERICWIN32_INCLUDE */