summaryrefslogtreecommitdiffstats
path: root/components/ownership
diff options
context:
space:
mode:
authornasko <nasko@chromium.org>2014-09-12 11:21:49 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-12 18:30:31 +0000
commit1d9925fdc873e99328ba6524d1600da678a9e306 (patch)
treea7aef61eefa971e3f10c61ada545a3877a627615 /components/ownership
parent445ee792be6efa64d9da2c67b05a7ec0c01c65dd (diff)
downloadchromium_src-1d9925fdc873e99328ba6524d1600da678a9e306.zip
chromium_src-1d9925fdc873e99328ba6524d1600da678a9e306.tar.gz
chromium_src-1d9925fdc873e99328ba6524d1600da678a9e306.tar.bz2
Revert of Non-plafrom-specific part of an OwnerSettingsService is moved to components/ownership/*. (patchset #4 id:60001 of https://codereview.chromium.org/548323003/)
Reason for revert: Breaks compile on multiple bots: http://build.chromium.org/p/chromium.win/builders/Win%20Builder%20%28dbg%29/builds/3134 http://build.chromium.org/p/chromium.mac/builders/Mac%20Builder%20%28dbg%29/builds/73424 http://build.chromium.org/p/chromium.webkit/builders/GPU%20Win%20Builder%20%28dbg%29/builds/13365 Original issue's description: > Non-plafrom-specific part of an OwnerSettingsService is moved to components/ownership/*. > > BUG=398856 > TEST=existing browser_tests and unit_tests > R=erg@chromium.org, jochen@chromium.org, nkostylev@chromium.org, pastarmovj@chromium.org > > Committed: https://chromium.googlesource.com/chromium/src/+/46a58bffbe303d3484d7cc288b47bfae5388109c TBR=jochen@chromium.org,erg@chromium.org,nkostylev@chromium.org,pastarmovj@chromium.org,ygorshenin@chromium.org NOTREECHECKS=true NOTRY=true BUG=398856 Review URL: https://codereview.chromium.org/565293003 Cr-Commit-Position: refs/heads/master@{#294618}
Diffstat (limited to 'components/ownership')
-rw-r--r--components/ownership/BUILD.gn4
-rw-r--r--components/ownership/DEPS2
-rw-r--r--components/ownership/owner_settings_service.cc118
-rw-r--r--components/ownership/owner_settings_service.h102
4 files changed, 0 insertions, 226 deletions
diff --git a/components/ownership/BUILD.gn b/components/ownership/BUILD.gn
index 5ef09b2..067f71f 100644
--- a/components/ownership/BUILD.gn
+++ b/components/ownership/BUILD.gn
@@ -10,8 +10,6 @@ component("ownership") {
"owner_key_util.h",
"owner_key_util_impl.cc",
"owner_key_util_impl.h",
- "owner_settings_service.cc",
- "owner_settings_service.h",
]
defines = [
@@ -20,8 +18,6 @@ component("ownership") {
deps = [
"//base",
- "//components/keyed_service/core",
- "//components/policy/proto",
"//crypto",
]
}
diff --git a/components/ownership/DEPS b/components/ownership/DEPS
index 719e7d0..bc55362 100644
--- a/components/ownership/DEPS
+++ b/components/ownership/DEPS
@@ -1,5 +1,3 @@
include_rules = [
-"+components/keyed_service",
"+crypto",
-"+policy",
]
diff --git a/components/ownership/owner_settings_service.cc b/components/ownership/owner_settings_service.cc
deleted file mode 100644
index 09c88d3..0000000
--- a/components/ownership/owner_settings_service.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/ownership/owner_settings_service.h"
-
-#include "base/basictypes.h"
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "base/task_runner.h"
-#include "base/task_runner_util.h"
-#include "components/ownership/owner_key_util.h"
-#include "crypto/signature_creator.h"
-
-namespace em = enterprise_management;
-
-namespace ownership {
-
-namespace {
-
-std::string AssembleAndSignPolicy(scoped_ptr<em::PolicyData> policy,
- crypto::RSAPrivateKey* private_key) {
- // Assemble the policy.
- em::PolicyFetchResponse policy_response;
- if (!policy->SerializeToString(policy_response.mutable_policy_data())) {
- LOG(ERROR) << "Failed to encode policy payload.";
- return std::string();
- }
-
- // Generate the signature.
- scoped_ptr<crypto::SignatureCreator> signature_creator(
- crypto::SignatureCreator::Create(private_key));
- signature_creator->Update(
- reinterpret_cast<const uint8*>(policy_response.policy_data().c_str()),
- policy_response.policy_data().size());
- std::vector<uint8> signature_bytes;
- std::string policy_blob;
- if (!signature_creator->Final(&signature_bytes)) {
- LOG(ERROR) << "Failed to create policy signature.";
- return std::string();
- }
-
- policy_response.mutable_policy_data_signature()->assign(
- reinterpret_cast<const char*>(vector_as_array(&signature_bytes)),
- signature_bytes.size());
- return policy_response.SerializeAsString();
-}
-
-} // namepace
-
-OwnerSettingsService::OwnerSettingsService(
- const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util)
- : owner_key_util_(owner_key_util), weak_factory_(this) {
-}
-
-OwnerSettingsService::~OwnerSettingsService() {
- DCHECK(thread_checker_.CalledOnValidThread());
-}
-
-bool OwnerSettingsService::IsOwner() {
- DCHECK(thread_checker_.CalledOnValidThread());
- return private_key_.get() && private_key_->key();
-}
-
-void OwnerSettingsService::IsOwnerAsync(const IsOwnerCallback& callback) {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (private_key_.get()) {
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, IsOwner()));
- } else {
- pending_is_owner_callbacks_.push_back(callback);
- }
-}
-
-bool OwnerSettingsService::AssembleAndSignPolicyAsync(
- base::TaskRunner* task_runner,
- scoped_ptr<em::PolicyData> policy,
- const AssembleAndSignPolicyAsyncCallback& callback) {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!task_runner || !IsOwner())
- return false;
- return base::PostTaskAndReplyWithResult(
- task_runner,
- FROM_HERE,
- base::Bind(
- &AssembleAndSignPolicy, base::Passed(&policy), private_key_->key()),
- callback);
-}
-
-void OwnerSettingsService::ReloadKeypair() {
- ReloadKeypairImpl(
- base::Bind(&OwnerSettingsService::OnKeypairLoaded, as_weak_ptr()));
-}
-
-void OwnerSettingsService::OnKeypairLoaded(
- const scoped_refptr<PublicKey>& public_key,
- const scoped_refptr<PrivateKey>& private_key) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- public_key_ = public_key;
- private_key_ = private_key;
-
- const bool is_owner = IsOwner();
- std::vector<IsOwnerCallback> is_owner_callbacks;
- is_owner_callbacks.swap(pending_is_owner_callbacks_);
- for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin());
- it != is_owner_callbacks.end();
- ++it) {
- it->Run(is_owner);
- }
-
- OnPostKeypairLoadedActions();
-}
-
-} // namespace ownership
diff --git a/components/ownership/owner_settings_service.h b/components/ownership/owner_settings_service.h
deleted file mode 100644
index ed4a1b5..0000000
--- a/components/ownership/owner_settings_service.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_
-#define COMPONENTS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_
-
-#include <string>
-#include <vector>
-
-#include "base/callback_forward.h"
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/thread_checker.h"
-#include "components/keyed_service/core/keyed_service.h"
-#include "components/ownership/ownership_export.h"
-#include "policy/proto/device_management_backend.pb.h"
-
-namespace base {
-class TaskRunner;
-}
-
-namespace ownership {
-class OwnerKeyUtil;
-class PrivateKey;
-class PublicKey;
-
-// This class is a common interface for platform-specific classes
-// which deal with ownership, keypairs and owner-related settings.
-class OWNERSHIP_EXPORT OwnerSettingsService : public KeyedService {
- public:
- typedef base::Callback<void(std::string policy_blob)>
- AssembleAndSignPolicyAsyncCallback;
-
- typedef base::Callback<void(bool is_owner)> IsOwnerCallback;
-
- explicit OwnerSettingsService(
- const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util);
- virtual ~OwnerSettingsService();
-
- base::WeakPtr<OwnerSettingsService> as_weak_ptr() {
- return weak_factory_.GetWeakPtr();
- }
-
- // Returns whether current user is owner or not. When this method
- // is called too early, incorrect result can be returned because
- // private key loading may be in progress.
- bool IsOwner();
-
- // Determines whether current user is owner or not, responds via
- // |callback|.
- void IsOwnerAsync(const IsOwnerCallback& callback);
-
- // Assembles and signs |policy| on the |task_runner|, responds on
- // the original thread via |callback|.
- bool AssembleAndSignPolicyAsync(
- base::TaskRunner* task_runner,
- scoped_ptr<enterprise_management::PolicyData> policy,
- const AssembleAndSignPolicyAsyncCallback& callback);
-
- // Signs |settings| with the private half of the owner key and sends
- // the resulting policy blob for storage. The
- // result of the operation is reported through |callback|.
- virtual void SignAndStorePolicyAsync(
- scoped_ptr<enterprise_management::PolicyData> policy,
- const base::Closure& callback) = 0;
-
- protected:
- void ReloadKeypair();
-
- void OnKeypairLoaded(const scoped_refptr<PublicKey>& public_key,
- const scoped_refptr<PrivateKey>& private_key);
-
- // Platform-specific keypair loading algorithm.
- virtual void ReloadKeypairImpl(const base::Callback<
- void(const scoped_refptr<PublicKey>& public_key,
- const scoped_refptr<PrivateKey>& private_key)>& callback) = 0;
-
- // Plafrom-specific actions which should be performed when keypair is loaded.
- virtual void OnPostKeypairLoadedActions() = 0;
-
- scoped_refptr<ownership::PublicKey> public_key_;
-
- scoped_refptr<ownership::PrivateKey> private_key_;
-
- scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_;
-
- std::vector<IsOwnerCallback> pending_is_owner_callbacks_;
-
- base::ThreadChecker thread_checker_;
-
- private:
- base::WeakPtrFactory<OwnerSettingsService> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(OwnerSettingsService);
-};
-
-} // namespace ownership
-
-#endif // COMPONENTS_OWNERSHIP_OWNER_SETTINGS_SERVICE_H_