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 // This file contains common routines used by NTLM and Negotiate authentication | 5 // This file contains common routines used by NTLM and Negotiate authentication |
6 // using the SSPI API on Windows. | 6 // using the SSPI API on Windows. |
7 | 7 |
8 #ifndef NET_HTTP_HTTP_AUTH_SSPI_WIN_H_ | 8 #ifndef NET_HTTP_HTTP_AUTH_SSPI_WIN_H_ |
9 #define NET_HTTP_HTTP_AUTH_SSPI_WIN_H_ | 9 #define NET_HTTP_HTTP_AUTH_SSPI_WIN_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 PTimeStamp ptsExpiry) = 0; | 56 PTimeStamp ptsExpiry) = 0; |
57 | 57 |
58 virtual SECURITY_STATUS QuerySecurityPackageInfo(LPWSTR pszPackageName, | 58 virtual SECURITY_STATUS QuerySecurityPackageInfo(LPWSTR pszPackageName, |
59 PSecPkgInfoW *pkgInfo) = 0; | 59 PSecPkgInfoW *pkgInfo) = 0; |
60 | 60 |
61 virtual SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential) = 0; | 61 virtual SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential) = 0; |
62 | 62 |
63 virtual SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext) = 0; | 63 virtual SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext) = 0; |
64 | 64 |
65 virtual SECURITY_STATUS FreeContextBuffer(PVOID pvContextBuffer) = 0; | 65 virtual SECURITY_STATUS FreeContextBuffer(PVOID pvContextBuffer) = 0; |
| 66 }; |
66 | 67 |
67 // Get the default SSPILibrary instance, which simply acts as a passthrough | 68 class SSPILibraryDefault : public SSPILibrary { |
68 // to the Windows SSPI implementation. The object returned is a singleton | 69 public: |
69 // instance, and the caller should not delete it. | 70 SSPILibraryDefault() {} |
70 static SSPILibrary* GetDefault(); | 71 virtual ~SSPILibraryDefault() {} |
| 72 |
| 73 virtual SECURITY_STATUS AcquireCredentialsHandle(LPWSTR pszPrincipal, |
| 74 LPWSTR pszPackage, |
| 75 unsigned long fCredentialUse, |
| 76 void* pvLogonId, |
| 77 void* pvAuthData, |
| 78 SEC_GET_KEY_FN pGetKeyFn, |
| 79 void* pvGetKeyArgument, |
| 80 PCredHandle phCredential, |
| 81 PTimeStamp ptsExpiry) { |
| 82 return ::AcquireCredentialsHandle(pszPrincipal, pszPackage, fCredentialUse, |
| 83 pvLogonId, pvAuthData, pGetKeyFn, |
| 84 pvGetKeyArgument, phCredential, |
| 85 ptsExpiry); |
| 86 } |
| 87 |
| 88 virtual SECURITY_STATUS InitializeSecurityContext(PCredHandle phCredential, |
| 89 PCtxtHandle phContext, |
| 90 SEC_WCHAR* pszTargetName, |
| 91 unsigned long fContextReq, |
| 92 unsigned long Reserved1, |
| 93 unsigned long TargetDataRep, |
| 94 PSecBufferDesc pInput, |
| 95 unsigned long Reserved2, |
| 96 PCtxtHandle phNewContext, |
| 97 PSecBufferDesc pOutput, |
| 98 unsigned long* contextAttr, |
| 99 PTimeStamp ptsExpiry) { |
| 100 return ::InitializeSecurityContext(phCredential, phContext, pszTargetName, |
| 101 fContextReq, Reserved1, TargetDataRep, |
| 102 pInput, Reserved2, phNewContext, pOutput, |
| 103 contextAttr, ptsExpiry); |
| 104 } |
| 105 |
| 106 virtual SECURITY_STATUS QuerySecurityPackageInfo(LPWSTR pszPackageName, |
| 107 PSecPkgInfoW *pkgInfo) { |
| 108 return ::QuerySecurityPackageInfo(pszPackageName, pkgInfo); |
| 109 } |
| 110 |
| 111 virtual SECURITY_STATUS FreeCredentialsHandle(PCredHandle phCredential) { |
| 112 return ::FreeCredentialsHandle(phCredential); |
| 113 } |
| 114 |
| 115 virtual SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext) { |
| 116 return ::DeleteSecurityContext(phContext); |
| 117 } |
| 118 |
| 119 virtual SECURITY_STATUS FreeContextBuffer(PVOID pvContextBuffer) { |
| 120 return ::FreeContextBuffer(pvContextBuffer); |
| 121 } |
71 }; | 122 }; |
72 | 123 |
73 class HttpAuthSSPI { | 124 class HttpAuthSSPI { |
74 public: | 125 public: |
75 HttpAuthSSPI(SSPILibrary* sspi_library, | 126 HttpAuthSSPI(SSPILibrary* sspi_library, |
76 const std::string& scheme, | 127 const std::string& scheme, |
77 SEC_WCHAR* security_package, | 128 SEC_WCHAR* security_package, |
78 ULONG max_token_length); | 129 ULONG max_token_length); |
79 ~HttpAuthSSPI(); | 130 ~HttpAuthSSPI(); |
80 | 131 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // If the return value is ERR_UNEXPECTED, there was an unanticipated problem | 198 // If the return value is ERR_UNEXPECTED, there was an unanticipated problem |
148 // in the underlying SSPI call. The details are logged, and |*max_token_length| | 199 // in the underlying SSPI call. The details are logged, and |*max_token_length| |
149 // is not changed. | 200 // is not changed. |
150 int DetermineMaxTokenLength(SSPILibrary* library, | 201 int DetermineMaxTokenLength(SSPILibrary* library, |
151 const std::wstring& package, | 202 const std::wstring& package, |
152 ULONG* max_token_length); | 203 ULONG* max_token_length); |
153 | 204 |
154 } // namespace net | 205 } // namespace net |
155 | 206 |
156 #endif // NET_HTTP_HTTP_AUTH_SSPI_WIN_H_ | 207 #endif // NET_HTTP_HTTP_AUTH_SSPI_WIN_H_ |
OLD | NEW |