OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_PROXIMITY_AUTH_AUTHENTICATOR_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_AUTHENTICATOR_H |
6 #define COMPONENTS_PROXIMITY_AUTH_AUTHENTICATOR_H | 6 #define COMPONENTS_PROXIMITY_AUTH_AUTHENTICATOR_H |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 | 11 |
11 namespace proximity_auth { | 12 namespace proximity_auth { |
12 | 13 |
13 class SecureContext; | 14 class SecureContext; |
14 | 15 |
15 // Interface for authenticating the remote connection. The two devices | 16 // Interface for authenticating the remote connection. The two devices |
16 // authenticate each other, and if the protocol succeeds, establishes a | 17 // authenticate each other, and if the protocol succeeds, establishes a |
17 // SecureContext that is used to securely encode and decode all messages sent | 18 // SecureContext that is used to securely encode and decode all messages sent |
18 // and received over the connection. | 19 // and received over the connection. |
19 // Do not reuse after calling |Authenticate()|. | 20 // Do not reuse after calling |Authenticate()|. |
20 class Authenticator { | 21 class Authenticator { |
21 public: | 22 public: |
22 // The result of the authentication protocol. | 23 // The result of the authentication protocol. |
23 enum class Result { | 24 enum class Result { |
24 SUCCESS, | 25 SUCCESS, |
25 DISCONNECTED, | 26 DISCONNECTED, |
26 FAILURE, | 27 FAILURE, |
27 }; | 28 }; |
28 | 29 |
29 virtual ~Authenticator() {} | 30 virtual ~Authenticator() {} |
30 | 31 |
31 // Initiates the authentication attempt, invoking |callback| with the result. | 32 // Initiates the authentication attempt, invoking |callback| with the result. |
32 // If the authentication protocol succeeds, then |secure_context| will be | 33 // If the authentication protocol succeeds, then |secure_context| will be |
33 // contain the SecureContext used to securely exchange messages. Otherwise, it | 34 // contain the SecureContext used to securely exchange messages. Otherwise, it |
34 // will be null if the protocol fails. | 35 // will be null if the protocol fails. |
35 typedef base::Callback<void(Result result, | 36 typedef base::Callback<void(Result result, |
36 scoped_ptr<SecureContext> secure_context)> | 37 std::unique_ptr<SecureContext> secure_context)> |
37 AuthenticationCallback; | 38 AuthenticationCallback; |
38 virtual void Authenticate(const AuthenticationCallback& callback) = 0; | 39 virtual void Authenticate(const AuthenticationCallback& callback) = 0; |
39 }; | 40 }; |
40 | 41 |
41 } // namespace proximity_auth | 42 } // namespace proximity_auth |
42 | 43 |
43 #endif // COMPONENTS_PROXIMITY_AUTH_AUTHENTICATOR_H | 44 #endif // COMPONENTS_PROXIMITY_AUTH_AUTHENTICATOR_H |
OLD | NEW |