| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // See "SSPI Sample Application" at | 5 // See "SSPI Sample Application" at |
| 6 // http://msdn.microsoft.com/en-us/library/aa918273.aspx | 6 // http://msdn.microsoft.com/en-us/library/aa918273.aspx |
| 7 | 7 |
| 8 #include "net/http/http_auth_sspi_win.h" | 8 #include "net/http/http_auth_sspi_win.h" |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/singleton.h" | |
| 13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 15 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 16 #include "net/http/http_auth.h" | 15 #include "net/http/http_auth.h" |
| 17 | 16 |
| 18 namespace net { | 17 namespace net { |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| 22 int MapAcquireCredentialsStatusToError(SECURITY_STATUS status, | 21 int MapAcquireCredentialsStatusToError(SECURITY_STATUS status, |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return rv; | 417 return rv; |
| 419 int token_length = pkg_info->cbMaxToken; | 418 int token_length = pkg_info->cbMaxToken; |
| 420 status = library->FreeContextBuffer(pkg_info); | 419 status = library->FreeContextBuffer(pkg_info); |
| 421 rv = MapFreeContextBufferStatusToError(status); | 420 rv = MapFreeContextBufferStatusToError(status); |
| 422 if (rv != OK) | 421 if (rv != OK) |
| 423 return rv; | 422 return rv; |
| 424 *max_token_length = token_length; | 423 *max_token_length = token_length; |
| 425 return OK; | 424 return OK; |
| 426 } | 425 } |
| 427 | 426 |
| 428 class SSPILibraryDefault : public SSPILibrary { | |
| 429 public: | |
| 430 SSPILibraryDefault() {} | |
| 431 virtual ~SSPILibraryDefault() {} | |
| 432 | |
| 433 virtual SECURITY_STATUS AcquireCredentialsHandle(LPWSTR pszPrincipal, | |
| 434 LPWSTR pszPackage, | |
| 435 unsigned long fCredentialUse, | |
| 436 void* pvLogonId, | |
| 437 void* pvAuthData, | |
| 438 SEC_GET_KEY_FN pGetKeyFn, | |
| 439 void* pvGetKeyArgument, | |
| 440 PCredHandle phCredential, | |
| 441 PTimeStamp ptsExpiry) { | |
| 442 return ::AcquireCredentialsHandle(pszPrincipal, pszPackage, fCredentialUse, | |
| 443 pvLogonId, pvAuthData, pGetKeyFn, | |
| 444 pvGetKeyArgument, phCredential, | |
| 445 ptsExpiry); | |
| 446 } | |
| 447 | |
| 448 virtual SECURITY_STATUS InitializeSecurityContext(PCredHandle phCredential, | |
| 449 PCtxtHandle phContext, | |
| 450 SEC_WCHAR* pszTargetName, | |
| 451 unsigned long fContextReq, | |
| 452 unsigned long Reserved1, | |
| 453 unsigned long TargetDataRep, | |
| 454 PSecBufferDesc pInput, | |
| 455 unsigned long Reserved2, | |
| 456 PCtxtHandle phNewContext, | |
| 457 PSecBufferDesc pOutput, | |
| 458 unsigned long* contextAttr, | |
| 459 PTimeStamp ptsExpiry) { | |
| 460 return ::InitializeSecurityContext(phCredential, phContext, pszTargetName, | |
| 461 fContextReq, Reserved1, TargetDataRep, | |
| 462 pInput, Reserved2, phNewContext, pOutput, | |
| 463 contextAttr, ptsExpiry); | |
| 464 } | |
| 465 | |
| 466 virtual SECURITY_STATUS QuerySecurityPackageInfo(LPWSTR pszPackageName, | |
| 467 PSecPkgInfoW *pkgInfo) { | |
| 468 return ::QuerySecurityPackageInfo(pszPackageName, pkgInfo); | |
| 469 } | |
| 470 | |
| 471 virtual SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential) { | |
| 472 return ::FreeCredentialsHandle(phCredential); | |
| 473 } | |
| 474 | |
| 475 virtual SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext) { | |
| 476 return ::DeleteSecurityContext(phContext); | |
| 477 } | |
| 478 | |
| 479 virtual SECURITY_STATUS FreeContextBuffer(PVOID pvContextBuffer) { | |
| 480 return ::FreeContextBuffer(pvContextBuffer); | |
| 481 } | |
| 482 | |
| 483 private: | |
| 484 friend struct DefaultSingletonTraits<SSPILibraryDefault>; | |
| 485 }; | |
| 486 | |
| 487 // static | |
| 488 SSPILibrary* SSPILibrary::GetDefault() { | |
| 489 return Singleton<SSPILibraryDefault>::get(); | |
| 490 } | |
| 491 | |
| 492 } // namespace net | 427 } // namespace net |
| OLD | NEW |