Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: talk/app/webrtc/test/fakedtlsidentitystore.h

Issue 1176383004: DtlsIdentityStore[Interface/Impl] updated, DtlsIdentityService to be removed (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge w master AFTER the landing of 1268363002. "CreatePC(service,store)" using store instead of service. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/app/webrtc/test/fakedtlsidentityservice.h ('k') | talk/app/webrtc/test/peerconnectiontestwrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/test/fakedtlsidentitystore.h
diff --git a/talk/app/webrtc/test/fakedtlsidentityservice.h b/talk/app/webrtc/test/fakedtlsidentitystore.h
similarity index 70%
rename from talk/app/webrtc/test/fakedtlsidentityservice.h
rename to talk/app/webrtc/test/fakedtlsidentitystore.h
index 6c59d4115a88024a33be854df38949dcf89f66ca..5ef19004a0c3abd3b8bda1a6697384f8deec09dc 100644
--- a/talk/app/webrtc/test/fakedtlsidentityservice.h
+++ b/talk/app/webrtc/test/fakedtlsidentitystore.h
@@ -28,6 +28,9 @@
#ifndef TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_
#define TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_
+#include <string>
+
+#include "talk/app/webrtc/dtlsidentitystore.h"
#include "talk/app/webrtc/peerconnectioninterface.h"
static const char kRSA_PRIVATE_KEY_PEM[] =
@@ -61,38 +64,28 @@ static const char kCERT_PEM[] =
"UD0A8qfhfDM+LK6rPAnCsVN0NRDY3jvd6rzix9M=\n"
"-----END CERTIFICATE-----\n";
-using webrtc::DTLSIdentityRequestObserver;
-
-class FakeIdentityService : public webrtc::DTLSIdentityServiceInterface,
- public rtc::MessageHandler {
+class FakeDtlsIdentityStore : public webrtc::DtlsIdentityStoreInterface,
+ public rtc::MessageHandler {
public:
- struct Request {
- Request(const std::string& common_name,
- DTLSIdentityRequestObserver* observer)
- : common_name(common_name), observer(observer) {}
-
- std::string common_name;
- rtc::scoped_refptr<DTLSIdentityRequestObserver> observer;
- };
- typedef rtc::TypedMessageData<Request> MessageData;
+ typedef rtc::TypedMessageData<rtc::scoped_refptr<
+ webrtc::DtlsIdentityRequestObserver> > MessageData;
- FakeIdentityService() : should_fail_(false) {}
+ FakeDtlsIdentityStore() : should_fail_(false) {}
void set_should_fail(bool should_fail) {
should_fail_ = should_fail;
}
- // DTLSIdentityServiceInterface implemenation.
- virtual bool RequestIdentity(const std::string& identity_name,
- const std::string& common_name,
- DTLSIdentityRequestObserver* observer) {
- MessageData* msg = new MessageData(Request(common_name, observer));
- if (should_fail_) {
- rtc::Thread::Current()->Post(this, MSG_FAILURE, msg);
- } else {
- rtc::Thread::Current()->Post(this, MSG_SUCCESS, msg);
- }
- return true;
+ void RequestIdentity(
+ rtc::KeyType key_type,
+ const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>&
+ observer) override {
+ // TODO(hbos): Should be able to generate KT_ECDSA too.
+ DCHECK(key_type == rtc::KT_RSA || should_fail_);
+ MessageData* msg = new MessageData(
+ rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer));
+ rtc::Thread::Current()->Post(
+ this, should_fail_ ? MSG_FAILURE : MSG_SUCCESS, msg);
}
private:
@@ -103,13 +96,16 @@ class FakeIdentityService : public webrtc::DTLSIdentityServiceInterface,
// rtc::MessageHandler implementation.
void OnMessage(rtc::Message* msg) {
- FakeIdentityService::MessageData* message_data =
- static_cast<FakeIdentityService::MessageData*>(msg->pdata);
- DTLSIdentityRequestObserver* observer = message_data->data().observer.get();
+ MessageData* message_data = static_cast<MessageData*>(msg->pdata);
+ rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer =
+ message_data->data();
switch (msg->message_id) {
case MSG_SUCCESS: {
- std::string cert, key;
- GenerateIdentity(message_data->data().common_name, &cert, &key);
+ std::string cert;
+ std::string key;
+ rtc::SSLIdentity::PemToDer("CERTIFICATE", kCERT_PEM, &cert);
+ rtc::SSLIdentity::PemToDer("RSA PRIVATE KEY", kRSA_PRIVATE_KEY_PEM,
+ &key);
observer->OnSuccess(cert, key);
break;
}
@@ -120,16 +116,6 @@ class FakeIdentityService : public webrtc::DTLSIdentityServiceInterface,
delete message_data;
}
- void GenerateIdentity(
- const std::string& common_name,
- std::string* der_cert,
- std::string* der_key) {
- rtc::SSLIdentity::PemToDer("CERTIFICATE", kCERT_PEM, der_cert);
- rtc::SSLIdentity::PemToDer("RSA PRIVATE KEY",
- kRSA_PRIVATE_KEY_PEM,
- der_key);
- }
-
bool should_fail_;
};
« no previous file with comments | « talk/app/webrtc/test/fakedtlsidentityservice.h ('k') | talk/app/webrtc/test/peerconnectiontestwrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698