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

Side by Side Diff: remoting/host/self_access_verifier.cc

Issue 8662001: Remove AccessVerifier interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/self_access_verifier.h ('k') | remoting/host/self_access_verifier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/host/self_access_verifier.h"
6
7 #include "base/logging.h"
8 #include "base/string_util.h"
9 #include "remoting/host/host_config.h"
10
11 namespace remoting {
12
13 SelfAccessVerifier::SelfAccessVerifier()
14 : initialized_(false) {
15 }
16
17 SelfAccessVerifier::~SelfAccessVerifier() { }
18
19 bool SelfAccessVerifier::Init(HostConfig* config) {
20 std::string host_jid;
21
22 if (!config->GetString(kXmppLoginConfigPath, &host_jid) ||
23 host_jid.empty()) {
24 LOG(ERROR) << "XMPP credentials are not defined in the config.";
25 return false;
26 }
27
28 host_jid_prefix_ = host_jid + '/';
29 initialized_ = true;
30
31 return true;
32 }
33
34 bool SelfAccessVerifier::VerifyPermissions(
35 const std::string& client_jid,
36 const std::string& encoded_access_token) {
37 CHECK(initialized_);
38
39 // Reject incoming connection if the client's jid is not an ASCII string.
40 if (!IsStringASCII(client_jid)) {
41 LOG(ERROR) << "Rejecting incoming connection from " << client_jid;
42 return false;
43 }
44
45 // Check that the client has the same bare jid as the host, i.e.
46 // client's full JID starts with host's bare jid. Comparison is case
47 // insensitive.
48 if (!StartsWithASCII(client_jid, host_jid_prefix_, false)) {
49 LOG(ERROR) << "Rejecting incoming connection from " << client_jid;
50 return false;
51 }
52
53 // Kick off directory access permissions.
54 // TODO(ajwong): Actually implement this.
55 return true;
56 }
57
58 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/self_access_verifier.h ('k') | remoting/host/self_access_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698