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
) {}
20 MOZ_IMPLICIT
ScopedCFType(decltype(nullptr)) : mValue(nullptr) {}
24 CFRelease((CFTypeRef
)mValue
);
28 T
get() { return mValue
; }
30 explicit operator bool() const { return mValue
!= nullptr; }
36 class KeychainSecret final
: public AbstractOSKeyStore
{
40 virtual nsresult
RetrieveSecret(const nsACString
& label
,
41 /* out */ nsACString
& secret
) override
;
42 virtual nsresult
StoreSecret(const nsACString
& secret
,
43 const nsACString
& label
) override
;
44 virtual nsresult
DeleteSecret(const nsACString
& label
) override
;
46 virtual ~KeychainSecret();
49 #endif // KeychainSecret_h