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

Unified Diff: examples/echo/echo_server.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: Default blessings Created 5 years, 5 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: examples/echo/echo_server.cc
diff --git a/examples/echo/echo_server.cc b/examples/echo/echo_server.cc
index 6ff79a68826c38f04029bd8db85b2ddab5eb4a79..3eaf81f7190656969a1467d3cd99d4cd948e1710 100644
--- a/examples/echo/echo_server.cc
+++ b/examples/echo/echo_server.cc
@@ -7,9 +7,12 @@
#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_impl.h"
#include "mojo/public/cpp/application/application_runner.h"
#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "mojo/public/cpp/utility/run_loop.h"
+#include "mojo/services/vanadium/security/public/interfaces/principal.mojom.h"
namespace mojo {
namespace examples {
@@ -48,15 +51,30 @@ class StrongBindingEchoImpl : public EchoImpl {
mojo::StrongBinding<Echo> strong_binding_;
};
+class GetBlessingResponse {
+ public:
+ void Run(const BlessingPtr& b) const {
+ // EchoClient user available in b.get()->chain[0]->extension
ataly 2015/07/31 19:04:04 MInor: Should we just say "user identity available
gauthamt 2015/07/31 20:24:16 Done.
+ RunLoop::current()->Quit();
+ }
+};
+
// MultiServer creates a new object to handle each message pipe.
class MultiServer : public mojo::ApplicationDelegate,
public mojo::InterfaceFactory<Echo> {
public:
MultiServer() {}
+ void Initialize(ApplicationImpl* app) override {
+ app->ConnectToService("mojo:go_principal_service", &login_service_);
+ }
+
// From ApplicationDelegate
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override {
+ AppNamePtr app(AppName::New());
+ app->url = connection->GetRemoteApplicationURL();
+ login_service_->GetUserBlessing(app.Pass(), GetBlessingResponse());
connection->AddService<Echo>(this);
return true;
}
@@ -68,6 +86,9 @@ class MultiServer : public mojo::ApplicationDelegate,
// StrongBinding<> for the declaration of |strong_binding_|.
new StrongBindingEchoImpl(request.Pass());
}
+
+ private:
+ PrincipalServicePtr login_service_;
};
// SingletonServer uses the same object to handle all message pipes. Useful

Powered by Google App Engine
This is Rietveld 408576698