appinstaller/AppinstUi/Plugin/CommonUI/Src/CUICertificateInfo.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2002-2006 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:   This file contains the implementation of CCUICertificateInfo
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <X509CertNameParser.h>
       
    22 #include <x509cert.h>
       
    23 #include "CUIDetailsDialog.h"
       
    24 
       
    25 using namespace SwiUI::CommonUI;
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CCUICertificateInfo::CCUICertificateInfo
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C CCUICertificateInfo::CCUICertificateInfo()  
       
    36     {  
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CCUICertificateDetailsDialog::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C void CCUICertificateInfo::BaseConstructL( const CX509Certificate& aCertificate  )
       
    45     {
       
    46     iCertificate = CX509Certificate::NewL( aCertificate ); 
       
    47     X509CertNameParser::SubjectFullNameL( *iCertificate, iSubject );
       
    48     X509CertNameParser::IssuerFullNameL( *iCertificate, iIssuer ); 
       
    49     iSerialNumber = iCertificate->SerialNumber().AllocL();    
       
    50     iFingerprint = iCertificate->Fingerprint().AllocL();    
       
    51     iEncoding = iCertificate->Encoding().AllocL(); 
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CCUICertificateInfo::NewL
       
    56 // Two-phased constructor.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C CCUICertificateInfo* CCUICertificateInfo::NewL( const CX509Certificate& aCertificate )     
       
    60     {
       
    61     CCUICertificateInfo* self = new ( ELeave ) CCUICertificateInfo();
       
    62     CleanupStack::PushL( self );
       
    63     self->BaseConstructL( aCertificate );
       
    64     CleanupStack::Pop( self );
       
    65     return self; 
       
    66     }
       
    67     
       
    68 // Destructor
       
    69 EXPORT_C CCUICertificateInfo::~CCUICertificateInfo()
       
    70     {    
       
    71     delete iCertificate;    
       
    72     delete iIssuer;
       
    73     delete iSubject;    
       
    74     delete iSerialNumber;
       
    75     delete iFingerprint;    
       
    76     delete iEncoding; 
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CCUICertificateInfo::X509Certificate
       
    81 // Returns pointer to X509Certificate where this info is based on.
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C CX509Certificate* CCUICertificateInfo::X509Certificate()
       
    86     {
       
    87     return iCertificate;    
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CCUICertificateInfo::SubjectName
       
    92 // Getter for subject field.
       
    93 // (other items were commented in a header).
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 const TDesC& CCUICertificateInfo::SubjectNameL() const
       
    97     {
       
    98     return *iSubject;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CCUICertificateInfo::IssuerName
       
   103 // Getter for issuer field.
       
   104 // (other items were commented in a header).
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 const TDesC& CCUICertificateInfo::IssuerNameL() const
       
   108     {
       
   109     return *iIssuer;    
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CCUICertificateInfo::ValidFrom
       
   114 // Getter for valid from field.
       
   115 // (other items were commented in a header).
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 TDateTime CCUICertificateInfo::ValidFromL() const
       
   119     {
       
   120     const CValidityPeriod& validityPeriod = iCertificate->ValidityPeriod();
       
   121     return validityPeriod.Start().DateTime();
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CCUICertificateInfo::ValidTo
       
   126 // Getter for certificate expiration date.
       
   127 // (other items were commented in a header).
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 TDateTime CCUICertificateInfo::ValidToL() const
       
   131     {
       
   132     const CValidityPeriod& validityPeriod = iCertificate->ValidityPeriod();
       
   133     return validityPeriod.Finish().DateTime();
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CCUICertificateInfo::Fingerprint
       
   138 // Getter for fingerprint of the certificate.
       
   139 // (other items were commented in a header).
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 const TDesC8& CCUICertificateInfo::FingerprintL() const
       
   143     {
       
   144     return *iFingerprint;    
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CCUICertificateInfo::SerialNumber
       
   149 // Getter for serial number of the certificate.
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 const TDesC8& CCUICertificateInfo::SerialNumberL() const
       
   154     {
       
   155     return *iSerialNumber;    
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CCUICertificateInfo::IsSelfSignedL
       
   160 // Indicates wheter this certificate is self signed.
       
   161 // (other items were commented in a header).
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TBool CCUICertificateInfo::IsSelfSignedL() const
       
   165     {
       
   166     return iCertificate->IsSelfSignedL();    
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CCUICertificateInfo::EncodingL
       
   171 // Gets the full encoding of this certificate.
       
   172 // (other items were commented in a header).
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 const TDesC8& CCUICertificateInfo::EncodingL() const
       
   176     {
       
   177     return *iEncoding;    
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CCUICertificateInfo::SignatureL
       
   182 // Gets the signature of this certificate.
       
   183 // (other items were commented in a header).
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 const TDesC8& CCUICertificateInfo::SignatureL() const
       
   187     {
       
   188     return KNullDesC8();
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CCUICertificateInfo::PublicKeyAlgorithmL
       
   193 // Gets the public key algorithm of the certificate.
       
   194 // (other items were commented in a header).
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 TAlgorithmId CCUICertificateInfo::PublicKeyAlgorithmL() const
       
   198     {
       
   199     return iCertificate->SigningAlgorithm().AsymmetricAlgorithm().Algorithm();
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CCUICertificateInfo::DigestAlgorithmL
       
   204 // Gets the digest algorithm of the certificate.
       
   205 // (other items were commented in a header).
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 TAlgorithmId CCUICertificateInfo::DigestAlgorithmL() const
       
   209     {
       
   210     return iCertificate->SigningAlgorithm().DigestAlgorithm().Algorithm();
       
   211     }
       
   212 
       
   213 //  End of File