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

Unified Diff: services/vanadium/security/principal_service.cc

Issue 1261403003: Initial skeletal implementation of the PrincipalService. Also, use the Login()/GetUserBlessing() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: minor logging fixes Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/vanadium/security/principal_service.cc
diff --git a/services/vanadium/security/principal_service.cc b/services/vanadium/security/principal_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..815a8780381fa26f20ed23bafabaa9f8c3be9e84
--- /dev/null
+++ b/services/vanadium/security/principal_service.cc
@@ -0,0 +1,75 @@
+// Copyright 2015 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 <cstdlib>
jamesr 2015/08/17 21:38:22 we generally use the <blahblah.h> headers instead
gautham 2015/08/18 01:54:22 Removed file.
+
+#include "mojo/common/binding_set.h"
+#include "mojo/public/c/system/main.h"
+#include "mojo/public/cpp/application/application_connection.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/application_runner.h"
+#include "mojo/public/cpp/application/interface_factory.h"
+#include "mojo/services/vanadium/security/public/interfaces/principal.mojom.h"
+
+namespace mojo {
jamesr 2015/08/17 21:38:22 no "mojo". namespace should match directory struct
gautham 2015/08/18 01:54:22 Removed file.
+namespace services {
+namespace vanadium {
+namespace security {
+
+// This is a native Mojo application which implements |PrincipalService|
+// interface for Linux.
jamesr 2015/08/17 21:38:22 what about this is Linux-specific?
gautham 2015/08/18 01:54:22 Removed file.
+class PrincipalServiceImpl : public ApplicationDelegate,
+ public PrincipalService,
+ public InterfaceFactory<PrincipalService> {
+ public:
+ PrincipalServiceImpl() {
+ CertificatePtr cert(Certificate::New());
+ cert->extension = "default";
+ default_blessing_.chain.push_back(cert.Pass());
+ }
+
+ void Login(const LoginCallback& callback) override {
+ callback.Run(default_blessing_.Clone());
+ }
+
+ void Logout() override {
+ }
+
+ void Sign(mojo::Array<uint8_t> message,
+ const SignCallback& callback) override {
+ }
+
+ void GetUserBlessing(AppInstanceNamePtr app,
+ const GetUserBlessingCallback& callback) override {
+ callback.Run(default_blessing_.Clone());
+ }
+
+ // |ApplicationDelegate| override.
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override {
+ connection->AddService<mojo::PrincipalService>(this);
jamesr 2015/08/17 21:38:22 you don't need to spell out the template parameter
gautham 2015/08/18 01:54:22 Removed file.
+ return true;
+ }
+
+ // |InterfaceFactory<PrincipalService>| implementation.
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::PrincipalService> request) override {
+ binding_.AddBinding(this, request.Pass());
+ }
+
+ private:
+ mojo::BindingSet<mojo::PrincipalService> binding_;
jamesr 2015/08/17 21:38:22 this means every connection to the PrincipalServic
gautham 2015/08/18 01:54:22 Removed file.
+ mojo::Blessing default_blessing_;
+};
+
+} // namespace security
+} // namespace vanadium
+} // namespace services
+} // namespace mojo
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunner runner(
+ new mojo::services::vanadium::security::PrincipalServiceImpl());
+ return runner.Run(application_request);
+}

Powered by Google App Engine
This is Rietveld 408576698