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 aheinecke@338: #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@338: * Get a formatted details string usable for user visible aheinecke@338: * certificate details. 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: 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: rrenkert@341: /** @brief get the subject OU from the certificate */ rrenkert@341: QString subjectOU() const {return mSubjectOU;} rrenkert@341: rrenkert@341: /** @brief get the subject CN from the certificate */ rrenkert@341: QString subjectCN() const {return mSubjectCN;} rrenkert@341: rrenkert@341: /** @brief get the subject O from the certificate */ rrenkert@341: QString subjectO() const {return mSubjectO;} rrenkert@341: rrenkert@341: /** @brief get the subject SN from the certificate */ rrenkert@341: QString subjectSN() const {return mSubjectSN;} rrenkert@341: rrenkert@341: /** @brief get the date the certificate was issued */ rrenkert@341: QDateTime validFrom() const {return mValidFrom;} rrenkert@341: rrenkert@341: /** @brief get the date the certificate expires */ rrenkert@341: QDateTime validTo() const {return mValidTo;} rrenkert@341: aheinecke@21: private: aheinecke@338: /** @brief Helper function to parse the details of a certificate **/ aheinecke@338: void parseDetails(const QByteArray& cert); aheinecke@338: aheinecke@21: bool mValid; aheinecke@248: bool mInstCert; aheinecke@83: aheinecke@338: QString mSubjectOU, aheinecke@338: mSubjectCN, aheinecke@338: mSubjectO, aheinecke@338: mSubjectSN, aheinecke@338: mDetails, aheinecke@338: mBaseLine; aheinecke@338: aheinecke@338: QDateTime mValidFrom, aheinecke@338: mValidTo; aheinecke@21: }; aheinecke@21: #endif