Class that represents a generic key for or from the Haiku key store. More...
Inherited by BPasswordKey.
Public Member Functions | |
BKey () | |
Constructor for an empty generic key. | |
BKey (BKey &other) | |
Copy constructor that makes a copy of an other BKey. | |
BKey (BKeyPurpose purpose, const char *identifier, const char *secondaryIdentifier=NULL, const uint8 *data=NULL, size_t length=0) | |
Constructor for a generic key with the provided data. | |
virtual | ~BKey () |
Free all resources associated with this key. | |
bigtime_t | CreationTime () const |
Get the creation time of the key. | |
const uint8 * | Data () const |
Get a pointer to the data of the key. | |
size_t | DataLength () const |
Get the size of the key in bytes. | |
virtual status_t | Flatten (BMessage &message) const |
Flatten the key into a message. | |
status_t | GetData (uint8 *buffer, size_t bufferSize) const |
Copy the key into the buffer. | |
const char * | Identifier () const |
Get the identifier of the key. | |
bool | operator!= (const BKey &other) const |
Compare this key to an other key. | |
BKey & | operator= (const BKey &other) |
Copy the data from the other key into this key. | |
bool | operator== (const BKey &other) const |
Compare this key to an other key. | |
const char * | Owner () const |
Get the owner of the key. | |
virtual void | PrintToStream () |
Dump the contents of the key to standard output. | |
BKeyPurpose | Purpose () const |
Get the purpose of the key. | |
const char * | SecondaryIdentifier () const |
Get the secondary identifier of the key. | |
status_t | SetData (const uint8 *data, size_t length) |
Set the data for the key. | |
void | SetIdentifier (const char *identifier) |
Set the identifier of the key. | |
void | SetPurpose (BKeyPurpose purpose) |
Set the purpose of the key. | |
void | SetSecondaryIdentifier (const char *identifier) |
Set the secondary identifier of the key. | |
status_t | SetTo (BKeyPurpose purpose, const char *identifier, const char *secondaryIdentifier=NULL, const uint8 *data=NULL, size_t length=0) |
Set the key to the specified values. | |
virtual BKeyType | Type () const |
Returns the type of key. | |
virtual status_t | Unflatten (const BMessage &message) |
Unflatten the key from a message. | |
void | Unset () |
Reset the values of the key. | |
Class that represents a generic key for or from the Haiku key store.
A key has the following properties:
BKey::BKey | ( | ) |
Constructor for an empty generic key.
An empty key has no data associated with it, other than that it has a generic purpose and a generic key type.
BKey::BKey | ( | BKeyPurpose | purpose, |
const char * | identifier, | ||
const char * | secondaryIdentifier = NULL , |
||
const uint8 * | data = NULL , |
||
size_t | length = 0 |
||
) |
Constructor for a generic key with the provided data.
See the class introduction for more information about the properties of a key. As you can see, the only required parameters are the purpose and the identifier. Any data you provide will be copied into the BKey object.
purpose | The purpose of this key |
identifier | A unique identifier for this key |
secondaryIdentifier | An (optional) secondary identifier for this key |
data | A pointer to a buffer that contains the value of the key, such as the password or the certificate data. |
length | The length of the data in bytes that should be copied. |
|
virtual |
Free all resources associated with this key.
bigtime_t BKey::CreationTime | ( | ) | const |
Get the creation time of the key.
const uint8 * BKey::Data | ( | ) | const |
Get a pointer to the data of the key.
size_t BKey::DataLength | ( | ) | const |
Get the size of the key in bytes.
Flatten the key into a message.
Copy the key into the buffer.
It is up to you to make sure the size of the buffer is the actual size of the key's data. If the provided buffer is smaller, only the bufferSize will be copied. If the buffer is larger, the key is copied, but the rest of the buffer will not be touched.
[out] | buffer | The buffer to copy the key to. |
[in] | bufferSize | The size of the provided buffer. |
B_OK
if the data is sucessfully copied.const char * BKey::Identifier | ( | ) | const |
Get the identifier of the key.
bool BKey::operator!= | ( | const BKey & | other | ) | const |
Compare this key to an other key.
true
if any of the properties in this key differ from other.Copy the data from the other key into this key.
bool BKey::operator== | ( | const BKey & | other | ) | const |
Compare this key to an other key.
true
if all the properties in both keys are identical.const char * BKey::Owner | ( | ) | const |
Get the owner of the key.
|
virtual |
Dump the contents of the key to standard output.
This is a debug function that helps you read the contents of the key. All properties, except for the actual data
of the key, will be printed to stdout
.
Reimplemented in BPasswordKey.
BKeyPurpose BKey::Purpose | ( | ) | const |
Get the purpose of the key.
const char * BKey::SecondaryIdentifier | ( | ) | const |
Get the secondary identifier of the key.
Set the data for the key.
data | A pointer to the buffer that contains the data of the key. |
length | The length in bytes of the data. |
B_OK
if the key data was updated.B_NO_MEMORY
in case it fails to allocate memory. void BKey::SetIdentifier | ( | const char * | identifier | ) |
Set the identifier of the key.
identifier | A pointer to a valid UTF-8 string. |
void BKey::SetPurpose | ( | BKeyPurpose | purpose | ) |
Set the purpose of the key.
void BKey::SetSecondaryIdentifier | ( | const char * | identifier | ) |
Set the secondary identifier of the key.
identifier | A pointer to a valid UTF-8 string. |
status_t BKey::SetTo | ( | BKeyPurpose | purpose, |
const char * | identifier, | ||
const char * | secondaryIdentifier = NULL , |
||
const uint8 * | data = NULL , |
||
size_t | length = 0 |
||
) |
Set the key to the specified values.
All properties of the key will be set to the parameters. If the key had a creation time set, it will be cleared. If there was an owner set, this piece of information will not be cleared.
purpose | The purpose of this key |
identifier | A unique identifier for this key |
secondaryIdentifier | An (optional) secondary identifier for this key |
data | A pointer to a buffer that contains the value of the key, such as the password or the certificate data. |
length | The length of the data in bytes that should be copied. |
B_OK
if the changes were successful.B_NO_MEMORY
in case it fails to allocate memory.
|
inlinevirtual |
Returns the type of key.
For a generic BKey, this will always be BKeyType::B_KEY_TYPE_GENERIC
Reimplemented in BPasswordKey.
References B_KEY_TYPE_GENERIC.
Unflatten the key from a message.
void BKey::Unset | ( | ) |
Reset the values of the key.
All properties of the key will be reset, except for the identifying owner.