OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/access_verifier.h" | 5 #include "remoting/host/access_verifier.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "remoting/host/host_config.h" | 9 #include "remoting/host/host_config.h" |
10 #include "remoting/proto/auth.pb.h" | 10 #include "remoting/proto/auth.pb.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 host_jid_prefix_ = host_jid + '/'; | 27 host_jid_prefix_ = host_jid + '/'; |
28 initialized_ = true; | 28 initialized_ = true; |
29 | 29 |
30 return true; | 30 return true; |
31 } | 31 } |
32 | 32 |
33 bool AccessVerifier::VerifyPermissions( | 33 bool AccessVerifier::VerifyPermissions( |
34 const std::string& client_jid, | 34 const std::string& client_jid, |
35 const std::string& encoded_access_token) { | 35 const std::string& encoded_access_token) { |
36 CHECK(initialized_); | 36 CHECK(initialized_); |
37 // Check that the client has the same bare jid as the host, i.e. | 37 |
38 // client's full jid starts with host's bare jid. | 38 // Reject incoming connection if the client's jid is not an ASCII string. |
39 if (!StartsWithASCII(client_jid, host_jid_prefix_, true)) { | 39 if (!IsStringASCII(client_jid)) { |
| 40 LOG(ERROR) << "Rejecting incoming connection from " << client_jid; |
40 return false; | 41 return false; |
41 } | 42 } |
42 | 43 |
| 44 // Check that the client has the same bare jid as the host, i.e. |
| 45 // client's full JID starts with host's bare jid. Comparison is case |
| 46 // insensitive. |
| 47 if (!StartsWithASCII(client_jid, host_jid_prefix_, false)) { |
| 48 LOG(ERROR) << "Rejecting incoming connection from " << client_jid; |
| 49 return false; |
| 50 } |
| 51 |
43 // Decode the auth token. | 52 // Decode the auth token. |
44 protocol::ClientAuthToken client_token; | 53 protocol::ClientAuthToken client_token; |
45 if (!DecodeClientAuthToken(encoded_access_token, &client_token)) { | 54 if (!DecodeClientAuthToken(encoded_access_token, &client_token)) { |
46 return false; | 55 return false; |
47 } | 56 } |
48 | 57 |
49 // Kick off directory access permissions. | 58 // Kick off directory access permissions. |
50 // TODO(ajwong): Actually implement this. | 59 // TODO(ajwong): Actually implement this. |
51 return true; | 60 return true; |
52 } | 61 } |
53 | 62 |
54 bool AccessVerifier::DecodeClientAuthToken( | 63 bool AccessVerifier::DecodeClientAuthToken( |
55 const std::string& encoded_client_token, | 64 const std::string& encoded_client_token, |
56 protocol::ClientAuthToken* client_token) { | 65 protocol::ClientAuthToken* client_token) { |
57 // TODO(ajwong): Implement this. | 66 // TODO(ajwong): Implement this. |
58 NOTIMPLEMENTED(); | 67 NOTIMPLEMENTED(); |
59 return true; | 68 return true; |
60 } | 69 } |
61 | 70 |
62 } // namespace remoting | 71 } // namespace remoting |
OLD | NEW |