Clarify and update GN build flags docs.
[chromium-blink-merge.git] / remoting / host / third_party_auth_config.h
blobb9e9c928b9148b619f06a7915a8b546114de521c
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.
5 #ifndef REMOTING_HOST_THIRD_PARTY_AUTH_CONFIG_H_
6 #define REMOTING_HOST_THIRD_PARTY_AUTH_CONFIG_H_
8 #include <ostream>
9 #include <string>
11 #include "base/gtest_prod_util.h"
12 #include "url/gurl.h"
14 namespace base {
15 class DictionaryValue;
16 } // namespace base
18 namespace remoting {
20 struct ThirdPartyAuthConfig {
21 GURL token_url;
22 GURL token_validation_url;
23 std::string token_validation_cert_issuer;
25 inline bool is_null() const {
26 return token_url.is_empty() && token_validation_url.is_empty();
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,
35 // |policy_dict| doesn't contain any ThirdPartyAuthConfig-related entries.
36 // |result| has not been modified.
37 NoPolicy,
39 // |policy_dict| contains valid entries that have been stored into |result|.
40 ParsingSuccess,
42 static ParseStatus Parse(const base::DictionaryValue& policy_dict,
43 ThirdPartyAuthConfig* result);
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);
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);
72 std::ostream& operator<<(std::ostream& os, const ThirdPartyAuthConfig& cfg);
74 } // namespace remoting
76 #endif // REMOTING_HOST_THIRD_PARTY_AUTH_CONFIG_H_