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 #include "net/http/http_auth_gssapi_posix.h" | 5 #include "net/http/http_auth_gssapi_posix.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 DescribeOid(gssapi_lib, | 378 DescribeOid(gssapi_lib, |
379 mech_type).c_str(), | 379 mech_type).c_str(), |
380 ctx_flags, | 380 ctx_flags, |
381 locally_initiated, | 381 locally_initiated, |
382 open); | 382 open); |
383 return description; | 383 return description; |
384 } | 384 } |
385 | 385 |
386 } // namespace | 386 } // namespace |
387 | 387 |
388 GSSAPISharedLibrary::GSSAPISharedLibrary() | 388 GSSAPISharedLibrary::GSSAPISharedLibrary(const std::string& gssapi_library_name) |
389 : initialized_(false), | 389 : initialized_(false), |
390 gssapi_library_name_(gssapi_library_name), | |
390 gssapi_library_(NULL), | 391 gssapi_library_(NULL), |
391 import_name_(NULL), | 392 import_name_(NULL), |
392 release_name_(NULL), | 393 release_name_(NULL), |
393 release_buffer_(NULL), | 394 release_buffer_(NULL), |
394 display_name_(NULL), | 395 display_name_(NULL), |
395 display_status_(NULL), | 396 display_status_(NULL), |
396 init_sec_context_(NULL), | 397 init_sec_context_(NULL), |
397 wrap_size_limit_(NULL), | 398 wrap_size_limit_(NULL), |
398 delete_sec_context_(NULL), | 399 delete_sec_context_(NULL), |
399 inquire_context_(NULL) { | 400 inquire_context_(NULL) { |
(...skipping 15 matching lines...) Expand all Loading... | |
415 bool GSSAPISharedLibrary::InitImpl() { | 416 bool GSSAPISharedLibrary::InitImpl() { |
416 DCHECK(!initialized_); | 417 DCHECK(!initialized_); |
417 gssapi_library_ = LoadSharedLibrary(); | 418 gssapi_library_ = LoadSharedLibrary(); |
418 if (gssapi_library_ == NULL) | 419 if (gssapi_library_ == NULL) |
419 return false; | 420 return false; |
420 initialized_ = true; | 421 initialized_ = true; |
421 return true; | 422 return true; |
422 } | 423 } |
423 | 424 |
424 base::NativeLibrary GSSAPISharedLibrary::LoadSharedLibrary() { | 425 base::NativeLibrary GSSAPISharedLibrary::LoadSharedLibrary() { |
425 static const char* kLibraryNames[] = { | 426 const char** kLibraryNames; |
cbentzel
2010/11/11 03:37:51
Nit: this should be library_names now [it's no lon
Jakob Kummerow (corp)
2010/11/11 11:10:53
Done.
| |
427 size_t num_lib_names; | |
428 const char* kTempLibraryName[1]; | |
cbentzel
2010/11/11 03:37:51
Nit: name this something like const char* user_spe
Jakob Kummerow (corp)
2010/11/11 11:10:53
Done.
| |
429 if (!gssapi_library_name_.empty()) { | |
430 // We have a user-specified library name, so we ignore hard-coded values. | |
danno
2010/11/10 16:52:01
Try to avoid using "we" or ""I" in the code and in
Jakob Kummerow (corp)
2010/11/10 17:48:39
Done.
| |
431 kTempLibraryName[0] = gssapi_library_name_.c_str(); | |
432 kLibraryNames = kTempLibraryName; | |
433 num_lib_names = 1; | |
434 } else { | |
435 static const char* kTempLibraryNames[] = { | |
cbentzel
2010/11/11 03:37:51
Nit: name kDefaultLibraryNames (there's nothing "T
Jakob Kummerow (corp)
2010/11/11 11:10:53
Done.
| |
426 #if defined(OS_MACOSX) | 436 #if defined(OS_MACOSX) |
427 "libgssapi_krb5.dylib" // MIT Kerberos | 437 "libgssapi_krb5.dylib" // MIT Kerberos |
428 #else | 438 #else |
429 "libgssapi_krb5.so.2", // MIT Kerberos - FC, Suse10, Debian | 439 "libgssapi_krb5.so.2", // MIT Kerberos - FC, Suse10, Debian |
430 "libgssapi.so.4", // Heimdal - Suse10, MDK | 440 "libgssapi.so.4", // Heimdal - Suse10, MDK |
431 "libgssapi.so.1" // Heimdal - Suse9, CITI - FC, MDK, Suse10 | 441 "libgssapi.so.1" // Heimdal - Suse9, CITI - FC, MDK, Suse10 |
432 #endif | 442 #endif |
433 }; | 443 }; |
434 static size_t num_lib_names = arraysize(kLibraryNames); | 444 kLibraryNames = kTempLibraryNames; |
445 num_lib_names = arraysize(kTempLibraryNames); | |
446 } | |
435 | 447 |
436 for (size_t i = 0; i < num_lib_names; ++i) { | 448 for (size_t i = 0; i < num_lib_names; ++i) { |
437 const char* library_name = kLibraryNames[i]; | 449 const char* library_name = kLibraryNames[i]; |
438 FilePath file_path(library_name); | 450 FilePath file_path(library_name); |
439 base::NativeLibrary lib = base::LoadNativeLibrary(file_path); | 451 base::NativeLibrary lib = base::LoadNativeLibrary(file_path); |
440 if (lib) { | 452 if (lib) { |
441 // Only return this library if we can bind the functions we need. | 453 // Only return this library if we can bind the functions we need. |
442 if (BindMethods(lib)) | 454 if (BindMethods(lib)) |
443 return lib; | 455 return lib; |
444 base::UnloadNativeLibrary(lib); | 456 base::UnloadNativeLibrary(lib); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 return inquire_context_(minor_status, | 618 return inquire_context_(minor_status, |
607 context_handle, | 619 context_handle, |
608 src_name, | 620 src_name, |
609 targ_name, | 621 targ_name, |
610 lifetime_rec, | 622 lifetime_rec, |
611 mech_type, | 623 mech_type, |
612 ctx_flags, | 624 ctx_flags, |
613 locally_initiated, | 625 locally_initiated, |
614 open); | 626 open); |
615 } | 627 } |
616 GSSAPILibrary* GSSAPILibrary::GetDefault() { | |
617 return Singleton<GSSAPISharedLibrary>::get(); | |
618 } | |
619 | 628 |
620 ScopedSecurityContext::ScopedSecurityContext(GSSAPILibrary* gssapi_lib) | 629 ScopedSecurityContext::ScopedSecurityContext(GSSAPILibrary* gssapi_lib) |
621 : security_context_(GSS_C_NO_CONTEXT), | 630 : security_context_(GSS_C_NO_CONTEXT), |
622 gssapi_lib_(gssapi_lib) { | 631 gssapi_lib_(gssapi_lib) { |
623 DCHECK(gssapi_lib_); | 632 DCHECK(gssapi_lib_); |
624 } | 633 } |
625 | 634 |
626 ScopedSecurityContext::~ScopedSecurityContext() { | 635 ScopedSecurityContext::~ScopedSecurityContext() { |
627 if (security_context_ != GSS_C_NO_CONTEXT) { | 636 if (security_context_ != GSS_C_NO_CONTEXT) { |
628 gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; | 637 gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
868 if (rv != OK) { | 877 if (rv != OK) { |
869 LOG(ERROR) << "Problem initializing context. \n" | 878 LOG(ERROR) << "Problem initializing context. \n" |
870 << DisplayExtendedStatus(library_, major_status, minor_status) | 879 << DisplayExtendedStatus(library_, major_status, minor_status) |
871 << '\n' | 880 << '\n' |
872 << DescribeContext(library_, scoped_sec_context_.get()); | 881 << DescribeContext(library_, scoped_sec_context_.get()); |
873 } | 882 } |
874 return rv; | 883 return rv; |
875 } | 884 } |
876 | 885 |
877 } // namespace net | 886 } // namespace net |
OLD | NEW |