OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef REMOTING_HOST_TOKEN_VALIDATOR_FACTORY_IMPL_H_ | 5 #ifndef REMOTING_HOST_TOKEN_VALIDATOR_FACTORY_IMPL_H_ |
6 #define REMOTING_HOST_TOKEN_VALIDATOR_FACTORY_IMPL_H_ | 6 #define REMOTING_HOST_TOKEN_VALIDATOR_FACTORY_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "net/url_request/url_request_context_getter.h" | 12 #include "net/url_request/url_request_context_getter.h" |
13 #include "remoting/protocol/third_party_host_authenticator.h" | 13 #include "remoting/host/token_validator_base.h" |
| 14 #include "remoting/protocol/token_validator.h" |
14 | 15 |
15 namespace remoting { | 16 namespace remoting { |
16 | 17 |
17 struct ThirdPartyAuthConfig { | |
18 inline bool is_empty() const { | |
19 return token_url.is_empty() && token_validation_url.is_empty(); | |
20 } | |
21 | |
22 inline bool is_valid() const { | |
23 return token_url.is_valid() && token_validation_url.is_valid(); | |
24 } | |
25 | |
26 GURL token_url; | |
27 GURL token_validation_url; | |
28 std::string token_validation_cert_issuer; | |
29 }; | |
30 | |
31 // This class dispenses |TokenValidator| implementations that use a UrlFetcher | 18 // This class dispenses |TokenValidator| implementations that use a UrlFetcher |
32 // to contact a |token_validation_url| and exchange the |token| for a | 19 // to contact a |token_validation_url| and exchange the |token| for a |
33 // |shared_secret|. | 20 // |shared_secret|. |
34 class TokenValidatorFactoryImpl | 21 class TokenValidatorFactoryImpl : public protocol::TokenValidatorFactory { |
35 : public protocol::ThirdPartyHostAuthenticator::TokenValidatorFactory { | |
36 public: | 22 public: |
37 // Creates a new factory. |token_url| and |token_validation_url| are the | 23 // Creates a new factory. |token_url| and |token_validation_url| are the |
38 // third party authentication service URLs, obtained via policy. |key_pair_| | 24 // third party authentication service URLs, obtained via policy. |key_pair_| |
39 // is used by the host to authenticate with the service by signing the token. | 25 // is used by the host to authenticate with the service by signing the token. |
40 TokenValidatorFactoryImpl( | 26 TokenValidatorFactoryImpl( |
41 const ThirdPartyAuthConfig& third_party_auth_config, | 27 const ThirdPartyAuthConfig& third_party_auth_config, |
42 scoped_refptr<RsaKeyPair> key_pair, | 28 scoped_refptr<RsaKeyPair> key_pair, |
43 scoped_refptr<net::URLRequestContextGetter> request_context_getter); | 29 scoped_refptr<net::URLRequestContextGetter> request_context_getter); |
44 | 30 |
45 virtual ~TokenValidatorFactoryImpl(); | 31 virtual ~TokenValidatorFactoryImpl(); |
46 | 32 |
47 // TokenValidatorFactory interface. | 33 // TokenValidatorFactory interface. |
48 virtual scoped_ptr<protocol::ThirdPartyHostAuthenticator::TokenValidator> | 34 virtual scoped_ptr<protocol::TokenValidator> CreateTokenValidator( |
49 CreateTokenValidator(const std::string& local_jid, | 35 const std::string& local_jid, |
50 const std::string& remote_jid) OVERRIDE; | 36 const std::string& remote_jid) OVERRIDE; |
51 | 37 |
52 private: | 38 private: |
53 ThirdPartyAuthConfig third_party_auth_config_; | 39 ThirdPartyAuthConfig third_party_auth_config_; |
54 scoped_refptr<RsaKeyPair> key_pair_; | 40 scoped_refptr<RsaKeyPair> key_pair_; |
55 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 41 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
56 | 42 |
57 DISALLOW_COPY_AND_ASSIGN(TokenValidatorFactoryImpl); | 43 DISALLOW_COPY_AND_ASSIGN(TokenValidatorFactoryImpl); |
58 }; | 44 }; |
59 | 45 |
60 } // namespace remoting | 46 } // namespace remoting |
61 | 47 |
62 #endif // REMOTING_HOST_URL_FETCHER_TOKEN_VALIDATOR_FACTORY_H_ | 48 #endif // REMOTING_HOST_URL_FETCHER_TOKEN_VALIDATOR_FACTORY_H_ |
OLD | NEW |