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 const std::string& id() const { return id_; } |
| 43 |
| 44 bool operator<(const Identification& right) const; |
| 45 |
| 46 private: |
| 47 explicit Identification(const std::string&); |
| 48 |
| 49 std::string id_; |
34 }; | 50 }; |
35 | 51 |
36 // Definition of the key (e.g. password) for the cryptohome. | 52 // Definition of the key (e.g. password) for the cryptohome. |
37 // It contains authorization data along with extra parameters like permissions | 53 // It contains authorization data along with extra parameters like permissions |
38 // associated with this key. | 54 // associated with this key. |
39 struct CHROMEOS_EXPORT KeyDefinition { | 55 struct CHROMEOS_EXPORT KeyDefinition { |
40 enum Type { | 56 enum Type { |
41 TYPE_PASSWORD = 0 | 57 TYPE_PASSWORD = 0 |
42 }; | 58 }; |
43 | 59 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 154 |
139 // If |true|, the mounted home dir will be backed by tmpfs. If |false|, the | 155 // 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 | 156 // ephemeral users policy decides whether tmpfs or an encrypted directory is |
141 // used as the backend. | 157 // used as the backend. |
142 bool ephemeral; | 158 bool ephemeral; |
143 | 159 |
144 // If not empty, home dir will be created with these keys if it exist. | 160 // If not empty, home dir will be created with these keys if it exist. |
145 std::vector<KeyDefinition> create_keys; | 161 std::vector<KeyDefinition> create_keys; |
146 }; | 162 }; |
147 | 163 |
| 164 // This function returns true if cryptohome of |account_id| is migrated to |
| 165 // gaiaId-based identifier (AccountId::GetGaiaIdKey()). |
| 166 bool GetGaiaIdMigrationStatus(const AccountId& account_id); |
| 167 |
| 168 // This function marks |account_id| cryptohome migrated to gaiaId-based |
| 169 // identifier (AccountId::GetGaiaIdKey()). |
| 170 void SetGaiaIdMigrationStatusDone(const AccountId& account_id); |
| 171 |
148 } // namespace cryptohome | 172 } // namespace cryptohome |
149 | 173 |
| 174 namespace BASE_HASH_NAMESPACE { |
| 175 |
| 176 // Implement hashing of cryptohome::Identification, so it can be used as a key |
| 177 // in STL containers. |
| 178 template <> |
| 179 struct hash<cryptohome::Identification> { |
| 180 std::size_t operator()(const cryptohome::Identification& cryptohome_id) const; |
| 181 }; |
| 182 |
| 183 } // namespace BASE_HASH_NAMESPACE |
| 184 |
150 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 185 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
OLD | NEW |