• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_IMPL_H_
18 #define TRUNKS_TRUNKS_FACTORY_IMPL_H_
19 
20 #include "trunks/trunks_factory.h"
21 
22 #include <string>
23 
24 #include <base/macros.h>
25 #include <base/memory/scoped_ptr.h>
26 
27 #include "trunks/command_transceiver.h"
28 #include "trunks/trunks_export.h"
29 
30 namespace trunks {
31 
32 class Tpm;
33 
34 // TrunksFactoryImpl is the default TrunksFactory implementation.
35 class TRUNKS_EXPORT TrunksFactoryImpl : public TrunksFactory {
36  public:
37   // Uses an IPC proxy as the default CommandTransceiver. If |failure_is_fatal|
38   // is set then a failure to initialize the proxy will abort.
39   explicit TrunksFactoryImpl(bool failure_is_fatal);
40   // TrunksFactoryImpl does not take ownership of |transceiver|. This
41   // transceiver is forwarded down to the Tpm instance maintained by
42   // this factory.
43   explicit TrunksFactoryImpl(CommandTransceiver* transceiver);
44   ~TrunksFactoryImpl() override;
45 
46   // TrunksFactory methods.
47   Tpm* GetTpm() const override;
48   scoped_ptr<TpmState> GetTpmState() const override;
49   scoped_ptr<TpmUtility> GetTpmUtility() const override;
50   scoped_ptr<AuthorizationDelegate> GetPasswordAuthorization(
51       const std::string& password) const override;
52   scoped_ptr<SessionManager> GetSessionManager() const override;
53   scoped_ptr<HmacSession> GetHmacSession() const override;
54   scoped_ptr<PolicySession> GetPolicySession() const override;
55   scoped_ptr<PolicySession> GetTrialSession() const override;
56   scoped_ptr<BlobParser> GetBlobParser() const override;
57 
58  private:
59   scoped_ptr<CommandTransceiver> default_transceiver_;
60   CommandTransceiver* transceiver_;
61   scoped_ptr<Tpm> tpm_;
62 
63   DISALLOW_COPY_AND_ASSIGN(TrunksFactoryImpl);
64 };
65 
66 }  // namespace trunks
67 
68 #endif  // TRUNKS_TRUNKS_FACTORY_IMPL_H_
69