diff --git a/src/servers/keystore/Keyring.cpp b/src/servers/keystore/Keyring.cpp index 144edcb5b5..f6f5f2e18c 100644 --- a/src/servers/keystore/Keyring.cpp +++ b/src/servers/keystore/Keyring.cpp @@ -103,6 +103,81 @@ Keyring::KeyMessage() const } +status_t +Keyring::FindApplication(const char* signature, const char* path, + BMessage& appMessage) +{ + if (!fAccessible) + return B_NOT_ALLOWED; + + int32 count; + type_code type; + if (fApplications.GetInfo(signature, &type, &count) != B_OK) + return B_ENTRY_NOT_FOUND; + + for (int32 i = 0; i < count; i++) { + if (fApplications.FindMessage(signature, i, &appMessage) != B_OK) + continue; + + BString appPath; + if (appMessage.FindString("path", &appPath) != B_OK) + continue; + + if (appPath == path) + return B_OK; + } + + appMessage.MakeEmpty(); + return B_ENTRY_NOT_FOUND; +} + + +status_t +Keyring::AddApplication(const char* signature, const BMessage& appMessage) +{ + if (!fAccessible) + return B_NOT_ALLOWED; + + status_t result = fApplications.AddMessage(signature, &appMessage); + if (result != B_OK) + return result; + + fModified = true; + return B_OK; +} + + +status_t +Keyring::RemoveApplication(const char* signature, const char* path) +{ + if (!fAccessible) + return B_NOT_ALLOWED; + + int32 count; + type_code type; + if (fApplications.GetInfo(signature, &type, &count) != B_OK) + return B_ENTRY_NOT_FOUND; + + for (int32 i = 0; i < count; i++) { + BMessage appMessage; + if (fApplications.FindMessage(signature, i, &appMessage) != B_OK) + return B_ERROR; + + BString appPath; + if (appMessage.FindString("path", &appPath) != B_OK) + continue; + + if (appPath == path) { + fApplications.RemoveData(signature, i); + fModified = true; + return B_OK; + } + } + + return B_ENTRY_NOT_FOUND; +} + + status_t Keyring::FindKey(const BString& identifier, const BString& secondaryIdentifier, bool secondaryIdentifierOptional, BMessage* _foundKeyMessage) const diff --git a/src/servers/keystore/Keyring.h b/src/servers/keystore/Keyring.h index 9539487419..0c75263aa2 100644 --- a/src/servers/keystore/Keyring.h +++ b/src/servers/keystore/Keyring.h @@ -25,6 +25,13 @@ public: bool IsAccessible() const; const BMessage& KeyMessage() const; + status_t FindApplication(const char* signature, + const char* path, BMessage& appMessage); + status_t AddApplication(const char* signature, + const BMessage& appMessage); + status_t RemoveApplication(const char* signature, + const char* path); + status_t FindKey(const BString& identifier, const BString& secondaryIdentifier, bool secondaryIdentifierOptional,