pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfobase.h
changeset 26 aad866c37519
child 30 cc1cea6aabaf
equal deleted inserted replaced
22:6b63ca65093a 26:aad866c37519
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Certificate info class for TLS untrusted certificate dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef UNTRUSTEDCERTIFICATEINFOBASE_H
       
    19 #define UNTRUSTEDCERTIFICATEINFOBASE_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QDateTime>
       
    23 
       
    24 /**
       
    25  * Certificate info class for secure connections (TLS) untrusted certificate dialog.
       
    26  * This is abstract class that is used in UI code to get displayable certificate
       
    27  * details. Concrete (possibly platform specific) classes implement the functionality.
       
    28  */
       
    29 class UntrustedCertificateInfoBase : public QObject
       
    30 {
       
    31     Q_OBJECT
       
    32 
       
    33 public:     // definitions
       
    34     enum CertificateFormat {
       
    35         UnknownCertificate,
       
    36         X509Certificate,
       
    37         WTLSCertificate,
       
    38         X968Certificate
       
    39     };
       
    40     enum Algorithm {
       
    41         Unknown,
       
    42         RSA,
       
    43         DSA,
       
    44         DH,
       
    45         MD2,
       
    46         MD5,
       
    47         SHA1,
       
    48         SHA224,
       
    49         SHA256,
       
    50         SHA384,
       
    51         SHA512
       
    52     };
       
    53 
       
    54 protected:  // constructor, available for derived classes only
       
    55     UntrustedCertificateInfoBase();
       
    56 
       
    57 public:     // destructor
       
    58     virtual ~UntrustedCertificateInfoBase();
       
    59 
       
    60 public:     // new functions
       
    61     virtual const QString subjectName() const;
       
    62     virtual const QString issuerName() const;
       
    63     virtual const QByteArray fingerprint() const;
       
    64     virtual const QString formattedFingerprint() const;
       
    65     virtual const QByteArray serialNumber() const;
       
    66     virtual const QString formattedSerialNumber() const;
       
    67     virtual const QDateTime validFrom() const;
       
    68     virtual const QDateTime validTo() const;
       
    69     virtual const QString format() const;
       
    70     virtual const QString digestAlgorithm() const;
       
    71     virtual const QString asymmetricAlgorithm() const;
       
    72     virtual const QString combinedAlgorithmName() const;
       
    73     virtual bool isDateValid() const;
       
    74 
       
    75 public:     // new abstract functions
       
    76     virtual bool commonNameMatches(const QString &siteName) const = 0;
       
    77     virtual bool isPermanentAcceptAllowed() const = 0;
       
    78     virtual QString certificateDetails() const = 0;
       
    79 
       
    80 private:    // new functions
       
    81     const QString algorithmName(Algorithm algorithm) const;
       
    82 
       
    83 protected:  // data
       
    84     QString mSubjectName;
       
    85     QString mIssuerName;
       
    86     QByteArray mFingerprint;
       
    87     QByteArray mSerialNumber;
       
    88     QDateTime mValidFrom;
       
    89     QDateTime mValidTo;
       
    90     CertificateFormat mFormat;
       
    91     Algorithm mDigestAlgorithm;
       
    92     Algorithm mAsymmetricAlgorithm;
       
    93 };
       
    94 
       
    95 #endif // UNTRUSTEDCERTIFICATEINFOBASE_H