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 "qopcuax509extensionsubjectalternativename.h" |
5 | #include "qopcuax509extension_p.h" |
6 | |
7 | #include <QList> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | /*! |
12 | \class QOpcUaX509ExtensionSubjectAlternativeName |
13 | \inmodule QtOpcUa |
14 | \since 5.14 |
15 | |
16 | \brief Class for an X509 subject alternative name. |
17 | |
18 | This class is currently available as a Technology Preview, and therefore the API |
19 | and functionality provided by the class may be subject to change at any time without |
20 | prior notice. |
21 | */ |
22 | |
23 | /*! |
24 | \enum QOpcUaX509ExtensionSubjectAlternativeName::Type |
25 | |
26 | Enum with entry types for subject alternative name. |
27 | |
28 | \value Email |
29 | Entry type for an email address |
30 | \value URI |
31 | Entry type for an URI |
32 | \value DNS |
33 | Entry type for DNS |
34 | \value IP |
35 | Entry type for an IP address |
36 | */ |
37 | |
38 | class QOpcUaX509ExtensionSubjectAlternativeNameData : public QOpcUaX509ExtensionData |
39 | { |
40 | public: |
41 | ~QOpcUaX509ExtensionSubjectAlternativeNameData() override = default; |
42 | QList <QPair<QOpcUaX509ExtensionSubjectAlternativeName::Type, QString>> entries; |
43 | }; |
44 | |
45 | /*! |
46 | Constructs a X509ExtensionSubjectAlternativeName. |
47 | */ |
48 | QOpcUaX509ExtensionSubjectAlternativeName::QOpcUaX509ExtensionSubjectAlternativeName() |
49 | : QOpcUaX509Extension(new QOpcUaX509ExtensionSubjectAlternativeNameData) |
50 | { |
51 | } |
52 | |
53 | /*! |
54 | Constructs a X509ExtensionSubjectAlternativeName from \a rhs. |
55 | */ |
56 | QOpcUaX509ExtensionSubjectAlternativeName::QOpcUaX509ExtensionSubjectAlternativeName(const QOpcUaX509ExtensionSubjectAlternativeName &rhs) |
57 | : QOpcUaX509Extension(rhs.data) |
58 | { |
59 | } |
60 | |
61 | /*! |
62 | Returns \c true if this X509ExtensionSubjectAlternativeName has the same value as \a rhs. |
63 | */ |
64 | bool QOpcUaX509ExtensionSubjectAlternativeName::operator==(const QOpcUaX509ExtensionSubjectAlternativeName &rhs) const |
65 | { |
66 | return data->critical == rhs.data->critical; |
67 | } |
68 | |
69 | /*! |
70 | Destructs a X509ExtensionSubjectAlternativeName. |
71 | */ |
72 | QOpcUaX509ExtensionSubjectAlternativeName::~QOpcUaX509ExtensionSubjectAlternativeName() |
73 | { |
74 | } |
75 | |
76 | /*! |
77 | Sets the values from \a rhs in this X509ExtensionSubjectAlternativeName. |
78 | */ |
79 | QOpcUaX509ExtensionSubjectAlternativeName &QOpcUaX509ExtensionSubjectAlternativeName::operator=(const QOpcUaX509ExtensionSubjectAlternativeName &rhs) |
80 | { |
81 | if (this != &rhs) |
82 | data.operator=(o: rhs.data); |
83 | return *this; |
84 | } |
85 | |
86 | /*! |
87 | Adds an entry of type \a type with content \a value. |
88 | */ |
89 | void QOpcUaX509ExtensionSubjectAlternativeName::addEntry(QOpcUaX509ExtensionSubjectAlternativeName::Type type, const QString &value) |
90 | { |
91 | QOpcUaX509ExtensionSubjectAlternativeNameData *d = static_cast<QOpcUaX509ExtensionSubjectAlternativeNameData*>(data.data()); |
92 | d->entries.append(t: qMakePair(value1&: type, value2: value)); |
93 | } |
94 | |
95 | /*! |
96 | Returns the vector of entries. |
97 | */ |
98 | const QList<QPair<QOpcUaX509ExtensionSubjectAlternativeName::Type, QString>> &QOpcUaX509ExtensionSubjectAlternativeName::entries() const |
99 | { |
100 | const QOpcUaX509ExtensionSubjectAlternativeNameData *d = static_cast<const QOpcUaX509ExtensionSubjectAlternativeNameData*>(data.data()); |
101 | return d->entries; |
102 | } |
103 | |
104 | QT_END_NAMESPACE |
105 |