1/*
2 * Copyright 2012, Michael Lotz, mmlr@mlotz.ch. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _KEY_STORE_SERVER_H
6#define _KEY_STORE_SERVER_H
7
8
9#include <Application.h>
10#include <File.h>
11#include <Key.h>
12#include <ObjectList.h>
13
14
15struct app_info;
16class Keyring;
17
18typedef BObjectList<Keyring> KeyringList;
19
20
21class KeyStoreServer : public BApplication {
22public:
23									KeyStoreServer();
24virtual								~KeyStoreServer();
25
26virtual	void						MessageReceived(BMessage* message);
27
28private:
29		status_t					_ReadKeyStoreDatabase();
30		status_t					_WriteKeyStoreDatabase();
31
32		uint32						_AccessFlagsFor(uint32 command) const;
33		const char*					_AccessStringFor(uint32 accessFlag) const;
34		status_t					_ResolveCallingApp(const BMessage& message,
35										app_info& callingAppInfo) const;
36
37		status_t					_ValidateAppAccess(Keyring& keyring,
38										const app_info& appInfo,
39										uint32 accessFlags);
40		status_t					_RequestAppAccess(
41										const BString& keyringName,
42										const char* signature,
43										const char* path,
44										const char* accessString, bool appIsNew,
45										bool appWasUpdated, uint32 accessFlags,
46										bool& allowAlways);
47
48		Keyring*					_FindKeyring(const BString& name);
49
50		status_t					_AddKeyring(const BString& name);
51		status_t					_RemoveKeyring(const BString& name);
52
53		status_t					_UnlockKeyring(Keyring& keyring);
54
55		status_t					_RequestKey(const BString& keyringName,
56										BMessage& keyMessage);
57
58		Keyring*					fMasterKeyring;
59		KeyringList					fKeyrings;
60		BFile						fKeyStoreFile;
61};
62
63
64#endif // _KEY_STORE_SERVER_H
65