| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslcertificateextension.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | 
|---|---|---|
| 1 | /**************************************************************************** | - | 
| 2 | ** | - | 
| 3 | ** Copyright (C) 2011 Richard J. Moore <rich@kde.org> | - | 
| 4 | ** Contact: http://www.qt.io/licensing/ | - | 
| 5 | ** | - | 
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - | 
| 7 | ** | - | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | 
| 9 | ** Commercial License Usage | - | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | 
| 11 | ** accordance with the commercial license agreement provided with the | - | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | 
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | 
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | 
| 16 | ** | - | 
| 17 | ** GNU Lesser General Public License Usage | - | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | 
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | 
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | 
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | 
| 22 | ** following information to ensure the GNU Lesser General Public License | - | 
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | 
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | 
| 25 | ** | - | 
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | 
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | 
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | 
| 29 | ** | - | 
| 30 | ** $QT_END_LICENSE$ | - | 
| 31 | ** | - | 
| 32 | ****************************************************************************/ | - | 
| 33 | - | |
| 34 | /*! | - | 
| 35 | \class QSslCertificateExtension | - | 
| 36 | \brief The QSslCertificateExtension class provides an API for accessing the | - | 
| 37 | extensions of an X509 certificate. | - | 
| 38 | \since 5.0 | - | 
| 39 | - | |
| 40 | \reentrant | - | 
| 41 | \ingroup network | - | 
| 42 | \ingroup ssl | - | 
| 43 | \ingroup shared | - | 
| 44 | \inmodule QtNetwork | - | 
| 45 | - | |
| 46 | QSslCertificateExtension provides access to an extension stored in | - | 
| 47 | an X509 certificate. The information available depends on the type | - | 
| 48 | of extension being accessed. | - | 
| 49 | - | |
| 50 | All X509 certificate extensions have the following properties: | - | 
| 51 | - | |
| 52 | \table | - | 
| 53 | \header | - | 
| 54 | \li Property | - | 
| 55 | \li Description | - | 
| 56 | \row | - | 
| 57 | \li name | - | 
| 58 | \li The human readable name of the extension, eg. 'basicConstraints'. | - | 
| 59 | \row | - | 
| 60 | \li criticality | - | 
| 61 | \li This is a boolean value indicating if the extension is critical | - | 
| 62 | to correctly interpreting the certificate. | - | 
| 63 | \row | - | 
| 64 | \li oid | - | 
| 65 | \li The ASN.1 object identifier that specifies which extension this | - | 
| 66 | is. | - | 
| 67 | \row | - | 
| 68 | \li supported | - | 
| 69 | \li If this is true the structure of the extension's value will not | - | 
| 70 | change between Qt versions. | - | 
| 71 | \row | - | 
| 72 | \li value | - | 
| 73 | \li A QVariant with a structure dependent on the type of extension. | - | 
| 74 | \endtable | - | 
| 75 | - | |
| 76 | Whilst this class provides access to any type of extension, only | - | 
| 77 | some are guaranteed to be returned in a format that will remain | - | 
| 78 | unchanged between releases. The isSupported() method returns \c true | - | 
| 79 | for extensions where this is the case. | - | 
| 80 | - | |
| 81 | The extensions currently supported, and the structure of the value | - | 
| 82 | returned are as follows: | - | 
| 83 | - | |
| 84 | \table | - | 
| 85 | \header | - | 
| 86 | \li Name | - | 
| 87 | \li OID | - | 
| 88 | \li Details | - | 
| 89 | \row | - | 
| 90 | \li basicConstraints | - | 
| 91 | \li 2.5.29.19 | - | 
| 92 | \li Returned as a QVariantMap. The key 'ca' contains a boolean value, | - | 
| 93 | the optional key 'pathLenConstraint' contains an integer. | - | 
| 94 | \row | - | 
| 95 | \li authorityInfoAccess | - | 
| 96 | \li 1.3.6.1.5.5.7.1.1 | - | 
| 97 | \li Returned as a QVariantMap. There is a key for each access method, | - | 
| 98 | with the value being a URI. | - | 
| 99 | \row | - | 
| 100 | \li subjectKeyIdentifier | - | 
| 101 | \li 2.5.29.14 | - | 
| 102 | \li Returned as a QVariant containing a QString. The string is the key | - | 
| 103 | identifier. | - | 
| 104 | \row | - | 
| 105 | \li authorityKeyIdentifier | - | 
| 106 | \li 2.5.29.35 | - | 
| 107 | \li Returned as a QVariantMap. The optional key 'keyid' contains the key | - | 
| 108 | identifier as a hex string stored in a QByteArray. The optional key | - | 
| 109 | 'serial' contains the authority key serial number as a qlonglong. | - | 
| 110 | Currently there is no support for the general names field of this | - | 
| 111 | extension. | - | 
| 112 | \endtable | - | 
| 113 | - | |
| 114 | In addition to the supported extensions above, many other common extensions | - | 
| 115 | will be returned in a reasonably structured way. Extensions that the SSL | - | 
| 116 | backend has no support for at all will be returned as a QByteArray. | - | 
| 117 | - | |
| 118 | Further information about the types of extensions certificates can | - | 
| 119 | contain can be found in RFC 5280. | - | 
| 120 | - | |
| 121 | \sa QSslCertificate::extensions() | - | 
| 122 | */ | - | 
| 123 | - | |
| 124 | #include "qsslcertificateextension.h" | - | 
| 125 | #include "qsslcertificateextension_p.h" | - | 
| 126 | - | |
| 127 | QT_BEGIN_NAMESPACE | - | 
| 128 | - | |
| 129 | /*! | - | 
| 130 | Constructs a QSslCertificateExtension. | - | 
| 131 | */ | - | 
| 132 | QSslCertificateExtension::QSslCertificateExtension() | - | 
| 133 | : d(new QSslCertificateExtensionPrivate) | - | 
| 134 | { | - | 
| 135 | } executed 18 times by 1 test:  end of blockExecuted by: 
 | 18 | 
| 136 | - | |
| 137 | /*! | - | 
| 138 | Constructs a copy of \a other. | - | 
| 139 | */ | - | 
| 140 | QSslCertificateExtension::QSslCertificateExtension(const QSslCertificateExtension &other) | - | 
| 141 | : d(other.d) | - | 
| 142 | { | - | 
| 143 | } executed 43 times by 1 test:  end of blockExecuted by: 
 | 43 | 
| 144 | - | |
| 145 | /*! | - | 
| 146 | Destroys the extension. | - | 
| 147 | */ | - | 
| 148 | QSslCertificateExtension::~QSslCertificateExtension() | - | 
| 149 | { | - | 
| 150 | } | - | 
| 151 | - | |
| 152 | /*! | - | 
| 153 | Assigns \a other to this extension and returns a reference to this extension. | - | 
| 154 | */ | - | 
| 155 | QSslCertificateExtension &QSslCertificateExtension::operator=(const QSslCertificateExtension &other) | - | 
| 156 | { | - | 
| 157 | d = other.d; | - | 
| 158 | return *this; never executed:  return *this; | 0 | 
| 159 | } | - | 
| 160 | - | |
| 161 | /*! | - | 
| 162 | \fn void QSslCertificateExtension::swap(QSslCertificateExtension &other) | - | 
| 163 | - | |
| 164 | Swaps this certificate extension instance with \a other. This | - | 
| 165 | function is very fast and never fails. | - | 
| 166 | */ | - | 
| 167 | - | |
| 168 | /*! | - | 
| 169 | Returns the ASN.1 OID of this extension. | - | 
| 170 | */ | - | 
| 171 | QString QSslCertificateExtension::oid() const | - | 
| 172 | { | - | 
| 173 | return d->oid; executed 16 times by 1 test:  return d->oid;Executed by: 
 | 16 | 
| 174 | } | - | 
| 175 | - | |
| 176 | /*! | - | 
| 177 | Returns the name of the extension. If no name is known for the | - | 
| 178 | extension then the OID will be returned. | - | 
| 179 | */ | - | 
| 180 | QString QSslCertificateExtension::name() const | - | 
| 181 | { | - | 
| 182 | return d->name; executed 61 times by 1 test:  return d->name;Executed by: 
 | 61 | 
| 183 | } | - | 
| 184 | - | |
| 185 | /*! | - | 
| 186 | Returns the value of the extension. The structure of the value | - | 
| 187 | returned depends on the extension type. | - | 
| 188 | */ | - | 
| 189 | QVariant QSslCertificateExtension::value() const | - | 
| 190 | { | - | 
| 191 | return d->value; executed 6 times by 1 test:  return d->value;Executed by: 
 | 6 | 
| 192 | } | - | 
| 193 | - | |
| 194 | /*! | - | 
| 195 | Returns the criticality of the extension. | - | 
| 196 | */ | - | 
| 197 | bool QSslCertificateExtension::isCritical() const | - | 
| 198 | { | - | 
| 199 | return d->critical; executed 7 times by 1 test:  return d->critical;Executed by: 
 | 7 | 
| 200 | } | - | 
| 201 | - | |
| 202 | /*! | - | 
| 203 | Returns the true if this extension is supported. In this case, | - | 
| 204 | supported simply means that the structure of the QVariant returned | - | 
| 205 | by the value() accessor will remain unchanged between versions. | - | 
| 206 | Unsupported extensions can be freely used, however there is no | - | 
| 207 | guarantee that the returned data will have the same structure | - | 
| 208 | between versions. | - | 
| 209 | */ | - | 
| 210 | bool QSslCertificateExtension::isSupported() const | - | 
| 211 | { | - | 
| 212 | return d->supported; executed 7 times by 1 test:  return d->supported;Executed by: 
 | 7 | 
| 213 | } | - | 
| 214 | - | |
| 215 | QT_END_NAMESPACE | - | 
| Source code | Switch to Preprocessed file |