Make Flatten/Unflatten public and remove IsRegistered().
The BKey doesn't know anything about the keyring concept, so the registered info isn't really useful. May be re-added later with keyring info as well.
This commit is contained in:
committed by
Ryan Leavengood
parent
6fb7a4569b
commit
94f897deea
@@ -67,7 +67,9 @@ public:
|
||||
|
||||
const char* Owner() const;
|
||||
bigtime_t CreationTime() const;
|
||||
bool IsRegistered() const;
|
||||
|
||||
virtual status_t Flatten(BMessage& message) const;
|
||||
virtual status_t Unflatten(const BMessage& message);
|
||||
|
||||
BKey& operator=(const BKey& other);
|
||||
|
||||
@@ -76,10 +78,6 @@ public:
|
||||
|
||||
virtual void PrintToStream();
|
||||
|
||||
protected:
|
||||
virtual status_t _Flatten(BMessage& message) const;
|
||||
virtual status_t _Unflatten(const BMessage& message);
|
||||
|
||||
private:
|
||||
friend class BKeyStore;
|
||||
|
||||
@@ -89,7 +87,6 @@ private:
|
||||
BString fOwner;
|
||||
bigtime_t fCreationTime;
|
||||
mutable BMallocIO fData;
|
||||
bool fRegistered;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+48
-49
@@ -52,6 +52,13 @@ BKey::~BKey()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BKey::Unset()
|
||||
{
|
||||
SetTo(B_KEY_PURPOSE_GENERIC, "", "", NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BKey::SetTo(BKeyPurpose purpose, const char* identifier,
|
||||
const char* secondaryIdentifier, const uint8* data, size_t length)
|
||||
@@ -157,10 +164,47 @@ BKey::CreationTime() const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BKey::IsRegistered() const
|
||||
status_t
|
||||
BKey::Flatten(BMessage& message) const
|
||||
{
|
||||
return fRegistered;
|
||||
if (message.MakeEmpty() != B_OK
|
||||
|| message.AddUInt32("type", Type()) != B_OK
|
||||
|| message.AddUInt32("purpose", fPurpose) != B_OK
|
||||
|| message.AddString("identifier", fIdentifier) != B_OK
|
||||
|| message.AddString("secondaryIdentifier", fSecondaryIdentifier)
|
||||
!= B_OK
|
||||
|| message.AddString("owner", fOwner) != B_OK
|
||||
|| message.AddInt64("creationTime", fCreationTime) != B_OK
|
||||
|| message.AddData("data", B_RAW_TYPE, fData.Buffer(),
|
||||
fData.BufferLength()) != B_OK) {
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BKey::Unflatten(const BMessage& message)
|
||||
{
|
||||
BKeyType type;
|
||||
if (message.FindUInt32("type", (uint32*)&type) != B_OK || type != Type())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
const void* data = NULL;
|
||||
ssize_t dataLength = 0;
|
||||
if (message.FindUInt32("purpose", (uint32*)&fPurpose) != B_OK
|
||||
|| message.FindString("identifier", &fIdentifier) != B_OK
|
||||
|| message.FindString("secondaryIdentifier", &fSecondaryIdentifier)
|
||||
!= B_OK
|
||||
|| message.FindString("owner", &fOwner) != B_OK
|
||||
|| message.FindInt64("creationTime", &fCreationTime) != B_OK
|
||||
|| message.FindData("data", B_RAW_TYPE, &data, &dataLength) != B_OK
|
||||
|| dataLength < 0) {
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
return SetData((const uint8*)data, (size_t)dataLength);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +217,7 @@ BKey::operator=(const BKey& other)
|
||||
fIdentifier = other.fIdentifier;
|
||||
fSecondaryIdentifier = other.fSecondaryIdentifier;
|
||||
fOwner = other.fOwner;
|
||||
fCreationTime = other.CreationTime();
|
||||
fRegistered = other.IsRegistered();
|
||||
fCreationTime = other.fCreationTime;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -237,50 +280,6 @@ BKey::PrintToStream()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BKey::_Flatten(BMessage& message) const
|
||||
{
|
||||
if (message.MakeEmpty() != B_OK
|
||||
|| message.AddUInt32("type", Type()) != B_OK
|
||||
|| message.AddUInt32("purpose", fPurpose) != B_OK
|
||||
|| message.AddString("identifier", fIdentifier) != B_OK
|
||||
|| message.AddString("secondaryIdentifier", fSecondaryIdentifier)
|
||||
!= B_OK
|
||||
|| message.AddString("owner", fOwner) != B_OK
|
||||
|| message.AddInt64("creationTime", fCreationTime) != B_OK
|
||||
|| message.AddData("data", B_RAW_TYPE, fData.Buffer(),
|
||||
fData.BufferLength()) != B_OK) {
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BKey::_Unflatten(const BMessage& message)
|
||||
{
|
||||
BKeyType type;
|
||||
if (message.FindUInt32("type", (uint32*)&type) != B_OK || type != Type())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
const void* data = NULL;
|
||||
ssize_t dataLength = 0;
|
||||
if (message.FindUInt32("purpose", (uint32*)&fPurpose) != B_OK
|
||||
|| message.FindString("identifier", &fIdentifier) != B_OK
|
||||
|| message.FindString("secondaryIdentifier", &fSecondaryIdentifier)
|
||||
!= B_OK
|
||||
|| message.FindString("owner", &fOwner) != B_OK
|
||||
|| message.FindInt64("creationTime", &fCreationTime) != B_OK
|
||||
|| message.FindData("data", B_RAW_TYPE, &data, &dataLength) != B_OK
|
||||
|| dataLength < 0) {
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
return SetData((const uint8*)data, (size_t)dataLength);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BPasswordKey
|
||||
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ BKeyStore::GetKey(const char* keyring, BKeyType type, BKeyPurpose purpose,
|
||||
if (reply.FindMessage("key", &keyMessage) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
return key._Unflatten(keyMessage);
|
||||
return key.Unflatten(keyMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ status_t
|
||||
BKeyStore::AddKey(const char* keyring, const BKey& key)
|
||||
{
|
||||
BMessage keyMessage;
|
||||
if (key._Flatten(keyMessage) != B_OK)
|
||||
if (key.Flatten(keyMessage) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage message(KEY_STORE_ADD_KEY);
|
||||
@@ -130,7 +130,7 @@ status_t
|
||||
BKeyStore::RemoveKey(const char* keyring, const BKey& key)
|
||||
{
|
||||
BMessage keyMessage;
|
||||
if (key._Flatten(keyMessage) != B_OK)
|
||||
if (key.Flatten(keyMessage) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage message(KEY_STORE_REMOVE_KEY);
|
||||
@@ -183,7 +183,7 @@ BKeyStore::GetNextKey(const char* keyring, BKeyType type, BKeyPurpose purpose,
|
||||
return B_ERROR;
|
||||
|
||||
reply.FindUInt32("cookie", &cookie);
|
||||
return key._Unflatten(keyMessage);
|
||||
return key.Unflatten(keyMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ status_t
|
||||
BKeyStore::AddKeyring(const char* keyring, const BKey& key)
|
||||
{
|
||||
BMessage keyMessage;
|
||||
if (key._Flatten(keyMessage) != B_OK)
|
||||
if (key.Flatten(keyMessage) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage message(KEY_STORE_ADD_KEYRING);
|
||||
@@ -240,7 +240,7 @@ status_t
|
||||
BKeyStore::SetMasterKey(const BKey& key)
|
||||
{
|
||||
BMessage keyMessage;
|
||||
if (key._Flatten(keyMessage) != B_OK)
|
||||
if (key.Flatten(keyMessage) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage message(KEY_STORE_SET_MASTER_KEY);
|
||||
@@ -341,7 +341,7 @@ BKeyStore::GetNextApplication(const BKey& key, uint32& cookie,
|
||||
BString& signature) const
|
||||
{
|
||||
BMessage keyMessage;
|
||||
if (key._Flatten(keyMessage) != B_OK)
|
||||
if (key.Flatten(keyMessage) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage message(KEY_STORE_GET_NEXT_APPLICATION);
|
||||
@@ -365,7 +365,7 @@ status_t
|
||||
BKeyStore::RemoveApplication(const BKey& key, const char* signature)
|
||||
{
|
||||
BMessage keyMessage;
|
||||
if (key._Flatten(keyMessage) != B_OK)
|
||||
if (key.Flatten(keyMessage) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage message(KEY_STORE_REMOVE_APPLICATION);
|
||||
|
||||
Reference in New Issue
Block a user