breakdeps/DRMEngine/RoapEng.cpp
author Tom Pritchard <tomp@symbian.org>
Wed, 27 Oct 2010 15:05:33 +0100
changeset 90 62156f66dbad
parent 88 ca165d35976d
permissions -rw-r--r--
Breaking DRM's dependency Etel so that AVKON can start. The ROM now boots, but doesn't seem to have any items in the matrix menu at all.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     1
/*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     8
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    11
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    12
* Contributors:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    13
*
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    14
* Description:  Roap engine
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    15
 *
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    16
*/
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    17
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    18
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    19
// INCLUDE FILES
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    20
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    21
#include <random.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    22
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    23
#include <DocumentHandler.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    24
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    25
#ifdef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    26
#include  <pathinfo.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    27
#include  <driveinfo.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    28
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    29
#include  <pathinfo.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    30
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    31
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    32
#ifndef __WINS__
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    33
#include <etelmm.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    34
#include <mmtsy_names.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    35
#include <SysUtil.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    36
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    37
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    38
#include <flogger.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    39
#include <x509cert.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    40
#include <x509certext.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    41
#include <hash.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    42
#include <utf.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    43
#include <asn1dec.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    44
#include <centralrepository.h>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    45
#include <e32base.h>  // CleanupResetAndDestroyPushL dependencies
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    46
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    47
#include "cleanupresetanddestroy.h" // CleanupResetAndDestroyPushL
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    48
#include "DRMRights.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    49
#include "RoapEng.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    50
#include "RoapTrigger.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    51
#include "wbxmlroaptriggerparser.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    52
#include "RoapResponse.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    53
#include "RoapMessage.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    54
#include "RoapParser.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    55
#include "RoapSigner.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    56
#include "DeviceHello.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    57
#include "RIHello.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    58
#include "RegistrationReq.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    59
#include "RegistrationResp.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    60
#include "RightsReq.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    61
#include "RightsResp.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    62
#include "JoinDomainReq.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    63
#include "JoinDomainResp.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    64
#include "LeaveDomainReq.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    65
#include "LeaveDomainResp.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    66
#ifdef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    67
#include "MeteringReportReq.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    68
#include "MeteringReportResp.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    69
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    70
#include "RoapStorageClient.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    71
#include "RoapDef.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    72
#include "RoapLog.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    73
#include "RoapObserver.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    74
#include "CmlaCrypto.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    75
#include "DRMRIContext.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    76
#include "DRMDomainContext.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    77
#include "DRMProtectedRoParser.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    78
#include "DRMClockClient.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    79
#include "DcfRep.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    80
#include "DcfEntry.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    81
#include "Base64.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    82
#include "drmsettingsplugininternalcrkeys.h"
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    83
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    84
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    85
#define STUB_C_CLASS_IN_NAMESPACE( n, c ) namespace n { class c: public CBase { private: c(); public: virtual ~c(); }; } n::c::c() {} n::c::~c() {}
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    86
#define STUB_C_CLASS( c ) class c : public CBase { private: c(); public: virtual ~c(); }; c::c() {} c::~c() {}
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    87
// This class does not do anything.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    88
// It is defined here only to keep binary compatibility,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    89
// because of unintentional class name leak in
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    90
// armv5 export history.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    91
// Don't ever use this class for anything.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    92
STUB_C_CLASS_IN_NAMESPACE( Roap , CWbxmlRoapTriggerToXmlParser )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    93
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    94
// Yet another stub classes because of moved classes
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    95
// which have leaked virtual table entries
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    96
STUB_C_CLASS( COCSPResponse )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    97
STUB_C_CLASS( COCSPResponseCertInfo )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    98
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    99
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   100
using namespace Roap;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   101
// ================= CONSTANTS =======================
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   102
// For parsing multipart content
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   103
_LIT8(KCmlaIp1, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-1");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   104
_LIT8(KLeaveDomainElement, "leaveDomain");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   105
_LIT8(KSignedInfoElement, "SignedInfo");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   106
_LIT(KBOM1, "\xFFFE");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   107
_LIT(KBOM2, "\xFEFF");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   108
#ifdef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   109
_LIT8( KRoapVersion11, "1.1" );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   110
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   111
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   112
static const TInt KDomainGenerationLength( 3 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   113
static const TInt KMinCertChainLength( 3 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   114
// ================= LOCAL FUNCTIONS =======================
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   115
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   116
LOCAL_C TBool SortArrays(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   117
    RPointerArray<HBufC8>& aKeys,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   118
    RPointerArray<HBufC8>& aMacs,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   119
    RPointerArray<HBufC8>& aElements,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   120
    RArray<TInt>& aOrder )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   121
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   122
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   123
    TInt j;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   124
    TInt index;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   125
    HBufC8* temp1 = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   126
    HBufC8* temp2 = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   127
    HBufC8* temp3 = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   128
    TBool isInOrder = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   129
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   130
    if ( aOrder.Count() != aKeys.Count() || aKeys.Count() != aMacs.Count()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   131
        || aMacs.Count() != aElements.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   132
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   133
        return EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   134
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   135
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   136
    for ( i = 0; i < aKeys.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   137
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   138
        index = aOrder[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   139
        temp1 = aKeys[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   140
        temp2 = aMacs[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   141
        temp3 = aElements[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   142
        j = i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   143
        while ( ( j > 0 ) && ( aOrder[j - 1] > index ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   144
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   145
            isInOrder = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   146
            aOrder[j] = aOrder[j - 1];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   147
            aKeys[j] = aKeys[j - 1];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   148
            aMacs[j] = aMacs[j - 1];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   149
            aElements[j] = aElements[j - 1];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   150
            j = j - 1;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   151
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   152
        aOrder[j] = index;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   153
        aKeys[j] = temp1;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   154
        aMacs[j] = temp2;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   155
        aElements[j] = temp3;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   156
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   157
    return isInOrder;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   158
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   159
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   160
// ================= MEMBER FUNCTIONS =======================
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   161
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   162
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   163
// CRoapEng::NewL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   164
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   165
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   166
EXPORT_C CRoapEng* CRoapEng::NewL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   167
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   168
    CRoapEng* engine = new ( ELeave ) CRoapEng();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   169
    CleanupStack::PushL( engine );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   170
    engine->ConstructL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   171
    CleanupStack::Pop( engine );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   172
    return engine;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   173
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   174
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   175
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   176
// CRoapEng::~CRoapEng()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   177
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   178
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   179
EXPORT_C CRoapEng::~CRoapEng()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   180
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   181
    if ( iStorageClient )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   182
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   183
        iStorageClient->Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   184
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   185
    delete iStorageClient;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   186
    if ( iClockClient )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   187
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   188
        iClockClient->Close();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   189
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   190
    delete iClockClient;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   191
    delete iParser;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   192
    delete iSigner;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   193
    delete iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   194
    delete iRoParser;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   195
    delete iDcfRep;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   196
    iRiAlgorithms.ResetAndDestroy();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   197
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   198
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   199
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   200
// CRoapEng::~CRoapEng()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   201
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   202
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   203
void CRoapEng::ConstructL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   204
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   205
    LOGLIT( "CRoapEng::ConstructL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   206
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   207
    CRoapEngBase::ConstructL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   208
    iParser = CRoapParser::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   209
    iStorageClient = new ( ELeave ) RRoapStorageClient;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   210
    User::LeaveIfError( iStorageClient->Connect() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   211
    iClockClient = new ( ELeave ) RDRMClockClient;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   212
    User::LeaveIfError( iClockClient->Connect() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   213
    TBuf8<SHA1_HASH> deviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   214
    iStorageClient->GetDevicePublicKeyHashL( deviceId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   215
    iDeviceId = deviceId.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   216
    iSigner = CRoapSigner::NewL( *iStorageClient );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   217
    iRoParser = CDrmProtectedRoParser::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   218
    iDcfRep = CDcfRep::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   219
    iCertNeeded = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   220
    iRiSupportsCertCaching = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   221
    iTransStatus = ENotAsked;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   222
    iSelectedAlgorithms = EOma;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   223
    iSelectedRoot = KNullDesC8;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   224
    iStorageClient->SelectTrustedRootL( KNullDesC8 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   225
    iDeviceTimeError = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   226
    iDomainId.SetLength( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   227
    iSecureTime = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   228
    iZone = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   229
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   230
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   231
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   232
// CRoapEng::CRoapEng()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   233
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   234
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   235
CRoapEng::CRoapEng() :
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   236
    CRoapEngBase()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   237
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   238
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   239
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   240
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   241
// CRoapEng::ParseTriggerL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   242
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   243
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   244
CRoapTrigger* CRoapEng::ParseTriggerL( const TDesC8& aTrigger )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   245
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   246
    LOGLIT( "CRoapEng::ParseTriggerL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   247
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   248
    CRoapTrigger* trigger( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   249
    RBuf8 xmlTrigger;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   250
    CleanupClosePushL( xmlTrigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   251
    _LIT8( KRoap, "<roap:roapTrigger" );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   252
    if ( aTrigger.FindF( KRoap ) == KErrNotFound )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   253
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   254
        DRM::CWbxmlRoapTriggerParser* wbParser(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   255
            DRM::CWbxmlRoapTriggerParser::NewLC() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   256
        HBufC8* b( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   257
        TRAPD( parseError, b = wbParser->ParseL( aTrigger ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   258
        if ( parseError == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   259
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   260
            xmlTrigger.Assign( b );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   261
            b = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   262
            LOGLIT( "  We have a WBXML trigger" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   263
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   264
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   265
            { // OMA BCAST: Check if this is an XML trigger after all..
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   266
            LOGLIT( "  We have an XML trigger after all" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   267
            xmlTrigger.CreateL( aTrigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   268
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   269
        CleanupStack::PopAndDestroy( wbParser );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   270
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   271
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   272
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   273
        xmlTrigger.CreateL( aTrigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   274
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   275
    trigger = iParser->ParseRoapTriggerL( xmlTrigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   276
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   277
    CleanupStack::PushL( trigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   278
    if ( !trigger || !trigger->ValidTrigger() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   279
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   280
        User::Leave( KErrRoapGeneral );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   281
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   282
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   283
    // check that SilentRightsUrl is on the white list
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   284
    // URL is searched from pre-configured white list
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   285
    TBool fromPreConfiguredWhiteList( ETrue );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   286
    if ( iStorageClient->WhiteListURLExistsL( *trigger->iRoapUrl, fromPreConfiguredWhiteList ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   287
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   288
        iAllowedToContactRi = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   289
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   290
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   291
    if ( trigger->iTriggerType == ELeaveDomainTrigger && trigger->iSignature )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   292
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   293
        if ( !VerifyTriggerSignatureL( xmlTrigger, *trigger ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   294
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   295
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   296
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   297
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   298
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   299
    CleanupStack::Pop( trigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   300
    CleanupStack::PopAndDestroy( &xmlTrigger );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   301
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   302
    return trigger;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   303
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   304
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   305
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   306
// CRoapEng::GetRIContextL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   307
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   308
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   309
void CRoapEng::GetRIContextL( TBool& aRegistered, const TDesC8& aRiId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   310
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   311
    LOGLIT( "CRoapEng::GetRIContextL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   312
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   313
    CDRMRIContext* context = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   314
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   315
    aRegistered = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   316
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   317
    // delete old RI context and obtain a new one
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   318
    delete iStoredRiContext;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   319
    iStoredRiContext = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   320
    context = iStorageClient->GetRIContextL( aRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   321
    if ( !context )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   322
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   323
        return;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   324
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   325
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   326
    iStoredRiContext = context;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   327
    iRiSupportsCertCaching = iStoredRiContext->DeviceCertCached();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   328
    iSelectedRoot = iStoredRiContext->SelectedDeviceRoot();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   329
    iStorageClient->SelectTrustedRootL( iSelectedRoot );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   330
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   331
    if ( context->CertificateChain().Count() && context->ExpiryTime()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   332
        > GetDrmTimeL() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   333
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   334
        aRegistered = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   335
        iUseRiContextUrl = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   336
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   337
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   338
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   339
        // Received Context was invalid or expired
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   340
        iUseRiContextUrl = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   341
        delete iStoredRiContext;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   342
        iStoredRiContext = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   343
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   344
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   345
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   346
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   347
// CRoapEng::GetDomainContextL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   348
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   349
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   350
void CRoapEng::GetDomainContextL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   351
    TBool& aIsJoined,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   352
    TBool& aIsValidGeneration,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   353
    const TDesC8& aDomainId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   354
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   355
    LOGLIT( "CRoapEng::GetDomainContextL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   356
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   357
    TInt generation = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   358
    CDRMDomainContext* context = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   359
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   360
    aIsJoined = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   361
    aIsValidGeneration = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   362
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   363
    // last 3 digits are for Domain generation
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   364
    context = iStorageClient->GetDomainContextL( aDomainId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   365
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   366
    if ( !context )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   367
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   368
        return;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   369
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   370
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   371
    if ( context->ExpiryTime() > GetDrmTimeL() || context->ExpiryTime()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   372
        == Time::NullTTime() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   373
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   374
        aIsJoined = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   375
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   376
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   377
    TLex8 lex( aDomainId.Right( KDomainGenerationLength ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   378
    lex.Val( generation );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   379
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   380
    if ( context->DomainGeneration() >= generation )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   381
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   382
        aIsValidGeneration = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   383
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   384
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   385
    delete context;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   386
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   387
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   388
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   389
// CRoapEng::CreateReqMessageL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   390
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   391
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   392
void CRoapEng::CreateReqMessageL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   393
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   394
    LOGLIT( "CRoapEng::CreateReqMessageL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   395
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   396
    __ASSERT_ALWAYS( iTrigger, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   397
    __ASSERT_ALWAYS( !iRequest, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   398
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   399
    switch ( iReqMessage )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   400
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   401
        case EDeviceHello:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   402
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   403
            iRequest = CreateDeviceHelloL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   404
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   405
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   406
        case ERegistration:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   407
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   408
            iRequest = CreateRegistrationRequestL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   409
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   410
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   411
        case EROAcquisition:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   412
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   413
            iRequest = CreateRightsRequestL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   414
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   415
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   416
        case EJoinDomain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   417
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   418
            iRequest = CreateJoinDomainRequestL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   419
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   420
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   421
        case ELeaveDomain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   422
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   423
            iRequest = CreateLeaveDomainRequestL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   424
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   425
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   426
#ifdef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   427
        case EMeteringRequest:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   428
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   429
            iRequest = CreateMeteringReportRequestL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   430
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   431
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   432
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   433
        default:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   434
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   435
            User::Leave( KErrArgument );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   436
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   437
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   438
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   439
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   440
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   441
// CRoapEng::CreateDeviceHelloL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   442
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   443
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   444
CRoapMessage* CRoapEng::CreateDeviceHelloL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   445
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   446
    LOGLIT( "CRoapEng::CreateDeviceHelloL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   447
    PERFORMANCE_LOGLIT( "Registration protocol started" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   448
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   449
    RPointerArray<TDesC8> idArray;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   450
    CDeviceHello* req = CDeviceHello::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   451
    CleanupStack::PushL( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   452
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   453
    // Multi-PKI addition
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   454
    CleanupResetAndDestroyPushL( idArray );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   455
    CreateDeviceIdHashArrayL( idArray );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   456
    for ( TInt i = 0; i < idArray.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   457
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   458
        req->iDeviceIdArray.AppendL( *idArray[i] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   459
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   460
    CleanupStack::PopAndDestroy( &idArray );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   461
    // Multi-PKI
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   462
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   463
#ifndef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   464
    req->iVersion.Copy( KRoapVersion ); // Version 1.0
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   465
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   466
    req->iVersion.Copy( KRoapVersion11 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   467
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   468
    if ( iTrigger->iNonce )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   469
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   470
        req->iTriggerNonce = iTrigger->iNonce->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   471
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   472
    CmlaCrypto::SupportedAlgorithmsL( req->iAlgorithms );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   473
    iSelectedAlgorithms = EOma;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   474
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   475
    CleanupStack::Pop( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   476
    return req;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   477
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   478
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   479
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   480
// CRoapEng::CreateRegistrationRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   481
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   482
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   483
CRoapMessage* CRoapEng::CreateRegistrationRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   484
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   485
    LOGLIT( "CRoapEng::CreateRegistrationRequestL ->" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   486
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   487
    __ASSERT_ALWAYS( iResponse, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   488
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   489
    CRegistrationReq* req = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   490
    CRIHello* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   491
    RPointerArray<HBufC8> trustedRootArray;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   492
    HBufC8* temp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   493
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   494
    resp = STATIC_CAST( CRIHello*, iResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   495
    req = CRegistrationReq::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   496
    CleanupStack::PushL( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   497
    if ( resp->iSession )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   498
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   499
        req->iSession = resp->iSession->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   500
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   501
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   502
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   503
        User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   504
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   505
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   506
    req->iNonce.SetLength( KDeviceNonceLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   507
    TRandom::Random( req->iNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   508
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   509
    req->iTime = GetDrmTimeL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   510
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   511
    // store the nonce for DRM Time sync
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   512
    iRegReqNonce = req->iNonce;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   513
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   514
    if ( iCertNeeded )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   515
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   516
        req->iCertificateChain = GetCertificateChainL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   517
        if ( resp->iCertificateCaching )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   518
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   519
            iCertNeeded = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   520
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   521
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   522
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   523
    // Send all our trusted roots to the RI
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   524
    CleanupResetAndDestroyPushL( trustedRootArray );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   525
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   526
    LOGLIT( "  Getting trusted roots" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   527
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   528
    iStorageClient->GetTrustedRootsL( trustedRootArray );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   529
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   530
    if ( !trustedRootArray.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   531
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   532
        // No trusted roots found!
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   533
        LOGLIT( "  No trusted roots found!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   534
        User::Leave( KErrRoapDevice );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   535
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   536
    for ( TInt i = 0; i < trustedRootArray.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   537
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   538
        temp = trustedRootArray[i]->AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   539
        req->iTrustedAuthorities.AppendL( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   540
        CleanupStack::Pop( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   541
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   542
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   543
    LOGLIT( "  Setting server info" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   544
    if ( resp->iServerInfo && resp->iServerInfo->Size() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   545
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   546
        req->iServerInfo = resp->iServerInfo->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   547
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   548
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   549
    if ( iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   550
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   551
        LOGLIT( "  RI context available" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   552
        req->iPeerKeyIdentifier = iStoredRiContext->RIID();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   553
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   554
        if ( iStoredRiContext->OCSPResponse().Count() && !iDeviceTimeError )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   555
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   556
            req->iOcspInfoStored = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   557
            req->iOcspResponderKeyId = GetOCSPResponderKeyHashL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   558
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   559
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   560
    if ( resp->iNeedDeviceDetails )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   561
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   562
        LOGLIT( "  Getting device details" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   563
        GetDeviceDetailsL( req->iDeviceDetailsManufacturer,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   564
            req->iDeviceDetailsModel, req->iDeviceDetailsVersion );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   565
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   566
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   567
    if ( iTrigger->iNonce )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   568
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   569
        req->iTriggerNonce = iTrigger->iNonce->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   570
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   571
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   572
    CleanupStack::PopAndDestroy( &trustedRootArray );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   573
    CleanupStack::Pop( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   574
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   575
    LOGLIT( "CRoapEng::CreateRegistrationRequestL <-" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   576
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   577
    return req;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   578
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   579
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   580
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   581
// CRoapEng::CreateRightsRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   582
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   583
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   584
CRoapMessage* CRoapEng::CreateRightsRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   585
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   586
    LOGLIT( "CRoapEng::CreateRightsRequestL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   587
    PERFORMANCE_LOGLIT( "RO acquisition protocol started" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   588
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   589
    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   590
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   591
    CRightsReq* req = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   592
    RPointerArray<HBufC8> ttIDs;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   593
    RPointerArray<HBufC8> cids;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   594
    HBufC8* temp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   595
    TBuf8<SHA1_HASH> deviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   596
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   597
    req = CRightsReq::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   598
    CleanupStack::PushL( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   599
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   600
    req->iNonce.SetLength( KDeviceNonceLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   601
    TRandom::Random( req->iNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   602
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   603
    req->iTime = GetDrmTimeL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   604
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   605
    iStorageClient->GetDevicePublicKeyHashL( deviceId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   606
    delete iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   607
    iDeviceId = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   608
    iDeviceId = deviceId.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   609
    req->iDeviceId = *iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   610
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   611
    req->iRiId.Copy( iTrigger->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   612
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   613
    if ( !iRiSupportsCertCaching )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   614
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   615
        req->iCertificateChain = GetCertificateChainL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   616
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   617
    if ( iTrigger->iDomainId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   618
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   619
        req->iDomainId = iTrigger->iDomainId->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   620
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   621
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   622
    for ( TInt i = 0; i < iTrigger->iRoIdList.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   623
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   624
        temp = iTrigger->iRoIdList[i]->AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   625
        req->iRoIdList.AppendL( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   626
        CleanupStack::Pop( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   627
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   628
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   629
    if ( iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   630
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   631
        req->iPeerKeyIdentifier = iStoredRiContext->RIID();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   632
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   633
        if ( iStoredRiContext->OCSPResponse().Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   634
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   635
            req->iOcspInfoStored = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   636
            req->iOcspResponderKeyId = GetOCSPResponderKeyHashL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   637
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   638
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   639
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   640
    CleanupResetAndDestroyPushL( cids );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   641
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   642
    CleanupResetAndDestroyPushL( ttIDs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   643
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   644
    FetchTransactionIDL( ttIDs, cids );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   645
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   646
    for ( TInt i = 0; i < ttIDs.Count() && i < cids.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   647
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   648
        temp = ttIDs[i]->AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   649
        req->iTransTrackIDs.AppendL( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   650
        CleanupStack::Pop( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   651
        temp = cids[i]->AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   652
        req->iContentIDs.AppendL( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   653
        CleanupStack::Pop( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   654
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   655
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   656
    CleanupStack::PopAndDestroy( &ttIDs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   657
    CleanupStack::PopAndDestroy( &cids );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   658
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   659
    if ( iTrigger->iNonce )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   660
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   661
        req->iTriggerNonce = iTrigger->iNonce->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   662
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   663
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   664
    CleanupStack::Pop( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   665
    return req;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   666
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   667
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   668
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   669
// CRoapEng::CreateJoinDomainRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   670
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   671
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   672
CRoapMessage* CRoapEng::CreateJoinDomainRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   673
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   674
    LOGLIT( "CRoapEng::CreateJoinDomainRequestL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   675
    PERFORMANCE_LOGLIT( "Join domain protocol started" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   676
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   677
    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   678
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   679
    CJoinDomainReq* req = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   680
    TBuf8<SHA1_HASH> deviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   681
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   682
    req = CJoinDomainReq::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   683
    CleanupStack::PushL( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   684
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   685
    req->iNonce.SetLength( KDeviceNonceLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   686
    TRandom::Random( req->iNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   687
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   688
    req->iTime = GetDrmTimeL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   689
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   690
    iStorageClient->GetDevicePublicKeyHashL( deviceId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   691
    delete iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   692
    iDeviceId = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   693
    iDeviceId = deviceId.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   694
    req->iDeviceId = *iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   695
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   696
    req->iRiId.Copy( iTrigger->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   697
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   698
    if ( !iRiSupportsCertCaching )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   699
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   700
        req->iCertificateChain = GetCertificateChainL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   701
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   702
    if ( iTrigger->iDomainId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   703
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   704
        req->iDomainId = iTrigger->iDomainId->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   705
        iDomainId.Copy( *req->iDomainId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   706
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   707
    else if ( iDomainId.Length() && iTrigger->iTriggerType
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   708
        == ERoAcquisitionTrigger )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   709
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   710
        req->iDomainId = iDomainId.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   711
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   712
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   713
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   714
        User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   715
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   716
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   717
    if ( iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   718
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   719
        req->iPeerKeyIdentifier = iStoredRiContext->RIID();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   720
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   721
        if ( iStoredRiContext->OCSPResponse().Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   722
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   723
            req->iOcspInfoStored = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   724
            req->iOcspResponderKeyId = GetOCSPResponderKeyHashL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   725
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   726
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   727
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   728
#ifdef _DISABLE_HASH_CHAIN_GENERATION
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   729
    req->iHashChainSupport = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   730
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   731
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   732
    if ( iTrigger->iNonce )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   733
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   734
        req->iTriggerNonce = iTrigger->iNonce->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   735
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   736
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   737
    CleanupStack::Pop( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   738
    return req;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   739
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   740
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   741
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   742
// CRoapEng::CreateLeaveDomainRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   743
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   744
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   745
CRoapMessage* CRoapEng::CreateLeaveDomainRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   746
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   747
    LOGLIT( "CRoapEng::CreateLeaveDomainRequestL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   748
    PERFORMANCE_LOGLIT( "Leave domain protocol started" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   749
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   750
    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   751
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   752
    if ( !iTrigger->iDomainId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   753
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   754
        User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   755
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   756
    // delete Domain context before sending LeaveDomain req
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   757
    TRAPD( ret, iStorageClient->DeleteDomainContextL( *iTrigger->iDomainId ));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   758
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   759
    CLeaveDomainReq* req = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   760
    TBuf8<SHA1_HASH> deviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   761
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   762
    req = CLeaveDomainReq::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   763
    CleanupStack::PushL( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   764
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   765
    if ( ret == KErrNotFound )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   766
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   767
        req->iNotMember = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   768
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   769
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   770
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   771
        req->iNotMember = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   772
        User::LeaveIfError( ret );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   773
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   774
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   775
    req->iNonce.SetLength( KDeviceNonceLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   776
    TRandom::Random( req->iNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   777
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   778
    req->iTime = GetDrmTimeL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   779
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   780
    iStorageClient->GetDevicePublicKeyHashL( deviceId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   781
    delete iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   782
    iDeviceId = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   783
    iDeviceId = deviceId.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   784
    req->iDeviceId = *iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   785
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   786
    req->iRiId.Copy( iTrigger->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   787
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   788
    if ( !iRiSupportsCertCaching )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   789
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   790
        req->iCertificateChain = GetCertificateChainL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   791
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   792
    if ( iTrigger->iDomainId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   793
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   794
        req->iDomainId = iTrigger->iDomainId->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   795
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   796
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   797
    if ( iTrigger->iNonce )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   798
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   799
        req->iTriggerNonce = iTrigger->iNonce->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   800
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   801
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   802
    CleanupStack::Pop( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   803
    return req;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   804
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   805
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   806
// CRoapEng::CreateMeteringReportRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   807
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   808
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   809
CRoapMessage* CRoapEng::CreateMeteringReportRequestL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   810
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   811
#ifndef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   812
    return NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   813
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   814
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   815
    LOGLIT( "CRoapEng::CreateMeteringReportRequestL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   816
    PERFORMANCE_LOGLIT( "Metering report creation started" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   817
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   818
    CMeteringReportReq* req = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   819
    TBuf8<SHA1_HASH> deviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   820
    TBuf8<OmaCrypto::KMacSize> macKey;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   821
    TBool registered( EFalse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   822
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   823
    req = CMeteringReportReq::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   824
    CleanupStack::PushL( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   825
    req->iAlgorithmInUse = iSelectedAlgorithms;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   826
    // check if we are not using OMA algorithms
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   827
    // and update selected algorithm accordingly
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   828
    GetRIContextL( registered, iTrigger->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   829
    if ( registered && iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   830
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   831
        for ( TInt i = 0; i < iStoredRiContext->Algorithms().Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   832
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   833
            if ( iStoredRiContext->Algorithms()[i]->CompareF( KCmlaIp1() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   834
                == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   835
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   836
                // note currently assumed that only
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   837
                // 1 of 7 ppossible algorithms used
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   838
                req->iAlgorithmInUse = ECmlaIp1;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   839
                break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   840
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   841
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   842
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   843
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   844
    // generate DeviceNonce
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   845
    req->iNonce.SetLength( KDeviceNonceLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   846
    TRandom::Random( req->iNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   847
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   848
    // generate MeteringNonce
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   849
    req->iReportNonce.SetLength( KDeviceNonceLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   850
    TRandom::Random( req->iReportNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   851
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   852
    // fetch secure time for request
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   853
    req->iTime = GetDrmTimeL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   854
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   855
    // insert DeviceId
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   856
    iStorageClient->GetDevicePublicKeyHashL( deviceId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   857
    delete iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   858
    iDeviceId = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   859
    iDeviceId = deviceId.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   860
    req->iDeviceId = *iDeviceId;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   861
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   862
    // insert RiId
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   863
    req->iRiId.Copy( iTrigger->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   864
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   865
    // insert Certificate chain if needed
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   866
    if ( !iRiSupportsCertCaching )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   867
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   868
        req->iCertificateChain = GetCertificateChainL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   869
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   870
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   871
    // add trigger Nonce
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   872
    if ( iTrigger->iNonce )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   873
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   874
        req->iTriggerNonce = iTrigger->iNonce->AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   875
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   876
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   877
    // Get from server encrypted metering report mac key as plain,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   878
    // MEK and MAC key as encypted, and hash of
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   879
    // PKI public key used in encryition
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   880
    req->iCipherValue = iStorageClient->GetMeteringDataL( req->iRiId, macKey,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   881
        req->iEncKeyHash, req->iEncryptedMekAndMak );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   882
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   883
    // calculate mac over <encryptedMeteringReport>
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   884
    req->InsertMacL( macKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   885
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   886
    CleanupStack::Pop( req );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   887
    return req;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   888
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   889
#endif //RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   890
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   891
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   892
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   893
// CRoapEng::HandleRoapResponseL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   894
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   895
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   896
void CRoapEng::HandleRoapResponseL( const TDesC8& aXmlResponse )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   897
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   898
    LOGLIT( "CRoapEng::HandleRoapMessageL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   899
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   900
    delete iResponse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   901
    iResponse = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   902
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   903
    switch ( iReqMessage )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   904
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   905
        case EDeviceHello:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   906
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   907
            HandleRIHelloPduL( aXmlResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   908
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   909
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   910
        case ERegistration:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   911
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   912
            HandleReqResponsePduL( aXmlResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   913
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   914
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   915
        case EROAcquisition:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   916
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   917
            HandleRightsResponsePduL( aXmlResponse, EFalse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   918
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   919
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   920
        case EJoinDomain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   921
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   922
            HandleJoinDomainResponsePduL( aXmlResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   923
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   924
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   925
        case ELeaveDomain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   926
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   927
            HandleLeaveDomainResponsePduL( aXmlResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   928
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   929
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   930
#ifdef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   931
        case EMeteringRequest:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   932
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   933
            HandleMeteringReportResponsePduL( aXmlResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   934
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   935
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   936
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   937
        default:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   938
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   939
            User::Leave( KErrArgument );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   940
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   941
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   942
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   943
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   944
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   945
// CRoapEng::HandleRIHelloPduL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   946
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   947
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   948
void CRoapEng::HandleRIHelloPduL( const TDesC8& aRiHello )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   949
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   950
    LOGLIT( "CRoapEng::HandleRIHelloPduL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   951
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   952
    CRIHello* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   953
    HBufC8* temp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   954
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   955
    resp = iParser->ParseRIHelloL( aRiHello );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   956
    iRoapStatus = resp->iStatus;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   957
    iResponse = resp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   958
    if ( iRoapStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   959
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   960
        iCertNeeded = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   961
        iRiSupportsCertCaching = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   962
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   963
        if ( resp->iPeerKeyIdentifier )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   964
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   965
            iRiSupportsCertCaching = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   966
            if ( resp->iPeerKeyId.Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   967
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   968
                if ( resp->iPeerKeyId.CompareF( *iDeviceId ) == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   969
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   970
                    iCertNeeded = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   971
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   972
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   973
            else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   974
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   975
                iCertNeeded = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   976
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   977
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   978
        else if ( resp->iCertificateCaching )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   979
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   980
            iRiSupportsCertCaching = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   981
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   982
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   983
        if ( resp->iAlgorithms.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   984
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   985
            iRiAlgorithms.ResetAndDestroy();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   986
            for ( TInt i = 0; i < resp->iAlgorithms.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   987
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   988
                if ( resp->iAlgorithms[i]->CompareF( KCmlaIp1() ) == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   989
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   990
                    iSelectedAlgorithms = ECmlaIp1;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   991
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   992
                temp = resp->iAlgorithms[i]->AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   993
                iRiAlgorithms.AppendL( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   994
                CleanupStack::Pop( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   995
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   996
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   997
        iRiId.Copy( resp->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   998
        iRiVersion.Copy( resp->iSelectedVersion );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   999
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1000
        /***
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1001
         This is needed when the multiple PKIs are supported.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1002
         ***/
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1003
        if ( resp->iTrustedAuthorities.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1004
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1005
            // select the first matching root from the list
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1006
            LOGLIT( "Choose the first matching trust anchor" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1007
            iStorageClient->SelectTrustedRootL( resp->iTrustedAuthorities,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1008
                iSelectedRoot );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1009
            LOGLIT( "The trust anchor selected" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1010
            DETAILLOGHEX( iSelectedRoot.Ptr(), iSelectedRoot.Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1011
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1012
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1013
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1014
            if ( iStoredRiContext && iStoredRiContext->RIID() == iRiId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1015
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1016
                if ( iSelectedRoot != iStoredRiContext->SelectedDeviceRoot() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1017
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1018
                    DETAILLOGLIT( "Changing trusted root to that of saved RI context" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1019
                    DETAILLOGLIT( "old root" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1020
                    DETAILLOGHEX( iSelectedRoot.Ptr(), iSelectedRoot.Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1021
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1022
                    iSelectedRoot = iStoredRiContext->SelectedDeviceRoot();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1023
                    iStorageClient->SelectTrustedRootL( iSelectedRoot );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1024
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1025
                DETAILLOGLIT( "Using trusted root of saved RI context" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1026
                DETAILLOGHEX( iSelectedRoot.Ptr(), iSelectedRoot.Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1027
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1028
            else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1029
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1030
                DETAILLOGLIT( "Using default trusted root" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1031
                iSelectedRoot = KNullDesC8;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1032
                iStorageClient->SelectTrustedRootL( iSelectedRoot );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1033
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1034
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1035
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1036
        iSigner->AddRequestL( aRiHello );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1037
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1038
    else if ( resp->iErrorUrl )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1039
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1040
        if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1041
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1042
            iObserver->ErrorUrlL( *resp->iErrorUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1043
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1044
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1045
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1046
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1047
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1048
// CRoapEng::HandleReqResponsePduL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1049
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1050
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1051
void CRoapEng::HandleReqResponsePduL( const TDesC8& aRegResp )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1052
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1053
    LOGLIT( "CRoapEng::HandleReqResponsePduL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1054
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1055
    CRegistrationResp* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1056
    CDRMRIContext* context = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1057
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1058
    TTime riExpiry;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1059
    TBool status = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1060
    TUint8 riCertCaching = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1061
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1062
    resp = iParser->ParseRegistrationRespL( aRegResp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1063
    iRoapStatus = resp->iStatus;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1064
    iResponse = resp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1065
    if ( iRoapStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1066
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1067
        if ( resp->iOcspResponse.Count() > 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1068
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1069
            // adjust DRM Time according to OCSP response
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1070
            // All needed verifications done in server side
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1071
            TBool deviceTimeUpdated( EFalse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1072
            if ( resp->iCertificateChain.Count() > 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1073
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1074
                deviceTimeUpdated = iStorageClient->UpdateDrmTimeL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1075
                    resp->iCertificateChain, resp->iOcspResponse,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1076
                    iRegReqNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1077
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1078
            else if ( iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1079
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1080
                deviceTimeUpdated = iStorageClient->UpdateDrmTimeL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1081
                    iStoredRiContext->CertificateChain(),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1082
                    resp->iOcspResponse, iRegReqNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1083
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1084
            if ( deviceTimeUpdated )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1085
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1086
                LOGLIT( "drm time updated" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1087
                iDeviceTimeError = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1088
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1089
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1090
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1091
        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1092
            && resp->iOcspResponse.Count() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1093
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1094
            status = VerifyCertificateChainL( resp->iCertificateChain,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1095
                resp->iOcspResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1096
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1097
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1098
                LOGLIT( "Certificate chain validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1099
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1100
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1101
            status = ValidateRiIdL( iRiId, *resp->iCertificateChain[0] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1102
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1103
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1104
                LOGLIT( "RI ID validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1105
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1106
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1107
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1108
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1109
        if ( iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1110
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1111
            // if we have already stored certificates -> use those.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1112
            status = VerifySignatureL( aRegResp, *resp->iSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1113
                iStoredRiContext->CertificateChain() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1114
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1115
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1116
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1117
            // otherwise use the received certificates
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1118
            status = VerifySignatureL( aRegResp, *resp->iSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1119
                resp->iCertificateChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1120
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1121
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1122
        if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1123
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1124
            LOGLIT( "Signature verification failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1125
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1126
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1127
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1128
        if ( resp->iCertificateChain.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1129
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1130
            // Validate RI certificate
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1131
            cert = CX509Certificate::NewLC( *resp->iCertificateChain[0] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1132
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1133
            status = ValidateRiCertificateL( cert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1134
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1135
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1136
                User::LeaveIfError( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1137
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1138
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1139
            riExpiry = cert->ValidityPeriod().Finish();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1140
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1141
            iRiSupportsCertCaching ? riCertCaching = ETrue : riCertCaching
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1142
                = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1143
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1144
            context = CDRMRIContext::NewLC( iRiId, *iRiAlias, iRiVersion,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1145
                iRiAlgorithms, resp->iWhiteList, *resp->iRiUrl, riExpiry,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1146
                resp->iCertificateChain, resp->iOcspResponse, riCertCaching,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1147
                iSelectedRoot, ETrue );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1148
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1149
            iStorageClient->AddRIContextL( *context );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1150
            delete iStoredRiContext;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1151
            iStoredRiContext = context;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1152
            CleanupStack::Pop( context );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1153
            CleanupStack::PopAndDestroy( cert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1154
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1155
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1156
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1157
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1158
        if ( resp->iErrorUrl )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1159
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1160
            if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1161
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1162
                iObserver->ErrorUrlL( *resp->iErrorUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1163
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1164
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1165
        iSigner->ResetResponses();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1166
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1167
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1168
    PERFORMANCE_LOGLIT( "Registration protocol completed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1169
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1170
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1171
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1172
// CRoapEng::HandleRightsResponseL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1173
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1174
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1175
void CRoapEng::HandleRightsResponsePduL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1176
    const TDesC8& aRightsResp,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1177
    TBool aOnePass )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1178
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1179
    LOGLIT( "CRoapEng::HandleRightsResponsePduL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1180
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1181
    CRightsResp* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1182
    TBool status = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1183
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1184
    resp = iParser->ParseRightsRespL( aRightsResp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1185
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1186
    CleanupStack::PushL( resp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1187
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1188
    if ( resp->iStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1189
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1190
        if ( !aOnePass )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1191
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1192
            // 2-pass protocol
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1193
            __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1194
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1195
            CRightsReq* request = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1196
            request = STATIC_CAST( CRightsReq*, iRequest );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1197
            if ( resp->iDeviceId.CompareF( request->iDeviceId ) != KErrNone
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1198
                || resp->iRiId.CompareF( request->iRiId ) != KErrNone
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1199
                || resp->iNonce->CompareF( request->iNonce ) != KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1200
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1201
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1202
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1203
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1204
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1205
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1206
            LOGLIT( "1-pass ROAP" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1207
            // 1-pass protocol
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1208
            TBool registered = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1209
            GetRIContextL( registered, resp->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1210
            if ( !registered )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1211
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1212
                // Recoverable error by re-registering the device
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1213
                // (after receiving user consent or iv device belongs to whiteliust)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1214
                LOGLIT( "Device not registered to RI" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1215
                User::Leave( KErrRoapNotRegistered );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1216
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1217
            if ( resp->iDeviceId.CompareF( *iDeviceId ) != KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1218
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1219
                // Unrecoverable error
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1220
                LOGLIT( "Device ID mismatch!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1221
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1222
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1223
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1224
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1225
        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1226
            && resp->iOcspResponse.Count() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1227
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1228
            status = VerifyCertificateChainL( resp->iCertificateChain,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1229
                resp->iOcspResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1230
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1231
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1232
                LOGLIT( "Certificate chain validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1233
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1234
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1235
            status = ValidateRiIdL( resp->iRiId, *resp->iCertificateChain[0] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1236
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1237
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1238
                LOGLIT( "RI ID validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1239
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1240
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1241
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1242
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1243
        status = VerifySignatureL( aRightsResp, *resp->iSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1244
            iStoredRiContext->CertificateChain() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1245
        if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1246
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1247
            LOGLIT( "Signature verification failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1248
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1249
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1250
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1251
        iReturnedROs.ResetAndDestroy();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1252
        TRAPD( r, iRoParser->ParseAndStoreL( aRightsResp, iReturnedROs ));
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1253
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1254
        if ( r == KErrRightsServerDomainNotRegistered )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1255
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1256
            // perform implicit Join Domain
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1257
            LOGLIT( "Domain RO received - Not joined" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1258
            LOGLIT( "Perform impicit Join Domain before storing the RO" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1259
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1260
            HBufC8* domainID = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1261
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1262
            domainID = iRoParser->GetDomainIdL( aRightsResp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1263
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1264
            if ( domainID && domainID->Length() <= KDomainIdLength )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1265
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1266
                iDomainId.Copy( *domainID );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1267
                delete domainID;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1268
                domainID = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1269
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1270
            else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1271
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1272
                LOGLIT( "No Domain ID available!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1273
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1274
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1275
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1276
            delete iDomainRightsResp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1277
            iDomainRightsResp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1278
            iDomainRightsResp = aRightsResp.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1279
            iImplicitJoinDomain = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1280
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1281
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1282
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1283
            User::LeaveIfError( r );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1284
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1285
            if ( !aOnePass )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1286
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1287
                if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1288
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1289
                    iObserver->RightsObjectDetailsL( iReturnedROs ); // pass RO details to UI
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1290
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1291
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1292
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1293
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1294
            TRAP( r, InsertTransactionIDL( resp->iTransTrackIDs, resp->iContentIDs ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1295
            TRAP( r, InsertDomainRosL() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1296
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1297
        // Device DRM Time is insecure, but server thinks that the time is correct
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1298
        // -> Set DRM Time as secure
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1299
        if ( !iSecureTime )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1300
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1301
            SetDrmTimeSecureL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1302
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1303
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1304
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1305
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1306
        if ( resp->iErrorUrl )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1307
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1308
            if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1309
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1310
                iObserver->ErrorUrlL( *resp->iErrorUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1311
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1312
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1313
        iSigner->ResetResponses();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1314
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1315
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1316
    CleanupStack::Pop( resp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1317
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1318
    if ( !aOnePass )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1319
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1320
        iRoapStatus = resp->iStatus;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1321
        iResponse = resp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1322
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1323
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1324
    PERFORMANCE_LOGLIT( "RO acquisition protocol completed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1325
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1326
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1327
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1328
// CRoapEng::HandleJoinDomainResponseL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1329
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1330
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1331
void CRoapEng::HandleJoinDomainResponsePduL( const TDesC8& aJoinResp )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1332
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1333
    LOGLIT( "CRoapEng::HandleJoinDomainResponsePduL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1334
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1335
    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1336
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1337
    CJoinDomainResp* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1338
    CDRMDomainContext* context = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1339
    RPointerArray<HBufC8> domainKeyElements;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1340
    TBool status = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1341
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1342
    CleanupResetAndDestroyPushL( domainKeyElements );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1343
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1344
    resp = iParser->ParseJoinDomainRespL( aJoinResp, domainKeyElements );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1345
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1346
    iResponse = resp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1347
    iRoapStatus = resp->iStatus;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1348
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1349
    if ( iRoapStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1350
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1351
        if ( resp->iDomainKeyRiId != resp->iRiId )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1352
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1353
            LOGLIT( "resp->iDomainKeyRiId != resp->iRiId" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1354
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1355
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1356
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1357
        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1358
            && resp->iOcspResponse.Count() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1359
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1360
            status = VerifyCertificateChainL( resp->iCertificateChain,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1361
                resp->iOcspResponse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1362
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1363
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1364
                LOGLIT( "Certificate chain validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1365
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1366
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1367
            status = ValidateRiIdL( resp->iRiId, *resp->iCertificateChain[0] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1368
            if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1369
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1370
                LOGLIT( "RI ID validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1371
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1372
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1373
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1374
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1375
        status = VerifySignatureL( aJoinResp, *resp->iSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1376
            iStoredRiContext->CertificateChain() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1377
        if ( !status )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1378
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1379
            LOGLIT( "Signature verification failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1380
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1381
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1382
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1383
        if ( resp->iDomainKeys.Count() > 1 && resp->iDomainKeyIDs.Count() > 1
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1384
            && resp->iDomainKeys.Count() == resp->iDomainKeyIDs.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1385
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1386
            // Sort domain keys by generation (000 generation is first)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1387
            TLex8 lex;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1388
            TInt generation = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1389
            RArray<TInt> generations;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1390
            CleanupClosePushL( generations );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1391
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1392
            for ( TInt i = 0; i < resp->iDomainKeyIDs.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1393
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1394
                lex = resp->iDomainKeyIDs[i]->Right( KDomainGenerationLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1395
                lex.Val( generation );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1396
                generations.AppendL( generation );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1397
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1398
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1399
            SortArrays( resp->iDomainKeys, resp->iMacs, domainKeyElements,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1400
                generations );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1401
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1402
            CleanupStack::PopAndDestroy( &generations );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1403
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1404
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1405
        if ( !resp->iDomainKeys.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1406
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1407
            LOGLIT( "No valid domain keys present!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1408
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1409
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1410
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1411
#ifdef _DISABLE_HASH_CHAIN_GENERATION
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1412
        resp->iHashChainSupport = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1413
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1414
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1415
        if ( resp->iHashChainSupport )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1416
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1417
            if ( resp->iDomainKeys.Count() > 1 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1418
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1419
                LOGLIT( "More than one Domain key present, hash chain key generation is supported!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1420
                // Might be KErrRoapServerFatal server error
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1421
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1422
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1423
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1424
        context = CDRMDomainContext::NewLC( iDomainId,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1425
            resp->iDomainExpiration, resp->iHashChainSupport,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1426
            resp->iDomainKeys, resp->iRiId,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1427
            iStoredRiContext->RightsIssuerURL() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1428
        iStorageClient->AddDomainContextL( *context, resp->iMacs,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1429
            domainKeyElements, resp->iTransportScheme );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1430
        iDomainId.SetLength( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1431
        CleanupStack::PopAndDestroy( context );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1432
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1433
        if ( iDomainRightsResp )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1434
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1435
            // It's a implicit Join Domain case
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1436
            // We still need to store the domain RO
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1437
            StoreDomainRightsL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1438
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1439
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1440
        // Device DRM Time is insecure, but server thinks that the time is correct
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1441
        // -> Set DRM Time as secure
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1442
        if ( !iSecureTime )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1443
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1444
            SetDrmTimeSecureL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1445
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1446
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1447
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1448
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1449
        if ( resp->iErrorUrl )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1450
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1451
            if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1452
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1453
                iObserver->ErrorUrlL( *resp->iErrorUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1454
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1455
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1456
        iSigner->ResetResponses();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1457
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1458
    CleanupStack::PopAndDestroy( &domainKeyElements );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1459
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1460
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1461
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1462
// CRoapEng::HandleLeaveDomainResponseL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1463
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1464
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1465
void CRoapEng::HandleLeaveDomainResponsePduL( const TDesC8& aLeaveResp )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1466
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1467
    LOGLIT( "CRoapEng::HandleLeaveDomainResponsePduL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1468
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1469
    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1470
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1471
    CLeaveDomainResp* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1472
    resp = iParser->ParseLeaveDomainRespL( aLeaveResp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1473
    iRoapStatus = resp->iStatus;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1474
    iResponse = resp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1475
    if ( iRoapStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1476
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1477
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1478
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1479
    else if ( resp->iErrorUrl )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1480
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1481
        if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1482
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1483
            iObserver->ErrorUrlL( *resp->iErrorUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1484
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1485
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1486
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1487
    PERFORMANCE_LOGLIT( "Leave domain protocol completed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1488
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1489
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1490
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1491
// CRoapEng::HandleMeteringReportResponsePduL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1492
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1493
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1494
#ifndef RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1495
void CRoapEng::HandleMeteringReportResponsePduL( const TDesC8& /*aMeteringResp*/)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1496
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1497
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1498
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1499
void CRoapEng::HandleMeteringReportResponsePduL( const TDesC8& aMeteringResp )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1500
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1501
    LOGLIT( "CRoapEng::HandleMeteringReportResponsePduL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1502
    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1503
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1504
    CMeteringResp* resp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1505
    CMeteringReportReq* request = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1506
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1507
    resp = iParser->ParseMeteringRespL( aMeteringResp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1508
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1509
    request = static_cast<CMeteringReportReq*> ( iRequest );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1510
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1511
    iRoapStatus = resp->iStatus;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1512
    iResponse = resp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1513
    if ( iRoapStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1514
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1515
        if ( resp->iDeviceId.CompareF( *iDeviceId ) != KErrNone
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1516
            || resp->iDeviceNonce->CompareF( request->iNonce ) != KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1517
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1518
            LOGLIT( "Mismatch in deviceId or in nonce" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1519
            LOGLIT( "Observed DeviceId" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1520
            LOGHEX( resp->iDeviceId.Ptr(), resp->iDeviceId.Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1521
            LOGLIT( "Expected DeviceId" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1522
            LOGHEX( request->iDeviceId.Ptr(), request->iDeviceId.Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1523
            LOGLIT( "Observed nonce" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1524
            LOGHEX( resp->iDeviceNonce->Ptr(), resp->iDeviceNonce->Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1525
            LOGLIT( "Expected nonce" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1526
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1527
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1528
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1529
        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1530
            && resp->iOcspResponse.Count() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1531
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1532
            if ( !VerifyCertificateChainL( resp->iCertificateChain,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1533
                resp->iOcspResponse ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1534
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1535
                LOGLIT( "Certificate chain validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1536
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1537
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1538
            if ( !ValidateRiIdL( resp->iRiId, *resp->iCertificateChain[0] ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1539
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1540
                LOGLIT( "RI ID validation failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1541
                User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1542
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1543
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1544
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1545
        if ( !VerifySignatureL( aMeteringResp, *resp->iSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1546
            iStoredRiContext->CertificateChain() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1547
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1548
            LOGLIT( "Signature verification failed" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1549
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1550
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1551
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1552
        // Everything is fine, we can delete metering data
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1553
        iStorageClient->DeleteMeteringDataL( resp->iRiId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1554
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1555
        // notify PostResponseUrl for iObserver
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1556
        if ( resp->iPrUrl )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1557
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1558
            HBufC8* prUrl( resp->iPrUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1559
            LOGLIT( "PrUrl" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1560
            LOGHEX( prUrl->Ptr(), prUrl->Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1561
            if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1562
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1563
                iObserver->PostResponseUrlL( *prUrl );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1564
                LOGLIT( "Notified observer with PostResponseUrl" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1565
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1566
            else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1567
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1568
                LOGLIT( "Warning no observer for PostResponseUrl" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1569
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1570
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1571
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1572
    return;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1573
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1574
#endif //RD_DRM_METERING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1575
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1576
// CRoapEng::HandleMultipartL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1577
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1578
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1579
void CRoapEng::HandleMultipartL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1580
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1581
    LOGLIT( "CRoapEng::HandleMultipartL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1582
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1583
    TInt rightsErr( KErrNone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1584
    TInt err( KErrNone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1585
    TInt docErr( KErrNone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1586
    TDataType type = TDataType();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1587
    TBool mmcAllowed( EFalse );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1588
    HBufC* contentName( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1589
    RBuf newPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1590
    TUid app_uid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1591
    RBuf rootPath;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1592
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1593
    TRAP( rightsErr, HandleRoapResponseL( iRoapResp->ProtocolUnit() ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1594
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1595
    newPath.CreateL( KMaxFileName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1596
    CleanupClosePushL( newPath  );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1597
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1598
    CDocumentHandler* docHandler( CDocumentHandler::NewLC() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1599
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1600
    if ( iRoapResp->DcfFileName().Left( 1 ).CompareF( _L ("e") ) == 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1601
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1602
        mmcAllowed = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1603
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1604
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1605
    RFs fs;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1606
    User::LeaveIfError( fs.Connect() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1607
    CleanupClosePushL( fs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1608
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1609
#ifndef RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1610
    rootPath.CreateL( mmcAllowed ?
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1611
        PathInfo::MemoryCardRootPath() :
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1612
        PathInfo::PhoneMemoryRootPath() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1613
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1614
#else //RD_MULTIPLE_DRIVE
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1615
    _LIT( KSysDriveRoot, "_:\\Data\\");
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1616
    _LIT( KMassDriveRoot, "_:\\" );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1617
    TInt driveNumber( -1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1618
    TChar driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1619
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1620
    if ( mmcAllowed )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1621
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1622
        // Set root path to memory card root
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1623
        rootPath.CreateL( KMassDriveRoot() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1624
        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1625
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1626
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1627
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1628
        // Set root path to system root
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1629
        rootPath.CreateL( KSysDriveRoot() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1630
        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1631
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1632
    fs.DriveToChar( driveNumber, driveLetter );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1633
    __ASSERT_ALWAYS( rootPath.Length()>0, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1634
    rootPath[0] = (TUint)driveLetter;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1635
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1636
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1637
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1638
    CleanupClosePushL( rootPath );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1639
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1640
    iRoapResp->GetContentNameLC( contentName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1641
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1642
    if ( contentName && contentName->Length()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1643
        && fs.IsValidName( *contentName ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1644
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1645
        if ( !rightsErr )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1646
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1647
            TRAP( err, docErr = docHandler->SilentMoveL( iRoapResp->DcfFileName(),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1648
                    *contentName, rootPath, type, KEntryAttNormal ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1649
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1650
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1651
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1652
            // when an error occured during RO storing -> show "saved to" note
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1653
            TRAP( err, docErr = docHandler->MoveL( iRoapResp->DcfFileName(),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1654
                    *contentName, type, KEntryAttNormal ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1655
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1656
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1657
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1658
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1659
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1660
        if ( !rightsErr )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1661
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1662
            // use the default name
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1663
            User::LeaveIfError( docHandler->SilentMoveL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1664
                iRoapResp->DcfFileName(), KNullDesC(), rootPath, type,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1665
                KEntryAttNormal ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1666
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1667
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1668
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1669
            // when an error occured during RO storing -> show "saved to" note
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1670
            docHandler->MoveL( iRoapResp->DcfFileName(), KNullDesC(), type,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1671
                KEntryAttNormal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1672
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1673
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1674
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1675
    if ( err || docErr )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1676
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1677
        if ( !rightsErr )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1678
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1679
            // use the default name
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1680
            User::LeaveIfError( docHandler->SilentMoveL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1681
                iRoapResp->DcfFileName(), KNullDesC(), rootPath, type,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1682
                KEntryAttNormal ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1683
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1684
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1685
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1686
            // when an error occured during RO storing -> show "saved to" note
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1687
            docHandler->MoveL( iRoapResp->DcfFileName(), KNullDesC(), type,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1688
                KEntryAttNormal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1689
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1690
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1691
    User::LeaveIfError( rightsErr );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1692
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1693
    User::LeaveIfError( docHandler->GetPath( newPath ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1694
    User::LeaveIfError( docHandler->HandlerAppUid( app_uid ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1695
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1696
    if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1697
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1698
        iObserver->ContentDetailsL( newPath, type.Des8(), app_uid );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1699
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1700
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1701
    CleanupStack::PopAndDestroy( contentName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1702
    CleanupStack::PopAndDestroy( &rootPath );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1703
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1704
    CleanupStack::PopAndDestroy( &fs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1705
    CleanupStack::PopAndDestroy( docHandler );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1706
    CleanupStack::PopAndDestroy( &newPath );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1707
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1708
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1709
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1710
// CRoapEng::SignMessageL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1711
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1712
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1713
HBufC8* CRoapEng::SignMessageL( const TDesC8& aMessage ) const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1714
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1715
    LOGLIT( "CRoapEng::SignMessageL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1716
    HBufC8* r = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1717
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1718
    if ( iReqMessage == EDeviceHello )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1719
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1720
        // Device Hello always resets signing chain!!
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1721
        iSigner->ResetRequests();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1722
        iSigner->ResetResponses();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1723
        // Device Hello or RI Hello is not signed
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1724
        iSigner->AddRequestL( aMessage );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1725
        r = aMessage.AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1726
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1727
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1728
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1729
        r = iSigner->SignAndAddRequestL( aMessage );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1730
        iSigner->ResetRequests();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1731
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1732
        if ( iReqMessage == ERegistration )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1733
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1734
            // Add signed request to the signer for verifying signature on
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1735
            // response (for Registration protocol only).
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1736
            iSigner->AddResponseL( *r );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1737
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1738
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1739
    return r;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1740
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1741
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1742
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1743
// CRoapEng::VerifySignatureL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1744
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1745
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1746
TBool CRoapEng::VerifySignatureL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1747
    const TDesC8& aMessage,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1748
    const TDesC8& aSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1749
    const RPointerArray<HBufC8>& aCertificateChain ) const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1750
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1751
    LOGLIT( "CRoapEng::VerifySignatureL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1752
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1753
    TBool isValid = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1754
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1755
    if ( iReqMessage != EDeviceHello && iReqMessage != ELeaveDomain )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1756
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1757
        // RI Hello and Leave Domain resp are not signed
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1758
        isValid = iSigner->VerifyAndAddResponseL( aMessage, aSignature,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1759
            aCertificateChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1760
        iSigner->ResetResponses();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1761
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1762
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1763
#ifdef _DISABLE_SIGNATURE_CHECK
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1764
    isValid = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1765
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1766
    return isValid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1767
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1768
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1769
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1770
// CRoapEng::VerifyTriggerSignatureL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1771
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1772
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1773
TBool CRoapEng::VerifyTriggerSignatureL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1774
    const TDesC8& aXmlTrigger,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1775
    const CRoapTrigger& aTrigger ) const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1776
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1777
    LOGLIT( "CRoapEng::ValidateTriggerSignatureL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1778
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1779
    TPtrC8 element( KNullDesC8 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1780
    TPtrC8 signedInfo( KNullDesC8 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1781
    CDRMDomainContext* context( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1782
    HBufC8* domainKey( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1783
    HBufC8* unwrappedMacKey( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1784
    CSHA1* digest( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1785
    CMessageDigest* hMac( NULL );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1786
    TBool result( ETrue );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1787
    TInt pos( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1788
    TInt generation( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1789
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1790
    element.Set( iParser->ExtractElement( aXmlTrigger, KLeaveDomainElement(),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1791
        pos ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1792
    pos = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1793
    signedInfo.Set( iParser->ExtractElement( aXmlTrigger,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1794
        KSignedInfoElement(), pos ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1795
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1796
    if ( !element.Length() || !signedInfo.Length() || !aTrigger.iEncKey
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1797
        || !aTrigger.iSignature )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1798
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1799
        User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1800
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1801
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1802
    context = iStorageClient->GetDomainContextL( *aTrigger.iDomainId );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1803
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1804
    if ( !context )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1805
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1806
        // we are not member of the domain
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1807
        LOGLIT( "No DomainContext for the domain -> Cannot verify Trigger signature" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1808
        return ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1809
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1810
    CleanupStack::PushL( context );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1811
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1812
    TLex8 lex( aTrigger.iDomainId->Right( KDomainGenerationLength ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1813
    lex.Val( generation );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1814
    domainKey = context->DomainKeyL( generation );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1815
    User::LeaveIfNull( domainKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1816
    CleanupStack::PushL( domainKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1817
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1818
    unwrappedMacKey = OmaCrypto::AesUnwrapL( *domainKey, *aTrigger.iEncKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1819
    CleanupStack::PopAndDestroy( domainKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1820
    CleanupStack::PushL( unwrappedMacKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1821
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1822
    // hash the leaveDomain element
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1823
    digest = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1824
    CleanupStack::PushL( digest );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1825
    digest->Update( element );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1826
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1827
    if ( digest->Final().CompareF( *aTrigger.iDigestValue ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1828
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1829
        LOGLIT( "Reference Validation failed!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1830
        result = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1831
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1832
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1833
    if ( result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1834
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1835
        // calculate HMAC signature
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1836
        hMac = CMessageDigestFactory::NewHMACLC( CMessageDigest::ESHA1,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1837
            *unwrappedMacKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1838
        hMac->Update( signedInfo );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1839
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1840
        if ( hMac->Final().CompareF( *aTrigger.iSignature ) != 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1841
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1842
            LOGLIT( "Signature Validation failed!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1843
            result = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1844
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1845
        CleanupStack::PopAndDestroy( hMac );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1846
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1847
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1848
    CleanupStack::PopAndDestroy( digest );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1849
    CleanupStack::PopAndDestroy( unwrappedMacKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1850
    CleanupStack::PopAndDestroy( context );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1851
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1852
    if ( !result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1853
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1854
        LOGLIT( "Trigger signature check failed!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1855
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1856
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1857
#ifdef _DISABLE_SIGNATURE_CHECK
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1858
    result = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1859
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1860
    return result;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1861
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1862
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1863
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1864
// CRoapEng::VerifyCertificateChainL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1865
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1866
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1867
TBool CRoapEng::VerifyCertificateChainL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1868
    const RPointerArray<HBufC8>& aCertificateChain,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1869
    const RPointerArray<HBufC8>& aOcspResponses ) const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1870
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1871
    LOGLIT( "CRoapEng::VerifyCertificateChainL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1872
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1873
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1874
    CX509Certificate* signingCert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1875
    CX509Certificate* riCA = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1876
    TBool result = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1877
    RPointerArray<HBufC8> serialNums;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1878
    CX500DistinguishedName* rootDistName = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1879
    HBufC* rootName = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1880
    HBufC8* rootCert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1881
    HBufC8* temp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1882
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1883
    if ( !aCertificateChain.Count() || !aOcspResponses.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1884
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1885
        User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1886
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1887
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1888
    // Get the last cert from the chain. It is signed by some of our trusted anchor
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1889
    riCA = CX509Certificate::NewLC(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1890
        *( aCertificateChain[aCertificateChain.Count() - 1] ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1891
    rootDistName = CX500DistinguishedName::NewLC( riCA->IssuerName() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1892
    rootName = rootDistName->DisplayNameL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1893
    CleanupStack::PushL( rootName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1894
    // Get the correct root cert for validating the whole chain
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1895
    rootCert = iStorageClient->GetRootCertificateL( *rootName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1896
    CleanupStack::PopAndDestroy( rootName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1897
    CleanupStack::PopAndDestroy( rootDistName );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1898
    CleanupStack::PopAndDestroy( riCA );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1899
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1900
    if ( !rootCert )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1901
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1902
        LOGLIT( "No root certificate present!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1903
        LOGLIT( "Certificate chain verification failed." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1904
        return EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1905
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1906
    CleanupStack::PushL( rootCert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1907
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1908
    CleanupResetAndDestroyPushL( serialNums );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1909
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1910
    for ( TInt i = 0; i < aCertificateChain.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1911
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1912
        cert = CX509Certificate::NewLC( *aCertificateChain[i] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1913
        temp = cert->SerialNumber().AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1914
        serialNums.AppendL( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1915
        CleanupStack::Pop( temp );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1916
        if ( aCertificateChain.Count() - 1 == i )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1917
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1918
            // signingCert = Trusted root cert
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1919
            signingCert = CX509Certificate::NewLC( *rootCert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1920
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1921
        else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1922
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1923
            signingCert = CX509Certificate::NewLC( *aCertificateChain[i + 1] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1924
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1925
        result = cert->VerifySignatureL( signingCert->PublicKey().KeyData() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1926
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1927
#ifdef _DISABLE_CERT_CHECK
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1928
        result = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1929
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1930
        CleanupStack::PopAndDestroy( signingCert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1931
        CleanupStack::PopAndDestroy( cert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1932
        if ( !result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1933
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1934
            LOGLIT( "Certificate chain verification failed." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1935
            CleanupStack::PopAndDestroy( 2, rootCert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1936
            return result;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1937
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1938
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1939
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1940
    if ( aCertificateChain.Count() >= 2 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1941
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1942
        result = VerifyOcspResponsesL( aOcspResponses, *aCertificateChain[1],
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1943
            serialNums );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1944
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1945
        if ( !result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1946
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1947
            // CoreMedia's OCSP responder cert is signed by the root -> against CMLA spec
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1948
            LOGLIT( "Try to verify OCSP response cert using root cert" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1949
            result = VerifyOcspResponsesL( aOcspResponses, *rootCert,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1950
                serialNums );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1951
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1952
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1953
    else if ( aCertificateChain.Count() == 1 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1954
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1955
        // There is only one cert in the cert chain -> the OCSP response cert is verified with root cert
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1956
        result = VerifyOcspResponsesL( aOcspResponses, *rootCert, serialNums );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1957
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1958
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1959
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1960
        result = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1961
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1962
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1963
    if ( iStoredRiContext && aCertificateChain.Count() && result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1964
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1965
        cert = CX509Certificate::NewLC( *aCertificateChain[0] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1966
        if ( iStoredRiContext->ExpiryTime() < cert->ValidityPeriod().Finish() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1967
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1968
            iStoredRiContext->SetCertificateChainL( aCertificateChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1969
            iStoredRiContext->SetOCSPResponseL( aOcspResponses );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1970
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1971
            // update RI Context
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1972
            iStorageClient->AddRIContextL( *iStoredRiContext );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1973
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1974
        CleanupStack::PopAndDestroy( cert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1975
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1976
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1977
    CleanupStack::PopAndDestroy( 2, rootCert ); // serialNums, rootCert
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1978
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1979
#ifdef _ROAP_TESTING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1980
    if ( result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1981
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1982
        LOGLIT( "Certificate chain verification ok." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1983
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1984
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1985
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1986
        LOGLIT( "Certificate chain verification failed." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1987
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1988
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1989
#ifdef _DISABLE_CERT_CHECK
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1990
    result = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1991
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1992
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1993
    return result;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1994
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1995
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1996
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1997
// CRoapEng::VerifyOcspResponsesL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1998
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  1999
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2000
TBool CRoapEng::VerifyOcspResponsesL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2001
    const RPointerArray<HBufC8>& aOcspResponses,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2002
    const TDesC8& aRiCaCert,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2003
    const RPointerArray<HBufC8>& aCertSerialNums ) const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2004
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2005
    LOGLIT( "CRoapEng::VerifyOcspResponsesL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2006
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2007
#ifdef _DISABLE_OCSP_CHECK
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2008
    TBool result( ETrue );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2009
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2010
    // Get verification result from the server
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2011
    TBool result( iStorageClient->VerifyOcspResponsesL( aOcspResponses,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2012
        aRiCaCert, aCertSerialNums ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2013
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2014
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2015
#ifdef _ROAP_TESTING
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2016
    if ( result )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2017
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2018
        LOGLIT( "OCSP response verification ok." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2019
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2020
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2021
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2022
        LOGLIT( "OCSP response verification failed." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2023
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2024
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2025
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2026
    return result;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2027
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2028
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2029
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2030
// CRoapEng::ValidateRiCertificateL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2031
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2032
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2033
TBool CRoapEng::ValidateRiCertificateL( const CX509Certificate* aCert )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2034
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2035
    LOGLIT( "CRoapEng::ValidateRiCertificateL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2036
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2037
    TBool ret = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2038
    const CX509CertExtension* ext = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2039
    CX509KeyUsageExt* keyUsageExt = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2040
    CX509ExtendedKeyUsageExt* extendedKeyUsage = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2041
    TTime riExpiry;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2042
    TInt count = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2043
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2044
    if ( iSelectedAlgorithms == ECmlaIp1 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2045
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2046
        // Check RI certificate extensions only in CMLA case
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2047
        ext = aCert->Extension( KKeyUsage() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2048
        if ( !ext || !( ext->Critical() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2049
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2050
            LOGLIT( "RI cert KeyUsage extension missing or not critical!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2051
            ret = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2052
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2053
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2054
        if ( ext && ret )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2055
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2056
            keyUsageExt = CX509KeyUsageExt::NewLC( ext->Data() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2057
            if ( !keyUsageExt->IsSet( EX509DigitalSignature ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2058
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2059
                LOGLIT( "DigitalSignature bit is not set in KeyUsageExt of RI cert!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2060
                ret = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2061
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2062
            CleanupStack::PopAndDestroy( keyUsageExt );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2063
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2064
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2065
        ext = aCert->Extension( KExtendedKeyUsage() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2066
        if ( !ext || !( ext->Critical() ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2067
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2068
            LOGLIT( "RI cert ExtendedKeyUsage extension missing or not critical!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2069
            ret = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2070
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2071
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2072
        if ( ext && ret )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2073
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2074
            ret = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2075
            extendedKeyUsage = CX509ExtendedKeyUsageExt::NewLC( ext->Data() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2076
            count = extendedKeyUsage->KeyUsages().Count();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2077
            for ( TInt i = 0; i < count && !ret; i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2078
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2079
                if ( extendedKeyUsage->KeyUsages().At( i )->CompareF(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2080
                    KOmaKpRightsIssuerOid() ) == 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2081
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2082
                    ret = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2083
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2084
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2085
            if ( !ret )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2086
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2087
                LOGLIT( "OmaKpRightsIssuer OID is not set in ExtendedKeyUsageExt of RI cert!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2088
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2089
            CleanupStack::PopAndDestroy( extendedKeyUsage );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2090
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2091
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2092
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2093
    riExpiry = aCert->ValidityPeriod().Finish();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2094
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2095
    if ( riExpiry < GetDrmTimeL() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2096
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2097
        LOGLIT( "RI Context certificate is expired!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2098
        ret = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2099
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2100
#ifdef _DISABLE_CERT_CHECK
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2101
    ret = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2102
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2103
    return ret;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2104
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2105
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2106
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2107
// CRoapEng::GetCertificateChainL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2108
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2109
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2110
RPointerArray<HBufC8> CRoapEng::GetCertificateChainL() const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2111
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2112
    LOGLIT( "CRoapEng::GetCertificateChainL ->" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2113
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2114
    TInt err = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2115
    RPointerArray<HBufC8> certificateChain;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2116
    HBufC8* root = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2117
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2118
    CleanupResetAndDestroyPushL( certificateChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2119
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2120
    err = iStorageClient->GetDeviceCertificateChainL( certificateChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2121
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2122
    if ( err )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2123
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2124
        User::Leave( err );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2125
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2126
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2127
    if ( certificateChain.Count() < KMinCertChainLength )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2128
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2129
        // the CMLA chain must always contain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2130
        // the device certificate,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2131
        // at lest one signing certificate (device CA),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2132
        // and the root certificate
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2133
        DETAILLOGLIT( "Got improper certificate chain!!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2134
        // Leaving in production devices.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2135
        User::Leave( KErrRoapDevice );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2136
        __ASSERT_DEBUG( ETrue, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2137
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2138
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2139
    // delete and remove the root certificate (it's always the last one in the list)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2140
    root = certificateChain[certificateChain.Count() - 1];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2141
    delete root;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2142
    certificateChain.Remove( certificateChain.Count() - 1 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2143
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2144
    CleanupStack::Pop( &certificateChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2145
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2146
    LOGLIT( "CRoapEng::GetCertificateChainL <-" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2147
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2148
    return certificateChain;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2149
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2150
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2151
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2152
// CRoapEng::GetDeviceDetailsL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2153
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2154
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2155
void CRoapEng::GetDeviceDetailsL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2156
    HBufC8*& aManufacturer,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2157
    HBufC8*& aModel,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2158
    HBufC8*& aVersion )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2159
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2160
    LOGLIT( "-> CRoapEng::GetDeviceDetailsL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2161
90
62156f66dbad Breaking DRM's dependency Etel so that AVKON can start. The ROM now boots, but doesn't seem to have any items in the matrix menu at all.
Tom Pritchard <tomp@symbian.org>
parents: 88
diff changeset
  2162
#if 0
88
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2163
    TInt numPhone = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2164
    TUint32 caps = 0;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2165
    TName tsyName;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2166
    RMobilePhone phone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2167
    RTelServer etelServer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2168
    RTelServer::TPhoneInfo phoneInfo;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2169
    HBufC* version = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2170
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2171
    User::LeaveIfError( etelServer.Connect() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2172
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2173
    CleanupClosePushL( etelServer );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2174
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2175
    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2176
    User::LeaveIfError( etelServer.EnumeratePhones( numPhone) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2177
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2178
    for (TInt i(0); i < numPhone; i++)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2179
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2180
        User::LeaveIfError( etelServer.GetPhoneInfo( i, phoneInfo ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2181
        User::LeaveIfError( etelServer.GetTsyName( i,tsyName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2182
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2183
        if ( tsyName.CompareF( KMmTsyModuleName ) == 0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2184
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2185
            break;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2186
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2187
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2188
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2189
    User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2190
    CleanupClosePushL( phone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2191
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2192
    phone.GetIdentityCaps( caps );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2193
    if ( !( caps & RMobilePhone::KCapsGetManufacturer ) &&
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2194
        !( caps & RMobilePhone::KCapsGetModel ) )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2195
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2196
        User::Leave( KErrRoapGeneral );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2197
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2198
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2199
    RMobilePhone::TMobilePhoneIdentityV1 details;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2200
    TRequestStatus status;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2201
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2202
    phone.GetPhoneId( status, details );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2203
    User::WaitForRequest( status );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2204
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2205
    User::LeaveIfError( status.Int() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2206
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2207
    HBufC8* manufacturer( HBufC8::NewLC( details.iManufacturer.Length() ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2208
    manufacturer->Des().Copy( details.iManufacturer );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2209
    HBufC8* model( HBufC8::NewLC( details.iModel.Length() ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2210
    model->Des().Copy( details.iModel );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2211
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2212
    version = HBufC::NewLC( KSysUtilVersionTextLength );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2213
    TPtr ptr( version->Des() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2214
    User::LeaveIfError( SysUtil::GetSWVersion( ptr ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2215
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2216
    // remove possible BOM from the end
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2217
    if ( ptr.Right( KBOM1().Length() ).CompareF( KBOM1 ) == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2218
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2219
        ptr.Delete( ptr.Length() - KBOM1().Length(), KBOM1().Length() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2220
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2221
    if ( ptr.Right( KBOM2().Length() ).CompareF( KBOM2 ) == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2222
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2223
        ptr.Delete( ptr.Length() - KBOM2().Length(), KBOM2().Length() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2224
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2225
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2226
    aVersion = CnvUtfConverter::ConvertFromUnicodeToUtf8L( ptr );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2227
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2228
    CleanupStack::PopAndDestroy( version );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2229
    CleanupStack::Pop( model );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2230
    CleanupStack::Pop( manufacturer );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2231
    aManufacturer = manufacturer;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2232
    aModel = model;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2233
    CleanupStack::PopAndDestroy( &phone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2234
    CleanupStack::PopAndDestroy( &etelServer );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2235
#else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2236
    aManufacturer = _L8("Nokia").AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2237
    aModel = _L8("Emulator").AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2238
    aVersion = _L8("9.0").AllocL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2239
#endif
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2240
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2241
    LOGLIT( "Device details:" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2242
    LOGLIT( "   Manufacturer: " )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2243
    LOG( aManufacturer->Des() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2244
    LOGLIT( "   Model: " )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2245
    LOG( aModel->Des() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2246
    LOGLIT( "   Revision: " )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2247
    LOG( aVersion->Des() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2248
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2249
    LOGLIT( "<- CRoapEng::GetDeviceDetailsL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2250
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2251
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2252
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2253
// CRoapEng::FetchTransactionIDL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2254
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2255
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2256
void CRoapEng::FetchTransactionIDL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2257
    RPointerArray<HBufC8>& aTransIDs,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2258
    RPointerArray<HBufC8>& aContentIDs )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2259
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2260
    LOGLIT( "CRoapEng::FetchTransactionIDL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2261
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2262
    __ASSERT_ALWAYS( iTrigger, User::Invariant() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2263
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2264
    RArray<TPair> array;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2265
    TInt err = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2266
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2267
    CleanupClosePushL( array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2268
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2269
    if ( !iTrigger->iContentIdList.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2270
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2271
        CleanupStack::PopAndDestroy( &array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2272
        return;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2273
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2274
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2275
    if ( iTransStatus == ENotAsked && iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2276
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2277
        UpdateTransactionTrackingStatusL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2278
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2279
    if ( iTransStatus == EAllowed )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2280
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2281
        for ( TInt i = 0; i < iTrigger->iContentIdList.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2282
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2283
            TPair pair;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2284
            pair.iCid = iTrigger->iContentIdList[i]->Alloc(); // duplicate contentID,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2285
            pair.iTtid = NULL; // pair.iCid is deleted by iRequest
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2286
            err = array.Append( pair );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2287
            if ( err )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2288
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2289
                delete pair.iCid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2290
                pair.iCid = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2291
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2292
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2293
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2294
            TRAP_IGNORE(iDcfRep->GetTtidL( array ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2295
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2296
        for ( TInt i = 0; i < array.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2297
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2298
            if ( array[i].iTtid && array[i].iCid && array[i].iTtid->Length()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2299
                && array[i].iCid->Length() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2300
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2301
                err = aContentIDs.Append( array[i].iCid );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2302
                if ( !err )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2303
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2304
                    aTransIDs.Append( array[i].iTtid );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2305
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2306
                else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2307
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2308
                    delete array[i].iCid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2309
                    array[i].iCid = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2310
                    delete array[i].iTtid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2311
                    array[i].iTtid = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2312
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2313
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2314
            else if ( array[i].iTtid || array[i].iCid )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2315
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2316
                delete array[i].iTtid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2317
                array[i].iTtid = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2318
                delete array[i].iCid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2319
                array[i].iCid = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2320
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2321
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2322
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2323
    CleanupStack::PopAndDestroy( &array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2324
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2325
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2326
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2327
// CRoapEng::InsertTransactionIDL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2328
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2329
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2330
void CRoapEng::InsertTransactionIDL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2331
    RPointerArray<HBufC8>& aTransIDs,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2332
    RPointerArray<HBufC8>& aContentIDs )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2333
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2334
    LOGLIT( "CRoapEng::InsertTransactionIDL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2335
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2336
    RArray<TPair> array;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2337
    TRequestStatus status;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2338
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2339
    CleanupClosePushL( array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2340
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2341
    if ( !aTransIDs.Count() || !aContentIDs.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2342
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2343
        LOGLIT( "Insert ttID: Wrong input data" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2344
        CleanupStack::PopAndDestroy( &array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2345
        return;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2346
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2347
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2348
    if ( aTransIDs.Count() != aContentIDs.Count() )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2349
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2350
        LOGLIT( "Insert ttID: ttID.Count != cid.Count" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2351
        CleanupStack::PopAndDestroy( &array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2352
        return;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2353
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2354
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2355
    if ( iTransStatus == ENotAsked && iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2356
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2357
        UpdateTransactionTrackingStatusL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2358
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2359
    if ( iTransStatus == EAllowed )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2360
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2361
        for ( TInt i = 0; i < aContentIDs.Count() && i < aTransIDs.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2362
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2363
            TPair pair;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2364
            pair.iCid = aContentIDs[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2365
            pair.iTtid = aTransIDs[i];
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2366
            array.Append( pair );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2367
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2368
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2369
        iDcfRep->SetTtid( array, status );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2370
        User::WaitForRequest( status );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2371
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2372
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2373
    CleanupStack::PopAndDestroy( &array );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2374
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2375
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2376
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2377
// CRoapEng::GetOCSPResponderKeyHashL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2378
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2379
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2380
HBufC8* CRoapEng::GetOCSPResponderKeyHashL() const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2381
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2382
    LOGLIT( "CRoapEng::GetOCSPResponderKeyHashL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2383
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2384
    if ( !iStoredRiContext )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2385
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2386
        User::Leave( KErrRoapNotRegistered );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2387
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2388
    return iStorageClient->GetOcspResponderIdL( iStoredRiContext->RIID() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2389
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2390
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2391
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2392
// CRoapEng::GetDrmTimeL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2393
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2394
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2395
TTime CRoapEng::GetDrmTimeL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2396
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2397
    LOGLIT( "CRoapEng::GetDrmTimeL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2398
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2399
    TTime drmTime;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2400
    DRMClock::ESecurityLevel secureTime;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2401
    TInt zone( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2402
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2403
    User::LeaveIfError( iClockClient->GetSecureTime( drmTime, zone,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2404
        secureTime ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2405
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2406
    if ( secureTime == DRMClock::KInsecure )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2407
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2408
        iSecureTime = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2409
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2410
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2411
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2412
        iSecureTime = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2413
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2414
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2415
    return drmTime;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2416
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2417
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2418
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2419
// CRoapEng::SetDrmTimeSecureL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2420
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2421
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2422
void CRoapEng::SetDrmTimeSecureL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2423
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2424
    LOGLIT( "CRoapEng::SetDrmTimeSecureL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2425
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2426
    TTime drmTime;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2427
    DRMClock::ESecurityLevel secureTime;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2428
    TInt zone( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2429
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2430
    User::LeaveIfError( iClockClient->GetSecureTime( drmTime, zone,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2431
        secureTime ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2432
    User::LeaveIfError( iClockClient->UpdateSecureTime( drmTime, zone ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2433
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2434
    iSecureTime = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2435
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2436
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2437
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2438
// CRoapEng::AdjustDrmTime()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2439
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2440
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2441
void CRoapEng::AdjustDrmTimeL(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2442
    const RPointerArray<HBufC8>& aOcspResponses,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2443
    TDesC8& aRegReqNonce ) const
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2444
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2445
    // To be removed on next API change.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2446
    // Replace calls with direct call to RRoapStorageClient.
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2447
    LOGLIT( "CRoapEng::AdjustDrmTime calling server" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2448
    if ( aOcspResponses.Count() > 0 )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2449
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2450
        iStorageClient->UpdateDrmTimeL( iStoredRiContext->CertificateChain(),
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2451
            aOcspResponses, aRegReqNonce );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2452
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2453
    else
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2454
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2455
        LOGLIT( "No OCSP responses present." )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2456
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2457
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2458
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2459
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2460
// CRoapEng::StoreDomainRightsL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2461
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2462
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2463
void CRoapEng::StoreDomainRightsL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2464
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2465
    LOGLIT( "CRoapEng::StoreDomainRightsL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2466
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2467
    RPointerArray<CDRMRights> returnedROs;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2468
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2469
    CleanupResetAndDestroyPushL( returnedROs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2470
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2471
    iRoParser->ParseAndStoreL( *iDomainRightsResp, returnedROs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2472
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2473
    if ( iObserver )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2474
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2475
        iObserver->RightsObjectDetailsL( returnedROs ); // pass RO details to UI
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2476
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2477
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2478
    delete iDomainRightsResp;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2479
    iDomainRightsResp = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2480
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2481
    iImplicitJoinDomain = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2482
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2483
    CleanupStack::PopAndDestroy( &returnedROs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2484
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2485
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2486
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2487
// CRoapEng::InsertDomainRosL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2488
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2489
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2490
void CRoapEng::InsertDomainRosL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2491
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2492
    CDcfRep* rep = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2493
    CDcfEntry* entry = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2494
    CContent* content = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2495
    TPtr8 ptr( NULL, 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2496
    TInt i;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2497
    RFile file;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2498
    RFs fs;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2499
    TInt error( 0 );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2500
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2501
    User::LeaveIfError( fs.Connect() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2502
    CleanupClosePushL( fs );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2503
    rep = CDcfRep::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2504
    CleanupStack::PushL( rep );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2505
    for ( i = 0; i < iReturnedROs.Count(); i++ )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2506
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2507
        if ( iReturnedROs[i]->GetPermission().iDomainID )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2508
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2509
            rep->OrderListL( *iReturnedROs[i]->GetAsset().iUid );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2510
            entry = rep->NextL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2511
            while ( entry )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2512
                {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2513
                CleanupStack::PushL( entry );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2514
                error = file.Open( fs, entry->FileName(), EFileWrite
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2515
                    | EFileShareReadersOrWriters );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2516
                if ( !error )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2517
                    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2518
                    CleanupClosePushL( file );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2519
                    content = CContent::NewLC( file );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2520
                    content->AgentSpecificCommand( EEmbedDomainRo,
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2521
                        KNullDesC8, ptr );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2522
                    CleanupStack::PopAndDestroy( 2, &file ); // content, file
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2523
                    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2524
                CleanupStack::PopAndDestroy( entry );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2525
                entry = rep->NextL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2526
                }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2527
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2528
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2529
    CleanupStack::PopAndDestroy( 2, &fs ); // rep, fs
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2530
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2531
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2532
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2533
// CRoapEng::MapStatusL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2534
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2535
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2536
TInt CRoapEng::MapStatusL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2537
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2538
    LOGLIT( "CRoapEng::MapStatusL" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2539
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2540
    if ( iRoapStatus == ESuccess )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2541
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2542
        LOGLIT( "ROAP Status: success " )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2543
        return KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2544
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2545
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2546
    if ( iRoapStatus == ENotRegistered || iRoapStatus == EDeviceTimeError )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2547
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2548
        // Initiate registration protocol
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2549
        LOG2( _L ( "Not Registered! Status: %d" ), iRoapStatus )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2550
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2551
        if ( iRoapStatus == EDeviceTimeError )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2552
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2553
            iDeviceTimeError = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2554
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2555
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2556
        return KErrRoapNotRegistered;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2557
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2558
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2559
    LOG2( _L ( "ROAP Error! Status: %d" ), iRoapStatus )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2560
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2561
    switch ( iRoapStatus )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2562
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2563
        case EUnknownError:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2564
        case EAbort:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2565
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2566
            User::Leave( KErrRoapServer );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2567
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2568
        case ENotSupported:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2569
        case EAccessDenied:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2570
        case ENotFound:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2571
        case EMalformedRequest:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2572
        case EUnknownRequest:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2573
        case EUnknownCriticalExtension:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2574
        case EUnsupportedVersion:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2575
        case EUnsupportedAlgorithm:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2576
        case ESignatureError:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2577
        case EInvalidDCFHash:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2578
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2579
            User::Leave( KErrRoapServerFatal );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2580
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2581
        case ENoCertificateChain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2582
        case EInvalidCertificateChain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2583
        case ETrustedRootCertificateNotPresent:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2584
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2585
            User::Leave( KErrRoapDevice );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2586
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2587
        case EInvalidDomain:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2588
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2589
            User::Leave( KErrRoapInvalidDomain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2590
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2591
        case EDomainFull:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2592
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2593
            User::Leave( KErrRoapDomainFull );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2594
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2595
        default:
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2596
            {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2597
            User::Leave( KErrRoapUnsupported );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2598
            }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2599
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2600
    return KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2601
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2602
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2603
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2604
// CRoapEng::ValidateRiIdL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2605
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2606
// Validates that RI ID equals to public key hash of RI certificate
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2607
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2608
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2609
TBool CRoapEng::ValidateRiIdL( TDesC8& aRiId, TDesC8& aCertBuf )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2610
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2611
    TBool valid = EFalse;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2612
    CX509Certificate* riCert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2613
    CSHA1* hash = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2614
    HBufC8* publicKeyHash = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2615
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2616
    riCert = CX509Certificate::NewLC( aCertBuf );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2617
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2618
    // hash the SubjectPublicKeyInfo element
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2619
    hash = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2620
    CleanupStack::PushL( hash );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2621
    hash->Hash( *riCert->DataElementEncoding(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2622
        CX509Certificate::ESubjectPublicKeyInfo ) );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2623
    publicKeyHash = hash->Final().AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2624
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2625
    if ( aRiId.Compare( *publicKeyHash ) == KErrNone )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2626
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2627
        valid = ETrue;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2628
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2629
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2630
    CleanupStack::PopAndDestroy( publicKeyHash );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2631
    CleanupStack::PopAndDestroy( hash );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2632
    CleanupStack::PopAndDestroy( riCert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2633
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2634
    return valid;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2635
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2636
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2637
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2638
// CRoapEng::UpdateTransactionTrackingStatusL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2639
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2640
// Update the status of transaction tracking variable
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2641
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2642
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2643
void CRoapEng::UpdateTransactionTrackingStatusL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2644
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2645
    TInt value = KErrNone;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2646
    CRepository* repository = CRepository::NewL( KCRUidDRMSettings );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2647
    repository->Get( KDRMSettingsTransactionTracking, value );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2648
    delete repository;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2649
    iTransStatus = value ? EAllowed : EForbidden;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2650
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2651
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2652
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2653
// CRoapEng::CreateDeviceIdHashArrayL()
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2654
// ---------------------------------------------------------
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2655
//
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2656
TInt CRoapEng::CreateDeviceIdHashArrayL( RPointerArray<TDesC8>& aIdArray )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2657
    {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2658
    TInt err( KErrNone );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2659
    RPointerArray<HBufC8> certChain;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2660
    CSHA1* hasher = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2661
    HBufC8* publicKey = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2662
    CX509Certificate* cert = NULL;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2663
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2664
    err = iStorageClient->GetDeviceCertificateChainL( certChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2665
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2666
    CleanupResetAndDestroyPushL( certChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2667
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2668
    hasher = CSHA1::NewL();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2669
    CleanupStack::PushL( hasher );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2670
    // take the hash of device certificate
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2671
    if (certChain.Count()<=0)
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2672
        {
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2673
        LOGLIT( "Could get Device id Hash!!!" )
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2674
        User::Leave( KErrGeneral );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2675
        }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2676
    cert = CX509Certificate::NewL( *certChain[0] );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2677
    CleanupStack::PushL( cert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2678
    publicKey = cert->DataElementEncoding(
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2679
        CX509Certificate::ESubjectPublicKeyInfo )->AllocLC();
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2680
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2681
    hasher->Hash( *publicKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2682
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2683
    HBufC8 *elem( hasher->Final().AllocLC() );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2684
    aIdArray.AppendL( elem );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2685
    CleanupStack::Pop( elem );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2686
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2687
    CleanupStack::PopAndDestroy( publicKey );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2688
    CleanupStack::PopAndDestroy( cert );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2689
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2690
    CleanupStack::PopAndDestroy( hasher );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2691
    CleanupStack::PopAndDestroy( &certChain );
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2692
    return err;
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2693
    }
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2694
ca165d35976d Adding parts of the DRM Engine to be rebuilt
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
  2695
// End of file