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
7QT_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
21class QOpcUaX509ExtensionBasicConstraintsData : public QOpcUaX509ExtensionData
22{
23public:
24 ~QOpcUaX509ExtensionBasicConstraintsData() override = default;
25 bool ca = false;
26 int pathLength = -1;
27};
28
29/*!
30 Constructs a default X509ExtensionBasicConstraints.
31*/
32QOpcUaX509ExtensionBasicConstraints::QOpcUaX509ExtensionBasicConstraints()
33 : QOpcUaX509Extension(new QOpcUaX509ExtensionBasicConstraintsData)
34{
35}
36
37/*!
38 Constructs a X509ExtensionBasicConstraints from \a rhs.
39*/
40QOpcUaX509ExtensionBasicConstraints::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*/
48bool QOpcUaX509ExtensionBasicConstraints::operator==(const QOpcUaX509ExtensionBasicConstraints &rhs) const
49{
50 return data->critical == rhs.data->critical;
51}
52
53/*!
54 Destructs a X509ExtensionBasicConstraints.
55*/
56QOpcUaX509ExtensionBasicConstraints::~QOpcUaX509ExtensionBasicConstraints()
57{
58}
59
60/*!
61 Sets the values from \a rhs in this X509ExtensionBasicConstraints.
62*/
63QOpcUaX509ExtensionBasicConstraints &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*/
73void 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*/
82bool 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*/
91void 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*/
100int QOpcUaX509ExtensionBasicConstraints::pathLength() const
101{
102 const QOpcUaX509ExtensionBasicConstraintsData *d = static_cast<const QOpcUaX509ExtensionBasicConstraintsData*>(data.data());
103 return d->pathLength;
104}
105
106QT_END_NAMESPACE
107

source code of qtopcua/src/opcua/x509/qopcuax509extensionbasicconstraints.cpp