omadrm/drmengine/roapstorage/src/response.cpp
changeset 0 95b198f216e5
child 12 8a03a285ab14
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  Methods of class representing
       
    15 *                decoded OCSP response
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <asn1dec.h>
       
    21 #include <x509cert.h>
       
    22 #include <x500dn.h>
       
    23 
       
    24 #include "roapocsp.h"
       
    25 #include "oids.h"
       
    26 #include "certid.h"
       
    27 
       
    28 COCSPResponse::COCSPResponse()
       
    29     {
       
    30     }
       
    31 
       
    32 COCSPResponse::~COCSPResponse()
       
    33     {
       
    34     delete iArchiveCutoff;
       
    35     iCertInfos.ResetAndDestroy();
       
    36     }
       
    37 
       
    38 TInt COCSPResponse::CertCount() const
       
    39     {
       
    40     return iCertInfos.Count();
       
    41     }
       
    42 
       
    43 COCSPResponseCertInfo* COCSPResponse::CertInfo( TUint aIndex ) const
       
    44     {
       
    45     return iCertInfos[aIndex];
       
    46     }
       
    47 
       
    48 const TPtrC8 COCSPResponse::SignedDataL() const
       
    49     {
       
    50     return iSignedData;
       
    51     }
       
    52 
       
    53 const TPtrC8* COCSPResponse::SigningCerts() const
       
    54     {
       
    55     return iSigningCerts.Length() ? &iSigningCerts : NULL;
       
    56     }
       
    57 
       
    58 const TPtrC8* COCSPResponse::DataElementEncoding( const TUint aIndex ) const
       
    59     {
       
    60     const TPtrC8* result( NULL );
       
    61 
       
    62     switch ( aIndex )
       
    63         {
       
    64         case ECertificateChain:
       
    65             result = iSigningCerts.Length() ? &iSigningCerts : NULL;
       
    66             break;
       
    67         case ENonce:
       
    68             result = iNonce.Length() ? &iNonce : NULL;
       
    69             break;
       
    70         case EResponderIDName:
       
    71             result = iResponderIDName.Length() ? &iResponderIDName : NULL;
       
    72             break;
       
    73         case EResponderIDKeyHash:
       
    74             result = iResponderIDKeyHash.Length() ? &iResponderIDKeyHash : NULL;
       
    75             break;
       
    76         default:
       
    77             return NULL;
       
    78         }
       
    79 
       
    80     return result;
       
    81     }
       
    82 
       
    83 void COCSPResponse::InternalizeL( RReadStream& /* aStream */)
       
    84     {
       
    85     User::Leave( KErrNotSupported );
       
    86     }
       
    87 
       
    88 TTime COCSPResponse::ProducedAt() const
       
    89     {
       
    90     return iProducedAt;
       
    91     }
       
    92 
       
    93 const TTime* COCSPResponse::ArchiveCutoff() const
       
    94     {
       
    95     return iArchiveCutoff;
       
    96     }
       
    97 
       
    98 TInt COCSPResponse::Find( const COCSPCertID& aCertID ) const
       
    99     {
       
   100     TInt count = CertCount();
       
   101     for ( TInt index = 0; index < count; ++index )
       
   102         {
       
   103         const COCSPCertID& responseCertID( *CertInfo( index )->CertID() );
       
   104         if ( responseCertID == aCertID )
       
   105             {
       
   106             return index;
       
   107             }
       
   108         }
       
   109 
       
   110     return KErrNotFound;
       
   111     }