view ui/certificate.h @ 340:9001eaa55549

Add first draft of packaging to build upon
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 09 Apr 2014 17:39:24 +0000
parents 64e38886f903
children 36c68dfb821d
line wrap: on
line source
#ifndef CERTIFICATE_H
#define CERTIFICATE_H
/**
 * @file certificate.h
 * @brief Class around native certificates.
 *
 */

#include <QByteArray>
#include <QDateTime>
#include <QMap>
#include <QString>

#ifdef Q_OS_WIN
#include <windows.h>
#include <wincrypt.h>
#endif

class Certificate
{
public:

    enum Status {
        InstallNew = 1,
        InstallOld,
        RemoveNew,
        RemoveOld
    };

    /** @brief construct a certificate from a line of a certificate list.
     *
     * The first two characters of the string are expected to be
     * the command. I: or R:
     *
     *  @param[in] b64Line The line from the certificate list.
     **/
    Certificate(const QString& b64Line = QString());

    /** @brief check if this certificate could be parsed */
    bool isValid() const {return mValid;}

    /** @brief get a short description of the certificate
     *
     *  This description should be used as a short overview
     *  for this certificate
     *
     **/
    QString shortDescription() const;

    /** @brief get details for the certificate
     *
     * Get a formatted details string usable for user visible
     * certificate details.
     *
     **/
    const QString& details() const {return mDetails;}

    /** @brief get the line from which this certificate was constructed
     *
     * The resulting line includes the instruction e.g.
     *
     * I:BASE64ENCODEDATA...
     *
     **/
    const QString& base64Line() const {return mBaseLine;}

    /** @brief Check if this certificate has the install instruction.
     *
     * This is shorthand for baseLine.startsWith("I:");
     **/
    bool isInstallCert() const {return mBaseLine.startsWith("I:");}

private:
    /** @brief Helper function to parse the details of a certificate **/
    void parseDetails(const QByteArray& cert);

    bool mValid;
    bool mInstCert;

    QString mSubjectOU,
            mSubjectCN,
            mSubjectO,
            mSubjectSN,
            mDetails,
            mBaseLine;

    QDateTime mValidFrom,
              mValidTo;
};
#endif

http://wald.intevation.org/projects/trustbridge/