| 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  | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   61     return true; |   61     return true; | 
|   62   } |   62   } | 
|   63   virtual bool ComputeDigest(const std::string& algorithm, |   63   virtual bool ComputeDigest(const std::string& algorithm, | 
|   64                              unsigned char* digest, |   64                              unsigned char* digest, | 
|   65                              size_t size, |   65                              size_t size, | 
|   66                              size_t* length) const { |   66                              size_t* length) const { | 
|   67     *length = rtc::ComputeDigest(algorithm, data_.c_str(), data_.size(), |   67     *length = rtc::ComputeDigest(algorithm, data_.c_str(), data_.size(), | 
|   68                                        digest, size); |   68                                        digest, size); | 
|   69     return (*length != 0); |   69     return (*length != 0); | 
|   70   } |   70   } | 
|   71   virtual bool GetChain(SSLCertChain** chain) const { |   71   virtual rtc::scoped_ptr<SSLCertChain> GetChain() const { | 
|   72     if (certs_.empty()) |   72     if (certs_.empty()) | 
|   73       return false; |   73       return nullptr; | 
|   74     std::vector<SSLCertificate*> new_certs(certs_.size()); |   74     std::vector<SSLCertificate*> new_certs(certs_.size()); | 
|   75     std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert); |   75     std::transform(certs_.begin(), certs_.end(), new_certs.begin(), DupCert); | 
|   76     *chain = new SSLCertChain(new_certs); |   76     rtc::scoped_ptr<SSLCertChain> chain(new SSLCertChain(new_certs)); | 
|   77     std::for_each(new_certs.begin(), new_certs.end(), DeleteCert); |   77     std::for_each(new_certs.begin(), new_certs.end(), DeleteCert); | 
|   78     return true; |   78     return chain; | 
|   79   } |   79   } | 
|   80  |   80  | 
|   81  private: |   81  private: | 
|   82   static FakeSSLCertificate* DupCert(FakeSSLCertificate cert) { |   82   static FakeSSLCertificate* DupCert(FakeSSLCertificate cert) { | 
|   83     return cert.GetReference(); |   83     return cert.GetReference(); | 
|   84   } |   84   } | 
|   85   static void DeleteCert(SSLCertificate* cert) { delete cert; } |   85   static void DeleteCert(SSLCertificate* cert) { delete cert; } | 
|   86   std::string data_; |   86   std::string data_; | 
|   87   std::vector<FakeSSLCertificate> certs_; |   87   std::vector<FakeSSLCertificate> certs_; | 
|   88   std::string digest_algorithm_; |   88   std::string digest_algorithm_; | 
|   89   // Expiration time in seconds relative to epoch, 1970-01-01T00:00:00Z (UTC). |   89   // Expiration time in seconds relative to epoch, 1970-01-01T00:00:00Z (UTC). | 
|   90   int64_t expiration_time_; |   90   int64_t expiration_time_; | 
|   91 }; |   91 }; | 
|   92  |   92  | 
|   93 class FakeSSLIdentity : public rtc::SSLIdentity { |   93 class FakeSSLIdentity : public rtc::SSLIdentity { | 
|   94  public: |   94  public: | 
|   95   explicit FakeSSLIdentity(const std::string& data) : cert_(data) {} |   95   explicit FakeSSLIdentity(const std::string& data) : cert_(data) {} | 
|   96   explicit FakeSSLIdentity(const FakeSSLCertificate& cert) : cert_(cert) {} |   96   explicit FakeSSLIdentity(const FakeSSLCertificate& cert) : cert_(cert) {} | 
|   97   virtual FakeSSLIdentity* GetReference() const { |   97   virtual FakeSSLIdentity* GetReference() const { | 
|   98     return new FakeSSLIdentity(*this); |   98     return new FakeSSLIdentity(*this); | 
|   99   } |   99   } | 
|  100   virtual const FakeSSLCertificate& certificate() const { return cert_; } |  100   virtual const FakeSSLCertificate& certificate() const { return cert_; } | 
|  101  private: |  101  private: | 
|  102   FakeSSLCertificate cert_; |  102   FakeSSLCertificate cert_; | 
|  103 }; |  103 }; | 
|  104  |  104  | 
|  105 }  // namespace rtc |  105 }  // namespace rtc | 
|  106  |  106  | 
|  107 #endif  // WEBRTC_BASE_FAKESSLIDENTITY_H_ |  107 #endif  // WEBRTC_BASE_FAKESSLIDENTITY_H_ | 
| OLD | NEW |