[cpp-sp] branch main updated: Remove unused cocde in HTTP interface.
Scott Cantor
cantor.2 at osu.edu
Mon Dec 2 20:20:57 UTC 2024
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:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=c14de588f4b0b746a5b5ad2da93cedea0a56eea9
The following commit(s) were added to refs/heads/main by this push:
new c14de588 Remove unused cocde in HTTP interface.
c14de588 is described below
commit c14de588f4b0b746a5b5ad2da93cedea0a56eea9
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Dec 2 15:20:53 2024 -0500
Remove unused cocde in HTTP interface.
---
shibsp/handler/impl/StatusHandler.cpp | 12 +--
shibsp/impl/XMLServiceProvider.cpp | 5 --
shibsp/io/GenericRequest.h | 62 +---------------
shibsp/io/HTTPRequest.h | 3 +-
shibsp/io/impl/HTTPRequest.cpp | 135 +---------------------------------
5 files changed, 7 insertions(+), 210 deletions(-)
diff --git a/shibsp/handler/impl/StatusHandler.cpp b/shibsp/handler/impl/StatusHandler.cpp
index 284b395a..8662973f 100644
--- a/shibsp/handler/impl/StatusHandler.cpp
+++ b/shibsp/handler/impl/StatusHandler.cpp
@@ -183,6 +183,9 @@ namespace shibsp {
string getContentType() const {
return "";
}
+ string getAuthType() const {
+ return "";
+ }
long getContentLength() const {
return 0;
}
@@ -221,15 +224,6 @@ namespace shibsp {
string getHeader(const char* name) const {
return "";
}
- virtual const
-#ifndef XMLTOOLING_NO_XMLSEC
- std::vector<XSECCryptoX509*>&
-#else
- std::vector<std::string>&
-#endif
- getClientCertificates() const {
- return g_NoCerts;
- }
private:
mutable scoped_ptr<CGIParser> m_parser;
diff --git a/shibsp/impl/XMLServiceProvider.cpp b/shibsp/impl/XMLServiceProvider.cpp
index fc535fb2..7c25e23f 100644
--- a/shibsp/impl/XMLServiceProvider.cpp
+++ b/shibsp/impl/XMLServiceProvider.cpp
@@ -273,11 +273,6 @@ XMLConfigImpl::XMLConfigImpl(const DOMElement* e, bool first, XMLConfig* outer,
split(HTTPResponse::getAllowedSchemes(), schemes, is_space(), algorithm::token_compress_on);
}
- // Default language handling.
- pair<bool,bool> langFromClient = getBool("langFromClient");
- pair<bool,const char*> langPriority = getString("langPriority");
- GenericRequest::setLangDefaults(!langFromClient.first || langFromClient.second, nullptr);
-
// Extensions
doExtensions(e, "global", log);
if (conf.isEnabled(SPConfig::OutOfProcess))
diff --git a/shibsp/io/GenericRequest.h b/shibsp/io/GenericRequest.h
index a51e8581..4261daa9 100644
--- a/shibsp/io/GenericRequest.h
+++ b/shibsp/io/GenericRequest.h
@@ -23,7 +23,6 @@
#include <xmltooling/unicode.h>
-#include <map>
#include <string>
#include <vector>
@@ -136,9 +135,7 @@ namespace shibsp {
*
* @return the authentication type or nullptr
*/
- virtual std::string getAuthType() const {
- return "";
- }
+ virtual std::string getAuthType() const=0;
/**
* Returns the IP address of the client.
@@ -153,63 +150,6 @@ namespace shibsp {
* @param url input URL to convert, will be modified in place
*/
virtual void absolutize(std::string& url) const;
-
- /**
- * Returns a language range to use in selecting language-specific
- * content for this request.
- * <p>The syntax is that of the HTTP 1.1 Accept-Language header, even
- * if the underlying request is not HTTP.
- *
- * @return an HTTP 1.1 syntax language range specifier
- */
- virtual std::string getLanguageRange() const {
- return "";
- }
-
- /**
- * Initializes the language matching process; call this method to begin the
- * matching process by calling the matchLang method.
- * <p>The language matching process is not thread-safe and must be externally
- * syncronized.
- *
- * @return true iff language matching is possible
- */
- bool startLangMatching() const;
-
- /**
- * Continues the language matching process; additional calls to matchLang can
- * be done as long as this method returns true.
- * <p>The language matching process is not thread-safe and must be externally
- * syncronized.
- *
- * @return true iff more ranges are available to match against
- */
- bool continueLangMatching() const;
-
- /**
- * Matches a language tag against the currently active range.
- * <p>The language matching process is not thread-safe and must be externally
- * syncronized.
- *
- * @param tag a language tag (e.g., an xml:lang value)
- * @return true iff the tag matches the active range
- */
- bool matchLang(const XMLCh* tag) const;
-
- /**
- * Establish default handling of language ranges.
- *
- * @param langFromClient honor client's language preferences if any
- * @param defaultRange priority list of space-delimited language tags to use by default
- */
- static void setLangDefaults(bool langFromClient, const XMLCh* defaultRange);
-
- private:
- typedef std::multimap< float,std::vector<xmltooling::xstring> > langrange_t;
- mutable langrange_t m_langRange;
- mutable langrange_t::const_reverse_iterator m_langRangeIter;
- static langrange_t m_defaultRange;
- static bool m_langFromClient;
};
#if defined (_MSC_VER)
diff --git a/shibsp/io/HTTPRequest.h b/shibsp/io/HTTPRequest.h
index a37e44ba..9d74a159 100644
--- a/shibsp/io/HTTPRequest.h
+++ b/shibsp/io/HTTPRequest.h
@@ -23,6 +23,8 @@
#include <shibsp/io/GenericRequest.h>
+#include <map>
+
namespace shibsp {
#if defined (_MSC_VER)
@@ -47,7 +49,6 @@ namespace shibsp {
bool isSecure() const;
bool isDefaultPort() const;
- std::string getLanguageRange() const;
/**
* Returns the HTTP method of the request (GET, POST, etc.)
diff --git a/shibsp/io/impl/HTTPRequest.cpp b/shibsp/io/impl/HTTPRequest.cpp
index 1f147750..aa41315e 100644
--- a/shibsp/io/impl/HTTPRequest.cpp
+++ b/shibsp/io/impl/HTTPRequest.cpp
@@ -28,20 +28,12 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
-#include <xercesc/util/XMLStringTokenizer.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xmltooling/util/Threads.h>
using namespace shibsp;
-using namespace xmltooling;
-using namespace xercesc;
using namespace boost;
using namespace std;
-bool GenericRequest::m_langFromClient = true;
-GenericRequest::langrange_t GenericRequest::m_defaultRange;
-
-GenericRequest::GenericRequest() : m_langRangeIter(m_langRange.rend())
+GenericRequest::GenericRequest()
{
}
@@ -68,126 +60,6 @@ void GenericRequest::absolutize(string& url) const
}
}
-void GenericRequest::setLangDefaults(bool langFromClient, const XMLCh* defaultRange)
-{
- m_langFromClient = langFromClient;
- m_defaultRange.clear();
- if (!defaultRange)
- return;
- float q = 0.0f;
- XMLStringTokenizer tokens(defaultRange);
- while (tokens.hasMoreTokens()) {
- const XMLCh* t = tokens.nextToken();
- if (t && *t) {
- vector<xstring> tagArray;
- static const XMLCh delims[] = {chDash, chNull};
- XMLStringTokenizer tags(t, delims);
- while (tags.hasMoreTokens())
- tagArray.push_back(tags.nextToken());
- m_defaultRange.insert(langrange_t::value_type(q, tagArray));
- q -= 0.0001f;
- }
- }
-}
-
-bool GenericRequest::startLangMatching() const
-{
- // This is a no-op except on the first call, to populate the
- // range information to use in matching.
- if (m_langRange.empty()) {
- if (m_langFromClient) {
- string hdr(getLanguageRange());
- char_separator<char> sep1(", "); // tags are split by commas or spaces
- char_separator<char> sep2("; "); // quality is separated by semicolon
- tokenizer< char_separator<char> > tokens(hdr, sep1);
- for (tokenizer< char_separator<char> >::iterator t = tokens.begin(); t != tokens.end(); ++t) {
- string tag = trim_copy(*t); // handle any surrounding ws
- tokenizer< char_separator<char> > subtokens(tag, sep2);
- tokenizer< char_separator<char> >::iterator s = subtokens.begin();
- if (s != subtokens.end() && *s != "*") {
- float q = 1.0f;
- auto_ptr_XMLCh lang((s++)->c_str());
-
- // Check for quality tag
- if (s != subtokens.end() && starts_with(*s, "q=")) {
- try {
- q = lexical_cast<float,string>(s->c_str() + 2);
- }
- catch (bad_lexical_cast&) {
- q = 0.0f;
- }
- }
-
- // Split range into tokens.
- vector<xstring> tagArray;
- static const XMLCh delims[] = {chDash, chNull};
- XMLStringTokenizer tags(lang.get(), delims);
- const XMLCh* tag;
- while (tags.hasMoreTokens()) {
- tag = tags.nextToken();
- if (*tag != chAsterisk)
- tagArray.push_back(tag);
- }
-
- if (tagArray.empty())
- continue;
-
- // Adjust q using the server priority list. As long as the supplied q deltas are larger than
- // factors like .0001, the client settings will always trump ours.
- if (!m_defaultRange.empty()) {
- float adj = (m_defaultRange.size() + 1) * 0.0001f;
- for (langrange_t::const_iterator prio = m_defaultRange.begin(); prio != m_defaultRange.end(); ++prio) {
- if (prio->second == tagArray) {
- adj = prio->first;
- break;
- }
- }
- q -= adj;
- }
- m_langRange.insert(langrange_t::value_type(q, tagArray));
- }
- }
- }
- else {
- m_langRange = m_defaultRange;
- }
- }
-
- m_langRangeIter = m_langRange.rbegin();
- return (m_langRangeIter != const_cast<const langrange_t&>(m_langRange).rend());
-}
-
-bool GenericRequest::continueLangMatching() const
-{
- return (++m_langRangeIter != const_cast<const langrange_t&>(m_langRange).rend());
-}
-
-bool GenericRequest::matchLang(const XMLCh* tag) const
-{
- if (m_langRangeIter == const_cast<const langrange_t&>(m_langRange).rend())
- return false;
-
- // To match against a given range, the range has to be built up and then
- // truncated segment by segment to look for a match against the tag.
- // That allows more specific ranges like en-US to match the tag en.
- // The "end" fence tells us how much of the original range to recompose
- // into a hyphenated string, and we stop on a match, or when the fence
- // moves back to the beginning of the array.
- bool match = false;
- vector<xstring>::size_type end = m_langRangeIter->second.size();
- do {
- // Skip single-character private extension separators.
- while (end > 1 && m_langRangeIter->second[end-1].length() <= 1)
- --end;
- // Build a range from 0 to end - 1 of segments.
- xstring compareTo(m_langRangeIter->second[0]);
- for (vector<xstring>::size_type ix = 1; ix <= end - 1; ++ix)
- compareTo = compareTo + chDash + m_langRangeIter->second[ix];
- match = (compareTo.length() > 1 && XMLString::compareIStringASCII(compareTo.c_str(), tag) == 0);
- } while (!match && --end > 0);
- return match;
-}
-
HTTPRequest::HTTPRequest()
{
}
@@ -209,11 +81,6 @@ bool HTTPRequest::isDefaultPort() const
return getPort() == 80;
}
-string HTTPRequest::getLanguageRange() const
-{
- return getHeader("Accept-Language");
-}
-
namespace {
void handle_cookie_fn(map<string,string>& cookieMap, vector<string>& nvpair, const string& s) {
nvpair.clear();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list