LCOV - code coverage report
Current view: directory - security/manager/ssl/src - nsCRLInfo.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 74 0 0.0 %
Date: 2012-06-02 Functions: 15 0 0.0 %

       1                 : /* ***** BEGIN LICENSE BLOCK *****
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  *
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  *
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  *
      14                 :  * The Original Code is the Netscape security libraries.
      15                 :  *
      16                 :  * The Initial Developer of the Original Code is
      17                 :  * Netscape Communications Corporation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2000
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      25                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #include "prmem.h"
      38                 : #include "prerror.h"
      39                 : #include "prprf.h"
      40                 : 
      41                 : #include "nsCRLInfo.h"
      42                 : #include "nsIDateTimeFormat.h"
      43                 : #include "nsDateTimeFormatCID.h"
      44                 : #include "nsCOMPtr.h"
      45                 : #include "nsComponentManagerUtils.h"
      46                 : #include "nsReadableUtils.h"
      47                 : #include "nsNSSShutDown.h"
      48                 : 
      49                 : #include "nspr.h"
      50                 : extern "C" {
      51                 : #include "pk11func.h"
      52                 : #include "certdb.h"
      53                 : #include "cert.h"
      54                 : #include "secerr.h"
      55                 : #include "nssb64.h"
      56                 : #include "secasn1.h"
      57                 : #include "secder.h"
      58                 : }
      59                 : 
      60               0 : NS_IMPL_ISUPPORTS1(nsCRLInfo, nsICRLInfo)
      61                 : 
      62               0 : nsCRLInfo::nsCRLInfo()
      63                 : {
      64                 :   /* member initializers and constructor code */
      65               0 : }
      66                 : 
      67               0 : nsCRLInfo::nsCRLInfo(CERTSignedCrl *signedCrl)
      68                 : {
      69               0 :   nsNSSShutDownPreventionLock locker;
      70               0 :   CERTCrl *crl = &(signedCrl->crl);
      71               0 :   nsAutoString org;
      72               0 :   nsAutoString orgUnit;
      73               0 :   nsAutoString nameInDb;
      74               0 :   nsAutoString nextUpdateLocale;
      75               0 :   nsAutoString lastUpdateLocale;
      76               0 :   nsCAutoString lastFetchURL;
      77               0 :   PRTime lastUpdate = 0;
      78               0 :   PRTime nextUpdate = 0;
      79                 :   SECStatus sec_rv;
      80                 :   
      81                 :   // Get the information we need here //
      82               0 :   char * o = CERT_GetOrgName(&(crl->name));
      83               0 :   if (o) {
      84               0 :     org = NS_ConvertASCIItoUTF16(o);
      85               0 :     PORT_Free(o);
      86                 :   }
      87                 : 
      88               0 :   char * ou = CERT_GetOrgUnitName(&(crl->name));
      89               0 :   if (ou) {
      90               0 :     orgUnit = NS_ConvertASCIItoUTF16(ou);
      91                 :     //At present, the ou is being used as the unique key - but this
      92                 :     //would change, one support for delta crls come in.
      93               0 :     nameInDb =  orgUnit;
      94               0 :     PORT_Free(ou);
      95                 :   }
      96                 :   
      97               0 :   nsCOMPtr<nsIDateTimeFormat> dateFormatter = do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID);
      98                 :   
      99                 :   // Last Update time
     100               0 :   if (crl->lastUpdate.len) {
     101               0 :     sec_rv = DER_UTCTimeToTime(&lastUpdate, &(crl->lastUpdate));
     102               0 :     if (sec_rv == SECSuccess && dateFormatter) {
     103               0 :       dateFormatter->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatNone,
     104               0 :                             lastUpdate, lastUpdateLocale);
     105                 :     }
     106                 :   }
     107                 : 
     108               0 :   if (crl->nextUpdate.len) {
     109                 :     // Next update time
     110               0 :     sec_rv = DER_UTCTimeToTime(&nextUpdate, &(crl->nextUpdate));
     111               0 :     if (sec_rv == SECSuccess && dateFormatter) {
     112               0 :       dateFormatter->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatNone,
     113               0 :                             nextUpdate, nextUpdateLocale);
     114                 :     }
     115                 :   }
     116                 : 
     117               0 :   char * url = signedCrl->url;
     118               0 :   if(url) {
     119               0 :     lastFetchURL =  url;
     120                 :   }
     121                 : 
     122               0 :   mOrg.Assign(org.get());
     123               0 :   mOrgUnit.Assign(orgUnit.get());
     124               0 :   mLastUpdateLocale.Assign(lastUpdateLocale.get());
     125               0 :   mNextUpdateLocale.Assign(nextUpdateLocale.get());
     126               0 :   mLastUpdate = lastUpdate;
     127               0 :   mNextUpdate = nextUpdate;
     128               0 :   mNameInDb.Assign(nameInDb.get());
     129               0 :   mLastFetchURL = lastFetchURL;
     130               0 : }
     131                 : 
     132               0 : nsCRLInfo::~nsCRLInfo()
     133                 : {
     134                 :   /* destructor code */
     135               0 : }
     136                 : 
     137                 : /* readonly attribute */
     138               0 : NS_IMETHODIMP nsCRLInfo::GetOrganization(nsAString & aOrg)
     139                 : {
     140               0 :   aOrg = mOrg;
     141               0 :   return NS_OK;
     142                 : }
     143                 : 
     144                 : /* readonly attribute */
     145               0 : NS_IMETHODIMP nsCRLInfo::GetOrganizationalUnit(nsAString & aOrgUnit)
     146                 : {
     147               0 :   aOrgUnit = mOrgUnit;
     148               0 :   return NS_OK;
     149                 : }
     150                 : 
     151               0 : NS_IMETHODIMP nsCRLInfo::GetLastUpdateLocale(nsAString & aLastUpdateLocale)
     152                 : {
     153               0 :   aLastUpdateLocale = mLastUpdateLocale;
     154               0 :   return NS_OK;
     155                 : }
     156                 : 
     157               0 : NS_IMETHODIMP nsCRLInfo::GetNextUpdateLocale(nsAString & aNextUpdateLocale)
     158                 : {
     159               0 :   aNextUpdateLocale = mNextUpdateLocale;
     160               0 :   return NS_OK;
     161                 : }
     162                 : 
     163               0 : NS_IMETHODIMP nsCRLInfo::GetLastUpdate(PRTime* aLastUpdate)
     164                 : {
     165               0 :   NS_ENSURE_ARG(aLastUpdate);
     166               0 :   *aLastUpdate = mLastUpdate;
     167               0 :   return NS_OK;
     168                 : }
     169                 : 
     170               0 : NS_IMETHODIMP nsCRLInfo::GetNextUpdate(PRTime* aNextUpdate)
     171                 : {
     172               0 :   NS_ENSURE_ARG(aNextUpdate);
     173               0 :   *aNextUpdate = mNextUpdate;
     174               0 :   return NS_OK;
     175                 : }
     176                 : 
     177               0 : NS_IMETHODIMP nsCRLInfo::GetNameInDb(nsAString & aNameInDb)
     178                 : {
     179               0 :   aNameInDb = mNameInDb;
     180               0 :   return NS_OK;
     181                 : }
     182                 : 
     183               0 : NS_IMETHODIMP nsCRLInfo::GetLastFetchURL(nsACString & aLastFetchURL)
     184                 : {
     185               0 :   aLastFetchURL = mLastFetchURL;
     186               0 :   return NS_OK;
     187                 : }

Generated by: LCOV version 1.7