blob: d3240dd49659998e81940b2c9562240b07083b05 [file] [log] [blame]
// Copyright (c) 2012 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 <vector>
#include <base/macros.h>
#include <base/memory/scoped_ptr.h>
#include "chaps/chaps.h"
#include "chaps/token_manager_interface.h"
#include "chromeos/secure_blob.h"
#include "pkcs11/cryptoki.h"
namespace chaps {
class ChapsProxyImpl;
// TokenManagerClient is an implementation of TokenManagerInterface which sends
// the token management calls to the Chaps daemon. Example usage:
// TokenManagerClient client;
// client.OpenIsolate(&my_isolate_credential, &new_isolate_created);
// client.LoadToken(my_isolate_credential,
// "path/to/token",
// "1234",
// "MyTokenLabel",
// &slot_id);
class EXPORT_SPEC TokenManagerClient : public TokenManagerInterface {
virtual ~TokenManagerClient();
// TokenManagerInterface methods.
virtual bool OpenIsolate(chromeos::SecureBlob* isolate_credential,
bool* new_isolate_created);
virtual void CloseIsolate(const chromeos::SecureBlob& isolate_credential);
virtual bool LoadToken(const chromeos::SecureBlob& isolate_credential,
const base::FilePath& path,
const chromeos::SecureBlob& auth_data,
const std::string& label,
int* slot_id);
virtual void UnloadToken(const chromeos::SecureBlob& isolate_credential,
const base::FilePath& path);
virtual void ChangeTokenAuthData(const base::FilePath& path,
const chromeos::SecureBlob& old_auth_data,
const chromeos::SecureBlob& new_auth_data);
virtual bool GetTokenPath(const chromeos::SecureBlob& isolate_credential,
int slot_id,
base::FilePath* path);
// Convenience method, not on TokenManagerInterface.
// Returns true on success, false on failure. If it succeeds, stores a list of
// the paths of all loaded tokens in |results|.
virtual bool GetTokenList(const chromeos::SecureBlob& isolate_credential,
std::vector<std::string>* results);
scoped_ptr<ChapsProxyImpl> proxy_;
bool is_connected_;
// Attempts to connect to the Chaps daemon. Returns true on success.
bool Connect();
} // namespace chaps