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 #ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 5 #ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
6 #define CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 6 #define CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
| 13 #include "base/containers/hash_tables.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
15 | 16 |
| 17 class AccountId; |
| 18 |
16 namespace cryptohome { | 19 namespace cryptohome { |
17 | 20 |
18 enum AuthKeyPrivileges { | 21 enum AuthKeyPrivileges { |
19 PRIV_MOUNT = 1 << 0, // Can mount with this key. | 22 PRIV_MOUNT = 1 << 0, // Can mount with this key. |
20 PRIV_ADD = 1 << 1, // Can add new keys. | 23 PRIV_ADD = 1 << 1, // Can add new keys. |
21 PRIV_REMOVE = 1 << 2, // Can remove other keys. | 24 PRIV_REMOVE = 1 << 2, // Can remove other keys. |
22 PRIV_MIGRATE = 1 << 3, // Destroy all keys and replace with new. | 25 PRIV_MIGRATE = 1 << 3, // Destroy all keys and replace with new. |
23 PRIV_AUTHORIZED_UPDATE = 1 << 4, // Key can be updated in place. | 26 PRIV_AUTHORIZED_UPDATE = 1 << 4, // Key can be updated in place. |
24 PRIV_DEFAULT = PRIV_MOUNT | PRIV_ADD | PRIV_REMOVE | PRIV_MIGRATE | 27 PRIV_DEFAULT = PRIV_MOUNT | PRIV_ADD | PRIV_REMOVE | PRIV_MIGRATE |
25 }; | 28 }; |
26 | 29 |
27 // Identification of the user calling cryptohome method. | 30 // Identification of the user calling cryptohome method. |
28 struct CHROMEOS_EXPORT Identification { | 31 class CHROMEOS_EXPORT Identification { |
29 explicit Identification(const std::string& user_id); | 32 public: |
| 33 Identification(); |
| 34 |
| 35 explicit Identification(const AccountId& account_id); |
30 | 36 |
31 bool operator==(const Identification& other) const; | 37 bool operator==(const Identification& other) const; |
32 | 38 |
33 std::string user_id; | 39 // This method should be used for migration purpose only. |
| 40 static Identification FromString(const std::string& id); |
| 41 |
| 42 // Look up known user and return its AccountId. |
| 43 AccountId GetAccountId() const; |
| 44 |
| 45 const std::string& id() const { return id_; } |
| 46 |
| 47 bool operator<(const Identification& right) const; |
| 48 |
| 49 private: |
| 50 explicit Identification(const std::string&); |
| 51 |
| 52 std::string id_; |
34 }; | 53 }; |
35 | 54 |
36 // Definition of the key (e.g. password) for the cryptohome. | 55 // Definition of the key (e.g. password) for the cryptohome. |
37 // It contains authorization data along with extra parameters like permissions | 56 // It contains authorization data along with extra parameters like permissions |
38 // associated with this key. | 57 // associated with this key. |
39 struct CHROMEOS_EXPORT KeyDefinition { | 58 struct CHROMEOS_EXPORT KeyDefinition { |
40 enum Type { | 59 enum Type { |
41 TYPE_PASSWORD = 0 | 60 TYPE_PASSWORD = 0 |
42 }; | 61 }; |
43 | 62 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 157 |
139 // If |true|, the mounted home dir will be backed by tmpfs. If |false|, the | 158 // If |true|, the mounted home dir will be backed by tmpfs. If |false|, the |
140 // ephemeral users policy decides whether tmpfs or an encrypted directory is | 159 // ephemeral users policy decides whether tmpfs or an encrypted directory is |
141 // used as the backend. | 160 // used as the backend. |
142 bool ephemeral; | 161 bool ephemeral; |
143 | 162 |
144 // If not empty, home dir will be created with these keys if it exist. | 163 // If not empty, home dir will be created with these keys if it exist. |
145 std::vector<KeyDefinition> create_keys; | 164 std::vector<KeyDefinition> create_keys; |
146 }; | 165 }; |
147 | 166 |
| 167 // This function returns true if cryptohome of |account_id| is migrated to |
| 168 // gaiaId-based identifier (AccountId::GetGaiaIdKey()). |
| 169 bool GetGaiaIdMigrationStatus(const AccountId& account_id); |
| 170 |
| 171 // This function marks |account_id| cryptohome migrated to gaiaId-based |
| 172 // identifier (AccountId::GetGaiaIdKey()). |
| 173 void SetGaiaIdMigrationStatusDone(const AccountId& account_id); |
| 174 |
148 } // namespace cryptohome | 175 } // namespace cryptohome |
149 | 176 |
| 177 namespace BASE_HASH_NAMESPACE { |
| 178 |
| 179 // Implement hashing of cryptohome::Identification, so it can be used as a key |
| 180 // in STL containers. |
| 181 template <> |
| 182 struct hash<cryptohome::Identification> { |
| 183 std::size_t operator()(const cryptohome::Identification& cryptohome_id) const; |
| 184 }; |
| 185 |
| 186 } // namespace BASE_HASH_NAMESPACE |
| 187 |
150 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 188 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
OLD | NEW |