1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_SMB_CLIENT_SMB_FILE_SYSTEM_ID_H_ 6 #define CHROME_BROWSER_CHROMEOS_SMB_CLIENT_SMB_FILE_SYSTEM_ID_H_ 7 8 #include <string> 9 10 #include "base/files/file_path.h" 11 #include "base/optional.h" 12 13 namespace chromeos { 14 namespace smb_client { 15 16 // Creates a FileSystemId by concatenating a random filesystem identifier and 17 // |share_path| with a delimiter. The random ID is used so that the same share 18 // path can be mounted multiple times. If |is_kerberos_chromad| is set, an 19 // additional symbol is appended. 20 std::string CreateFileSystemId(const base::FilePath& share_path, 21 bool is_kerberos_chromad); 22 23 // Creates a FileSystemId by concatenating a random filesystem identifier, 24 // |share_path|, and |username| with a delimiter. The random ID is used so that 25 // the same share path can be mounted multiple times. |username| must be either 26 // a name without a domain/workgroup, or in the "user@domain.com" format 27 // parsable by ParseUserPrincipalName(). 28 std::string CreateFileSystemIdForUser(const base::FilePath& share_path, 29 const std::string& username); 30 31 // Returns the SharePath component of a |file_system_id|. |file_system_id| must 32 // be well-formed (e.g. 2@@smb://192.168.1.1/testShare). 33 base::FilePath GetSharePathFromFileSystemId(const std::string& file_system_id); 34 35 // Returns whether |file_system_id| corresponds to a share that was mounted 36 // using ChromAD Kerberos. 37 bool IsKerberosChromadFileSystemId(const std::string& file_system_id); 38 39 // Returns the username if |file_system_id| was constructed with 40 // CreateFileSystemIdForUser(). Returns nullopt if |file_system_id| does not 41 // store the username. 42 base::Optional<std::string> GetUserFromFileSystemId( 43 const std::string& file_system_id); 44 45 } // namespace smb_client 46 } // namespace chromeos 47 48 #endif // CHROME_BROWSER_CHROMEOS_SMB_CLIENT_SMB_FILE_SYSTEM_ID_H_ 49