2 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
4 * All rights reserved. Distributed under the terms of the MIT License.
6 #ifndef CREDENTIAL_STORAGE_H
7 #define CREDENTIAL_STORAGE_H
23 Credentials(const BString
& username
,
24 const BString
& password
);
26 const Credentials
& other
);
27 Credentials(const BMessage
* archive
);
30 status_t
Archive(BMessage
* archive
) const;
32 Credentials
& operator=(const Credentials
& other
);
34 bool operator==(const Credentials
& other
) const;
35 bool operator!=(const Credentials
& other
) const;
37 const BString
& Username() const;
38 const BString
& Password() const;
46 class CredentialsStorage
: public BLocker
{
48 static CredentialsStorage
* SessionInstance();
49 static CredentialsStorage
* PersistentInstance();
51 bool Contains(const HashKeyString
& key
);
52 status_t
PutCredentials(const HashKeyString
& key
,
53 const Credentials
& credentials
);
54 Credentials
GetCredentials(const HashKeyString
& key
);
57 CredentialsStorage(bool persistent
);
58 virtual ~CredentialsStorage();
61 void _SaveSettings() const;
62 bool _OpenSettingsFile(BFile
& file
,
66 typedef HashMap
<HashKeyString
, Credentials
> CredentialMap
;
67 CredentialMap fCredentialMap
;
69 static CredentialsStorage sPersistentInstance
;
70 static CredentialsStorage sSessionInstance
;
76 #endif // CREDENTIAL_STORAGE_H