aheinecke@21: #ifndef CERTIFICATE_H aheinecke@21: #define CERTIFICATE_H aheinecke@21: /** aheinecke@21: * @file certificate.h aheinecke@21: * @brief Class around native certificates. aheinecke@21: * aheinecke@21: */ aheinecke@21: aheinecke@21: #include andre@186: #include aheinecke@21: #include aheinecke@21: aheinecke@21: #ifdef Q_OS_WIN aheinecke@21: #include aheinecke@21: #include aheinecke@21: #endif aheinecke@21: aheinecke@21: class Certificate aheinecke@21: { aheinecke@21: public: aheinecke@94: rrenkert@265: enum Status { rrenkert@265: InstallNew = 1, rrenkert@265: InstallOld, rrenkert@265: RemoveNew, rrenkert@265: RemoveOld rrenkert@265: }; rrenkert@265: aheinecke@83: /** @brief construct a certificate from a line of a certificate list. aheinecke@83: * aheinecke@83: * The first two characters of the string are expected to be aheinecke@83: * the command. I: or R: aheinecke@83: * aheinecke@83: * @param[in] b64Line The line from the certificate list. aheinecke@21: **/ aheinecke@94: Certificate(const QString& b64Line = QString()); aheinecke@21: aheinecke@21: /** @brief check if this certificate could be parsed */ aheinecke@78: bool isValid() const {return mValid;} aheinecke@21: aheinecke@21: /** @brief get a short description of the certificate aheinecke@21: * aheinecke@21: * This description should be used as a short overview aheinecke@21: * for this certificate aheinecke@21: * aheinecke@21: **/ andre@186: QString shortDescription() const; aheinecke@83: aheinecke@83: /** @brief get details for the certificate aheinecke@83: * aheinecke@83: * Get the X509 information that is returned by x509_crt_info aheinecke@83: * aheinecke@83: **/ aheinecke@83: const QString& details() const {return mDetails;} aheinecke@83: aheinecke@83: /** @brief get the line from which this certificate was constructed aheinecke@83: * aheinecke@83: * The resulting line includes the instruction e.g. aheinecke@83: * aheinecke@83: * I:BASE64ENCODEDATA... aheinecke@83: * aheinecke@83: **/ aheinecke@83: const QString& base64Line() const {return mBaseLine;} aheinecke@21: andre@186: /** @brief get a single attribute of the subject andre@186: * andre@186: * Returns a single attribute of the subject such as the andre@186: * common name. andre@186: * andre@186: * @param[in] attr the Attribute name. to get e.g. "CN" andre@186: * andre@186: * @returns the value of the attribute or a null string andre@186: **/ andre@186: QString getSubjectAttr(const QString& attr) const; andre@186: aheinecke@248: /** @brief Check if this certificate has the install instruction. aheinecke@248: * aheinecke@248: * This is shorthand for baseLine.startsWith("I:"); aheinecke@248: **/ aheinecke@248: bool isInstallCert() const {return mBaseLine.startsWith("I:");} aheinecke@248: aheinecke@21: private: aheinecke@21: bool mValid; aheinecke@248: bool mInstCert; aheinecke@83: aheinecke@83: QString mDetails; aheinecke@83: QString mBaseLine; andre@186: QMap mSubjectAttrs; aheinecke@21: }; aheinecke@21: #endif