1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef COMPONENTS_OS_CRYPT_KEYCHAIN_PASSWORD_MAC_H_ 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define COMPONENTS_OS_CRYPT_KEYCHAIN_PASSWORD_MAC_H_ 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <string> 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/macros.h" 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace crypto { 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class AppleKeychain; 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class KeychainPassword { 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) explicit KeychainPassword(const crypto::AppleKeychain& keychain) 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) : keychain_(keychain) { 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Get the OSCrypt password for this system. If no password exists 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // in the Keychain then one is generated, stored in the Mac keychain, and 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // returned. 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // If one exists then it is fetched from the Keychain and returned. 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // If the user disallows access to the Keychain (or an error occurs) then an 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // empty string is returned. 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string GetPassword() const; 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const crypto::AppleKeychain& keychain_; 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(KeychainPassword); 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif // COMPONENTS_OS_CRYPT_KEYCHAIN_PASSWORD_MAC_H_ 37