summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
authoralemate <alemate@chromium.org>2016-03-04 02:39:54 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-04 10:41:09 +0000
commit627f65303a4a1a6b4d1beb62c9ea5b6ed5affda7 (patch)
tree5b57e0a8999752be8165706373ba5abfe5851729 /chromeos/dbus
parent0cdae918ae7ffe4d4046027182807b9d99b6b719 (diff)
downloadchromium_src-627f65303a4a1a6b4d1beb62c9ea5b6ed5affda7.zip
chromium_src-627f65303a4a1a6b4d1beb62c9ea5b6ed5affda7.tar.gz
chromium_src-627f65303a4a1a6b4d1beb62c9ea5b6ed5affda7.tar.bz2
ChromeOS cryptohome should be able to use gaia id as user identifier.
This CL adds support for using Gaia ID as cryptohome identifier. BUG=462823 TEST=unit tests Review URL: https://codereview.chromium.org/1693383003 Cr-Commit-Position: refs/heads/master@{#379262}
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/cryptohome_client.cc150
-rw-r--r--chromeos/dbus/cryptohome_client.h163
-rw-r--r--chromeos/dbus/fake_cryptohome_client.cc65
-rw-r--r--chromeos/dbus/fake_cryptohome_client.h73
-rw-r--r--chromeos/dbus/fake_session_manager_client.cc39
-rw-r--r--chromeos/dbus/fake_session_manager_client.h18
-rw-r--r--chromeos/dbus/mock_cryptohome_client.h106
-rw-r--r--chromeos/dbus/mock_session_manager_client.h12
-rw-r--r--chromeos/dbus/session_manager_client.cc74
-rw-r--r--chromeos/dbus/session_manager_client.h39
10 files changed, 391 insertions, 348 deletions
diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc
index c2b3e82..0df97a3 100644
--- a/chromeos/dbus/cryptohome_client.cc
+++ b/chromeos/dbus/cryptohome_client.cc
@@ -13,6 +13,7 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "chromeos/cryptohome/async_method_caller.h"
+#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/blocking_method_caller.h"
#include "chromeos/dbus/cryptohome/key.pb.h"
#include "chromeos/dbus/cryptohome/rpc.pb.h"
@@ -28,8 +29,8 @@ const int CryptohomeClient::kNotReadyAsyncId = -1;
namespace {
-// This suffix is appended to user_id to get hash in stub implementation:
-// stub_hash = "[user_id]-hash";
+// This suffix is appended to cryptohome_id to get hash in stub implementation:
+// stub_hash = "[cryptohome_id]-hash";
static const char kUserIdStubHashSuffix[] = "-hash";
// Timeout for TPM operations. On slow machines it should be larger, than
@@ -37,6 +38,11 @@ static const char kUserIdStubHashSuffix[] = "-hash";
// is 2 minutes.
const int kTpmDBusTimeoutMs = 2 * 60 * 1000;
+void FillIdentificationProtobuf(const cryptohome::Identification& id,
+ cryptohome::AccountIdentifier* id_proto) {
+ id_proto->set_account_id(id.id());
+}
+
// The CryptohomeClient implementation.
class CryptohomeClientImpl : public CryptohomeClient {
public:
@@ -77,13 +83,13 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void AsyncCheckKey(const std::string& username,
+ void AsyncCheckKey(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncCheckKey);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
@@ -92,14 +98,14 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void AsyncMigrateKey(const std::string& username,
+ void AsyncMigrateKey(const cryptohome::Identification& cryptohome_id,
const std::string& from_key,
const std::string& to_key,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncMigrateKey);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(from_key);
writer.AppendString(to_key);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
@@ -109,12 +115,12 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void AsyncRemove(const std::string& username,
+ void AsyncRemove(const cryptohome::Identification& cryptohome_id,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncRemove);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
weak_ptr_factory_.GetWeakPtr(),
@@ -132,12 +138,12 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override,
- void GetSanitizedUsername(const std::string& username,
+ void GetSanitizedUsername(const cryptohome::Identification& cryptohome_id,
const StringDBusMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeGetSanitizedUsername);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnStringMethod,
weak_ptr_factory_.GetWeakPtr(),
@@ -146,11 +152,11 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
std::string BlockingGetSanitizedUsername(
- const std::string& username) override {
+ const cryptohome::Identification& cryptohome_id) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeGetSanitizedUsername);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
scoped_ptr<dbus::Response> response =
blocking_method_caller_->CallMethodAndBlock(&method_call);
@@ -165,14 +171,14 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void AsyncMount(const std::string& username,
+ void AsyncMount(const cryptohome::Identification& cryptohome_id,
const std::string& key,
int flags,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncMount);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key);
writer.AppendBool(flags & cryptohome::CREATE_IF_MISSING);
writer.AppendBool(flags & cryptohome::ENSURE_EPHEMERAL);
@@ -185,14 +191,14 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void AsyncAddKey(const std::string& username,
+ void AsyncAddKey(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const std::string& new_key,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncAddKey);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key);
writer.AppendString(new_key);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
@@ -212,13 +218,13 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void AsyncMountPublic(const std::string& public_mount_id,
+ void AsyncMountPublic(const cryptohome::Identification& public_mount_id,
int flags,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeAsyncMountPublic);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(public_mount_id);
+ writer.AppendString(public_mount_id.id());
writer.AppendBool(flags & cryptohome::CREATE_IF_MISSING);
writer.AppendBool(flags & cryptohome::ENSURE_EPHEMERAL);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
@@ -336,13 +342,13 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void Pkcs11GetTpmTokenInfoForUser(
- const std::string& user_email,
+ const cryptohome::Identification& cryptohome_id,
const Pkcs11GetTpmTokenInfoCallback& callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomePkcs11GetTpmTokenInfoForUser);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(user_email);
+ writer.AppendString(cryptohome_id.id());
proxy_->CallMethod(
&method_call, kTpmDBusTimeoutMs ,
base::Bind(
@@ -473,7 +479,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
void AsyncTpmAttestationCreateCertRequest(
attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& request_origin,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(
@@ -482,7 +488,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
writer.AppendInt32(pca_type);
writer.AppendInt32(certificate_profile);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(request_origin);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
@@ -494,7 +500,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(
@@ -506,7 +512,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
pca_response.size());
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
@@ -517,7 +523,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationDoesKeyExist(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const BoolDBusMethodCallback& callback) override {
dbus::MethodCall method_call(
@@ -526,7 +532,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
CallBoolMethod(&method_call, callback);
}
@@ -534,7 +540,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationGetCertificate(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) override {
dbus::MethodCall method_call(
@@ -543,7 +549,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnDataMethod,
@@ -552,17 +558,18 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void TpmAttestationGetPublicKey(attestation::AttestationKeyType key_type,
- const std::string& user_id,
- const std::string& key_name,
- const DataMethodCallback& callback) override {
+ void TpmAttestationGetPublicKey(
+ attestation::AttestationKeyType key_type,
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& key_name,
+ const DataMethodCallback& callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeTpmAttestationGetPublicKey);
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnDataMethod,
@@ -571,17 +578,18 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
- void TpmAttestationRegisterKey(attestation::AttestationKeyType key_type,
- const std::string& user_id,
- const std::string& key_name,
- const AsyncMethodCallback& callback) override {
+ void TpmAttestationRegisterKey(
+ attestation::AttestationKeyType key_type,
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& key_name,
+ const AsyncMethodCallback& callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeTpmAttestationRegisterKey);
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnAsyncMethodCall,
@@ -592,7 +600,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationSignEnterpriseChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& domain,
const std::string& device_id,
@@ -605,7 +613,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
writer.AppendString(domain);
writer.AppendArrayOfBytes(
@@ -624,7 +632,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationSignSimpleChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& challenge,
const AsyncMethodCallback& callback) override {
@@ -634,7 +642,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(challenge.data()), challenge.size());
@@ -647,7 +655,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) override {
dbus::MethodCall method_call(
@@ -656,7 +664,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
base::Bind(&CryptohomeClientImpl::OnDataMethod,
@@ -667,7 +675,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& payload,
const BoolDBusMethodCallback& callback) override {
@@ -677,7 +685,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_name);
writer.AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(payload.data()),
payload.size());
@@ -687,7 +695,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
// CryptohomeClient override.
void TpmAttestationDeleteKeys(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_prefix,
const BoolDBusMethodCallback& callback) override {
dbus::MethodCall method_call(
@@ -696,19 +704,22 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MessageWriter writer(&method_call);
bool is_user_specific = (key_type == attestation::KEY_USER);
writer.AppendBool(is_user_specific);
- writer.AppendString(user_id);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(key_prefix);
CallBoolMethod(&method_call, callback);
}
- void GetKeyDataEx(const cryptohome::AccountIdentifier& id,
+ void GetKeyDataEx(const cryptohome::Identification& id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::GetKeyDataRequest& request,
const ProtobufMethodCallback& callback) override {
+ cryptohome::AccountIdentifier id_proto;
+ FillIdentificationProtobuf(id, &id_proto);
+
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeGetKeyDataEx);
dbus::MessageWriter writer(&method_call);
- writer.AppendProtoAsArrayOfBytes(id);
+ writer.AppendProtoAsArrayOfBytes(id_proto);
writer.AppendProtoAsArrayOfBytes(auth);
writer.AppendProtoAsArrayOfBytes(request);
@@ -719,7 +730,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback));
}
- void CheckKeyEx(const cryptohome::AccountIdentifier& id,
+ void CheckKeyEx(const cryptohome::Identification& id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::CheckKeyRequest& request,
const ProtobufMethodCallback& callback) override {
@@ -727,8 +738,11 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
method_name);
+ cryptohome::AccountIdentifier id_proto;
+ FillIdentificationProtobuf(id, &id_proto);
+
dbus::MessageWriter writer(&method_call);
- writer.AppendProtoAsArrayOfBytes(id);
+ writer.AppendProtoAsArrayOfBytes(id_proto);
writer.AppendProtoAsArrayOfBytes(auth);
writer.AppendProtoAsArrayOfBytes(request);
@@ -738,7 +752,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback));
}
- void MountEx(const cryptohome::AccountIdentifier& id,
+ void MountEx(const cryptohome::Identification& id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::MountRequest& request,
const ProtobufMethodCallback& callback) override {
@@ -746,8 +760,11 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
method_name);
+ cryptohome::AccountIdentifier id_proto;
+ FillIdentificationProtobuf(id, &id_proto);
+
dbus::MessageWriter writer(&method_call);
- writer.AppendProtoAsArrayOfBytes(id);
+ writer.AppendProtoAsArrayOfBytes(id_proto);
writer.AppendProtoAsArrayOfBytes(auth);
writer.AppendProtoAsArrayOfBytes(request);
@@ -757,7 +774,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback));
}
- void AddKeyEx(const cryptohome::AccountIdentifier& id,
+ void AddKeyEx(const cryptohome::Identification& id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::AddKeyRequest& request,
const ProtobufMethodCallback& callback) override {
@@ -765,8 +782,11 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
method_name);
+ cryptohome::AccountIdentifier id_proto;
+ FillIdentificationProtobuf(id, &id_proto);
+
dbus::MessageWriter writer(&method_call);
- writer.AppendProtoAsArrayOfBytes(id);
+ writer.AppendProtoAsArrayOfBytes(id_proto);
writer.AppendProtoAsArrayOfBytes(auth);
writer.AppendProtoAsArrayOfBytes(request);
@@ -776,7 +796,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback));
}
- void UpdateKeyEx(const cryptohome::AccountIdentifier& id,
+ void UpdateKeyEx(const cryptohome::Identification& id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::UpdateKeyRequest& request,
const ProtobufMethodCallback& callback) override {
@@ -784,8 +804,11 @@ class CryptohomeClientImpl : public CryptohomeClient {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
method_name);
+ cryptohome::AccountIdentifier id_proto;
+ FillIdentificationProtobuf(id, &id_proto);
+
dbus::MessageWriter writer(&method_call);
- writer.AppendProtoAsArrayOfBytes(id);
+ writer.AppendProtoAsArrayOfBytes(id_proto);
writer.AppendProtoAsArrayOfBytes(auth);
writer.AppendProtoAsArrayOfBytes(request);
@@ -796,15 +819,18 @@ class CryptohomeClientImpl : public CryptohomeClient {
callback));
}
- void RemoveKeyEx(const cryptohome::AccountIdentifier& id,
+ void RemoveKeyEx(const cryptohome::Identification& id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::RemoveKeyRequest& request,
const ProtobufMethodCallback& callback) override {
const char* method_name = cryptohome::kCryptohomeRemoveKeyEx;
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name);
+ cryptohome::AccountIdentifier id_proto;
+ FillIdentificationProtobuf(id, &id_proto);
+
dbus::MessageWriter writer(&method_call);
- writer.AppendProtoAsArrayOfBytes(id);
+ writer.AppendProtoAsArrayOfBytes(id_proto);
writer.AppendProtoAsArrayOfBytes(auth);
writer.AppendProtoAsArrayOfBytes(request);
@@ -1139,8 +1165,8 @@ CryptohomeClient* CryptohomeClient::Create() {
// static
std::string CryptohomeClient::GetStubSanitizedUsername(
- const std::string& username) {
- return username + kUserIdStubHashSuffix;
+ const cryptohome::Identification& cryptohome_id) {
+ return cryptohome_id.id() + kUserIdStubHashSuffix;
}
} // namespace chromeos
diff --git a/chromeos/dbus/cryptohome_client.h b/chromeos/dbus/cryptohome_client.h
index 09116e3..233ff93 100644
--- a/chromeos/dbus/cryptohome_client.h
+++ b/chromeos/dbus/cryptohome_client.h
@@ -19,7 +19,6 @@
namespace cryptohome {
-class AccountIdentifier;
class AddKeyRequest;
class AuthorizationRequest;
class BaseReply;
@@ -32,6 +31,8 @@ class RemoveKeyRequest;
class SetBootAttributeRequest;
class UpdateKeyRequest;
+class Identification;
+
} // namespace cryptohome
namespace chromeos {
@@ -95,7 +96,8 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
static CryptohomeClient* Create();
// Returns the sanitized |username| that the stub implementation would return.
- static std::string GetStubSanitizedUsername(const std::string& username);
+ static std::string GetStubSanitizedUsername(
+ const cryptohome::Identification& cryptohome_id);
// Sets AsyncCallStatus signal handlers.
// |handler| is called when results for AsyncXXX methods are returned.
@@ -121,20 +123,20 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// Calls AsyncCheckKey method. |callback| is called after the method call
// succeeds.
- virtual void AsyncCheckKey(const std::string& username,
+ virtual void AsyncCheckKey(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const AsyncMethodCallback& callback) = 0;
// Calls AsyncMigrateKey method. |callback| is called after the method call
// succeeds.
- virtual void AsyncMigrateKey(const std::string& username,
+ virtual void AsyncMigrateKey(const cryptohome::Identification& cryptohome_id,
const std::string& from_key,
const std::string& to_key,
const AsyncMethodCallback& callback) = 0;
// Calls AsyncRemove method. |callback| is called after the method call
// succeeds.
- virtual void AsyncRemove(const std::string& username,
+ virtual void AsyncRemove(const cryptohome::Identification& cryptohome_id,
const AsyncMethodCallback& callback) = 0;
// Calls GetSystemSalt method. |callback| is called after the method call
@@ -144,7 +146,7 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// Calls GetSanitizedUsername method. |callback| is called after the method
// call succeeds.
virtual void GetSanitizedUsername(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const StringDBusMethodCallback& callback) = 0;
// Same as GetSanitizedUsername() but blocks until a reply is received, and
@@ -154,13 +156,13 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// considered acceptable (e.g. restarting the browser after a crash or after
// a flag change).
virtual std::string BlockingGetSanitizedUsername(
- const std::string& username) = 0;
+ const cryptohome::Identification& cryptohome_id) = 0;
// Calls the AsyncMount method to asynchronously mount the cryptohome for
// |username|, using |key| to unlock it. For supported |flags|, see the
// documentation of AsyncMethodCaller::AsyncMount().
// |callback| is called after the method call succeeds.
- virtual void AsyncMount(const std::string& username,
+ virtual void AsyncMount(const cryptohome::Identification& cryptohome_id,
const std::string& key,
int flags,
const AsyncMethodCallback& callback) = 0;
@@ -168,7 +170,7 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// Calls the AsyncAddKey method to asynchronously add another |new_key| for
// |username|, using |key| to unlock it first.
// |callback| is called after the method call succeeds.
- virtual void AsyncAddKey(const std::string& username,
+ virtual void AsyncAddKey(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const std::string& new_key,
const AsyncMethodCallback& callback) = 0;
@@ -181,9 +183,10 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// |public_mount_id|. For supported |flags|, see the documentation of
// AsyncMethodCaller::AsyncMount(). |callback| is called after the method
// call succeeds.
- virtual void AsyncMountPublic(const std::string& public_mount_id,
- int flags,
- const AsyncMethodCallback& callback) = 0;
+ virtual void AsyncMountPublic(
+ const cryptohome::Identification& public_mount_id,
+ int flags,
+ const AsyncMethodCallback& callback) = 0;
// Calls TpmIsReady method.
virtual void TpmIsReady(const BoolDBusMethodCallback& callback) = 0;
@@ -241,11 +244,10 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
const Pkcs11GetTpmTokenInfoCallback& callback) = 0;
// Calls Pkcs11GetTpmTokenInfoForUser method. On success |callback| will
- // receive PKCS #11 token information for the user identified by |user_email|.
- // The |user_email| must be a canonical email address as returned by
- // user_manager::User::email().
+ // receive PKCS #11 token information for the user identified by
+ // |cryptohome_id|.
virtual void Pkcs11GetTpmTokenInfoForUser(
- const std::string& user_email,
+ const cryptohome::Identification& cryptohome_id,
const Pkcs11GetTpmTokenInfoCallback& callback) = 0;
// Calls InstallAttributesGet method and returns true when the call succeeds.
@@ -308,19 +310,19 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
const AsyncMethodCallback& callback) = 0;
// Asynchronously creates an attestation certificate request according to
- // |certificate_profile|. Some profiles require that the |user_id| of the
- // currently active user and an identifier of the |request_origin| be
+ // |certificate_profile|. Some profiles require that the |cryptohome_id| of
+ // the currently active user and an identifier of the |request_origin| be
// provided. |callback| will be called when the dbus call completes. When
// the operation completes, the AsyncCallStatusWithDataHandler signal handler
// is called. The data that is sent with the signal is a certificate request
// to be sent to the Privacy CA of type |pca_type|. The certificate request
// is completed by calling AsyncTpmAttestationFinishCertRequest. The
- // |user_id| will not be included in the certificate request for the Privacy
- // CA.
+ // |cryptohome_id| will not be included in the certificate request for the
+ // Privacy CA.
virtual void AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& request_origin,
const AsyncMethodCallback& callback) = 0;
@@ -331,46 +333,45 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// is the response to the certificate request emitted by the Privacy CA.
// |key_type| determines whether the certified key is to be associated with
// the current user. |key_name| is a name for the key. If |key_type| is
- // KEY_USER, a |user_id| must be provided. Otherwise |user_id| is ignored.
- // For normal GAIA users the |user_id| is a canonical email address.
+ // KEY_USER, a |cryptohome_id| must be provided. Otherwise |cryptohome_id|
+ // is ignored.
virtual void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback) = 0;
// Checks if an attestation key already exists. If the key specified by
// |key_type| and |key_name| exists, then the result sent to the callback will
- // be true. If |key_type| is KEY_USER, a |user_id| must be provided.
- // Otherwise |user_id| is ignored. For normal GAIA users the |user_id| is a
- // canonical email address.
+ // be true. If |key_type| is KEY_USER, a |cryptohome_id| must be provided.
+ // Otherwise |cryptohome_id| is ignored.
virtual void TpmAttestationDoesKeyExist(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const BoolDBusMethodCallback& callback) = 0;
// Gets the attestation certificate for the key specified by |key_type| and
// |key_name|. |callback| will be called when the operation completes. If
// the key does not exist the callback |result| parameter will be false. If
- // |key_type| is KEY_USER, a |user_id| must be provided. Otherwise |user_id|
- // is ignored. For normal GAIA users the |user_id| is a canonical email
- // address.
+ // |key_type| is KEY_USER, a |cryptohome_id| must be provided. Otherwise
+ // |cryptohome_id|
+ // is ignored.
virtual void TpmAttestationGetCertificate(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) = 0;
// Gets the public key for the key specified by |key_type| and |key_name|.
// |callback| will be called when the operation completes. If the key does
// not exist the callback |result| parameter will be false. If |key_type| is
- // KEY_USER, a |user_id| must be provided. Otherwise |user_id| is ignored.
- // For normal GAIA users the |user_id| is a canonical email address.
+ // KEY_USER, a |cryptohome_id| must be provided. Otherwise |cryptohome_id|
+ // is ignored.
virtual void TpmAttestationGetPublicKey(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) = 0;
@@ -378,12 +379,11 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// PKCS #11 token. The |callback| will be called when the dbus call
// completes. When the operation completes, the AsyncCallStatusHandler signal
// handler is called. |key_type| and |key_name| specify the key to register.
- // If |key_type| is KEY_USER, a |user_id| must be provided. Otherwise
- // |user_id| is ignored. For normal GAIA users the |user_id| is a canonical
- // email address.
+ // If |key_type| is KEY_USER, a |cryptohome_id| must be provided. Otherwise
+ // |cryptohome_id| is ignored.
virtual void TpmAttestationRegisterKey(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback) = 0;
@@ -393,12 +393,11 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// generated. |challenge| must be a valid enterprise attestation challenge.
// The |callback| will be called when the dbus call completes. When the
// operation completes, the AsyncCallStatusWithDataHandler signal handler is
- // called. If |key_type| is KEY_USER, a |user_id| must be provided.
- // Otherwise |user_id| is ignored. For normal GAIA users the |user_id| is a
- // canonical email address.
+ // called. If |key_type| is KEY_USER, a |cryptohome_id| must be provided.
+ // Otherwise |cryptohome_id| is ignored.
virtual void TpmAttestationSignEnterpriseChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& domain,
const std::string& device_id,
@@ -412,11 +411,11 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// cannot be used to sign arbitrary data. The |callback| will be called when
// the dbus call completes. When the operation completes, the
// AsyncCallStatusWithDataHandler signal handler is called. If |key_type| is
- // KEY_USER, a |user_id| must be provided. Otherwise |user_id| is ignored.
- // For normal GAIA users the |user_id| is a canonical email address.
+ // KEY_USER, a |cryptohome_id| must be provided. Otherwise |cryptohome_id|
+ // is ignored.
virtual void TpmAttestationSignSimpleChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& challenge,
const AsyncMethodCallback& callback) = 0;
@@ -426,23 +425,22 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// If the key does not exist the callback |result| parameter will be false.
// If no payload has been set for the key the callback |result| parameter will
// be true and the |data| parameter will be empty. If |key_type| is
- // KEY_USER, a |user_id| must be provided. Otherwise |user_id| is ignored.
- // For normal GAIA users the |user_id| is a canonical email address.
+ // KEY_USER, a |cryptohome_id| must be provided. Otherwise |cryptohome_id|
+ // is ignored.
virtual void TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) = 0;
// Sets the |payload| associated with the key specified by |key_type| and
// |key_name|. The |callback| will be called when the operation completes.
// If the operation succeeds, the callback |result| parameter will be true.
- // If |key_type| is KEY_USER, a |user_id| must be provided. Otherwise
- // |user_id| is ignored. For normal GAIA users the |user_id| is a canonical
- // email address.
+ // If |key_type| is KEY_USER, a |cryptohome_id| must be provided. Otherwise
+ // |cryptohome_id| is ignored.
virtual void TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& payload,
const BoolDBusMethodCallback& callback) = 0;
@@ -450,14 +448,14 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// Deletes certified keys as specified by |key_type| and |key_prefix|. The
// |callback| will be called when the operation completes. If the operation
// succeeds, the callback |result| parameter will be true. If |key_type| is
- // KEY_USER, a |user_id| must be provided. Otherwise |user_id| is ignored.
- // For normal GAIA users the |user_id| is a canonical email address. All keys
- // where the key name has a prefix matching |key_prefix| will be deleted. All
- // meta-data associated with the key, including certificates, will also be
- // deleted.
+ // KEY_USER, a |cryptohome_id| must be provided. Otherwise |cryptohome_id|
+ // is ignored.
+ // All keys where the key name has a prefix matching |key_prefix| will be
+ // deleted. All meta-data associated with the key, including certificates,
+ // will also be deleted.
virtual void TpmAttestationDeleteKeys(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_prefix,
const BoolDBusMethodCallback& callback) = 0;
@@ -466,56 +464,51 @@ class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
// GetKeyDataEx returns information about the key specified in |request|. At
// present, this does not include any secret information and the call should
// not be authenticated (|auth| should be empty).
- virtual void GetKeyDataEx(
- const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::GetKeyDataRequest& request,
- const ProtobufMethodCallback& callback) = 0;
+ virtual void GetKeyDataEx(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::GetKeyDataRequest& request,
+ const ProtobufMethodCallback& callback) = 0;
// Asynchronously calls CheckKeyEx method. |callback| is called after method
// call, and with reply protobuf.
// CheckKeyEx just checks if authorization information is valid.
- virtual void CheckKeyEx(
- const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::CheckKeyRequest& request,
- const ProtobufMethodCallback& callback) = 0;
+ virtual void CheckKeyEx(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::CheckKeyRequest& request,
+ const ProtobufMethodCallback& callback) = 0;
// Asynchronously calls MountEx method. |callback| is called after method
// call, and with reply protobuf.
// MountEx attempts to mount home dir using given authorization, and can
// create new home dir if necessary values are specified in |request|.
- virtual void MountEx(
- const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::MountRequest& request,
- const ProtobufMethodCallback& callback) = 0;
+ virtual void MountEx(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::MountRequest& request,
+ const ProtobufMethodCallback& callback) = 0;
// Asynchronously calls AddKeyEx method. |callback| is called after method
// call, and with reply protobuf.
// AddKeyEx adds another key to the given key set. |request| also defines
// behavior in case when key with specified label already exist.
- virtual void AddKeyEx(
- const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::AddKeyRequest& request,
- const ProtobufMethodCallback& callback) = 0;
+ virtual void AddKeyEx(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::AddKeyRequest& request,
+ const ProtobufMethodCallback& callback) = 0;
// Asynchronously calls UpdateKeyEx method. |callback| is called after method
// call, and with reply protobuf. Reply will contain MountReply extension.
// UpdateKeyEx replaces key used for authorization, without affecting any
// other keys. If specified at home dir creation time, new key may have
// to be signed and/or encrypted.
- virtual void UpdateKeyEx(
- const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::UpdateKeyRequest& request,
- const ProtobufMethodCallback& callback) = 0;
+ virtual void UpdateKeyEx(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::UpdateKeyRequest& request,
+ const ProtobufMethodCallback& callback) = 0;
// Asynchronously calls RemoveKeyEx method. |callback| is called after method
// call, and with reply protobuf.
// RemoveKeyEx removes key from the given key set.
- virtual void RemoveKeyEx(const cryptohome::AccountIdentifier& id,
+ virtual void RemoveKeyEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::RemoveKeyRequest& request,
const ProtobufMethodCallback& callback) = 0;
diff --git a/chromeos/dbus/fake_cryptohome_client.cc b/chromeos/dbus/fake_cryptohome_client.cc
index 236b1f9..2ae9197 100644
--- a/chromeos/dbus/fake_cryptohome_client.cc
+++ b/chromeos/dbus/fake_cryptohome_client.cc
@@ -73,14 +73,14 @@ bool FakeCryptohomeClient::Unmount(bool* success) {
}
void FakeCryptohomeClient::AsyncCheckKey(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key,
const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, false);
}
void FakeCryptohomeClient::AsyncMigrateKey(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const std::string& from_key,
const std::string& to_key,
const AsyncMethodCallback& callback) {
@@ -88,7 +88,7 @@ void FakeCryptohomeClient::AsyncMigrateKey(
}
void FakeCryptohomeClient::AsyncRemove(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, false);
}
@@ -101,30 +101,31 @@ void FakeCryptohomeClient::GetSystemSalt(
}
void FakeCryptohomeClient::GetSanitizedUsername(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const StringDBusMethodCallback& callback) {
// Even for stub implementation we have to return different values so that
// multi-profiles would work.
- std::string sanitized_username = GetStubSanitizedUsername(username);
+ std::string sanitized_username = GetStubSanitizedUsername(cryptohome_id);
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, sanitized_username));
}
std::string FakeCryptohomeClient::BlockingGetSanitizedUsername(
- const std::string& username) {
- return GetStubSanitizedUsername(username);
+ const cryptohome::Identification& cryptohome_id) {
+ return GetStubSanitizedUsername(cryptohome_id);
}
-void FakeCryptohomeClient::AsyncMount(const std::string& username,
- const std::string& key,
- int flags,
- const AsyncMethodCallback& callback) {
+void FakeCryptohomeClient::AsyncMount(
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& key,
+ int flags,
+ const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, false);
}
void FakeCryptohomeClient::AsyncAddKey(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key,
const std::string& new_key,
const AsyncMethodCallback& callback) {
@@ -137,7 +138,7 @@ void FakeCryptohomeClient::AsyncMountGuest(
}
void FakeCryptohomeClient::AsyncMountPublic(
- const std::string& public_mount_id,
+ const cryptohome::Identification& public_mount_id,
int flags,
const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, false);
@@ -228,7 +229,7 @@ void FakeCryptohomeClient::Pkcs11GetTpmTokenInfo(
}
void FakeCryptohomeClient::Pkcs11GetTpmTokenInfoForUser(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const Pkcs11GetTpmTokenInfoCallback& callback) {
Pkcs11GetTpmTokenInfo(callback);
}
@@ -360,7 +361,7 @@ void FakeCryptohomeClient::AsyncTpmAttestationEnroll(
void FakeCryptohomeClient::AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& request_origin,
const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, true);
@@ -369,7 +370,7 @@ void FakeCryptohomeClient::AsyncTpmAttestationCreateCertRequest(
void FakeCryptohomeClient::AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, true);
@@ -377,7 +378,7 @@ void FakeCryptohomeClient::AsyncTpmAttestationFinishCertRequest(
void FakeCryptohomeClient::TpmAttestationDoesKeyExist(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const BoolDBusMethodCallback& callback) {
base::MessageLoop::current()->PostTask(
@@ -386,7 +387,7 @@ void FakeCryptohomeClient::TpmAttestationDoesKeyExist(
void FakeCryptohomeClient::TpmAttestationGetCertificate(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) {
base::MessageLoop::current()->PostTask(
@@ -396,7 +397,7 @@ void FakeCryptohomeClient::TpmAttestationGetCertificate(
void FakeCryptohomeClient::TpmAttestationGetPublicKey(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) {
base::MessageLoop::current()->PostTask(
@@ -406,7 +407,7 @@ void FakeCryptohomeClient::TpmAttestationGetPublicKey(
void FakeCryptohomeClient::TpmAttestationRegisterKey(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback) {
ReturnAsyncMethodResult(callback, true);
@@ -414,7 +415,7 @@ void FakeCryptohomeClient::TpmAttestationRegisterKey(
void FakeCryptohomeClient::TpmAttestationSignEnterpriseChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& domain,
const std::string& device_id,
@@ -426,7 +427,7 @@ void FakeCryptohomeClient::TpmAttestationSignEnterpriseChallenge(
void FakeCryptohomeClient::TpmAttestationSignSimpleChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& challenge,
const AsyncMethodCallback& callback) {
@@ -435,7 +436,7 @@ void FakeCryptohomeClient::TpmAttestationSignSimpleChallenge(
void FakeCryptohomeClient::TpmAttestationGetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) {
base::MessageLoop::current()->PostTask(
@@ -445,7 +446,7 @@ void FakeCryptohomeClient::TpmAttestationGetKeyPayload(
void FakeCryptohomeClient::TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& payload,
const BoolDBusMethodCallback& callback) {
@@ -455,7 +456,7 @@ void FakeCryptohomeClient::TpmAttestationSetKeyPayload(
void FakeCryptohomeClient::TpmAttestationDeleteKeys(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_prefix,
const BoolDBusMethodCallback& callback) {
base::MessageLoop::current()->PostTask(
@@ -463,7 +464,7 @@ void FakeCryptohomeClient::TpmAttestationDeleteKeys(
}
void FakeCryptohomeClient::GetKeyDataEx(
- const cryptohome::AccountIdentifier& id,
+ const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::GetKeyDataRequest& request,
const ProtobufMethodCallback& callback) {
@@ -473,7 +474,7 @@ void FakeCryptohomeClient::GetKeyDataEx(
}
void FakeCryptohomeClient::CheckKeyEx(
- const cryptohome::AccountIdentifier& id,
+ const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::CheckKeyRequest& request,
const ProtobufMethodCallback& callback) {
@@ -482,19 +483,19 @@ void FakeCryptohomeClient::CheckKeyEx(
}
void FakeCryptohomeClient::MountEx(
- const cryptohome::AccountIdentifier& id,
+ const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::MountRequest& request,
const ProtobufMethodCallback& callback) {
cryptohome::BaseReply reply;
cryptohome::MountReply* mount =
reply.MutableExtension(cryptohome::MountReply::reply);
- mount->set_sanitized_username(GetStubSanitizedUsername(id.email()));
+ mount->set_sanitized_username(GetStubSanitizedUsername(cryptohome_id));
ReturnProtobufMethodCallback(reply, callback);
}
void FakeCryptohomeClient::AddKeyEx(
- const cryptohome::AccountIdentifier& id,
+ const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::AddKeyRequest& request,
const ProtobufMethodCallback& callback) {
@@ -503,7 +504,7 @@ void FakeCryptohomeClient::AddKeyEx(
}
void FakeCryptohomeClient::RemoveKeyEx(
- const cryptohome::AccountIdentifier& id,
+ const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::RemoveKeyRequest& request,
const ProtobufMethodCallback& callback) {
@@ -512,7 +513,7 @@ void FakeCryptohomeClient::RemoveKeyEx(
}
void FakeCryptohomeClient::UpdateKeyEx(
- const cryptohome::AccountIdentifier& id,
+ const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::UpdateKeyRequest& request,
const ProtobufMethodCallback& callback) {
diff --git a/chromeos/dbus/fake_cryptohome_client.h b/chromeos/dbus/fake_cryptohome_client.h
index 801faaf..20402dc 100644
--- a/chromeos/dbus/fake_cryptohome_client.h
+++ b/chromeos/dbus/fake_cryptohome_client.h
@@ -29,30 +29,30 @@ class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient {
const WaitForServiceToBeAvailableCallback& callback) override;
void IsMounted(const BoolDBusMethodCallback& callback) override;
bool Unmount(bool* success) override;
- void AsyncCheckKey(const std::string& username,
+ void AsyncCheckKey(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const AsyncMethodCallback& callback) override;
- void AsyncMigrateKey(const std::string& username,
+ void AsyncMigrateKey(const cryptohome::Identification& cryptohome_id,
const std::string& from_key,
const std::string& to_key,
const AsyncMethodCallback& callback) override;
- void AsyncRemove(const std::string& username,
+ void AsyncRemove(const cryptohome::Identification& cryptohome_id,
const AsyncMethodCallback& callback) override;
void GetSystemSalt(const GetSystemSaltCallback& callback) override;
- void GetSanitizedUsername(const std::string& username,
+ void GetSanitizedUsername(const cryptohome::Identification& cryptohome_id,
const StringDBusMethodCallback& callback) override;
std::string BlockingGetSanitizedUsername(
- const std::string& username) override;
- void AsyncMount(const std::string& username,
+ const cryptohome::Identification& cryptohome_id) override;
+ void AsyncMount(const cryptohome::Identification& cryptohome_id,
const std::string& key,
int flags,
const AsyncMethodCallback& callback) override;
- void AsyncAddKey(const std::string& username,
+ void AsyncAddKey(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const std::string& new_key,
const AsyncMethodCallback& callback) override;
void AsyncMountGuest(const AsyncMethodCallback& callback) override;
- void AsyncMountPublic(const std::string& public_mount_id,
+ void AsyncMountPublic(const cryptohome::Identification& public_mount_id,
int flags,
const AsyncMethodCallback& callback) override;
void TpmIsReady(const BoolDBusMethodCallback& callback) override;
@@ -70,7 +70,7 @@ class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient {
void Pkcs11GetTpmTokenInfo(
const Pkcs11GetTpmTokenInfoCallback& callback) override;
void Pkcs11GetTpmTokenInfoForUser(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const Pkcs11GetTpmTokenInfoCallback& callback) override;
bool InstallAttributesGet(const std::string& name,
std::vector<uint8_t>* value,
@@ -96,36 +96,38 @@ class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient {
void AsyncTpmAttestationCreateCertRequest(
chromeos::attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& request_origin,
const AsyncMethodCallback& callback) override;
void AsyncTpmAttestationFinishCertRequest(
const std::string& pca_response,
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback) override;
void TpmAttestationDoesKeyExist(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const BoolDBusMethodCallback& callback) override;
void TpmAttestationGetCertificate(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback) override;
- void TpmAttestationGetPublicKey(attestation::AttestationKeyType key_type,
- const std::string& user_id,
- const std::string& key_name,
- const DataMethodCallback& callback) override;
- void TpmAttestationRegisterKey(attestation::AttestationKeyType key_type,
- const std::string& user_id,
- const std::string& key_name,
- const AsyncMethodCallback& callback) override;
+ void TpmAttestationGetPublicKey(
+ attestation::AttestationKeyType key_type,
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& key_name,
+ const DataMethodCallback& callback) override;
+ void TpmAttestationRegisterKey(
+ attestation::AttestationKeyType key_type,
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& key_name,
+ const AsyncMethodCallback& callback) override;
void TpmAttestationSignEnterpriseChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& domain,
const std::string& device_id,
@@ -134,46 +136,47 @@ class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient {
const AsyncMethodCallback& callback) override;
void TpmAttestationSignSimpleChallenge(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& challenge,
const AsyncMethodCallback& callback) override;
- void TpmAttestationGetKeyPayload(attestation::AttestationKeyType key_type,
- const std::string& user_id,
- const std::string& key_name,
- const DataMethodCallback& callback) override;
+ void TpmAttestationGetKeyPayload(
+ attestation::AttestationKeyType key_type,
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& key_name,
+ const DataMethodCallback& callback) override;
void TpmAttestationSetKeyPayload(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& payload,
const BoolDBusMethodCallback& callback) override;
void TpmAttestationDeleteKeys(
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_prefix,
const BoolDBusMethodCallback& callback) override;
- void GetKeyDataEx(const cryptohome::AccountIdentifier& id,
+ void GetKeyDataEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::GetKeyDataRequest& request,
const ProtobufMethodCallback& callback) override;
- void CheckKeyEx(const cryptohome::AccountIdentifier& id,
+ void CheckKeyEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::CheckKeyRequest& request,
const ProtobufMethodCallback& callback) override;
- void MountEx(const cryptohome::AccountIdentifier& id,
+ void MountEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::MountRequest& request,
const ProtobufMethodCallback& callback) override;
- void AddKeyEx(const cryptohome::AccountIdentifier& id,
+ void AddKeyEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::AddKeyRequest& request,
const ProtobufMethodCallback& callback) override;
- void UpdateKeyEx(const cryptohome::AccountIdentifier& id,
+ void UpdateKeyEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::UpdateKeyRequest& request,
const ProtobufMethodCallback& callback) override;
- void RemoveKeyEx(const cryptohome::AccountIdentifier& id,
+ void RemoveKeyEx(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::RemoveKeyRequest& request,
const ProtobufMethodCallback& callback) override;
diff --git a/chromeos/dbus/fake_session_manager_client.cc b/chromeos/dbus/fake_session_manager_client.cc
index 77e8b37..e66b15b 100644
--- a/chromeos/dbus/fake_session_manager_client.cc
+++ b/chromeos/dbus/fake_session_manager_client.cc
@@ -50,11 +50,12 @@ void FakeSessionManagerClient::EmitLoginPromptVisible() {
void FakeSessionManagerClient::RestartJob(
const std::vector<std::string>& argv) {}
-void FakeSessionManagerClient::StartSession(const std::string& user_email) {
- DCHECK_EQ(0UL, user_sessions_.count(user_email));
+void FakeSessionManagerClient::StartSession(
+ const cryptohome::Identification& cryptohome_id) {
+ DCHECK_EQ(0UL, user_sessions_.count(cryptohome_id));
std::string user_id_hash =
- CryptohomeClient::GetStubSanitizedUsername(user_email);
- user_sessions_[user_email] = user_id_hash;
+ CryptohomeClient::GetStubSanitizedUsername(cryptohome_id);
+ user_sessions_[cryptohome_id] = user_id_hash;
}
void FakeSessionManagerClient::StopSession() {
@@ -94,15 +95,15 @@ void FakeSessionManagerClient::RetrieveDevicePolicy(
}
void FakeSessionManagerClient::RetrievePolicyForUser(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const RetrievePolicyCallback& callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(callback, user_policies_[username]));
+ FROM_HERE, base::Bind(callback, user_policies_[cryptohome_id]));
}
std::string FakeSessionManagerClient::BlockingRetrievePolicyForUser(
- const std::string& username) {
- return user_policies_[username];
+ const cryptohome::Identification& cryptohome_id) {
+ return user_policies_[cryptohome_id];
}
void FakeSessionManagerClient::RetrieveDeviceLocalAccountPolicy(
@@ -123,10 +124,10 @@ void FakeSessionManagerClient::StoreDevicePolicy(
}
void FakeSessionManagerClient::StorePolicyForUser(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) {
- user_policies_[username] = policy_blob;
+ user_policies_[cryptohome_id] = policy_blob;
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
base::Bind(callback, true));
}
@@ -141,9 +142,8 @@ void FakeSessionManagerClient::StoreDeviceLocalAccountPolicy(
}
void FakeSessionManagerClient::SetFlagsForUser(
- const std::string& username,
- const std::vector<std::string>& flags) {
-}
+ const cryptohome::Identification& cryptohome_id,
+ const std::vector<std::string>& flags) {}
void FakeSessionManagerClient::GetServerBackedStateKeys(
const StateKeysCallback& callback) {
@@ -178,15 +178,16 @@ void FakeSessionManagerClient::set_device_policy(
}
const std::string& FakeSessionManagerClient::user_policy(
- const std::string& username) const {
- std::map<std::string, std::string>::const_iterator it =
- user_policies_.find(username);
+ const cryptohome::Identification& cryptohome_id) const {
+ std::map<cryptohome::Identification, std::string>::const_iterator it =
+ user_policies_.find(cryptohome_id);
return it == user_policies_.end() ? base::EmptyString() : it->second;
}
-void FakeSessionManagerClient::set_user_policy(const std::string& username,
- const std::string& policy_blob) {
- user_policies_[username] = policy_blob;
+void FakeSessionManagerClient::set_user_policy(
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& policy_blob) {
+ user_policies_[cryptohome_id] = policy_blob;
}
const std::string& FakeSessionManagerClient::device_local_account_policy(
diff --git a/chromeos/dbus/fake_session_manager_client.h b/chromeos/dbus/fake_session_manager_client.h
index b281847..4150091 100644
--- a/chromeos/dbus/fake_session_manager_client.h
+++ b/chromeos/dbus/fake_session_manager_client.h
@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/observer_list.h"
+#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/session_manager_client.h"
namespace chromeos {
@@ -32,7 +33,7 @@ class FakeSessionManagerClient : public SessionManagerClient {
bool IsScreenLocked() const override;
void EmitLoginPromptVisible() override;
void RestartJob(const std::vector<std::string>& argv) override;
- void StartSession(const std::string& user_email) override;
+ void StartSession(const cryptohome::Identification& cryptohome_id) override;
void StopSession() override;
void NotifySupervisedUserCreationStarted() override;
void NotifySupervisedUserCreationFinished() override;
@@ -42,23 +43,23 @@ class FakeSessionManagerClient : public SessionManagerClient {
void NotifyLockScreenDismissed() override;
void RetrieveActiveSessions(const ActiveSessionsCallback& callback) override;
void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) override;
- void RetrievePolicyForUser(const std::string& username,
+ void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id,
const RetrievePolicyCallback& callback) override;
std::string BlockingRetrievePolicyForUser(
- const std::string& username) override;
+ const cryptohome::Identification& cryptohome_id) override;
void RetrieveDeviceLocalAccountPolicy(
const std::string& account_id,
const RetrievePolicyCallback& callback) override;
void StoreDevicePolicy(const std::string& policy_blob,
const StorePolicyCallback& callback) override;
- void StorePolicyForUser(const std::string& username,
+ void StorePolicyForUser(const cryptohome::Identification& cryptohome_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) override;
void StoreDeviceLocalAccountPolicy(
const std::string& account_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) override;
- void SetFlagsForUser(const std::string& username,
+ void SetFlagsForUser(const cryptohome::Identification& cryptohome_id,
const std::vector<std::string>& flags) override;
void GetServerBackedStateKeys(const StateKeysCallback& callback) override;
@@ -70,8 +71,9 @@ class FakeSessionManagerClient : public SessionManagerClient {
const std::string& device_policy() const;
void set_device_policy(const std::string& policy_blob);
- const std::string& user_policy(const std::string& username) const;
- void set_user_policy(const std::string& username,
+ const std::string& user_policy(
+ const cryptohome::Identification& cryptohome_id) const;
+ void set_user_policy(const cryptohome::Identification& cryptohome_id,
const std::string& policy_blob);
const std::string& device_local_account_policy(
@@ -105,7 +107,7 @@ class FakeSessionManagerClient : public SessionManagerClient {
private:
std::string device_policy_;
- std::map<std::string, std::string> user_policies_;
+ std::map<cryptohome::Identification, std::string> user_policies_;
std::map<std::string, std::string> device_local_account_policy_;
base::ObserverList<Observer> observers_;
SessionManagerClient::ActiveSessionsMap user_sessions_;
diff --git a/chromeos/dbus/mock_cryptohome_client.h b/chromeos/dbus/mock_cryptohome_client.h
index 4382d35..c4e166b 100644
--- a/chromeos/dbus/mock_cryptohome_client.h
+++ b/chromeos/dbus/mock_cryptohome_client.h
@@ -9,6 +9,7 @@
#include <string>
+#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/cryptohome/rpc.pb.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -30,35 +31,40 @@ class MockCryptohomeClient : public CryptohomeClient {
MOCK_METHOD1(IsMounted, void(const BoolDBusMethodCallback& callback));
MOCK_METHOD1(Unmount, bool(bool* success));
MOCK_METHOD3(AsyncCheckKey,
- void(const std::string& username,
+ void(const cryptohome::Identification& cryptohome_id,
const std::string& key,
const AsyncMethodCallback& callback));
MOCK_METHOD4(AsyncMigrateKey,
- void(const std::string& username,
+ void(const cryptohome::Identification& cryptohome_id,
const std::string& from_key,
const std::string& to_key,
const AsyncMethodCallback& callback));
- MOCK_METHOD2(AsyncRemove, void(const std::string& username,
- const AsyncMethodCallback& callback));
+ MOCK_METHOD2(AsyncRemove,
+ void(const cryptohome::Identification& cryptohome_id,
+ const AsyncMethodCallback& callback));
+
MOCK_METHOD1(GetSystemSalt, void(const GetSystemSaltCallback& callback));
MOCK_METHOD2(GetSanitizedUsername,
- void(const std::string& username,
+ void(const cryptohome::Identification& cryptohome_id,
const StringDBusMethodCallback& callback));
MOCK_METHOD1(BlockingGetSanitizedUsername,
- std::string(const std::string& username));
- MOCK_METHOD4(AsyncMount, void(const std::string& username,
- const std::string& key,
- int flags,
- const AsyncMethodCallback& callback));
- MOCK_METHOD4(AsyncAddKey, void(const std::string& username,
- const std::string& key,
- const std::string& new_key,
- const AsyncMethodCallback& callback));
+ std::string(const cryptohome::Identification& cryptohome_id));
+ MOCK_METHOD4(AsyncMount,
+ void(const cryptohome::Identification& cryptohome_id,
+ const std::string& key,
+ int flags,
+ const AsyncMethodCallback& callback));
+ MOCK_METHOD4(AsyncAddKey,
+ void(const cryptohome::Identification& cryptohome_id,
+ const std::string& key,
+ const std::string& new_key,
+ const AsyncMethodCallback& callback));
MOCK_METHOD1(AsyncMountGuest,
void(const AsyncMethodCallback& callback));
- MOCK_METHOD3(AsyncMountPublic, void(const std::string& public_mount_id,
- int flags,
- const AsyncMethodCallback& callback));
+ MOCK_METHOD3(AsyncMountPublic,
+ void(const cryptohome::Identification& public_mount_id,
+ int flags,
+ const AsyncMethodCallback& callback));
MOCK_METHOD1(TpmIsReady, void(const BoolDBusMethodCallback& callback));
MOCK_METHOD1(TpmIsEnabled, void(const BoolDBusMethodCallback& callback));
MOCK_METHOD1(CallTpmIsEnabledAndBlock, bool(bool* enabled));
@@ -77,7 +83,7 @@ class MockCryptohomeClient : public CryptohomeClient {
MOCK_METHOD1(Pkcs11GetTpmTokenInfo,
void(const Pkcs11GetTpmTokenInfoCallback& callback));
MOCK_METHOD2(Pkcs11GetTpmTokenInfoForUser,
- void(const std::string& username,
+ void(const cryptohome::Identification& cryptohome_id,
const Pkcs11GetTpmTokenInfoCallback& callback));
MOCK_METHOD3(InstallAttributesGet,
bool(const std::string& name,
@@ -107,38 +113,38 @@ class MockCryptohomeClient : public CryptohomeClient {
AsyncTpmAttestationCreateCertRequest,
void(attestation::PrivacyCAType pca_type,
attestation::AttestationCertificateProfile certificate_profile,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& request_origin,
const AsyncMethodCallback& callback));
MOCK_METHOD5(AsyncTpmAttestationFinishCertRequest,
void(const std::string& pca_response,
attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback));
MOCK_METHOD4(TpmAttestationDoesKeyExist,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const BoolDBusMethodCallback& callback));
MOCK_METHOD4(TpmAttestationGetCertificate,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback));
MOCK_METHOD4(TpmAttestationGetPublicKey,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback));
MOCK_METHOD4(TpmAttestationRegisterKey,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const AsyncMethodCallback& callback));
MOCK_METHOD8(TpmAttestationSignEnterpriseChallenge,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& domain,
const std::string& device_id,
@@ -147,53 +153,53 @@ class MockCryptohomeClient : public CryptohomeClient {
const AsyncMethodCallback& callback));
MOCK_METHOD5(TpmAttestationSignSimpleChallenge,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& challenge,
const AsyncMethodCallback& callback));
MOCK_METHOD4(TpmAttestationGetKeyPayload,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const DataMethodCallback& callback));
MOCK_METHOD5(TpmAttestationSetKeyPayload,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_name,
const std::string& payload,
const BoolDBusMethodCallback& callback));
MOCK_METHOD4(TpmAttestationDeleteKeys,
void(attestation::AttestationKeyType key_type,
- const std::string& user_id,
+ const cryptohome::Identification& cryptohome_id,
const std::string& key_prefix,
const BoolDBusMethodCallback& callback));
MOCK_METHOD4(GetKeyDataEx,
- void(const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::GetKeyDataRequest& request,
- const ProtobufMethodCallback& callback));
+ void(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::GetKeyDataRequest& request,
+ const ProtobufMethodCallback& callback));
MOCK_METHOD4(CheckKeyEx,
- void(const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::CheckKeyRequest& request,
- const ProtobufMethodCallback& callback));
+ void(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::CheckKeyRequest& request,
+ const ProtobufMethodCallback& callback));
MOCK_METHOD4(MountEx,
- void(const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::MountRequest& request,
- const ProtobufMethodCallback& callback));
+ void(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::MountRequest& request,
+ const ProtobufMethodCallback& callback));
MOCK_METHOD4(AddKeyEx,
- void(const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::AddKeyRequest& request,
- const ProtobufMethodCallback& callback));
+ void(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::AddKeyRequest& request,
+ const ProtobufMethodCallback& callback));
MOCK_METHOD4(UpdateKeyEx,
- void(const cryptohome::AccountIdentifier& id,
- const cryptohome::AuthorizationRequest& auth,
- const cryptohome::UpdateKeyRequest& request,
- const ProtobufMethodCallback& callback));
+ void(const cryptohome::Identification& cryptohome_id,
+ const cryptohome::AuthorizationRequest& auth,
+ const cryptohome::UpdateKeyRequest& request,
+ const ProtobufMethodCallback& callback));
MOCK_METHOD4(RemoveKeyEx,
- void(const cryptohome::AccountIdentifier& id,
+ void(const cryptohome::Identification& cryptohome_id,
const cryptohome::AuthorizationRequest& auth,
const cryptohome::RemoveKeyRequest& request,
const ProtobufMethodCallback& callback));
diff --git a/chromeos/dbus/mock_session_manager_client.h b/chromeos/dbus/mock_session_manager_client.h
index aec901a..dc7d095 100644
--- a/chromeos/dbus/mock_session_manager_client.h
+++ b/chromeos/dbus/mock_session_manager_client.h
@@ -7,6 +7,7 @@
#include <string>
+#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/session_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -25,7 +26,7 @@ class MockSessionManagerClient : public SessionManagerClient {
MOCK_CONST_METHOD0(IsScreenLocked, bool(void));
MOCK_METHOD0(EmitLoginPromptVisible, void(void));
MOCK_METHOD1(RestartJob, void(const std::vector<std::string>&));
- MOCK_METHOD1(StartSession, void(const std::string&));
+ MOCK_METHOD1(StartSession, void(const cryptohome::Identification&));
MOCK_METHOD0(StopSession, void(void));
MOCK_METHOD0(NotifySupervisedUserCreationStarted, void(void));
MOCK_METHOD0(NotifySupervisedUserCreationFinished, void(void));
@@ -36,9 +37,10 @@ class MockSessionManagerClient : public SessionManagerClient {
MOCK_METHOD1(RetrieveActiveSessions, void(const ActiveSessionsCallback&));
MOCK_METHOD1(RetrieveDevicePolicy, void(const RetrievePolicyCallback&));
MOCK_METHOD2(RetrievePolicyForUser,
- void(const std::string&,
+ void(const cryptohome::Identification&,
const RetrievePolicyCallback&));
- MOCK_METHOD1(BlockingRetrievePolicyForUser, std::string(const std::string&));
+ MOCK_METHOD1(BlockingRetrievePolicyForUser,
+ std::string(const cryptohome::Identification&));
MOCK_METHOD2(RetrieveDeviceLocalAccountPolicy,
void(const std::string&,
const RetrievePolicyCallback&));
@@ -46,7 +48,7 @@ class MockSessionManagerClient : public SessionManagerClient {
void(const std::string&,
const StorePolicyCallback&));
MOCK_METHOD3(StorePolicyForUser,
- void(const std::string&,
+ void(const cryptohome::Identification&,
const std::string&,
const StorePolicyCallback&));
MOCK_METHOD3(StoreDeviceLocalAccountPolicy,
@@ -54,7 +56,7 @@ class MockSessionManagerClient : public SessionManagerClient {
const std::string&,
const StorePolicyCallback&));
MOCK_METHOD2(SetFlagsForUser,
- void(const std::string&,
+ void(const cryptohome::Identification&,
const std::vector<std::string>&));
MOCK_METHOD1(GetServerBackedStateKeys, void(const StateKeysCallback&));
MOCK_METHOD1(CheckArcAvailability, void(const ArcCallback&));
diff --git a/chromeos/dbus/session_manager_client.cc b/chromeos/dbus/session_manager_client.cc
index dd9c13a..95559ea 100644
--- a/chromeos/dbus/session_manager_client.cc
+++ b/chromeos/dbus/session_manager_client.cc
@@ -20,6 +20,7 @@
#include "base/task_runner_util.h"
#include "base/threading/worker_pool.h"
#include "chromeos/chromeos_paths.h"
+#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/blocking_method_caller.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "crypto/sha2.h"
@@ -34,15 +35,16 @@ namespace chromeos {
namespace {
-// Returns a location for |file| that is specific to the given |username|.
+// Returns a location for |file| that is specific to the given |cryptohome_id|.
// These paths will be relative to DIR_USER_POLICY_KEYS, and can be used only
// to store stub files.
-base::FilePath GetUserFilePath(const std::string& username, const char* file) {
+base::FilePath GetUserFilePath(const cryptohome::Identification& cryptohome_id,
+ const char* file) {
base::FilePath keys_path;
if (!PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &keys_path))
return base::FilePath();
const std::string sanitized =
- CryptohomeClient::GetStubSanitizedUsername(username);
+ CryptohomeClient::GetStubSanitizedUsername(cryptohome_id);
return keys_path.AppendASCII(sanitized).AppendASCII(file);
}
@@ -153,11 +155,11 @@ class SessionManagerClientImpl : public SessionManagerClient {
false);
}
- void StartSession(const std::string& user_email) override {
+ void StartSession(const cryptohome::Identification& cryptohome_id) override {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
login_manager::kSessionManagerStartSession);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(user_email);
+ writer.AppendString(cryptohome_id.id());
writer.AppendString(""); // Unique ID is deprecated
session_manager_proxy_->CallMethod(
&method_call,
@@ -238,21 +240,20 @@ class SessionManagerClientImpl : public SessionManagerClient {
callback));
}
- void RetrievePolicyForUser(const std::string& username,
+ void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id,
const RetrievePolicyCallback& callback) override {
CallRetrievePolicyByUsername(
- login_manager::kSessionManagerRetrievePolicyForUser,
- username,
+ login_manager::kSessionManagerRetrievePolicyForUser, cryptohome_id.id(),
callback);
}
std::string BlockingRetrievePolicyForUser(
- const std::string& username) override {
+ const cryptohome::Identification& cryptohome_id) override {
dbus::MethodCall method_call(
login_manager::kSessionManagerInterface,
login_manager::kSessionManagerRetrievePolicyForUser);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
scoped_ptr<dbus::Response> response =
blocking_method_caller_->CallMethodAndBlock(&method_call);
std::string policy;
@@ -289,13 +290,11 @@ class SessionManagerClientImpl : public SessionManagerClient {
callback));
}
- void StorePolicyForUser(const std::string& username,
+ void StorePolicyForUser(const cryptohome::Identification& cryptohome_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) override {
CallStorePolicyByUsername(login_manager::kSessionManagerStorePolicyForUser,
- username,
- policy_blob,
- callback);
+ cryptohome_id.id(), policy_blob, callback);
}
void StoreDeviceLocalAccountPolicy(
@@ -309,12 +308,12 @@ class SessionManagerClientImpl : public SessionManagerClient {
callback);
}
- void SetFlagsForUser(const std::string& username,
+ void SetFlagsForUser(const cryptohome::Identification& cryptohome_id,
const std::vector<std::string>& flags) override {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
login_manager::kSessionManagerSetFlagsForUser);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(cryptohome_id.id());
writer.AppendArrayOfStrings(flags);
session_manager_proxy_->CallMethod(
&method_call,
@@ -423,12 +422,12 @@ class SessionManagerClientImpl : public SessionManagerClient {
// Helper for RetrieveDeviceLocalAccountPolicy and RetrievePolicyForUser.
void CallRetrievePolicyByUsername(const std::string& method_name,
- const std::string& username,
+ const std::string& account_id,
const RetrievePolicyCallback& callback) {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
method_name);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(account_id);
session_manager_proxy_->CallMethod(
&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
@@ -440,13 +439,13 @@ class SessionManagerClientImpl : public SessionManagerClient {
}
void CallStorePolicyByUsername(const std::string& method_name,
- const std::string& username,
+ const std::string& account_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) {
dbus::MethodCall method_call(login_manager::kSessionManagerInterface,
method_name);
dbus::MessageWriter writer(&method_call);
- writer.AppendString(username);
+ writer.AppendString(account_id);
// static_cast does not work due to signedness.
writer.AppendArrayOfBytes(
reinterpret_cast<const uint8_t*>(policy_blob.data()),
@@ -544,7 +543,7 @@ class SessionManagerClientImpl : public SessionManagerClient {
LOG(ERROR) << method_name << " response is incorrect: "
<< response->ToString();
} else {
- sessions[key] = value;
+ sessions[cryptohome::Identification::FromString(key)] = value;
}
}
success = true;
@@ -741,7 +740,7 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
bool IsScreenLocked() const override { return screen_is_locked_; }
void EmitLoginPromptVisible() override {}
void RestartJob(const std::vector<std::string>& argv) override {}
- void StartSession(const std::string& user_email) override {}
+ void StartSession(const cryptohome::Identification& cryptohome_id) override {}
void StopSession() override {}
void NotifySupervisedUserCreationStarted() override {}
void NotifySupervisedUserCreationFinished() override {}
@@ -774,22 +773,23 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
base::Bind(&GetFileContent, device_policy_path),
callback);
}
- void RetrievePolicyForUser(const std::string& username,
+ void RetrievePolicyForUser(const cryptohome::Identification& cryptohome_id,
const RetrievePolicyCallback& callback) override {
base::PostTaskAndReplyWithResult(
- base::WorkerPool::GetTaskRunner(false).get(),
- FROM_HERE,
- base::Bind(&GetFileContent, GetUserFilePath(username, "stub_policy")),
+ base::WorkerPool::GetTaskRunner(false).get(), FROM_HERE,
+ base::Bind(&GetFileContent,
+ GetUserFilePath(cryptohome_id, "stub_policy")),
callback);
}
std::string BlockingRetrievePolicyForUser(
- const std::string& username) override {
- return GetFileContent(GetUserFilePath(username, "stub_policy"));
+ const cryptohome::Identification& cryptohome_id) override {
+ return GetFileContent(GetUserFilePath(cryptohome_id, "stub_policy"));
}
void RetrieveDeviceLocalAccountPolicy(
- const std::string& account_name,
+ const std::string& account_id,
const RetrievePolicyCallback& callback) override {
- RetrievePolicyForUser(account_name, callback);
+ RetrievePolicyForUser(cryptohome::Identification::FromString(account_id),
+ callback);
}
void StoreDevicePolicy(const std::string& policy_blob,
const StorePolicyCallback& callback) override {
@@ -821,7 +821,7 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
base::Bind(callback, true),
false);
}
- void StorePolicyForUser(const std::string& username,
+ void StorePolicyForUser(const cryptohome::Identification& cryptohome_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) override {
// The session manager writes the user policy key to a well-known
@@ -834,7 +834,7 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
}
if (response.has_new_public_key()) {
- base::FilePath key_path = GetUserFilePath(username, "policy.pub");
+ base::FilePath key_path = GetUserFilePath(cryptohome_id, "policy.pub");
base::WorkerPool::PostTask(
FROM_HERE,
base::Bind(&StoreFile, key_path, response.new_public_key()),
@@ -843,7 +843,8 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
// This file isn't read directly by Chrome, but is used by this class to
// reload the user policy across restarts.
- base::FilePath stub_policy_path = GetUserFilePath(username, "stub_policy");
+ base::FilePath stub_policy_path =
+ GetUserFilePath(cryptohome_id, "stub_policy");
base::WorkerPool::PostTaskAndReply(
FROM_HERE,
base::Bind(&StoreFile, stub_policy_path, policy_blob),
@@ -851,12 +852,13 @@ class SessionManagerClientStubImpl : public SessionManagerClient {
false);
}
void StoreDeviceLocalAccountPolicy(
- const std::string& account_name,
+ const std::string& account_id,
const std::string& policy_blob,
const StorePolicyCallback& callback) override {
- StorePolicyForUser(account_name, policy_blob, callback);
+ StorePolicyForUser(cryptohome::Identification::FromString(account_id),
+ policy_blob, callback);
}
- void SetFlagsForUser(const std::string& username,
+ void SetFlagsForUser(const cryptohome::Identification& cryptohome_id,
const std::vector<std::string>& flags) override {}
void GetServerBackedStateKeys(const StateKeysCallback& callback) override {
diff --git a/chromeos/dbus/session_manager_client.h b/chromeos/dbus/session_manager_client.h
index 4fd4c09..d0e3566 100644
--- a/chromeos/dbus/session_manager_client.h
+++ b/chromeos/dbus/session_manager_client.h
@@ -16,6 +16,10 @@
#include "chromeos/dbus/dbus_client.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
+namespace cryptohome {
+class Identification;
+}
+
namespace chromeos {
// SessionManagerClient is used to communicate with the session manager.
@@ -78,7 +82,8 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
virtual void RestartJob(const std::vector<std::string>& argv) = 0;
// Starts the session for the user.
- virtual void StartSession(const std::string& user_email) = 0;
+ virtual void StartSession(
+ const cryptohome::Identification& cryptohome_id) = 0;
// Stops the current session.
virtual void StopSession() = 0;
@@ -102,19 +107,19 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
virtual void NotifySupervisedUserCreationFinished() = 0;
// Map that is used to describe the set of active user sessions where |key|
- // is user_id and |value| is user_id_hash.
- typedef std::map<std::string, std::string> ActiveSessionsMap;
+ // is cryptohome id and |value| is user_id_hash.
+ using ActiveSessionsMap = std::map<cryptohome::Identification, std::string>;
// The ActiveSessionsCallback is used for the RetrieveActiveSessions()
- // method. It receives |sessions| argument where the keys are user_ids for
- // all users that are currently active and |success| argument which indicates
- // whether or not the request succeded.
+ // method. It receives |sessions| argument where the keys are cryptohome_ids
+ // for all users that are currently active and |success| argument which
+ // indicates whether or not the request succeded.
typedef base::Callback<void(const ActiveSessionsMap& sessions,
bool success)> ActiveSessionsCallback;
// Enumerates active user sessions. Usually Chrome naturally keeps track of
// active users when they are added into current session. When Chrome is
- // restarted after crash by session_manager it only receives user_id and
+ // restarted after crash by session_manager it only receives cryptohome id and
// user_id_hash for one user. This method is used to retrieve list of all
// active users.
virtual void RetrieveActiveSessions(
@@ -131,10 +136,10 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0;
// Fetches the user policy blob stored by the session manager for the given
- // |username|. Upon completion of the retrieve attempt, we will call the
+ // |cryptohome_id|. Upon completion of the retrieve attempt, we will call the
// provided callback.
virtual void RetrievePolicyForUser(
- const std::string& username,
+ const cryptohome::Identification& cryptohome_id,
const RetrievePolicyCallback& callback) = 0;
// Same as RetrievePolicyForUser() but blocks until a reply is received, and
@@ -144,7 +149,7 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
// considered acceptable (e.g. restarting the browser after a crash or after
// a flag change).
virtual std::string BlockingRetrievePolicyForUser(
- const std::string& username) = 0;
+ const cryptohome::Identification& cryptohome_id) = 0;
// Fetches the policy blob associated with the specified device-local account
// from session manager. |callback| is invoked up on completion.
@@ -162,11 +167,13 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
virtual void StoreDevicePolicy(const std::string& policy_blob,
const StorePolicyCallback& callback) = 0;
- // Attempts to asynchronously store |policy_blob| as user policy for the given
- // |username|. Upon completion of the store attempt, we will call callback.
- virtual void StorePolicyForUser(const std::string& username,
- const std::string& policy_blob,
- const StorePolicyCallback& callback) = 0;
+ // Attempts to asynchronously store |policy_blob| as user policy for the
+ // given |cryptohome_id|. Upon completion of the store attempt, we will call
+ // callback.
+ virtual void StorePolicyForUser(
+ const cryptohome::Identification& cryptohome_id,
+ const std::string& policy_blob,
+ const StorePolicyCallback& callback) = 0;
// Sends a request to store a policy blob for the specified device-local
// account. The result of the operation is reported through |callback|.
@@ -177,7 +184,7 @@ class CHROMEOS_EXPORT SessionManagerClient : public DBusClient {
// Sets the flags to be applied next time by the session manager when Chrome
// is restarted inside an already started session for a particular user.
- virtual void SetFlagsForUser(const std::string& username,
+ virtual void SetFlagsForUser(const cryptohome::Identification& cryptohome_id,
const std::vector<std::string>& flags) = 0;
typedef base::Callback<void(const std::vector<std::string>& state_keys)>