| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 output += AppendIfPredefinedValue(oid, | 292 output += AppendIfPredefinedValue(oid, |
| 293 GSS_C_NT_ANONYMOUS, | 293 GSS_C_NT_ANONYMOUS, |
| 294 "GSS_C_NT_ANONYMOUS"); | 294 "GSS_C_NT_ANONYMOUS"); |
| 295 output += AppendIfPredefinedValue(oid, | 295 output += AppendIfPredefinedValue(oid, |
| 296 GSS_C_NT_EXPORT_NAME, | 296 GSS_C_NT_EXPORT_NAME, |
| 297 "GSS_C_NT_EXPORT_NAME"); | 297 "GSS_C_NT_EXPORT_NAME"); |
| 298 | 298 |
| 299 return output; | 299 return output; |
| 300 } | 300 } |
| 301 | 301 |
| 302 std::string DescribeBuffer(const gss_buffer_t buffer) { | |
| 303 if (!buffer) | |
| 304 return "<NULL>"; | |
| 305 size_t length = buffer->length; | |
| 306 std::string output(StringPrintf("(%" PRIuS ") ", length)); | |
| 307 if (!buffer->value) { | |
| 308 output += "<NULL>"; | |
| 309 return output; | |
| 310 } | |
| 311 const char* value = | |
| 312 reinterpret_cast<const char*>(buffer->value); | |
| 313 bool is_printable = true; | |
| 314 for (size_t i = 0; i < length; ++i) { | |
| 315 if (!isprint(value[i])) { | |
| 316 // Allow the last character to be a '0'. | |
| 317 if ((i < (length - 1)) && !value[i]) | |
| 318 continue; | |
| 319 is_printable = false; | |
| 320 break; | |
| 321 } | |
| 322 } | |
| 323 if (is_printable) { | |
| 324 output += "\""; | |
| 325 output += value; | |
| 326 output += "\""; | |
| 327 } else { | |
| 328 output += "["; | |
| 329 for (size_t i = 0; i < buffer->length; ++i) { | |
| 330 output += StringPrintf("\\x%02X", value[i] & 0x0FF); | |
| 331 } | |
| 332 output += "]"; | |
| 333 } | |
| 334 | |
| 335 return output; | |
| 336 } | |
| 337 | |
| 338 std::string DescribeName(GSSAPILibrary* gssapi_lib, const gss_name_t name) { | 302 std::string DescribeName(GSSAPILibrary* gssapi_lib, const gss_name_t name) { |
| 339 OM_uint32 major_status = 0; | 303 OM_uint32 major_status = 0; |
| 340 OM_uint32 minor_status = 0; | 304 OM_uint32 minor_status = 0; |
| 341 gss_buffer_desc_struct output_name_buffer = GSS_C_EMPTY_BUFFER; | 305 gss_buffer_desc_struct output_name_buffer = GSS_C_EMPTY_BUFFER; |
| 342 gss_OID_desc output_name_type_desc = GSS_C_EMPTY_BUFFER; | 306 gss_OID_desc output_name_type_desc = GSS_C_EMPTY_BUFFER; |
| 343 gss_OID output_name_type = &output_name_type_desc; | 307 gss_OID output_name_type = &output_name_type_desc; |
| 344 major_status = gssapi_lib->display_name(&minor_status, | 308 major_status = gssapi_lib->display_name(&minor_status, |
| 345 name, | 309 name, |
| 346 &output_name_buffer, | 310 &output_name_buffer, |
| 347 &output_name_type); | 311 &output_name_type); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 minor_status) | 875 minor_status) |
| 912 << std::endl | 876 << std::endl |
| 913 << DescribeContext(library_, scoped_sec_context_.get()); | 877 << DescribeContext(library_, scoped_sec_context_.get()); |
| 914 return rv; | 878 return rv; |
| 915 } | 879 } |
| 916 | 880 |
| 917 return OK; | 881 return OK; |
| 918 } | 882 } |
| 919 | 883 |
| 920 } // namespace net | 884 } // namespace net |
| OLD | NEW |