Details
Description
Below is a patch to util/NetAccessors/Socket/UnixHTTPURLInputStream.cpp that sends a basic authentication header if the XMLURL has the username and password defined.
--diff below--
-
-
- util/NetAccessors/Socket/UnixHTTPURLInputStream.cpp 2004-09-08 06:56:35.000000000 -0700
- /home/xdb/UnixHTTPURLInputStream.cpp 2005-08-05 14:21:01.000000000 -0700
***************
- 127,132 ****
- 127,133 ----
#include <xercesc/util/TransService.hpp>
#include <xercesc/util/TranscodingException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
+ #include <xercesc/util/Base64.hpp>
-
XERCES_CPP_NAMESPACE_BEGIN
***************
-
-
- 211,216 ****
- 212,219 ----
const XMLCh* path = urlSource.getPath();
const XMLCh* fragment = urlSource.getFragment();
const XMLCh* query = urlSource.getQuery(); + const XMLCh* username = urlSource.getUser();
+ const XMLCh* password = urlSource.getPassword();
-
//
// Convert the hostName to the platform's code page for gethostbyname and
***************
-
-
- 371,376 ****
- 374,399 ----
}
strcat(fBuffer, CRLF);
-
+ if (username && password)
+ {
+ unsigned int len = XMLString::stringLen(username) + XMLString::stringLen(password) + 1;
+ char* userPass = (char *)fMemoryManager->allocate((len + 1) * sizeof(*userPass));
+ char* encodedData;
+
+ userPass[0] = '\0';
+ strcat(userPass, XMLString::transcode(username, fMemoryManager));
+ strcat(userPass, ":");
+ strcat(userPass, XMLString::transcode(password, fMemoryManager));
+ encodedData = (char *)Base64::encode((XMLByte *)userPass, strlen(userPass), &len, fMemoryManager);
+
+ if (encodedData)
+
+ }
+
if(httpInfo!=0 && httpInfo->fHeaders!=0)
strncat(fBuffer,httpInfo->fHeaders,httpInfo->fHeadersLen);