Libkleo

keyusage.h
1/* -*- mode: c++; c-basic-offset:4 -*-
2 utils/keyusage.h
3
4 This file is part of libkleopatra, the KDE keymanagement library
5 SPDX-FileCopyrightText: 2022 g10 Code GmbH
6 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "kleo_export.h"
14
15#include <QFlags>
16
17namespace Kleo
18{
19
20class KLEO_EXPORT KeyUsage
21{
22public:
23 enum Flag {
24 None = 0,
25 Certify = 1,
26 Sign = 2,
27 Encrypt = 4,
28 Authenticate = 8,
29 };
30 Q_DECLARE_FLAGS(Flags, Flag)
31
32 KeyUsage()
33 {
34 }
35
36 explicit KeyUsage(Flags flags)
37 : mFlags{flags}
38 {
39 }
40
41 void setValue(Flags flags)
42 {
43 mFlags = flags;
44 }
45 Flags value() const
46 {
47 return mFlags;
48 }
49
50 void setCanAuthenticate(bool set)
51 {
52 mFlags.setFlag(Authenticate, set);
53 }
54 bool canAuthenticate() const
55 {
56 return mFlags.testFlag(Authenticate);
57 }
58
59 void setCanCertify(bool set)
60 {
61 mFlags.setFlag(Certify, set);
62 }
63 bool canCertify() const
64 {
65 return mFlags.testFlag(Certify);
66 }
67
68 void setCanEncrypt(bool set)
69 {
70 mFlags.setFlag(Encrypt, set);
71 }
72 bool canEncrypt() const
73 {
74 return mFlags.testFlag(Encrypt);
75 }
76
77 void setCanSign(bool set)
78 {
79 mFlags.setFlag(Sign, set);
80 }
81 bool canSign() const
82 {
83 return mFlags.testFlag(Sign);
84 }
85
86private:
87 Flags mFlags;
88};
89
90Q_DECLARE_OPERATORS_FOR_FLAGS(KeyUsage::Flags)
91
92}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.