2 * Copyright 2011, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
11 #include <ObjectList.h>
17 B_KEY_PURPOSE_GENERIC
,
18 B_KEY_PURPOSE_KEYRING
,
20 B_KEY_PURPOSE_NETWORK
,
29 B_KEY_TYPE_CERTIFICATE
36 BKey(BKeyPurpose purpose
,
37 const char* identifier
,
38 const char* secondaryIdentifier
= NULL
,
39 const uint8
* data
= NULL
,
44 virtual BKeyType
Type() const { return B_KEY_TYPE_GENERIC
; };
48 status_t
SetTo(BKeyPurpose purpose
,
49 const char* identifier
,
50 const char* secondaryIdentifier
= NULL
,
51 const uint8
* data
= NULL
,
54 void SetPurpose(BKeyPurpose purpose
);
55 BKeyPurpose
Purpose() const;
57 void SetIdentifier(const char* identifier
);
58 const char* Identifier() const;
60 void SetSecondaryIdentifier(const char* identifier
);
61 const char* SecondaryIdentifier() const;
63 status_t
SetData(const uint8
* data
, size_t length
);
64 size_t DataLength() const;
65 const uint8
* Data() const;
66 status_t
GetData(uint8
* buffer
, size_t bufferSize
) const;
68 const char* Owner() const;
69 bigtime_t
CreationTime() const;
71 virtual status_t
Flatten(BMessage
& message
) const;
72 virtual status_t
Unflatten(const BMessage
& message
);
74 BKey
& operator=(const BKey
& other
);
76 bool operator==(const BKey
& other
) const;
77 bool operator!=(const BKey
& other
) const;
79 virtual void PrintToStream();
82 friend class BKeyStore
;
86 BString fSecondaryIdentifier
;
88 bigtime_t fCreationTime
;
89 mutable BMallocIO fData
;
93 class BPasswordKey
: public BKey
{
96 BPasswordKey(const char* password
,
97 BKeyPurpose purpose
, const char* identifier
,
98 const char* secondaryIdentifier
= NULL
);
99 BPasswordKey(BPasswordKey
& other
);
100 virtual ~BPasswordKey();
102 virtual BKeyType
Type() const { return B_KEY_TYPE_PASSWORD
; };
104 status_t
SetTo(const char* password
,
106 const char* identifier
,
107 const char* secondaryIdentifier
= NULL
);
109 status_t
SetPassword(const char* password
);
110 const char* Password() const;
112 virtual void PrintToStream();