OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/cert/internal/cert_errors.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/values.h" |
| 13 #include "net/der/input.h" |
| 14 |
| 15 namespace net { |
| 16 |
| 17 namespace { |
| 18 |
| 19 std::string HexEncodeString(const std::string& bytes) { |
| 20 return base::HexEncode(bytes.data(), bytes.size()); |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 25 CertErrorParams::CertErrorParams() = default; |
| 26 CertErrorParams::~CertErrorParams() = default; |
| 27 |
| 28 CertError::CertError() = default; |
| 29 CertError::~CertError() = default; |
| 30 CertError::CertError(CertError&& other) = default; |
| 31 |
| 32 CertErrors::CertErrors() = default; |
| 33 |
| 34 CertErrors::~CertErrors() = default; |
| 35 |
| 36 void CertErrors::Add(CertErrorType type) { |
| 37 AddWithParam(type, nullptr); |
| 38 } |
| 39 |
| 40 void CertErrors::AddWithParam(CertErrorType type, |
| 41 std::unique_ptr<CertErrorParams> params) { |
| 42 errors_.resize(errors_.size() + 1); |
| 43 errors_.back().type = type; |
| 44 errors_.back().params = std::move(params); |
| 45 } |
| 46 |
| 47 void CertErrors::AddWith1DerParam(CertErrorType type, const der::Input& der1) { |
| 48 AddWithParam(type, base::MakeUnique<CertErrorParamsDer1>(der1)); |
| 49 } |
| 50 |
| 51 void CertErrors::AddWith2DerParams(CertErrorType type, |
| 52 const der::Input& der1, |
| 53 const der::Input& der2) { |
| 54 AddWithParam(type, base::MakeUnique<CertErrorParamsDer2>(der1, der2)); |
| 55 } |
| 56 |
| 57 ScopedCertErrorsCertContext::ScopedCertErrorsCertContext( |
| 58 CertErrors* parent, |
| 59 const ParsedCertificate* cert, |
| 60 size_t i) { |
| 61 // TODO(crbug.com/634443): Implement. |
| 62 } |
| 63 |
| 64 ScopedCertErrorsCertContext::~ScopedCertErrorsCertContext() { |
| 65 // TODO(crbug.com/634443): Implement. |
| 66 } |
| 67 |
| 68 ScopedCertErrorsTrustAnchorContext::ScopedCertErrorsTrustAnchorContext( |
| 69 CertErrors* parent, |
| 70 const TrustAnchor* trust_anchor) { |
| 71 // TODO(crbug.com/634443): Implement. |
| 72 } |
| 73 |
| 74 ScopedCertErrorsTrustAnchorContext::~ScopedCertErrorsTrustAnchorContext() { |
| 75 // TODO(crbug.com/634443): Implement. |
| 76 } |
| 77 |
| 78 CertErrorParamsDer1::CertErrorParamsDer1(const der::Input& der1) |
| 79 : der1_(der1.AsString()) {} |
| 80 |
| 81 std::unique_ptr<base::Value> CertErrorParamsDer1::ToValue() const { |
| 82 auto dict = base::MakeUnique<base::DictionaryValue>(); |
| 83 dict->SetString("der1", HexEncodeString(der1_)); |
| 84 return std::move(dict); |
| 85 } |
| 86 |
| 87 CertErrorParamsDer2::CertErrorParamsDer2(const der::Input& der1, |
| 88 const der::Input& der2) |
| 89 : der1_(der1.AsString()), der2_(der2.AsString()) {} |
| 90 |
| 91 std::unique_ptr<base::Value> CertErrorParamsDer2::ToValue() const { |
| 92 auto dict = base::MakeUnique<base::DictionaryValue>(); |
| 93 dict->SetString("der1", HexEncodeString(der1_)); |
| 94 dict->SetString("der2", HexEncodeString(der2_)); |
| 95 return std::move(dict); |
| 96 } |
| 97 |
| 98 } // namespace net |
OLD | NEW |