Public Member Functions | List of all members
BPasswordKey Class Reference

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

Inherits BKey.

Public Member Functions

 BPasswordKey ()
 Constructor for an empty password key. More...
 
 BPasswordKey (BPasswordKey &other)
 Copy constructor that makes a copy of an other BPasswordKey. More...
 
 BPasswordKey (const char *password, BKeyPurpose purpose, const char *identifier, const char *secondaryIdentifier=NULL)
 Constructor for a password key with the provided data. More...
 
virtual ~BPasswordKey ()
 Free all resources associated with this key. More...
 
const char * Password () const
 Get the password for the key. More...
 
virtual void PrintToStream ()
 Dump the contents of the key to standard output. More...
 
status_t SetPassword (const char *password)
 Set the password for this key. More...
 
status_t SetTo (const char *password, BKeyPurpose purpose, const char *identifier, const char *secondaryIdentifier=NULL)
 Set the key to specific values. More...
 
virtual BKeyType Type () const
 Returns BKeyType::B_KEY_TYPE_PASSWORD. More...
 
- Public Member Functions inherited from BKey
 BKey ()
 Constructor for an empty generic key. More...
 
 BKey (BKey &other)
 Copy constructor that makes a copy of an other BKey. More...
 
 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. More...
 
virtual ~BKey ()
 Free all resources associated with this key. More...
 
bigtime_t CreationTime () const
 Get the creation time of the key. More...
 
const uint8Data () const
 Get a pointer to the data of the key. More...
 
size_t DataLength () const
 Get the size of the key in bytes. More...
 
virtual status_t Flatten (BMessage &message) const
 Flatten the key into a message. More...
 
status_t GetData (uint8 *buffer, size_t bufferSize) const
 Copy the key into the buffer. More...
 
const char * Identifier () const
 Get the identifier of the key. More...
 
bool operator!= (const BKey &other) const
 Compare this key to an other key. More...
 
BKeyoperator= (const BKey &other)
 Copy the data from the other key into this key. More...
 
bool operator== (const BKey &other) const
 Compare this key to an other key. More...
 
const char * Owner () const
 Get the owner of the key. More...
 
BKeyPurpose Purpose () const
 Get the purpose of the key. More...
 
const char * SecondaryIdentifier () const
 Get the secondary identifier of the key. More...
 
status_t SetData (const uint8 *data, size_t length)
 Set the data for the key. More...
 
void SetIdentifier (const char *identifier)
 Set the identifier of the key. More...
 
void SetPurpose (BKeyPurpose purpose)
 Set the purpose of the key. More...
 
void SetSecondaryIdentifier (const char *identifier)
 Set the secondary identifier of the key. More...
 
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. More...
 
virtual status_t Unflatten (const BMessage &message)
 Unflatten the key from a message. More...
 
void Unset ()
 Reset the values of the key. More...
 

Detailed Description

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

This is a specialized version of the BKey class, which represents a key of the BKeyType::B_KEY_TYPE_PASSWORD.

Since
Haiku R1

Constructor & Destructor Documentation

◆ BPasswordKey() [1/3]

BPasswordKey::BPasswordKey ( )

Constructor for an empty password key.

An empty key has no data associated with it, other than that it has a generic purpose and a password key type.

Since
Haiku R1

◆ BPasswordKey() [2/3]

BPasswordKey::BPasswordKey ( const char *  password,
BKeyPurpose  purpose,
const char *  identifier,
const char *  secondaryIdentifier = NULL 
)

Constructor for a password key with the provided data.

See the BKey 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
passwordA null-terminated string that contains the password
purposeThe purpose of this key
identifierA unique identifier for this key
secondaryIdentifierAn (optional) secondary identifier for this key
Since
Haiku R1

◆ BPasswordKey() [3/3]

BPasswordKey::BPasswordKey ( BPasswordKey other)

Copy constructor that makes a copy of an other BPasswordKey.

Since
Haiku R1

◆ ~BPasswordKey()

BPasswordKey::~BPasswordKey ( )
virtual

Free all resources associated with this key.

Since
Haiku R1

Member Function Documentation

◆ Password()

const char * BPasswordKey::Password ( ) const

Get the password for the key.

Since
Haiku R1

◆ PrintToStream()

void BPasswordKey::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, including the actual password, will be printed to stdout.

Since
Haiku R1

Reimplemented from BKey.

◆ SetPassword()

status_t BPasswordKey::SetPassword ( const char *  password)

Set the password for this key.

Parameters
passwordA null-terminated string that contains the password.
Since
Haiku R1

◆ SetTo()

status_t BPasswordKey::SetTo ( const char *  password,
BKeyPurpose  purpose,
const char *  identifier,
const char *  secondaryIdentifier = NULL 
)

Set the key to specific 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
passwordA null-terminated string that contains the password
purposeThe purpose of this key
identifierA unique identifier for this key
secondaryIdentifierAn (optional) secondary identifier for this key
Returns
  • B_OK if the changes were successful.
  • B_NO_MEMORY in case it fails to allocate memory.
Since
Haiku R1

◆ Type()

BKeyType BPasswordKey::Type ( ) const
inlinevirtual

Returns BKeyType::B_KEY_TYPE_PASSWORD.

Since
Haiku R1

Reimplemented from BKey.

References B_KEY_TYPE_PASSWORD.