trunks_factory.h revision 9caf492818a4cc51ba471534d3fcaa84c9ce0278
1//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#ifndef TRUNKS_TRUNKS_FACTORY_H_
18#define TRUNKS_TRUNKS_FACTORY_H_
19
20#include <string>
21
22#include <base/macros.h>
23#include <base/memory/scoped_ptr.h>
24
25#include "trunks/trunks_export.h"
26
27namespace trunks {
28
29class AuthorizationDelegate;
30class BlobParser;
31class CommandTransceiver;
32class HmacSession;
33class PolicySession;
34class SessionManager;
35class Tpm;
36class TpmState;
37class TpmUtility;
38
39// TrunksFactory is an interface to act as a factory for trunks objects. This
40// mechanism assists in injecting mocks for testing. This class is not
41// thread-safe.
42class TRUNKS_EXPORT TrunksFactory {
43 public:
44  TrunksFactory() {}
45  virtual ~TrunksFactory() {}
46
47  // Returns a Tpm instance. The caller does not take ownership.
48  virtual Tpm* GetTpm() const = 0;
49
50  // Returns an uninitialized TpmState instance. The caller takes ownership.
51  virtual scoped_ptr<TpmState> GetTpmState() const = 0;
52
53  // Returns a TpmUtility instance. The caller takes ownership.
54  virtual scoped_ptr<TpmUtility> GetTpmUtility() const = 0;
55
56  // Returns an AuthorizationDelegate instance for basic password authorization.
57  // The caller takes ownership.
58  virtual scoped_ptr<AuthorizationDelegate> GetPasswordAuthorization(
59      const std::string& password) const = 0;
60
61  // Returns a SessionManager instance. The caller takes ownership.
62  virtual scoped_ptr<SessionManager> GetSessionManager() const = 0;
63
64  // Returns a HmacSession instance. The caller takes ownership.
65  virtual scoped_ptr<HmacSession> GetHmacSession() const = 0;
66
67  // Returns a PolicySession instance. The caller takes ownership.
68  virtual scoped_ptr<PolicySession> GetPolicySession() const = 0;
69
70  // Returns a TrialSession instance. The caller takes ownership.
71  virtual scoped_ptr<PolicySession> GetTrialSession() const = 0;
72
73  // Returns a BlobParser instance. The caller takes ownership.
74  virtual scoped_ptr<BlobParser> GetBlobParser() const = 0;
75
76 private:
77  DISALLOW_COPY_AND_ASSIGN(TrunksFactory);
78};
79
80}  // namespace trunks
81
82#endif  // TRUNKS_TRUNKS_FACTORY_H_
83