1 | // Copyright (C) 2019 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qopcuax509extensionbasicconstraints.h" |
5 | #include "qopcuax509extension_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | /*! |
10 | \class QOpcUaX509ExtensionBasicConstraints |
11 | \inmodule QtOpcUa |
12 | \since 5.14 |
13 | |
14 | \brief Class for X509 basic constraints. |
15 | |
16 | This class is currently available as a Technology Preview, and therefore the API |
17 | and functionality provided by the class may be subject to change at any time without |
18 | prior notice. |
19 | */ |
20 | |
21 | class QOpcUaX509ExtensionBasicConstraintsData : public QOpcUaX509ExtensionData |
22 | { |
23 | public: |
24 | ~QOpcUaX509ExtensionBasicConstraintsData() override = default; |
25 | bool ca = false; |
26 | int pathLength = -1; |
27 | }; |
28 | |
29 | /*! |
30 | Constructs a default X509ExtensionBasicConstraints. |
31 | */ |
32 | QOpcUaX509ExtensionBasicConstraints::QOpcUaX509ExtensionBasicConstraints() |
33 | : QOpcUaX509Extension(new QOpcUaX509ExtensionBasicConstraintsData) |
34 | { |
35 | } |
36 | |
37 | /*! |
38 | Constructs a X509ExtensionBasicConstraints from \a rhs. |
39 | */ |
40 | QOpcUaX509ExtensionBasicConstraints::QOpcUaX509ExtensionBasicConstraints(const QOpcUaX509ExtensionBasicConstraints &rhs) |
41 | : QOpcUaX509Extension(rhs.data) |
42 | { |
43 | } |
44 | |
45 | /*! |
46 | Returns \c true if this X509ExtensionBasicConstraints has the same value as \a rhs. |
47 | */ |
48 | bool QOpcUaX509ExtensionBasicConstraints::operator==(const QOpcUaX509ExtensionBasicConstraints &rhs) const |
49 | { |
50 | return data->critical == rhs.data->critical; |
51 | } |
52 | |
53 | /*! |
54 | Destructs a X509ExtensionBasicConstraints. |
55 | */ |
56 | QOpcUaX509ExtensionBasicConstraints::~QOpcUaX509ExtensionBasicConstraints() |
57 | { |
58 | } |
59 | |
60 | /*! |
61 | Sets the values from \a rhs in this X509ExtensionBasicConstraints. |
62 | */ |
63 | QOpcUaX509ExtensionBasicConstraints &QOpcUaX509ExtensionBasicConstraints::operator=(const QOpcUaX509ExtensionBasicConstraints &rhs) |
64 | { |
65 | if (this != &rhs) |
66 | data.operator=(o: rhs.data); |
67 | return *this; |
68 | } |
69 | |
70 | /*! |
71 | Sets the flag, if the certificate's subject is a CA to \a value. |
72 | */ |
73 | void QOpcUaX509ExtensionBasicConstraints::setCa(bool value) |
74 | { |
75 | QOpcUaX509ExtensionBasicConstraintsData *d = static_cast<QOpcUaX509ExtensionBasicConstraintsData*>(data.data()); |
76 | d->ca = value; |
77 | } |
78 | |
79 | /*! |
80 | Returns the flag, if the certificate's subject is a CA. |
81 | */ |
82 | bool QOpcUaX509ExtensionBasicConstraints::ca() const |
83 | { |
84 | const QOpcUaX509ExtensionBasicConstraintsData *d = static_cast<const QOpcUaX509ExtensionBasicConstraintsData*>(data.data()); |
85 | return d->ca; |
86 | } |
87 | |
88 | /*! |
89 | Sets the validation path length of the certificate to \a length. |
90 | */ |
91 | void QOpcUaX509ExtensionBasicConstraints::setPathLength(int length) |
92 | { |
93 | QOpcUaX509ExtensionBasicConstraintsData *d = static_cast<QOpcUaX509ExtensionBasicConstraintsData*>(data.data()); |
94 | d->pathLength = length; |
95 | } |
96 | |
97 | /*! |
98 | Returns the validation path length of the certificate. |
99 | */ |
100 | int QOpcUaX509ExtensionBasicConstraints::pathLength() const |
101 | { |
102 | const QOpcUaX509ExtensionBasicConstraintsData *d = static_cast<const QOpcUaX509ExtensionBasicConstraintsData*>(data.data()); |
103 | return d->pathLength; |
104 | } |
105 | |
106 | QT_END_NAMESPACE |
107 |