Skip to content

Commit

Permalink
Add missing bssid and ssid args to shill client interface.
Browse files Browse the repository at this point in the history
Also, merged the common "verification" parameters into a separate struct so
we don't need so many arguments.

BUG=chromium:237289

Review URL: https://chromiumcodereview.appspot.com/14957009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198624 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
gspencer@chromium.org committed May 7, 2013
1 parent f0cee37 commit ae1ad6f
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 189 deletions.
59 changes: 43 additions & 16 deletions chrome/browser/chromeos/extensions/networking_private_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,37 @@
#include "chromeos/network/onc/onc_signature.h"
#include "chromeos/network/onc/onc_translator.h"

using namespace chromeos;
namespace api = extensions::api::networking_private;
namespace onc = chromeos::onc;
using chromeos::DBusThreadManager;
using chromeos::ManagedNetworkConfigurationHandler;
using chromeos::NetworkState;
using chromeos::NetworkStateHandler;
using chromeos::ShillManagerClient;

namespace {

// Helper function that converts between the two types of verification
// properties. They should always have the same fields, but we do this here to
// prevent ShillManagerClient from depending directly on the extension API.
ShillManagerClient::VerificationProperties ConvertVerificationProperties(
const api::VerificationProperties& input) {
ShillManagerClient::VerificationProperties output;
COMPILE_ASSERT(sizeof(api::VerificationProperties) ==
sizeof(ShillManagerClient::VerificationProperties),
verification_properties_no_longer_match);

output.certificate = input.certificate;
output.public_key = input.public_key;
output.nonce = input.nonce;
output.signed_data = input.signed_data;
output.device_serial = input.device_serial;
output.device_ssid = input.device_ssid;
output.device_bssid = input.device_bssid;
return output;
}

} // namespace

////////////////////////////////////////////////////////////////////////////////
// NetworkingPrivateGetPropertiesFunction
Expand Down Expand Up @@ -302,12 +331,11 @@ bool NetworkingPrivateVerifyDestinationFunction::RunImpl() {
api::VerifyDestination::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);

ShillManagerClient::VerificationProperties verification_properties =
ConvertVerificationProperties(params->properties);

DBusThreadManager::Get()->GetShillManagerClient()->VerifyDestination(
params->properties.certificate,
params->properties.public_key,
params->properties.nonce,
params->properties.signed_data,
params->properties.device_serial,
verification_properties,
base::Bind(
&NetworkingPrivateVerifyDestinationFunction::ResultCallback,
this),
Expand Down Expand Up @@ -342,12 +370,12 @@ bool NetworkingPrivateVerifyAndEncryptCredentialsFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(params);
ShillManagerClient* shill_manager_client =
DBusThreadManager::Get()->GetShillManagerClient();

ShillManagerClient::VerificationProperties verification_properties =
ConvertVerificationProperties(params->properties);

shill_manager_client->VerifyAndEncryptCredentials(
params->properties.certificate,
params->properties.public_key,
params->properties.nonce,
params->properties.signed_data,
params->properties.device_serial,
verification_properties,
params->guid,
base::Bind(
&NetworkingPrivateVerifyAndEncryptCredentialsFunction::ResultCallback,
Expand Down Expand Up @@ -382,12 +410,11 @@ bool NetworkingPrivateVerifyAndEncryptDataFunction::RunImpl() {
api::VerifyAndEncryptData::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);

ShillManagerClient::VerificationProperties verification_properties =
ConvertVerificationProperties(params->properties);

DBusThreadManager::Get()->GetShillManagerClient()->VerifyAndEncryptData(
params->properties.certificate,
params->properties.public_key,
params->properties.nonce,
params->properties.signed_data,
params->properties.device_serial,
verification_properties,
params->data,
base::Bind(
&NetworkingPrivateVerifyAndEncryptDataFunction::ResultCallback,
Expand Down
8 changes: 8 additions & 0 deletions chrome/common/extensions/api/networking_private.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
"deviceSerial": {
"type": "string",
"description": "A string containing the serial number of the device."
},
"deviceSsid": {
"type": "string",
"description": "A string containing the SSID of the device. Only set if the device has already been setup once."
},
"deviceBssid": {
"type": "string",
"description": "A string containing the BSSID of the device. Only set if the device has already been setup."
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion chrome/test/data/extensions/api_test/networking/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ var verificationProperties = {
"publicKey": "public_key",
"nonce": "nonce",
"signedData": "signed_data",
"deviceSerial": "device_serial"
"deviceSerial": "device_serial",
"deviceSsid": "Device 0123",
"deviceBssid": "00:01:02:03:04:05"
};

var privateHelpers = {
Expand Down
18 changes: 3 additions & 15 deletions chromeos/dbus/fake_shill_manager_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ void FakeShillManagerClient::RemovePropertyChangedObserver(
}

void FakeShillManagerClient::VerifyAndEncryptData(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const std::string& data,
const StringCallback& callback,
const ErrorCallback& error_callback) {
Expand Down Expand Up @@ -75,11 +71,7 @@ void FakeShillManagerClient::GetProperties(
}

void FakeShillManagerClient::VerifyAndEncryptCredentials(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const std::string& service_path,
const StringCallback& callback,
const ErrorCallback& error_callback) {
Expand All @@ -98,11 +90,7 @@ void FakeShillManagerClient::ConfigureService(
}

void FakeShillManagerClient::VerifyDestination(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const BooleanCallback& callback,
const ErrorCallback& error_callback) {
}
Expand Down
18 changes: 3 additions & 15 deletions chromeos/dbus/fake_shill_manager_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,16 @@ class FakeShillManagerClient : public ShillManagerClient {
virtual void GetService(const base::DictionaryValue& properties,
const ObjectPathCallback& callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void VerifyDestination(const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
virtual void VerifyDestination(const VerificationProperties& properties,
const BooleanCallback& callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void VerifyAndEncryptCredentials(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const std::string& service_path,
const StringCallback& callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void VerifyAndEncryptData(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const std::string& data,
const StringCallback& callback,
const ErrorCallback& error_callback) OVERRIDE;
Expand Down
32 changes: 11 additions & 21 deletions chromeos/dbus/mock_shill_manager_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,20 @@ class MockShillManagerClient : public ShillManagerClient {
MOCK_METHOD3(GetService, void(const base::DictionaryValue& properties,
const ObjectPathCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD7(VerifyDestination, void(const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const BooleanCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD8(VerifyAndEncryptCredentials,
void(const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
MOCK_METHOD3(VerifyDestination,
void(const VerificationProperties& properties,
const BooleanCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD4(VerifyAndEncryptCredentials,
void(const VerificationProperties& properties,
const std::string& service_path,
const StringCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD8(VerifyAndEncryptData, void(const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const std::string& data,
const StringCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD4(VerifyAndEncryptData,
void(const VerificationProperties& properties,
const std::string& data,
const StringCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD2(ConnectToBestServices,
void(const base::Closure& callback,
const ErrorCallback& error_callback));
Expand Down
76 changes: 37 additions & 39 deletions chromeos/dbus/shill_manager_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,70 +175,61 @@ class ShillManagerClientImpl : public ShillManagerClient {
error_callback);
}

virtual void VerifyDestination(const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
virtual void VerifyDestination(const VerificationProperties& properties,
const BooleanCallback& callback,
const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
shill::kVerifyDestinationFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(certificate);
writer.AppendString(public_key);
writer.AppendString(nonce);
writer.AppendString(signed_data);
writer.AppendString(device_serial);
helper_.CallBooleanMethodWithErrorCallback(&method_call,
callback,
error_callback);
writer.AppendString(properties.certificate);
writer.AppendString(properties.public_key);
writer.AppendString(properties.nonce);
writer.AppendString(properties.signed_data);
writer.AppendString(properties.device_serial);
writer.AppendString(properties.device_ssid);
writer.AppendString(properties.device_bssid);
helper_.CallBooleanMethodWithErrorCallback(
&method_call, callback, error_callback);
}

virtual void VerifyAndEncryptCredentials(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const std::string& service_path,
const StringCallback& callback,
const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
shill::kVerifyAndEncryptCredentialsFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(certificate);
writer.AppendString(public_key);
writer.AppendString(nonce);
writer.AppendString(signed_data);
writer.AppendString(device_serial);
writer.AppendString(properties.certificate);
writer.AppendString(properties.public_key);
writer.AppendString(properties.nonce);
writer.AppendString(properties.signed_data);
writer.AppendString(properties.device_serial);
writer.AppendString(properties.device_ssid);
writer.AppendString(properties.device_bssid);
writer.AppendObjectPath(dbus::ObjectPath(service_path));
helper_.CallStringMethodWithErrorCallback(&method_call,
callback,
error_callback);
helper_.CallStringMethodWithErrorCallback(
&method_call, callback, error_callback);
}

virtual void VerifyAndEncryptData(
const std::string& certificate,
const std::string& public_key,
const std::string& nonce,
const std::string& signed_data,
const std::string& device_serial,
const VerificationProperties& properties,
const std::string& data,
const StringCallback& callback,
const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
shill::kVerifyAndEncryptDataFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(certificate);
writer.AppendString(public_key);
writer.AppendString(nonce);
writer.AppendString(signed_data);
writer.AppendString(device_serial);
writer.AppendString(properties.certificate);
writer.AppendString(properties.public_key);
writer.AppendString(properties.nonce);
writer.AppendString(properties.signed_data);
writer.AppendString(properties.device_serial);
writer.AppendString(properties.device_ssid);
writer.AppendString(properties.device_bssid);
writer.AppendString(data);
helper_.CallStringMethodWithErrorCallback(&method_call,
callback,
error_callback);
helper_.CallStringMethodWithErrorCallback(
&method_call, callback, error_callback);
}

virtual void ConnectToBestServices(
Expand Down Expand Up @@ -278,4 +269,11 @@ ShillManagerClient* ShillManagerClient::Create(
return new ShillManagerClientStub();
}

// ShillManagerClient::VerificationProperties implementation.
ShillManagerClient::VerificationProperties::VerificationProperties() {
}

ShillManagerClient::VerificationProperties::~VerificationProperties() {
}

} // namespace chromeos
Loading

0 comments on commit ae1ad6f

Please sign in to comment.