OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_FAKESSLIDENTITY_H_ | 11 #ifndef WEBRTC_BASE_FAKESSLIDENTITY_H_ |
12 #define WEBRTC_BASE_FAKESSLIDENTITY_H_ | 12 #define WEBRTC_BASE_FAKESSLIDENTITY_H_ |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
| 15 #include <memory> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "webrtc/base/common.h" | 18 #include "webrtc/base/common.h" |
18 #include "webrtc/base/messagedigest.h" | 19 #include "webrtc/base/messagedigest.h" |
19 #include "webrtc/base/sslidentity.h" | 20 #include "webrtc/base/sslidentity.h" |
20 | 21 |
21 namespace rtc { | 22 namespace rtc { |
22 | 23 |
23 class FakeSSLCertificate : public rtc::SSLCertificate { | 24 class FakeSSLCertificate : public rtc::SSLCertificate { |
24 public: | 25 public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return true; | 62 return true; |
62 } | 63 } |
63 virtual bool ComputeDigest(const std::string& algorithm, | 64 virtual bool ComputeDigest(const std::string& algorithm, |
64 unsigned char* digest, | 65 unsigned char* digest, |
65 size_t size, | 66 size_t size, |
66 size_t* length) const { | 67 size_t* length) const { |
67 *length = rtc::ComputeDigest(algorithm, data_.c_str(), data_.size(), | 68 *length = rtc::ComputeDigest(algorithm, data_.c_str(), data_.size(), |
68 digest, size); | 69 digest, size); |
69 return (*length != 0); | 70 return (*length != 0); |
70 } | 71 } |
71 virtual rtc::scoped_ptr<SSLCertChain> GetChain() const { | 72 virtual std::unique_ptr<SSLCertChain> GetChain() const { |
72 if (certs_.empty()) | 73 if (certs_.empty()) |
73 return nullptr; | 74 return nullptr; |
74 std::vector<SSLCertificate*> new_certs(certs_.size()); | 75 std::vector<SSLCertificate*> new_certs(certs_.size()); |
75 std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert); | 76 std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert); |
76 rtc::scoped_ptr<SSLCertChain> chain(new SSLCertChain(new_certs)); | 77 std::unique_ptr<SSLCertChain> chain(new SSLCertChain(new_certs)); |
77 std::for_each(new_certs.begin(), new_certs.end(), DeleteCert); | 78 std::for_each(new_certs.begin(), new_certs.end(), DeleteCert); |
78 return chain; | 79 return chain; |
79 } | 80 } |
80 | 81 |
81 private: | 82 private: |
82 static FakeSSLCertificate* DupCert(FakeSSLCertificate cert) { | 83 static FakeSSLCertificate* DupCert(FakeSSLCertificate cert) { |
83 return cert.GetReference(); | 84 return cert.GetReference(); |
84 } | 85 } |
85 static void DeleteCert(SSLCertificate* cert) { delete cert; } | 86 static void DeleteCert(SSLCertificate* cert) { delete cert; } |
86 std::string data_; | 87 std::string data_; |
(...skipping 11 matching lines...) Expand all Loading... |
98 return new FakeSSLIdentity(*this); | 99 return new FakeSSLIdentity(*this); |
99 } | 100 } |
100 virtual const FakeSSLCertificate& certificate() const { return cert_; } | 101 virtual const FakeSSLCertificate& certificate() const { return cert_; } |
101 private: | 102 private: |
102 FakeSSLCertificate cert_; | 103 FakeSSLCertificate cert_; |
103 }; | 104 }; |
104 | 105 |
105 } // namespace rtc | 106 } // namespace rtc |
106 | 107 |
107 #endif // WEBRTC_BASE_FAKESSLIDENTITY_H_ | 108 #endif // WEBRTC_BASE_FAKESSLIDENTITY_H_ |
OLD | NEW |