OLD | NEW |
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 #include "chromeos/login/auth/fake_extended_authenticator.h" | 5 #include "chromeos/login/auth/fake_extended_authenticator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chromeos/login/auth/auth_status_consumer.h" | 8 #include "chromeos/login/auth/auth_status_consumer.h" |
9 | 9 |
10 namespace chromeos { | 10 namespace chromeos { |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 void FakeExtendedAuthenticator::SetConsumer(AuthStatusConsumer* consumer) { | 31 void FakeExtendedAuthenticator::SetConsumer(AuthStatusConsumer* consumer) { |
32 old_consumer_ = consumer; | 32 old_consumer_ = consumer; |
33 } | 33 } |
34 | 34 |
35 void FakeExtendedAuthenticator::AuthenticateToMount( | 35 void FakeExtendedAuthenticator::AuthenticateToMount( |
36 const UserContext& context, | 36 const UserContext& context, |
37 const ResultCallback& success_callback) { | 37 const ResultCallback& success_callback) { |
38 if (expected_user_context_ == context) { | 38 if (expected_user_context_ == context) { |
39 UserContext reported_user_context(context); | 39 UserContext reported_user_context(context); |
40 const std::string mount_hash = reported_user_context.GetUserID() + "-hash"; | 40 const std::string mount_hash = reported_user_context.GetUserID().GetUserEmai
l() + "-hash"; |
41 reported_user_context.SetUserIDHash(mount_hash); | 41 reported_user_context.SetUserIDHash(mount_hash); |
42 if (!success_callback.is_null()) | 42 if (!success_callback.is_null()) |
43 success_callback.Run(mount_hash); | 43 success_callback.Run(mount_hash); |
44 OnAuthSuccess(reported_user_context); | 44 OnAuthSuccess(reported_user_context); |
45 return; | 45 return; |
46 } | 46 } |
47 | 47 |
48 OnAuthFailure(FAILED_MOUNT, | 48 OnAuthFailure(FAILED_MOUNT, |
49 AuthFailure(AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME)); | 49 AuthFailure(AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME)); |
50 } | 50 } |
51 | 51 |
52 void FakeExtendedAuthenticator::AuthenticateToCheck( | 52 void FakeExtendedAuthenticator::AuthenticateToCheck( |
53 const UserContext& context, | 53 const UserContext& context, |
54 const base::Closure& success_callback) { | 54 const base::Closure& success_callback) { |
55 if (expected_user_context_ == context) { | 55 if (expected_user_context_ == context) { |
56 if (!success_callback.is_null()) | 56 if (!success_callback.is_null()) |
57 success_callback.Run(); | 57 success_callback.Run(); |
58 OnAuthSuccess(context); | 58 OnAuthSuccess(context); |
59 return; | 59 return; |
60 } | 60 } |
61 | 61 |
62 OnAuthFailure(FAILED_MOUNT, | 62 OnAuthFailure(FAILED_MOUNT, |
63 AuthFailure(AuthFailure::UNLOCK_FAILED)); | 63 AuthFailure(AuthFailure::UNLOCK_FAILED)); |
64 } | 64 } |
65 | 65 |
66 void FakeExtendedAuthenticator::CreateMount(const std::string& user_id, | 66 void FakeExtendedAuthenticator::CreateMount(const user_manager::UserID& user_id, |
67 const std::vector<cryptohome::KeyDefinition>& keys, | 67 const std::vector<cryptohome::KeyDefinition>& keys, |
68 const ResultCallback& success_callback) { | 68 const ResultCallback& success_callback) { |
69 NOTREACHED(); | 69 NOTREACHED(); |
70 } | 70 } |
71 | 71 |
72 void FakeExtendedAuthenticator::AddKey(const UserContext& context, | 72 void FakeExtendedAuthenticator::AddKey(const UserContext& context, |
73 const cryptohome::KeyDefinition& key, | 73 const cryptohome::KeyDefinition& key, |
74 bool replace_existing, | 74 bool replace_existing, |
75 const base::Closure& success_callback) { | 75 const base::Closure& success_callback) { |
76 NOTREACHED(); | 76 NOTREACHED(); |
(...skipping 27 matching lines...) Expand all Loading... |
104 | 104 |
105 void FakeExtendedAuthenticator::OnAuthFailure(AuthState state, | 105 void FakeExtendedAuthenticator::OnAuthFailure(AuthState state, |
106 const AuthFailure& error) { | 106 const AuthFailure& error) { |
107 if (consumer_) | 107 if (consumer_) |
108 consumer_->OnAuthenticationFailure(state); | 108 consumer_->OnAuthenticationFailure(state); |
109 if (old_consumer_) | 109 if (old_consumer_) |
110 old_consumer_->OnAuthFailure(error); | 110 old_consumer_->OnAuthFailure(error); |
111 } | 111 } |
112 | 112 |
113 } // namespace chromeos | 113 } // namespace chromeos |
OLD | NEW |