blob: b40efca0a29c7bf4b37af0af23fc13a514ed3927 [file] [log] [blame]
// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <base/macros.h>
#include <chromeos/secure_blob.h>
#include "chaps/chaps.h"
namespace chaps {
const size_t kIsolateCredentialBytes = 16;
// Manages a user's isolate credentials, including saving and retrieval of
// isolate credentials. Sample usage:
// IsolateCredentialManager isolate_manager;
// SecureBlob isolate_credential;
// isolate_manager.GetCurrentUserIsolateCredential(&isolate_credential);
// Only virtual to enable mocking in tests.
class IsolateCredentialManager {
virtual ~IsolateCredentialManager();
// Get the well known credential for the default isolate.
static chromeos::SecureBlob GetDefaultIsolateCredential() {
// Default isolate credential is all zeros.
return chromeos::SecureBlob(kIsolateCredentialBytes);
// Get the isolate credential for the current user, returning true if it
// exists.
virtual bool GetCurrentUserIsolateCredential(
chromeos::SecureBlob* isolate_credential);
// Get the isolate credential for the given user name, returning true if it
// exists.
virtual bool GetUserIsolateCredential(
const std::string& user,
chromeos::SecureBlob* isolate_credential);
// Save the isolate credential such that it can be retrieved with
// GetUserIsolateCredential. Return true on success and false on failure.
virtual bool SaveIsolateCredential(
const std::string& user,
const chromeos::SecureBlob& isolate_credential);
} // namespace chaps
#endif // CHAPS_ISOLATE_H_