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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/HostInfo.java

Issue 348433002: Verify the host-supplied URL matches the domain's allowed URL patterns (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import org.json.JSONArray;
8 import org.json.JSONException;
9 import org.json.JSONObject;
10
11 import java.util.ArrayList;
12
7 /** Class to represent a Host returned by {@link HostListLoader}. */ 13 /** Class to represent a Host returned by {@link HostListLoader}. */
8 public class HostInfo { 14 public class HostInfo {
9 public final String name; 15 public final String name;
10 public final String id; 16 public final String id;
11 public final String jabberId; 17 public final String jabberId;
12 public final String publicKey; 18 public final String publicKey;
19 public final ArrayList<String> tokenUrlPatterns;
Lambros 2014/06/18 23:29:06 This might trigger a findbugs warning. You might n
kelvinp 2014/06/19 01:03:50 Done.
13 public final boolean isOnline; 20 public final boolean isOnline;
14 21
15 public HostInfo(String name, String id, String jabberId, String publicKey, b oolean isOnline) { 22 public HostInfo(String name,
23 String id,
24 String jabberId,
25 String publicKey,
26 ArrayList<String> tokenUrlPatterns,
27 boolean isOnline) {
16 this.name = name; 28 this.name = name;
17 this.id = id; 29 this.id = id;
18 this.jabberId = jabberId; 30 this.jabberId = jabberId;
19 this.publicKey = publicKey; 31 this.publicKey = publicKey;
32 this.tokenUrlPatterns = tokenUrlPatterns;
20 this.isOnline = isOnline; 33 this.isOnline = isOnline;
21 } 34 }
35
36 public static HostInfo create(JSONObject json) throws JSONException {
37 assert json != null;
38
39 ArrayList<String> tokenUrlPatterns = new ArrayList<String>();
40 // TODO(kelvinp): remove the line below before shipping.
Lambros 2014/06/18 23:29:06 Please remove these lines before landing.
kelvinp 2014/06/19 01:03:49 Done.
41 // tokenUrlPatterns.add("^http://<test machine>:<test port>/.*$");
42 JSONArray jsonPatterns = json.optJSONArray("tokenUrlPatterns");
43
44 if (jsonPatterns != null) {
45 for (int i = 0; i < jsonPatterns.length(); i++) {
46 String pattern = jsonPatterns.getString(i);
47 if (pattern != null && !pattern.isEmpty()) {
48 tokenUrlPatterns.add(pattern);
49 }
50 }
51 }
52 return new HostInfo(
53 json.getString("hostName"),
54 json.getString("hostId"),
55 json.optString("jabberId"),
56 json.optString("publicKey"),
57 tokenUrlPatterns,
58 json.optString("status").equals("ONLINE"));
59 }
22 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698