LCOV - code coverage report
Current view: top level - lang/cpp/src - verificationresult.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 16 100.0 %
Date: 2018-11-14 16:53:58 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /*
       2             :   verificationresult.h - wraps a gpgme verify result
       3             :   Copyright (C) 2004 Klarälvdalens Datakonsult AB
       4             :   2016 Bundesamt für Sicherheit in der Informationstechnik
       5             :   Software engineering by Intevation GmbH
       6             : 
       7             :   This file is part of GPGME++.
       8             : 
       9             :   GPGME++ is free software; you can redistribute it and/or
      10             :   modify it under the terms of the GNU Library General Public
      11             :   License as published by the Free Software Foundation; either
      12             :   version 2 of the License, or (at your option) any later version.
      13             : 
      14             :   GPGME++ is distributed in the hope that it will be useful,
      15             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :   GNU Library General Public License for more details.
      18             : 
      19             :   You should have received a copy of the GNU Library General Public License
      20             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      21             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      22             :   Boston, MA 02110-1301, USA.
      23             : */
      24             : 
      25             : #ifndef __GPGMEPP_VERIFICATIONRESULT_H__
      26             : #define __GPGMEPP_VERIFICATIONRESULT_H__
      27             : 
      28             : #include "gpgmefw.h"
      29             : #include "result.h"
      30             : #include "gpgmepp_export.h"
      31             : 
      32             : #include <time.h>
      33             : 
      34             : #include <memory>
      35             : 
      36             : #include <vector>
      37             : #include <iosfwd>
      38             : 
      39             : namespace GpgME
      40             : {
      41             : 
      42             : class Error;
      43             : class Signature;
      44             : class Notation;
      45             : class Key;
      46             : 
      47         117 : class GPGMEPP_EXPORT VerificationResult : public Result
      48             : {
      49             : public:
      50             :     VerificationResult();
      51             :     VerificationResult(gpgme_ctx_t ctx, int error);
      52             :     VerificationResult(gpgme_ctx_t ctx, const Error &error);
      53             :     explicit VerificationResult(const Error &err);
      54             : 
      55          16 :     const VerificationResult &operator=(VerificationResult other)
      56             :     {
      57          16 :         swap(other);
      58          16 :         return *this;
      59             :     }
      60             : 
      61          16 :     void swap(VerificationResult &other)
      62             :     {
      63          16 :         Result::swap(other);
      64             :         using std::swap;
      65          16 :         swap(this->d, other.d);
      66          16 :     }
      67             : 
      68             :     bool isNull() const;
      69             : 
      70             :     const char *fileName() const;
      71             : 
      72             :     unsigned int numSignatures() const;
      73             :     Signature signature(unsigned int index) const;
      74             :     std::vector<Signature> signatures() const;
      75             : 
      76             :     class Private;
      77             : private:
      78             :     void init(gpgme_ctx_t ctx);
      79             :     std::shared_ptr<Private> d;
      80             : };
      81             : 
      82             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const VerificationResult &result);
      83             : 
      84          65 : class GPGMEPP_EXPORT Signature
      85             : {
      86             :     friend class ::GpgME::VerificationResult;
      87             :     Signature(const std::shared_ptr<VerificationResult::Private> &parent, unsigned int index);
      88             : public:
      89             :     typedef GPGMEPP_DEPRECATED GpgME::Notation Notation;
      90             : 
      91             :     Signature();
      92             : 
      93           3 :     const Signature &operator=(Signature other)
      94             :     {
      95           3 :         swap(other);
      96           3 :         return *this;
      97             :     }
      98             : 
      99           3 :     void swap(Signature &other)
     100             :     {
     101             :         using std::swap;
     102           3 :         swap(this->d, other.d);
     103           3 :         swap(this->idx, other.idx);
     104           3 :     }
     105             : 
     106             :     bool isNull() const;
     107             : 
     108             :     enum Summary {
     109             :         None       = 0x000,
     110             :         Valid      = 0x001,
     111             :         Green      = 0x002,
     112             :         Red        = 0x004,
     113             :         KeyRevoked = 0x008,
     114             :         KeyExpired = 0x010,
     115             :         SigExpired = 0x020,
     116             :         KeyMissing = 0x040,
     117             :         CrlMissing = 0x080,
     118             :         CrlTooOld  = 0x100,
     119             :         BadPolicy  = 0x200,
     120             :         SysError   = 0x400,
     121             :         TofuConflict= 0x800
     122             :     };
     123             :     Summary summary() const;
     124             : 
     125             :     const char *fingerprint() const;
     126             : 
     127             :     Error status() const;
     128             : 
     129             :     time_t creationTime() const;
     130             :     time_t expirationTime() const;
     131             :     bool neverExpires() const;
     132             : 
     133             :     GPGMEPP_DEPRECATED bool wrongKeyUsage() const
     134             :     {
     135             :         return isWrongKeyUsage();
     136             :     }
     137             :     bool isWrongKeyUsage() const;
     138             :     bool isVerifiedUsingChainModel() const;
     139             :     bool isDeVs() const;
     140             : 
     141             :     enum PKAStatus {
     142             :         UnknownPKAStatus, PKAVerificationFailed, PKAVerificationSucceeded
     143             :     };
     144             :     PKAStatus pkaStatus() const;
     145             :     const char *pkaAddress() const;
     146             : 
     147             :     enum Validity {
     148             :         Unknown, Undefined, Never, Marginal, Full, Ultimate
     149             :     };
     150             :     Validity validity() const;
     151             :     char validityAsString() const;
     152             :     Error nonValidityReason() const;
     153             : 
     154             :     unsigned int publicKeyAlgorithm() const;
     155             :     const char *publicKeyAlgorithmAsString() const;
     156             : 
     157             :     unsigned int hashAlgorithm() const;
     158             :     const char *hashAlgorithmAsString() const;
     159             : 
     160             :     const char *policyURL() const;
     161             :     GpgME::Notation notation(unsigned int index) const;
     162             :     std::vector<GpgME::Notation> notations() const;
     163             : 
     164             :     /** Returns the key object associated with this signature.
     165             :      * May be incomplete but will have at least the fingerprint
     166             :      * set or the associated TOFU Information if applicable. */
     167             :     GpgME::Key key() const;
     168             : 
     169             :     /* Search / Update the key of this signature.
     170             :      *
     171             :      * Same as above but if search is set to true this will
     172             :      * either update the key provided by the engine or search
     173             :      * the key in the engine. The key is cached.
     174             :      *
     175             :      * As this involves an engine call it might take some time
     176             :      * to finish so it should be avoided to do this in a UI
     177             :      * thread. The result will be cached and no engine call
     178             :      * will be done if update is set to false and a key is
     179             :      * already cached.
     180             :      *
     181             :      * If no key was provided by the engine this will look
     182             :      * up the key so this call might block while the engine
     183             :      * is called to obtain the key.
     184             :      *
     185             :      * If both search and update are false this is the same
     186             :      * as calling key()
     187             :      */
     188             :     GpgME::Key key(bool search, bool update) const;
     189             : 
     190             : private:
     191             :     std::shared_ptr<VerificationResult::Private> d;
     192             :     unsigned int idx;
     193             : };
     194             : 
     195             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Signature &sig);
     196             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Signature::PKAStatus pkaStatus);
     197             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Signature::Summary summary);
     198             : 
     199             : }
     200             : 
     201             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(VerificationResult)
     202             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Signature)
     203             : 
     204             : #endif // __GPGMEPP_VERIFICATIONRESULT_H__

Generated by: LCOV version 1.13