195eee1a3SMichael Lotz /* 295eee1a3SMichael Lotz * Copyright 2012, Michael Lotz, mmlr@mlotz.ch. All Rights Reserved. 395eee1a3SMichael Lotz * Distributed under the terms of the MIT License. 495eee1a3SMichael Lotz */ 595eee1a3SMichael Lotz #ifndef _KEYRING_H 695eee1a3SMichael Lotz #define _KEYRING_H 795eee1a3SMichael Lotz 895eee1a3SMichael Lotz 995eee1a3SMichael Lotz #include <Key.h> 1095eee1a3SMichael Lotz #include <Message.h> 1195eee1a3SMichael Lotz 1295eee1a3SMichael Lotz 1395eee1a3SMichael Lotz class Keyring { 1495eee1a3SMichael Lotz public: 1595eee1a3SMichael Lotz Keyring(const char* name, 16*1dd765c9SMichael Lotz const BMessage& data, 17*1dd765c9SMichael Lotz const BMessage* keyMessage = NULL); 1895eee1a3SMichael Lotz ~Keyring(); 1995eee1a3SMichael Lotz 2095eee1a3SMichael Lotz const char* Name() const { return fName; } 2195eee1a3SMichael Lotz const BMessage& Data() const { return fData; } 2295eee1a3SMichael Lotz 23ac9b28f0SMichael Lotz status_t Access(const BMessage& keyMessage); 24ac9b28f0SMichael Lotz void RevokeAccess(); 25*1dd765c9SMichael Lotz bool IsAccessible() const; 26*1dd765c9SMichael Lotz const BMessage& KeyMessage() const; 2795eee1a3SMichael Lotz 2895eee1a3SMichael Lotz status_t FindKey(const BString& identifier, 2995eee1a3SMichael Lotz const BString& secondaryIdentifier, 3095eee1a3SMichael Lotz bool secondaryIdentifierOptional, 31*1dd765c9SMichael Lotz BMessage* _foundKeyMessage) const; 3295eee1a3SMichael Lotz status_t FindKey(BKeyType type, BKeyPurpose purpose, 3395eee1a3SMichael Lotz uint32 index, 34*1dd765c9SMichael Lotz BMessage& _foundKeyMessage) const; 3595eee1a3SMichael Lotz 3695eee1a3SMichael Lotz status_t AddKey(const BString& identifier, 3795eee1a3SMichael Lotz const BString& secondaryIdentifier, 3895eee1a3SMichael Lotz const BMessage& keyMessage); 3995eee1a3SMichael Lotz status_t RemoveKey(const BString& identifier, 4095eee1a3SMichael Lotz const BMessage& keyMessage); 4195eee1a3SMichael Lotz 4295eee1a3SMichael Lotz static int Compare(const Keyring* one, 4395eee1a3SMichael Lotz const Keyring* two); 4495eee1a3SMichael Lotz static int Compare(const BString* name, 4595eee1a3SMichael Lotz const Keyring* keyring); 4695eee1a3SMichael Lotz 4795eee1a3SMichael Lotz private: 4895eee1a3SMichael Lotz BString fName; 4995eee1a3SMichael Lotz BMessage fData; 50*1dd765c9SMichael Lotz BMessage fKeyMessage; 51ac9b28f0SMichael Lotz bool fAccessible; 5295eee1a3SMichael Lotz }; 5395eee1a3SMichael Lotz 5495eee1a3SMichael Lotz 5595eee1a3SMichael Lotz #endif // _KEYRING_H 56