1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef KeychainSecret_h
8 #define KeychainSecret_h
10 #include "CoreFoundation/CFBase.h"
12 #include "OSKeyStore.h"
18 explicit ScopedCFType(T value
) : mValue(value
) {}
22 CFRelease((CFTypeRef
)mValue
);
26 T
get() { return mValue
; }
28 explicit operator bool() const { return mValue
!= nullptr; }
34 class KeychainSecret final
: public AbstractOSKeyStore
{
38 virtual nsresult
RetrieveSecret(const nsACString
& label
,
39 /* out */ nsACString
& secret
) override
;
40 virtual nsresult
StoreSecret(const nsACString
& secret
,
41 const nsACString
& label
) override
;
42 virtual nsresult
DeleteSecret(const nsACString
& label
) override
;
43 virtual nsresult
Lock() override
;
44 virtual nsresult
Unlock() override
;
46 virtual ~KeychainSecret();
49 #endif // KeychainSecret_h