Blame lang/cpp/src/verificationresult.h

Packit d7e8d0
/*
Packit d7e8d0
  verificationresult.h - wraps a gpgme verify result
Packit d7e8d0
  Copyright (C) 2004 Klarälvdalens Datakonsult AB
Packit d7e8d0
  2016 Bundesamt für Sicherheit in der Informationstechnik
Packit d7e8d0
  Software engineering by Intevation GmbH
Packit d7e8d0
Packit d7e8d0
  This file is part of GPGME++.
Packit d7e8d0
Packit d7e8d0
  GPGME++ is free software; you can redistribute it and/or
Packit d7e8d0
  modify it under the terms of the GNU Library General Public
Packit d7e8d0
  License as published by the Free Software Foundation; either
Packit d7e8d0
  version 2 of the License, or (at your option) any later version.
Packit d7e8d0
Packit d7e8d0
  GPGME++ is distributed in the hope that it will be useful,
Packit d7e8d0
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit d7e8d0
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit d7e8d0
  GNU Library General Public License for more details.
Packit d7e8d0
Packit d7e8d0
  You should have received a copy of the GNU Library General Public License
Packit d7e8d0
  along with GPGME++; see the file COPYING.LIB.  If not, write to the
Packit d7e8d0
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit d7e8d0
  Boston, MA 02110-1301, USA.
Packit d7e8d0
*/
Packit d7e8d0
Packit d7e8d0
#ifndef __GPGMEPP_VERIFICATIONRESULT_H__
Packit d7e8d0
#define __GPGMEPP_VERIFICATIONRESULT_H__
Packit d7e8d0
Packit d7e8d0
#include "gpgmefw.h"
Packit d7e8d0
#include "result.h"
Packit d7e8d0
#include "gpgmepp_export.h"
Packit d7e8d0
Packit d7e8d0
#include <time.h>
Packit d7e8d0
Packit d7e8d0
#include <memory>
Packit d7e8d0
Packit d7e8d0
#include <vector>
Packit d7e8d0
#include <iosfwd>
Packit d7e8d0
Packit d7e8d0
namespace GpgME
Packit d7e8d0
{
Packit d7e8d0
Packit d7e8d0
class Error;
Packit d7e8d0
class Signature;
Packit d7e8d0
class Notation;
Packit d7e8d0
class Key;
Packit d7e8d0
Packit d7e8d0
class GPGMEPP_EXPORT VerificationResult : public Result
Packit d7e8d0
{
Packit d7e8d0
public:
Packit d7e8d0
    VerificationResult();
Packit d7e8d0
    VerificationResult(gpgme_ctx_t ctx, int error);
Packit d7e8d0
    VerificationResult(gpgme_ctx_t ctx, const Error &error);
Packit d7e8d0
    explicit VerificationResult(const Error &err;;
Packit d7e8d0
Packit d7e8d0
    const VerificationResult &operator=(VerificationResult other)
Packit d7e8d0
    {
Packit d7e8d0
        swap(other);
Packit d7e8d0
        return *this;
Packit d7e8d0
    }
Packit d7e8d0
Packit d7e8d0
    void swap(VerificationResult &other)
Packit d7e8d0
    {
Packit d7e8d0
        Result::swap(other);
Packit d7e8d0
        using std::swap;
Packit d7e8d0
        swap(this->d, other.d);
Packit d7e8d0
    }
Packit d7e8d0
Packit d7e8d0
    bool isNull() const;
Packit d7e8d0
Packit d7e8d0
    const char *fileName() const;
Packit d7e8d0
Packit d7e8d0
    unsigned int numSignatures() const;
Packit d7e8d0
    Signature signature(unsigned int index) const;
Packit d7e8d0
    std::vector<Signature> signatures() const;
Packit d7e8d0
Packit d7e8d0
    class Private;
Packit d7e8d0
private:
Packit d7e8d0
    void init(gpgme_ctx_t ctx);
Packit d7e8d0
    std::shared_ptr<Private> d;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const VerificationResult &result);
Packit d7e8d0
Packit d7e8d0
class GPGMEPP_EXPORT Signature
Packit d7e8d0
{
Packit d7e8d0
    friend class ::GpgME::VerificationResult;
Packit d7e8d0
    Signature(const std::shared_ptr<VerificationResult::Private> &parent, unsigned int index);
Packit d7e8d0
public:
Packit d7e8d0
    typedef GPGMEPP_DEPRECATED GpgME::Notation Notation;
Packit d7e8d0
Packit d7e8d0
    Signature();
Packit d7e8d0
Packit d7e8d0
    const Signature &operator=(Signature other)
Packit d7e8d0
    {
Packit d7e8d0
        swap(other);
Packit d7e8d0
        return *this;
Packit d7e8d0
    }
Packit d7e8d0
Packit d7e8d0
    void swap(Signature &other)
Packit d7e8d0
    {
Packit d7e8d0
        using std::swap;
Packit d7e8d0
        swap(this->d, other.d);
Packit d7e8d0
        swap(this->idx, other.idx);
Packit d7e8d0
    }
Packit d7e8d0
Packit d7e8d0
    bool isNull() const;
Packit d7e8d0
Packit d7e8d0
    enum Summary {
Packit d7e8d0
        None       = 0x000,
Packit d7e8d0
        Valid      = 0x001,
Packit d7e8d0
        Green      = 0x002,
Packit d7e8d0
        Red        = 0x004,
Packit d7e8d0
        KeyRevoked = 0x008,
Packit d7e8d0
        KeyExpired = 0x010,
Packit d7e8d0
        SigExpired = 0x020,
Packit d7e8d0
        KeyMissing = 0x040,
Packit d7e8d0
        CrlMissing = 0x080,
Packit d7e8d0
        CrlTooOld  = 0x100,
Packit d7e8d0
        BadPolicy  = 0x200,
Packit d7e8d0
        SysError   = 0x400,
Packit d7e8d0
        TofuConflict= 0x800
Packit d7e8d0
    };
Packit d7e8d0
    Summary summary() const;
Packit d7e8d0
Packit d7e8d0
    const char *fingerprint() const;
Packit d7e8d0
Packit d7e8d0
    Error status() const;
Packit d7e8d0
Packit d7e8d0
    time_t creationTime() const;
Packit d7e8d0
    time_t expirationTime() const;
Packit d7e8d0
    bool neverExpires() const;
Packit d7e8d0
Packit d7e8d0
    GPGMEPP_DEPRECATED bool wrongKeyUsage() const
Packit d7e8d0
    {
Packit d7e8d0
        return isWrongKeyUsage();
Packit d7e8d0
    }
Packit d7e8d0
    bool isWrongKeyUsage() const;
Packit d7e8d0
    bool isVerifiedUsingChainModel() const;
Packit d7e8d0
    bool isDeVs() const;
Packit d7e8d0
Packit d7e8d0
    enum PKAStatus {
Packit d7e8d0
        UnknownPKAStatus, PKAVerificationFailed, PKAVerificationSucceeded
Packit d7e8d0
    };
Packit d7e8d0
    PKAStatus pkaStatus() const;
Packit d7e8d0
    const char *pkaAddress() const;
Packit d7e8d0
Packit d7e8d0
    enum Validity {
Packit d7e8d0
        Unknown, Undefined, Never, Marginal, Full, Ultimate
Packit d7e8d0
    };
Packit d7e8d0
    Validity validity() const;
Packit d7e8d0
    char validityAsString() const;
Packit d7e8d0
    Error nonValidityReason() const;
Packit d7e8d0
Packit d7e8d0
    unsigned int publicKeyAlgorithm() const;
Packit d7e8d0
    const char *publicKeyAlgorithmAsString() const;
Packit d7e8d0
Packit d7e8d0
    unsigned int hashAlgorithm() const;
Packit d7e8d0
    const char *hashAlgorithmAsString() const;
Packit d7e8d0
Packit d7e8d0
    const char *policyURL() const;
Packit d7e8d0
    GpgME::Notation notation(unsigned int index) const;
Packit d7e8d0
    std::vector<GpgME::Notation> notations() const;
Packit d7e8d0
Packit d7e8d0
    /** Returns the key object associated with this signature.
Packit d7e8d0
     * May be incomplete but will have at least the fingerprint
Packit d7e8d0
     * set or the associated TOFU Information if applicable. */
Packit d7e8d0
    GpgME::Key key() const;
Packit d7e8d0
Packit d7e8d0
    /* Search / Update the key of this signature.
Packit d7e8d0
     *
Packit d7e8d0
     * Same as above but if search is set to true this will
Packit d7e8d0
     * either update the key provided by the engine or search
Packit d7e8d0
     * the key in the engine. The key is cached.
Packit d7e8d0
     *
Packit d7e8d0
     * As this involves an engine call it might take some time
Packit d7e8d0
     * to finish so it should be avoided to do this in a UI
Packit d7e8d0
     * thread. The result will be cached and no engine call
Packit d7e8d0
     * will be done if update is set to false and a key is
Packit d7e8d0
     * already cached.
Packit d7e8d0
     *
Packit d7e8d0
     * If no key was provided by the engine this will look
Packit d7e8d0
     * up the key so this call might block while the engine
Packit d7e8d0
     * is called to obtain the key.
Packit d7e8d0
     *
Packit d7e8d0
     * If both search and update are false this is the same
Packit d7e8d0
     * as calling key()
Packit d7e8d0
     */
Packit d7e8d0
    GpgME::Key key(bool search, bool update) const;
Packit d7e8d0
Packit d7e8d0
private:
Packit d7e8d0
    std::shared_ptr<VerificationResult::Private> d;
Packit d7e8d0
    unsigned int idx;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Signature &sig);
Packit d7e8d0
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Signature::PKAStatus pkaStatus);
Packit d7e8d0
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Signature::Summary summary);
Packit d7e8d0
Packit d7e8d0
}
Packit d7e8d0
Packit d7e8d0
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(VerificationResult)
Packit d7e8d0
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Signature)
Packit d7e8d0
Packit d7e8d0
#endif // __GPGMEPP_VERIFICATIONRESULT_H__