This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
object_impl.h
73 lines (60 loc) · 2.38 KB
/
object_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// 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.
#ifndef P11NET_OBJECT_IMPL_H_
#define P11NET_OBJECT_IMPL_H_
#include "object.h"
#include <memory>
#include <set>
#include <string>
#include <base/macros.h>
#include "pkcs11/cryptoki.h"
namespace p11net {
class P11NetFactory;
class ObjectPolicy;
class ObjectImpl : public Object {
public:
explicit ObjectImpl(P11NetFactory* factory);
virtual ~ObjectImpl();
virtual ObjectStage GetStage() const;
virtual int GetSize() const;
virtual CK_OBJECT_CLASS GetObjectClass() const;
virtual bool IsTokenObject() const;
virtual bool IsModifiable() const;
virtual bool IsPrivate() const;
virtual CK_RV FinalizeNewObject();
virtual CK_RV Copy(const Object* original);
virtual CK_RV GetAttributes(CK_ATTRIBUTE_PTR attributes,
int num_attributes) const;
virtual CK_RV SetAttributes(const CK_ATTRIBUTE_PTR attributes,
int num_attributes);
virtual bool IsAttributePresent(CK_ATTRIBUTE_TYPE type) const;
virtual bool GetAttributeBool(CK_ATTRIBUTE_TYPE type,
bool default_value) const;
virtual void SetAttributeBool(CK_ATTRIBUTE_TYPE type, bool value);
virtual int GetAttributeInt(CK_ATTRIBUTE_TYPE type,
int default_value) const;
virtual void SetAttributeInt(CK_ATTRIBUTE_TYPE type, int value);
virtual std::string GetAttributeString(CK_ATTRIBUTE_TYPE type) const;
virtual void SetAttributeString(CK_ATTRIBUTE_TYPE type,
const std::string& value);
virtual void RemoveAttribute(CK_ATTRIBUTE_TYPE type);
virtual const AttributeMap* GetAttributeMap() const;
virtual int handle() const {return handle_;}
virtual void set_handle(int handle) {handle_ = handle;}
virtual int store_id() const {return store_id_;}
virtual void set_store_id(int store_id) {store_id_ = store_id;}
private:
P11NetFactory* factory_;
ObjectStage stage_;
AttributeMap attributes_;
// Tracks attributes which have been set by the user.
std::set<CK_ATTRIBUTE_TYPE> external_attributes_;
std::unique_ptr<ObjectPolicy> policy_;
int handle_;
int store_id_;
bool SetPolicyByClass();
DISALLOW_COPY_AND_ASSIGN(ObjectImpl);
};
} // namespace p11net
#endif // P11NET_OBJECT_IMPL_H_