1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/http/http_auth_handler_negotiate.h" 6 7 #include "net/base/net_errors.h" 8 9 namespace net { 10 11 HttpAuthHandlerNegotiate::HttpAuthHandlerNegotiate() : 12 auth_sspi_("Negotiate", NEGOSSP_NAME) { 13 } 14 15 HttpAuthHandlerNegotiate::~HttpAuthHandlerNegotiate() { 16 } 17 18 std::string HttpAuthHandlerNegotiate::GenerateCredentials( 19 const std::wstring& username, 20 const std::wstring& password, 21 const HttpRequestInfo* request, 22 const ProxyInfo* proxy) { 23 std::string auth_credentials; 24 25 int rv = auth_sspi_.GenerateCredentials( 26 username, 27 password, 28 origin_, 29 request, 30 proxy, 31 &auth_credentials); 32 if (rv == OK) 33 return auth_credentials; 34 return std::string(); 35 } 36 37 // The Negotiate challenge header looks like: 38 // WWW-Authenticate: NEGOTIATE auth-data 39 bool HttpAuthHandlerNegotiate::Init( 40 std::string::const_iterator challenge_begin, 41 std::string::const_iterator challenge_end) { 42 scheme_ = "negotiate"; 43 score_ = 4; 44 properties_ = ENCRYPTS_IDENTITY | IS_CONNECTION_BASED; 45 return auth_sspi_.ParseChallenge(challenge_begin, challenge_end); 46 } 47 48 // Require identity on first pass instead of second. 49 bool HttpAuthHandlerNegotiate::NeedsIdentity() { 50 return auth_sspi_.NeedsIdentity(); 51 } 52 53 bool HttpAuthHandlerNegotiate::IsFinalRound() { 54 return auth_sspi_.IsFinalRound(); 55 } 56 57 } // namespace net 58