Loading...
Searching...
No Matches
Public Member Functions | List of all members
BKey Class Reference

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 uint8Data () 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.
 
BKeyoperator= (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.
 

Detailed Description

Class that represents a generic key for or from the Haiku key store.

A key has the following properties:

Since
Haiku R1

Constructor & Destructor Documentation

◆ BKey() [1/3]

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.

Since
Haiku R1

◆ BKey() [2/3]

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.

Parameters
purposeThe purpose of this key
identifierA unique identifier for this key
secondaryIdentifierAn (optional) secondary identifier for this key
dataA pointer to a buffer that contains the value of the key, such as the password or the certificate data.
lengthThe length of the data in bytes that should be copied.
Since
Haiku R1

◆ BKey() [3/3]

BKey::BKey ( BKey other)

Copy constructor that makes a copy of an other BKey.

Since
Haiku R1

◆ ~BKey()

BKey::~BKey ( )
virtual

Free all resources associated with this key.

Since
Haiku R1

Member Function Documentation

◆ CreationTime()

bigtime_t BKey::CreationTime ( ) const

Get the creation time of the key.

Since
Haiku R1

◆ Data()

const uint8 * BKey::Data ( ) const

Get a pointer to the data of the key.

Since
Haiku R1

◆ DataLength()

size_t BKey::DataLength ( ) const

Get the size of the key in bytes.

Since
Haiku R1

◆ Flatten()

status_t BKey::Flatten ( BMessage message) const
virtual

Flatten the key into a message.

Since
Haiku R1

◆ GetData()

status_t BKey::GetData ( uint8 buffer,
size_t  bufferSize 
) const

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.

Parameters
[out]bufferThe buffer to copy the key to.
[in]bufferSizeThe size of the provided buffer.
Returns
  • B_OK if the data is sucessfully copied.
  • An other error code if there was an issue copying the data.
Since
Haiku R1

◆ Identifier()

const char * BKey::Identifier ( ) const

Get the identifier of the key.

Since
Haiku R1

◆ operator!=()

bool BKey::operator!= ( const BKey other) const

Compare this key to an other key.

Returns
true if any of the properties in this key differ from other.
Since
Haiku R1

◆ operator=()

BKey & BKey::operator= ( const BKey other)

Copy the data from the other key into this key.

Since
Haiku R1

◆ operator==()

bool BKey::operator== ( const BKey other) const

Compare this key to an other key.

Returns
true if all the properties in both keys are identical.
Since
Haiku R1

◆ Owner()

const char * BKey::Owner ( ) const

Get the owner of the key.

Since
Haiku R1

◆ PrintToStream()

void BKey::PrintToStream ( )
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.

Since
Haiku R1

Reimplemented in BPasswordKey.

◆ Purpose()

BKeyPurpose BKey::Purpose ( ) const

Get the purpose of the key.

Since
Haiku R1

◆ SecondaryIdentifier()

const char * BKey::SecondaryIdentifier ( ) const

Get the secondary identifier of the key.

Since
Haiku R1

◆ SetData()

status_t BKey::SetData ( const uint8 data,
size_t  length 
)

Set the data for the key.

Parameters
dataA pointer to the buffer that contains the data of the key.
lengthThe length in bytes of the data.
Returns
  • B_OK if the key data was updated.
  • B_NO_MEMORY in case it fails to allocate memory.
Since
Haiku R1

◆ SetIdentifier()

void BKey::SetIdentifier ( const char *  identifier)

Set the identifier of the key.

Parameters
identifierA pointer to a valid UTF-8 string.
Since
Haiku R1

◆ SetPurpose()

void BKey::SetPurpose ( BKeyPurpose  purpose)

Set the purpose of the key.

Since
Haiku R1

◆ SetSecondaryIdentifier()

void BKey::SetSecondaryIdentifier ( const char *  identifier)

Set the secondary identifier of the key.

Parameters
identifierA pointer to a valid UTF-8 string.
Since
Haiku R1

◆ SetTo()

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.

Parameters
purposeThe purpose of this key
identifierA unique identifier for this key
secondaryIdentifierAn (optional) secondary identifier for this key
dataA pointer to a buffer that contains the value of the key, such as the password or the certificate data.
lengthThe length of the data in bytes that should be copied.
Returns
  • B_OK if the changes were successful.
  • B_NO_MEMORY in case it fails to allocate memory.
Since
Haiku R1

◆ Type()

virtual BKeyType BKey::Type ( ) const
inlinevirtual

Returns the type of key.

For a generic BKey, this will always be BKeyType::B_KEY_TYPE_GENERIC

Since
Haiku R1

Reimplemented in BPasswordKey.

References B_KEY_TYPE_GENERIC.

◆ Unflatten()

status_t BKey::Unflatten ( const BMessage message)
virtual

Unflatten the key from a message.

Since
Haiku R1

◆ Unset()

void BKey::Unset ( )

Reset the values of the key.

All properties of the key will be reset, except for the identifying owner.

Since
Haiku R1