OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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/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 AccessVerifier::AccessVerifier() |
| 14 : initialized_(false) { |
| 15 } |
| 16 |
| 17 bool AccessVerifier::Init(HostConfig* config) { |
| 18 std::string host_jid; |
| 19 |
| 20 if (!config->GetString(kXmppLoginConfigPath, &host_jid) || |
| 21 host_jid.empty()) { |
| 22 LOG(ERROR) << "XMPP credentials are not defined in the config."; |
| 23 return false; |
| 24 } |
| 25 |
| 26 host_jid_prefix_ = host_jid + '/'; |
| 27 initialized_ = true; |
| 28 |
| 29 return true; |
| 30 } |
| 31 |
| 32 bool AccessVerifier::VerifyPermissions(const std::string& client_jid) { |
| 33 CHECK(initialized_); |
| 34 // Check that the client has the same bare jid as the host, i.e. |
| 35 // client's full jid starts with host's bare jid. |
| 36 return StartsWithASCII(client_jid, host_jid_prefix_, true); |
| 37 } |
| 38 |
| 39 } // namespace remoting |
OLD | NEW |