summaryrefslogtreecommitdiffstats
path: root/net/http/http_auth.h
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-15 14:25:50 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-15 14:25:50 +0000
commitfa55e1931013409ddbce59ed39f8b12a351fd0c4 (patch)
tree1ff77c48d22f36173c1fa63ae8acb1faf896aa0d /net/http/http_auth.h
parente8da0a0066695284dbf698c9900617b3b159f33b (diff)
downloadchromium_src-fa55e1931013409ddbce59ed39f8b12a351fd0c4.zip
chromium_src-fa55e1931013409ddbce59ed39f8b12a351fd0c4.tar.gz
chromium_src-fa55e1931013409ddbce59ed39f8b12a351fd0c4.tar.bz2
Added factories for HttpAuthHandler.
The driving rationale for this change was to prevent choosing an AuthHandler when it is not supported on the system due to a missing runtime component (such as not being able to locate a gssapi shared library when seeing a Negotiate scheme). It also has the advantage (currently unused) of determining some per-auth-scheme properties only the first time that a challenge for that scheme is seen (such as maximum token length for the SSPI implementation of NTLM). Finally, it may make unit tests easier to generate since the factory can be easily mocked. BUG=34795 TEST=New unit test for HttpAuthHandlerDispatchFactory. Review URL: http://codereview.chromium.org/582007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth.h')
-rw-r--r--net/http/http_auth.h35
1 files changed, 21 insertions, 14 deletions
diff --git a/net/http/http_auth.h b/net/http/http_auth.h
index 38c9918..76deca8 100644
--- a/net/http/http_auth.h
+++ b/net/http/http_auth.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,6 +12,7 @@ template <class T> class scoped_refptr;
namespace net {
class HttpAuthHandler;
+class HttpAuthHandlerFactory;
class HttpResponseHeaders;
// Utility class for http authentication.
@@ -70,14 +71,6 @@ class HttpAuth {
// (either Authorization or Proxy-Authorization).
static std::string GetAuthorizationHeaderName(Target target);
- // Create a handler to generate credentials for the challenge, and pass
- // it back in |*handler|. If the challenge is unsupported or invalid
- // |*handler| is set to NULL.
- static void CreateAuthHandler(const std::string& challenge,
- Target target,
- const GURL& origin,
- scoped_refptr<HttpAuthHandler>* handler);
-
// Iterate through the challenge headers, and pick the best one that
// we support. Obtains the implementation class for handling the challenge,
// and passes it back in |*handler|. If the existing handler in |*handler|
@@ -91,10 +84,12 @@ class HttpAuth {
// TODO(wtc): Continuing to use the existing handler in |*handler| (for
// NTLM) is new behavior. Rename ChooseBestChallenge to fully encompass
// what it does now.
- static void ChooseBestChallenge(const HttpResponseHeaders* headers,
- Target target,
- const GURL& origin,
- scoped_refptr<HttpAuthHandler>* handler);
+ static void ChooseBestChallenge(
+ HttpAuthHandlerFactory* http_auth_handler_factory,
+ const HttpResponseHeaders* headers,
+ Target target,
+ const GURL& origin,
+ scoped_refptr<HttpAuthHandler>* handler);
// ChallengeTokenizer breaks up a challenge string into the the auth scheme
// and parameter list, according to RFC 2617 Sec 1.2:
@@ -107,7 +102,7 @@ class HttpAuth {
public:
ChallengeTokenizer(std::string::const_iterator begin,
std::string::const_iterator end)
- : props_(begin, end, ','), valid_(true) {
+ : props_(begin, end, ','), valid_(true), expect_base64_token_(false) {
Init(begin, end);
}
@@ -127,6 +122,17 @@ class HttpAuth {
// Returns true if there is none to consume.
bool GetNext();
+ // Inform the tokenizer whether the next token should be treated as a base64
+ // encoded value. If |expect_base64_token| is true, |GetNext| will treat the
+ // next token as a base64 encoded value, and will include the trailing '='
+ // padding rather than attempt to split the token into a name/value pair.
+ // In this case, |name| will be empty, and |value| will contain the token.
+ // Subsequent calls to |GetNext()| will not treat the token like a base64
+ // encoded token unless the caller again calls |set_expect_base64_token|.
+ void set_expect_base64_token(bool expect_base64_token) {
+ expect_base64_token_ = expect_base64_token;
+ }
+
// The name of the current name-value pair.
std::string::const_iterator name_begin() const { return name_begin_; }
std::string::const_iterator name_end() const { return name_end_; }
@@ -164,6 +170,7 @@ class HttpAuth {
std::string::const_iterator value_end_;
bool value_is_quoted_;
+ bool expect_base64_token_;
};
};