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

Side by Side Diff: remoting/host/third_party_auth_config.h

Issue 966433002: Malformed PortRange or ThirdPartyAuthConfig trigger OnPolicyError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a Windows-specific, pre-processor-related build break. Created 5 years, 9 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
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/host/third_party_auth_config.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 2015 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 #ifndef REMOTING_HOST_THIRD_PARTY_AUTH_CONFIG_H_
6 #define REMOTING_HOST_THIRD_PARTY_AUTH_CONFIG_H_
7
8 #include <ostream>
9 #include <string>
10
11 #include "base/gtest_prod_util.h"
12 #include "url/gurl.h"
13
14 namespace base {
15 class DictionaryValue;
16 } // namespace base
17
18 namespace remoting {
19
20 struct ThirdPartyAuthConfig {
21 GURL token_url;
22 GURL token_validation_url;
23 std::string token_validation_cert_issuer;
24
25 inline bool is_null() const {
26 return token_url.is_empty() && token_validation_url.is_empty();
27 }
28
29 // Status of Parse method call.
30 enum ParseStatus {
31 // |policy_dict| contains invalid entries (i.e. malformed urls).
32 // |result| has not been modified.
33 InvalidPolicy,
34
35 // |policy_dict| doesn't contain any ThirdPartyAuthConfig-related entries.
36 // |result| has not been modified.
37 NoPolicy,
38
39 // |policy_dict| contains valid entries that have been stored into |result|.
40 ParsingSuccess,
41 };
42 static ParseStatus Parse(const base::DictionaryValue& policy_dict,
43 ThirdPartyAuthConfig* result);
44
45 private:
46 // Returns false and doesn't modify |result| if parsing fails (i.e. some input
47 // values are invalid).
48 static bool ParseStrings(const std::string& token_url,
49 const std::string& token_validation_url,
50 const std::string& token_validation_cert_issuer,
51 ThirdPartyAuthConfig* result);
52 FRIEND_TEST_ALL_PREFIXES(InvalidUrlTest, ParseInvalidUrl);
53 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ParseEmpty);
54 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ParseValidAll);
55 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ParseValidNoCert);
56 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ParseInvalidCombination);
57 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ParseHttp);
58
59 // Extracts raw (raw = as strings) policy values from |policy_dict|.
60 // Missing policy values are set to an empty string.
61 // Returns false if no ThirdPartyAuthConfig-related policies were present.
62 static bool ExtractStrings(const base::DictionaryValue& policy_dict,
63 std::string* token_url,
64 std::string* token_validation_url,
65 std::string* token_validation_cert_issuer);
66 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ExtractEmpty);
67 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ExtractUnknown);
68 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ExtractAll);
69 FRIEND_TEST_ALL_PREFIXES(ThirdPartyAuthConfig, ExtractPartial);
70 };
71
72 std::ostream& operator<<(std::ostream& os, const ThirdPartyAuthConfig& cfg);
73
74 } // namespace remoting
75
76 #endif // REMOTING_HOST_THIRD_PARTY_AUTH_CONFIG_H_
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/host/third_party_auth_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698