|
1 /* |
|
2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: OMA DRM rights parser |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <e32math.h> |
|
23 #include <apmstd.h> |
|
24 #include <utf.h> |
|
25 #include <stringpool.h> |
|
26 #include <xml/parserfeature.h> |
|
27 #include "DrmRights.h" |
|
28 #include "DcfCommon.h" |
|
29 #include "DrmRightsParser.h" |
|
30 #include "DrmRightsClient.h" |
|
31 #include "hash.h" |
|
32 #include "base64.h" |
|
33 #include "DRMPermission.h" |
|
34 #include "DRMConstraint.h" |
|
35 #include "DRMClockClient.h" |
|
36 |
|
37 // MODULE DATA STRUCTURES |
|
38 enum TElementEnum |
|
39 { |
|
40 ERights = 0, |
|
41 EContext, |
|
42 EVersion, |
|
43 EUid, |
|
44 EAgreement, |
|
45 EAsset, |
|
46 EInherit, |
|
47 EDigest, |
|
48 EDigestMethod, |
|
49 EDigestValue, |
|
50 EKeyInfo, |
|
51 EEncryptedKey, |
|
52 EEncryptionMethod, |
|
53 ECipherData, |
|
54 ECipherValue, |
|
55 ERetreivalMethod, |
|
56 EPermission, |
|
57 EPlay, |
|
58 EDisplay, |
|
59 EPrint, |
|
60 EExecute, |
|
61 EConstraint, |
|
62 ECount, |
|
63 ETimedCount, |
|
64 EDateTime, |
|
65 EStart, |
|
66 EEnd, |
|
67 EInterval, |
|
68 EAccumulated, |
|
69 EIndividual, |
|
70 EExport, |
|
71 ESystem, |
|
72 EKeyValue, |
|
73 EId, |
|
74 EIdRef, |
|
75 EProperty, |
|
76 ESoftware, |
|
77 EContainer, |
|
78 #ifdef RD_DRM_METERING |
|
79 ERequirement, |
|
80 ETracked, |
|
81 #endif |
|
82 ELast, |
|
83 }; |
|
84 |
|
85 struct TElements |
|
86 { |
|
87 const TText8* iString; |
|
88 TInt iNumber; |
|
89 }; |
|
90 |
|
91 NONSHARABLE_CLASS( CDrmRightsParser::CParsedAsset ): public CBase |
|
92 { |
|
93 public: |
|
94 static CParsedAsset* NewL(); |
|
95 ~CParsedAsset(); |
|
96 void ConstructL(); |
|
97 |
|
98 private: |
|
99 CParsedAsset(); |
|
100 |
|
101 public: |
|
102 HBufC8* iUid; |
|
103 TBuf8< KDCFKeySize > iKey; |
|
104 TBuf8< KProtectedDCFKeySize > iProtectedKey; |
|
105 TBuf8< KDCFKeySize > iAuthenticationSeed; |
|
106 TBuf8< KProtectedDCFKeySize > iProtectedAuthSeed; |
|
107 TBuf8< SHA1_HASH > iDigest; |
|
108 |
|
109 HBufC8* iId; |
|
110 HBufC8* iIdRef; |
|
111 |
|
112 HBufC8* iInherit; |
|
113 }; |
|
114 |
|
115 // Note the class CDrmRightsParser::CParsedPermission maps to |
|
116 // OMA DRM2 permission container element <permission> |
|
117 // CDRMConstraint reperesents indivdual permissions as constraint container |
|
118 // (except Toplevel constraint really represents |
|
119 // constraint container <constraint>) |
|
120 NONSHARABLE_CLASS( CDrmRightsParser::CParsedPermission ): public CBase |
|
121 { |
|
122 public: |
|
123 static CParsedPermission* NewL(); |
|
124 ~CParsedPermission(); |
|
125 // Removes invalidated permissions, and marks the total permission invalid, |
|
126 // if all constraint containers are invalid, or toplevel container |
|
127 // is invalid |
|
128 void RemoveInvalidL(); |
|
129 // Sets current constraint and updates available rights ( iAvailableRights ) |
|
130 void SetCurrentConstraint ( TRightsType aCurrentConstraint ); |
|
131 |
|
132 RPointerArray< CParsedAsset > iAssets; |
|
133 TUint8 iAvailableRights; |
|
134 |
|
135 CDRMConstraint *iTopLevel; |
|
136 CDRMConstraint *iPlay; |
|
137 CDRMConstraint *iDisplay; |
|
138 CDRMConstraint *iPrint; |
|
139 CDRMConstraint *iExecute; |
|
140 CDRMConstraint *iExport; |
|
141 |
|
142 //2.1 addition: |
|
143 // URL to send HTTP GET on expiration of permission |
|
144 HBufC8* iOnExpiredUrl; |
|
145 |
|
146 // if constraint has unknown tags, this is ored with iCurrentConstraint |
|
147 TUint8 iInvalidConstraints; |
|
148 |
|
149 // maintained during parsing. possible values: TRightsType enumerations |
|
150 TUint8 iCurrentConstraint; |
|
151 |
|
152 // if top level constraint is invalid or all other constraints ate invalid |
|
153 // permission will become invalid |
|
154 TBool iInvalid; |
|
155 // count of not_owned_assets, (updated in transform...) |
|
156 TInt iNotOwned; |
|
157 |
|
158 private: |
|
159 CParsedPermission(); |
|
160 void ConstructL(); |
|
161 void ResetConstraintL( CDRMConstraint*& aConstraint ); |
|
162 }; |
|
163 |
|
164 NONSHARABLE_CLASS( CDrmRightsParser::CParsedRightsObject ): public CBase |
|
165 { |
|
166 public: |
|
167 CParsedRightsObject(); |
|
168 ~CParsedRightsObject(); |
|
169 |
|
170 // Removes invalidated permission containers |
|
171 // (of type CParsedPermission ), and marks the whole rights object |
|
172 // invalid, if all permission containers are invalid |
|
173 void RemoveInvalid(); |
|
174 |
|
175 HBufC8* iRightsObjectId; |
|
176 RPointerArray< CParsedAsset > iAssets; |
|
177 RPointerArray< CParsedPermission > iPermissions; |
|
178 |
|
179 CParsedAsset* iCurrentAsset; |
|
180 CParsedPermission* iCurrentPermission; |
|
181 CDRMConstraint* iCurrentConstraint; |
|
182 TBool iKeyIsCek; |
|
183 TBool iInvalid; |
|
184 }; |
|
185 |
|
186 // CONSTANTS |
|
187 #define ELEMENT_COUNT( x ) static_cast< TInt >( ( sizeof( x ) / sizeof( x[ 0 ] ) ) ) |
|
188 |
|
189 // LOCAL CONSTANTS AND MACROS |
|
190 const TInt KParserChunkSize = 512; |
|
191 const TInt KMaxElementNesting = 24; |
|
192 |
|
193 // 15 minutes per time zone, 60 seconds per minute |
|
194 const TInt KSecondsPerTimeZone = 900; |
|
195 const TInt KMinuteInMicroseconds = 60000000; |
|
196 const TInt KTimeZoneIncrement = 15; |
|
197 |
|
198 _LIT8( KXmlParserMimeType, "text/xml" ); |
|
199 _LIT8( KWbxmlParserMimeType, "text/wbxml" ); |
|
200 _LIT8( KSchemaAttribute, "schema" ); |
|
201 _LIT8( KSchemeAttribute, "scheme" ); |
|
202 _LIT8( KSchemaSymbianSid, "symbiansid" ); |
|
203 _LIT8( KSchemaSymbianVid, "symbianvid" ); |
|
204 _LIT8( KTimerAttribute, "timer" ); |
|
205 _LIT8( KIdAttribute, "id" ); |
|
206 _LIT8( KIdAttrUpperCase, "Id" ); |
|
207 _LIT8( KIdRefAttribute, "idref" ); |
|
208 _LIT8( KAuthSeed, "authSeed" ); |
|
209 // OMA DRM 2.1 additions |
|
210 _LIT8( KOnExpiredUrlAttribute, "onExpiredURL" ); //requested on premission expiry if present |
|
211 #ifdef RD_DRM_METERING |
|
212 _LIT8( KTimedAttribute, "timed" ); |
|
213 _LIT8( KContentAccessGrantedAttribute, "contentAccessGranted" ); |
|
214 _LIT8( KContentAccessGrantedValueTrue, "true" ); |
|
215 #endif // RD_DRM_METERING |
|
216 |
|
217 static const TElements KElements[] = |
|
218 { |
|
219 { _S8( "rights" ), ::ERights }, |
|
220 { _S8( "context" ), EContext }, |
|
221 { _S8( "version" ), EVersion }, |
|
222 { _S8( "uid" ), EUid }, |
|
223 { _S8( "agreement" ), EAgreement }, |
|
224 { _S8( "asset" ), EAsset }, |
|
225 { _S8( "inherit" ), EInherit }, |
|
226 { _S8( "digest" ), EDigest }, |
|
227 { _S8( "DigestMethod" ), EDigestMethod }, |
|
228 { _S8( "DigestValue" ), EDigestValue }, |
|
229 { _S8( "KeyInfo" ), EKeyInfo }, |
|
230 { _S8( "EncryptedKey" ), EEncryptedKey }, |
|
231 { _S8( "EncryptionMethod" ), EEncryptionMethod }, |
|
232 { _S8( "CipherData" ), ECipherData }, |
|
233 { _S8( "CipherValue" ), ECipherValue }, |
|
234 { _S8( "RetrievalMethod" ), ERetreivalMethod }, |
|
235 { _S8( "permission" ), EPermission }, |
|
236 { _S8( "play" ), ::EPlay }, |
|
237 { _S8( "display" ), ::EDisplay }, |
|
238 { _S8( "execute" ), ::EExecute }, |
|
239 { _S8( "print" ), ::EPrint }, |
|
240 { _S8( "constraint" ), EConstraint }, |
|
241 { _S8( "count" ), ECount }, |
|
242 { _S8( "timed-count" ), ETimedCount }, |
|
243 { _S8( "datetime" ), EDateTime }, |
|
244 { _S8( "start" ), EStart }, |
|
245 { _S8( "end" ), EEnd }, |
|
246 { _S8( "interval" ), EInterval }, |
|
247 { _S8( "accumulated" ), EAccumulated }, |
|
248 { _S8( "individual" ), EIndividual }, |
|
249 { _S8( "export" ), EExport }, |
|
250 { _S8( "system" ), ESystem }, |
|
251 { _S8( "KeyValue" ), EKeyValue }, |
|
252 { _S8( "software" ), ESoftware }, |
|
253 { _S8( "property" ), EProperty }, |
|
254 { _S8( "container" ), EContainer }, |
|
255 #ifdef RD_DRM_METERING |
|
256 { _S8( "requirement" ), ERequirement }, |
|
257 { _S8( "tracked" ), ETracked }, |
|
258 #endif //RD_DRM_METERING |
|
259 }; |
|
260 |
|
261 enum TParserStackState |
|
262 { |
|
263 EUnknownState = -1, |
|
264 ERoUidState = 0, |
|
265 ETopLevelConstraintState, |
|
266 EDisplayConstraintState, |
|
267 EPlayConstraintState, |
|
268 EPrintConstraintState, |
|
269 EExecuteConstraintState, |
|
270 EDateTimeStartState, |
|
271 EDateTimeEndState, |
|
272 EIntervalState, |
|
273 ECountState, |
|
274 ETimedCountState, |
|
275 EIndividualState, |
|
276 EAgreementAssetState, |
|
277 EPermissionAssetState, |
|
278 EAssetUidState, |
|
279 EAssetDigestState, |
|
280 EAssetKeyState, |
|
281 EEncryptedKeyState, |
|
282 EAssetInheritUidState, |
|
283 EPermissionState, |
|
284 ESoftwareState, |
|
285 EAccumulatedState, |
|
286 EKeyInfoState, |
|
287 ESystemState, |
|
288 EExportConstraintState, |
|
289 #ifdef RD_DRM_METERING |
|
290 ETrackRequirementState, |
|
291 #endif // RD_DRM_METERING |
|
292 }; |
|
293 |
|
294 struct TStackState |
|
295 { |
|
296 TParserStackState iState; |
|
297 TElementEnum iStack[ KMaxElementNesting ]; |
|
298 }; |
|
299 |
|
300 // Keep these sorted by the number of elements in the stack |
|
301 static const TStackState KParserStackStates[] = |
|
302 { |
|
303 // 5 elements |
|
304 { EEncryptedKeyState, { ECipherValue, ECipherData, EEncryptedKey, |
|
305 EKeyInfo, EAsset, ELast } }, |
|
306 // 4 elements |
|
307 { EAssetInheritUidState, { EUid, EContext, EInherit, EAsset, ELast } }, |
|
308 { EPermissionAssetState, { EAsset, EPermission, EAgreement, ::ERights, |
|
309 ELast } }, |
|
310 { ESoftwareState, { EProperty, EContext, ESoftware, EContainer, ELast } }, |
|
311 // 3 elements |
|
312 { EAgreementAssetState, { EAsset, EAgreement, ::ERights, ELast } }, |
|
313 { EIndividualState, { EUid, EContext, EIndividual, ELast } }, |
|
314 { ESystemState, { EUid, EContext, ESystem, ELast } }, |
|
315 { ERoUidState, { EUid, EContext, ::ERights, ELast } }, |
|
316 { EAssetUidState, { EUid, EContext, EAsset, ELast } }, |
|
317 { EAssetDigestState, { EDigestValue, EDigest, EAsset, ELast } }, |
|
318 { EAssetKeyState, { EKeyValue, EKeyInfo, EAsset, ELast } }, |
|
319 // 2 elements |
|
320 { EKeyInfoState, { EKeyInfo, EAsset, ELast } }, |
|
321 { ETopLevelConstraintState, { EConstraint, EPermission, ELast } }, |
|
322 { EDisplayConstraintState, { ::EDisplay, EPermission, ELast } }, |
|
323 { EPlayConstraintState, { ::EPlay, EPermission, ELast } }, |
|
324 { EPrintConstraintState, { ::EPrint, EPermission, ELast } }, |
|
325 { EExecuteConstraintState, { ::EExecute, EPermission, ELast } }, |
|
326 { EExportConstraintState, { EExport, EPermission, ELast } }, |
|
327 #ifdef RD_DRM_METERING |
|
328 { ETrackRequirementState, { ETracked, ERequirement, ELast } }, |
|
329 #endif // RD_DRM_METERING |
|
330 //1 element |
|
331 { EDateTimeStartState, { EStart, ELast } }, |
|
332 { EDateTimeEndState, { EEnd, ELast } }, |
|
333 { EIntervalState, { EInterval, ELast } }, |
|
334 { ECountState, { ECount, ELast } }, |
|
335 { ETimedCountState, { ETimedCount, ELast } }, |
|
336 { EAccumulatedState, { EAccumulated, ELast } }, |
|
337 { EPermissionState, { EPermission, ELast } }, |
|
338 }; |
|
339 |
|
340 // LOCAL FUNCTION PROTOTYPES |
|
341 |
|
342 // ============================= LOCAL FUNCTIONS =============================== |
|
343 |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CDrmRightsParser::ValidateDay |
|
347 // Returns ETrue if the day is valid |
|
348 // EFalse if the day is not valid |
|
349 // |
|
350 // If the month is January, March, May, July, August, October, December |
|
351 // - Check that the day is between 1 and 31 |
|
352 // If the month is April, June, September, November |
|
353 // - Check that the day is between 1 and 30 |
|
354 // If the month is February |
|
355 // - Check that the day is between 1 and 29, |
|
356 // - if it is 29 check that the following conditions are met in that order: |
|
357 // * The year is dividable by 400 it's valid |
|
358 // * The year is dividable by 100 it is not valid |
|
359 // * The year is dividable by 4 it is valid |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 |
|
363 TBool CDrmRightsParser::ValidateDay( TInt aYear, TMonth aMonth, TInt aDay ) |
|
364 { |
|
365 TBool retVal = ETrue; |
|
366 |
|
367 switch ( aMonth ) |
|
368 { |
|
369 case EJanuary: |
|
370 case EMarch: |
|
371 case EMay: |
|
372 case EJuly: |
|
373 case EAugust: |
|
374 case EOctober: |
|
375 case EDecember: |
|
376 { |
|
377 if ( aDay < 0 || aDay > 30 ) |
|
378 { |
|
379 retVal = EFalse; |
|
380 } |
|
381 } |
|
382 break; |
|
383 case EApril: |
|
384 case EJune: |
|
385 case ESeptember: |
|
386 case ENovember: |
|
387 { |
|
388 if ( aDay < 0 || aDay > 29 ) |
|
389 { |
|
390 retVal = EFalse; |
|
391 } |
|
392 } |
|
393 break; |
|
394 case EFebruary: |
|
395 { |
|
396 if ( aDay < 0 || aDay > 28 ) |
|
397 { |
|
398 retVal = EFalse; |
|
399 } |
|
400 else |
|
401 { |
|
402 // If we are at day 29, it is possible that it is valid: |
|
403 if ( aDay == 28 ) |
|
404 { |
|
405 // if the year is dividable by 400 it is valid |
|
406 if ( ( aYear % 400 ) ) |
|
407 { |
|
408 // if the year is dividable by 100 it is not valid |
|
409 if ( aYear % 100 ) |
|
410 { |
|
411 // if the year is dividable by 4 it is valid |
|
412 if ( aYear % 4 ) |
|
413 { |
|
414 retVal = EFalse; |
|
415 } |
|
416 } |
|
417 else |
|
418 { |
|
419 retVal = EFalse; |
|
420 } |
|
421 } |
|
422 } |
|
423 } |
|
424 } |
|
425 break; |
|
426 default: |
|
427 retVal = EFalse; |
|
428 break; |
|
429 } |
|
430 return retVal; |
|
431 } |
|
432 |
|
433 |
|
434 |
|
435 // ----------------------------------------------------------------------------- |
|
436 // CDrmRightsParser::ValidTimeValues |
|
437 // Returns ETrue if the time values are valid |
|
438 // EFalse if any of them are valid |
|
439 // Checks done as per symbian documentations |
|
440 // ----------------------------------------------------------------------------- |
|
441 // |
|
442 TBool CDrmRightsParser::ValidTimeValues( TInt aYear, TMonth aMonth, |
|
443 TInt aDay, TInt aHour, |
|
444 TInt aMinute, TInt aSecond, |
|
445 TInt aMicrosecond ) |
|
446 { |
|
447 // No check for Year |
|
448 |
|
449 // check Month |
|
450 if ( aMonth < EJanuary || aMonth > EDecember ) |
|
451 { |
|
452 return EFalse; |
|
453 } |
|
454 |
|
455 // check Day |
|
456 if ( !ValidateDay( aYear, aMonth, aDay ) ) |
|
457 { |
|
458 return EFalse; |
|
459 } |
|
460 |
|
461 // check Hour |
|
462 if ( aHour < 0 || aHour > 23 ) |
|
463 { |
|
464 return EFalse; |
|
465 } |
|
466 |
|
467 // check Minute |
|
468 if ( aMinute < 0 || aMinute > 59 ) |
|
469 { |
|
470 return EFalse; |
|
471 } |
|
472 |
|
473 // check Second |
|
474 if ( aSecond < 0 || aSecond > 59 ) |
|
475 { |
|
476 return EFalse; |
|
477 } |
|
478 |
|
479 // check Microsecond |
|
480 if ( aMicrosecond < 0 || aMicrosecond > 9999999 ) |
|
481 { |
|
482 return EFalse; |
|
483 } |
|
484 |
|
485 return ETrue; |
|
486 }; |
|
487 |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CDrmRightsParser::ParseRelTime |
|
491 // Parses a ISO8601 relative time string |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 TTime CDrmRightsParser::ParseRelTimeL( TDesC8& aRelTimeString ) |
|
495 { |
|
496 TLex8 lex; |
|
497 TInt year( 0 ); |
|
498 TInt month( 0 ); |
|
499 TInt day( 0 ); |
|
500 TInt hour( 0 ); |
|
501 TInt minute( 0 ); |
|
502 TInt second( 0 ); |
|
503 TTime r; |
|
504 TTimeIntervalSeconds offset( 0 ); |
|
505 |
|
506 lex = aRelTimeString; |
|
507 lex.Val( year ); |
|
508 lex.Inc(); |
|
509 lex.Val( month ); |
|
510 lex.Inc(); |
|
511 lex.Val( day ); |
|
512 lex.Inc(); |
|
513 lex.Val( hour ); |
|
514 lex.Inc(); |
|
515 lex.Val( minute ); |
|
516 lex.Inc(); |
|
517 lex.Val( second ); |
|
518 |
|
519 |
|
520 // The time needs to be validated before |
|
521 if ( !ValidTimeValues( year, static_cast< TMonth >( month - 1 ), day - 1, |
|
522 hour, minute, second, 0 ) ) |
|
523 { |
|
524 User::Leave( KErrArgument ); |
|
525 } |
|
526 |
|
527 r = TTime( TDateTime( year, static_cast< TMonth >( month - 1 ), day - 1, |
|
528 hour, minute, second, 0 ) ); |
|
529 if ( lex.Get() != 'Z' ) |
|
530 { |
|
531 offset = iTimeZone * KSecondsPerTimeZone; |
|
532 r -= offset; |
|
533 } |
|
534 return r; |
|
535 } |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CDrmRightsParser::ParseRelInterval |
|
539 // Parses a ISO8601 relative interval string |
|
540 // ----------------------------------------------------------------------------- |
|
541 // |
|
542 TTimeIntervalSeconds CDrmRightsParser::ParseRelInterval( |
|
543 TDesC8& aRelTimeString ) |
|
544 { |
|
545 TLex8 lex; |
|
546 TInt year( 0 ); |
|
547 TInt month( 0 ); |
|
548 TInt day( 0 ); |
|
549 TInt hour( 0 ); |
|
550 TInt minute( 0 ); |
|
551 TInt second( 0 ); |
|
552 TInt n( 0 ); |
|
553 TTimeIntervalSeconds r( 0 ); |
|
554 TBool done( EFalse ); |
|
555 TBool inDate( ETrue ); |
|
556 |
|
557 lex = aRelTimeString; |
|
558 lex.Inc(); |
|
559 while ( !done ) |
|
560 { |
|
561 if ( lex.Peek() == 'T' ) |
|
562 { |
|
563 lex.Inc(); |
|
564 inDate = EFalse; |
|
565 } |
|
566 |
|
567 lex.Val( n ); |
|
568 switch ( lex.Get() ) |
|
569 { |
|
570 case 'Y': |
|
571 year = n; |
|
572 break; |
|
573 case 'D': |
|
574 day = n; |
|
575 break; |
|
576 case 'M': |
|
577 if ( inDate ) |
|
578 { |
|
579 month = n; |
|
580 } |
|
581 else |
|
582 { |
|
583 minute = n; |
|
584 } |
|
585 break; |
|
586 case 'H': |
|
587 hour = n; |
|
588 break; |
|
589 case 'S': |
|
590 second = n; |
|
591 break; |
|
592 default: |
|
593 done = ETrue; |
|
594 break; |
|
595 } |
|
596 } |
|
597 |
|
598 r = ( ( ( ( year * 365 + month * 30 + day ) * 24 + hour ) |
|
599 * 60 + minute ) * 60 + second ); |
|
600 return r; |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // DecodeAndDeleteUndecodedL() |
|
605 // Decodes base64 encoded HbufC8 buffer arcument, deletes undecoded buffer, and |
|
606 // substitutes argument with Decoded buffer |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 LOCAL_C void DecodeAndDeleteUndecodedL( HBufC8*& aDecodee ) |
|
610 { |
|
611 HBufC8* b( aDecodee ); |
|
612 aDecodee = NULL; |
|
613 CleanupStack::PushL( b ); |
|
614 aDecodee = Base64DecodeL( *b ); |
|
615 CleanupStack::PopAndDestroy( b ); |
|
616 } |
|
617 |
|
618 // ----------------------------------------------------------------------------- |
|
619 // CopyOrLeaveL( TDes8& aDest, const TDesC8& aSrc ) |
|
620 // Copies aSrc to aDest. |
|
621 // Leaves, if length of aSrc exceeds capacity of aDest |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 LOCAL_C void CopyOrLeaveL( TDes8& aDest, const TDesC8& aSrc ) |
|
625 { |
|
626 if ( aSrc.Length() > aDest.MaxLength() ) |
|
627 { |
|
628 User::Leave( KErrArgument ); |
|
629 } |
|
630 aDest.Copy( aSrc ); |
|
631 } |
|
632 |
|
633 // ============================ MEMBER FUNCTIONS =============================== |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // CDrmRightsParser::CParsedAsset::NewL |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 CDrmRightsParser::CParsedAsset* |
|
640 CDrmRightsParser::CParsedAsset::NewL() |
|
641 { |
|
642 CParsedAsset* self = new ( ELeave ) CParsedAsset; |
|
643 CleanupStack::PushL( self ); |
|
644 self->ConstructL(); |
|
645 CleanupStack::Pop( self ); |
|
646 return self; |
|
647 } |
|
648 |
|
649 // ----------------------------------------------------------------------------- |
|
650 // CDrmRightsParser::CParsedAsset::~CParsedAsset |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 CDrmRightsParser::CParsedAsset::~CParsedAsset() |
|
654 { |
|
655 delete iUid; |
|
656 delete iId; |
|
657 delete iIdRef; |
|
658 delete iInherit; |
|
659 } |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CDrmRightsParser::CParsedAsset::ConstructL |
|
663 // Allocate the list of attribute values |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CDrmRightsParser::CParsedAsset::ConstructL() |
|
667 { |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // CDrmRightsParser::CParsedAsset::CParsedAsset |
|
672 // ----------------------------------------------------------------------------- |
|
673 // |
|
674 CDrmRightsParser::CParsedAsset::CParsedAsset(): |
|
675 iUid( NULL ), |
|
676 iId( NULL ), |
|
677 iIdRef( NULL ), |
|
678 iInherit( NULL ) |
|
679 { |
|
680 } |
|
681 |
|
682 // ----------------------------------------------------------------------------- |
|
683 // CDrmRightsParser::CParsedPermission::NewL |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 CDrmRightsParser::CParsedPermission* |
|
687 CDrmRightsParser::CParsedPermission::NewL() |
|
688 { |
|
689 CParsedPermission* self = new ( ELeave ) CParsedPermission; |
|
690 CleanupStack::PushL( self ); |
|
691 self->ConstructL(); |
|
692 CleanupStack::Pop( self ); |
|
693 return self; |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // CDrmRightsParser::CParsedPermission::~CParsedPermission |
|
698 // ----------------------------------------------------------------------------- |
|
699 // |
|
700 CDrmRightsParser::CParsedPermission::~CParsedPermission() |
|
701 { |
|
702 for ( TInt i( 0 ); i < iNotOwned; ++i ) |
|
703 { |
|
704 iAssets.Remove( 0 ); |
|
705 } |
|
706 iAssets.ResetAndDestroy(); |
|
707 iAssets.Close(); |
|
708 delete iTopLevel; |
|
709 delete iPlay; |
|
710 delete iDisplay; |
|
711 delete iPrint; |
|
712 delete iExecute; |
|
713 delete iExport; |
|
714 delete iOnExpiredUrl; |
|
715 } |
|
716 |
|
717 // ----------------------------------------------------------------------------- |
|
718 // CDrmRightsParser::CParsedPermission::SetCurrentConstraint |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CDrmRightsParser::CParsedPermission::SetCurrentConstraint( |
|
722 TRightsType aCurrentConstraint ) |
|
723 { |
|
724 iAvailableRights |= aCurrentConstraint; |
|
725 iCurrentConstraint = aCurrentConstraint; |
|
726 } |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CDrmRightsParser::CParsedPermission::RemoveInvalid |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 void CDrmRightsParser::CParsedPermission::RemoveInvalidL() |
|
732 { |
|
733 TUint8 valid = ( iInvalidConstraints ^ ERightsAll ) & ERightsAll; |
|
734 iAvailableRights &= valid; |
|
735 if ( !valid ) |
|
736 { |
|
737 iInvalid = ETrue; |
|
738 } |
|
739 if ( iInvalid || ( iInvalidConstraints & ERightsTopLevel ) ) |
|
740 { |
|
741 iInvalid = ETrue; |
|
742 ResetConstraintL( iTopLevel ); |
|
743 } |
|
744 if ( iInvalid || ( iInvalidConstraints & ERightsPlay ) ) |
|
745 { |
|
746 ResetConstraintL( iPlay ); |
|
747 } |
|
748 if ( iInvalid || ( iInvalidConstraints & ERightsDisplay ) ) |
|
749 { |
|
750 ResetConstraintL( iDisplay ); |
|
751 } |
|
752 if ( iInvalid || ( iInvalidConstraints & ERightsExecute ) ) |
|
753 { |
|
754 ResetConstraintL( iExecute ); |
|
755 } |
|
756 if ( iInvalid || ( iInvalidConstraints & ERightsPrint ) ) |
|
757 { |
|
758 ResetConstraintL( iPrint ); |
|
759 } |
|
760 if ( iInvalid || ( iInvalidConstraints & ERightsExport ) ) |
|
761 { |
|
762 ResetConstraintL( iExport ); |
|
763 } |
|
764 } |
|
765 |
|
766 // ----------------------------------------------------------------------------- |
|
767 // CDrmRightsParser::CParsedPermission::CParsedPermission |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 CDrmRightsParser::CParsedPermission::CParsedPermission() |
|
771 { |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // CDrmRightsParser::CParsedPermission::ConstructL |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 void CDrmRightsParser::CParsedPermission::ConstructL() |
|
779 { |
|
780 iTopLevel = CDRMConstraint::NewL(); |
|
781 iPlay = CDRMConstraint::NewL(); |
|
782 iDisplay = CDRMConstraint::NewL(); |
|
783 iPrint = CDRMConstraint::NewL(); |
|
784 iExecute = CDRMConstraint::NewL(); |
|
785 iExport = CDRMConstraint::NewL(); |
|
786 } |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CDrmRightsParser::CParsedPermission::ResetConstraintL |
|
790 // ----------------------------------------------------------------------------- |
|
791 // |
|
792 void CDrmRightsParser::CParsedPermission::ResetConstraintL( |
|
793 CDRMConstraint*& aConstraint ) |
|
794 { |
|
795 delete aConstraint; |
|
796 aConstraint = NULL; |
|
797 aConstraint = CDRMConstraint::NewL(); |
|
798 } |
|
799 |
|
800 // ----------------------------------------------------------------------------- |
|
801 // CDrmRightsParser::CParsedRightsObject::CParsedRightsObject |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 CDrmRightsParser::CParsedRightsObject::CParsedRightsObject(): |
|
805 iRightsObjectId( NULL ), |
|
806 iCurrentAsset( NULL ), |
|
807 iCurrentPermission( NULL ), |
|
808 iCurrentConstraint( NULL ) |
|
809 { |
|
810 } |
|
811 |
|
812 // ----------------------------------------------------------------------------- |
|
813 // CDrmRightsParser::CParsedRightsObject::~CParsedRightsObject |
|
814 // ----------------------------------------------------------------------------- |
|
815 // |
|
816 CDrmRightsParser::CParsedRightsObject::~CParsedRightsObject() |
|
817 { |
|
818 delete iRightsObjectId; |
|
819 iAssets.ResetAndDestroy(); |
|
820 iAssets.Close(); |
|
821 iPermissions.ResetAndDestroy(); |
|
822 iPermissions.Close(); |
|
823 } |
|
824 |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // CDrmRightsParser::CParsedRightsObject::RemoveInvalid |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 void CDrmRightsParser::CParsedRightsObject::RemoveInvalid() |
|
831 { |
|
832 if ( iPermissions.Count() == 0 ) |
|
833 { |
|
834 return; |
|
835 } |
|
836 for ( TInt j( 0 ); j < iPermissions.Count(); ++j ) |
|
837 { |
|
838 CDrmRightsParser::CParsedPermission* permission( NULL ); |
|
839 permission = iPermissions[ j ]; |
|
840 if ( permission->iInvalid ) |
|
841 { |
|
842 iPermissions.Remove( j ); |
|
843 delete permission; |
|
844 } |
|
845 permission = NULL; |
|
846 } |
|
847 if ( iPermissions.Count() == 0 ) |
|
848 { |
|
849 iInvalid = ETrue; |
|
850 } |
|
851 } |
|
852 |
|
853 // ----------------------------------------------------------------------------- |
|
854 // CDrmRightsParser::CDrmRightsParser |
|
855 // ----------------------------------------------------------------------------- |
|
856 // |
|
857 CDrmRightsParser::CDrmRightsParser(): |
|
858 iParser( NULL ), |
|
859 iRights( NULL ), |
|
860 iContent( NULL ), |
|
861 iUnknownTag( NULL ) |
|
862 { |
|
863 } |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // CDrmRightsParser::ConstructL |
|
867 // ----------------------------------------------------------------------------- |
|
868 // |
|
869 void CDrmRightsParser::ConstructL( |
|
870 TParserType aType ) |
|
871 { |
|
872 TTime currentUniversal; |
|
873 TTime currentLocal; |
|
874 TInt64 result( 0 ); |
|
875 |
|
876 currentUniversal.UniversalTime(); |
|
877 currentLocal.HomeTime(); |
|
878 |
|
879 result = currentLocal.Int64() - currentUniversal.Int64(); |
|
880 result /= KMinuteInMicroseconds; |
|
881 result /= KTimeZoneIncrement; |
|
882 |
|
883 iTimeZone = I64INT( result ); |
|
884 |
|
885 iParserType = aType; |
|
886 if ( aType == EXmlParser ) |
|
887 { |
|
888 iParser = CParser::NewL( KXmlParserMimeType, *this ); |
|
889 } |
|
890 else |
|
891 { |
|
892 iParser = CParser::NewL( KWbxmlParserMimeType, *this ); |
|
893 } |
|
894 |
|
895 for ( TInt i( 0 ); i < ELEMENT_COUNT( KElements ); i++ ) |
|
896 { |
|
897 TPtrC8 ptr( KElements[ i ].iString, |
|
898 User::StringLength( KElements[ i ].iString ) ); |
|
899 iElements[ KElements[ i ].iNumber ] = |
|
900 iParser->StringPool().OpenStringL( ptr ); |
|
901 } |
|
902 } |
|
903 |
|
904 // ----------------------------------------------------------------------------- |
|
905 // CDrmRightsParser::NewL |
|
906 // Two-phased constructor. |
|
907 // ----------------------------------------------------------------------------- |
|
908 // |
|
909 EXPORT_C CDrmRightsParser* CDrmRightsParser::NewL( |
|
910 TParserType aType ) |
|
911 { |
|
912 CDrmRightsParser* self( new ( ELeave ) CDrmRightsParser ); |
|
913 |
|
914 CleanupStack::PushL( self ); |
|
915 self->ConstructL( aType ); |
|
916 CleanupStack::Pop( self ); |
|
917 |
|
918 return self; |
|
919 } |
|
920 |
|
921 |
|
922 // Destructor |
|
923 EXPORT_C CDrmRightsParser::~CDrmRightsParser() |
|
924 { |
|
925 for ( TInt i( 0 ); i < ELEMENT_COUNT( KElements ); i++ ) |
|
926 { |
|
927 iElements[ KElements[ i ].iNumber ].Close(); |
|
928 } |
|
929 delete iParser; |
|
930 delete iRights; |
|
931 delete iContent; |
|
932 delete iUnknownTag; |
|
933 } |
|
934 |
|
935 |
|
936 // ----------------------------------------------------------------------------- |
|
937 // CDrmRightsParser::ParseL |
|
938 // ----------------------------------------------------------------------------- |
|
939 // |
|
940 EXPORT_C void CDrmRightsParser::ParseL( |
|
941 const TDesC8& aRightsObject, |
|
942 RPointerArray< CDRMRights >& aResultRights ) |
|
943 { |
|
944 TInt i( 0 ); |
|
945 |
|
946 iElementStackDepth = 0; |
|
947 delete iRights; |
|
948 iRights = NULL; |
|
949 delete iContent; |
|
950 iContent = NULL; |
|
951 iRights = new ( ELeave ) CParsedRightsObject; |
|
952 iParser->ParseBeginL(); |
|
953 if ( iParserType == EWbxmlParser ) |
|
954 { |
|
955 iParser->EnableFeature( ERawContent ); |
|
956 } |
|
957 |
|
958 while ( i < aRightsObject.Length() ) |
|
959 { |
|
960 TInt n( Min( aRightsObject.Length() - i, KParserChunkSize ) ); |
|
961 iParser->ParseL( aRightsObject.Mid( i, n ) ); |
|
962 i += n; |
|
963 } |
|
964 iParser->ParseEndL(); |
|
965 TransformRightsObjectL( aResultRights ); |
|
966 } |
|
967 |
|
968 // ----------------------------------------------------------------------------- |
|
969 // CDrmRightsParser::ParseAndStoreL |
|
970 // ----------------------------------------------------------------------------- |
|
971 // |
|
972 EXPORT_C void CDrmRightsParser::ParseAndStoreL( |
|
973 const TDesC8& aRightsObject, |
|
974 RPointerArray< CDRMRights >& aResultRights ) |
|
975 { |
|
976 RDRMRightsClient client; |
|
977 |
|
978 User::LeaveIfError( client.Connect() ); |
|
979 CleanupClosePushL( client ); |
|
980 ParseL( aRightsObject, aResultRights ); |
|
981 for ( TInt i( 0 ); i < aResultRights.Count(); i++ ) |
|
982 { |
|
983 TDRMUniqueID id; |
|
984 HBufC8 *cid( NULL ); |
|
985 CDRMRights* rights( aResultRights[ i ] ); |
|
986 rights->GetContentURI( cid ); |
|
987 if ( rights->GetAsset().iKey.Length() == 0 ) |
|
988 { |
|
989 for ( TInt j( 0 ); j < KDCFKeySize; j++ ) |
|
990 { |
|
991 rights->GetAsset().iKey.Append( Math::Random() ); |
|
992 } |
|
993 } |
|
994 client.AddRecord( rights->GetAsset().iKey, rights->GetPermission(), |
|
995 *cid, id ); |
|
996 rights->SetLocalID( id ); |
|
997 delete cid; |
|
998 } |
|
999 |
|
1000 CleanupStack::PopAndDestroy( &client ); |
|
1001 } |
|
1002 |
|
1003 // ----------------------------------------------------------------------------- |
|
1004 // CDrmRightsParser::OnStartDocumentL |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // |
|
1007 void CDrmRightsParser::OnStartDocumentL( |
|
1008 const RDocumentParameters& /*aDocParam*/, |
|
1009 TInt /*aErrorCode*/ ) |
|
1010 { |
|
1011 } |
|
1012 |
|
1013 // ----------------------------------------------------------------------------- |
|
1014 // CDrmRightsParser::OnEndDocumentL |
|
1015 // ----------------------------------------------------------------------------- |
|
1016 // |
|
1017 void CDrmRightsParser::OnEndDocumentL( |
|
1018 TInt /*aErrorCode*/ ) |
|
1019 { |
|
1020 if ( iRights ) |
|
1021 { |
|
1022 // Remove invalid parsed permissions, |
|
1023 // and invalidate parsed rights object, |
|
1024 // if there are no valid ROs left |
|
1025 iRights->RemoveInvalid(); |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // CDrmRightsParser::OnStartElementL |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 void CDrmRightsParser::OnStartElementL( |
|
1034 const RTagInfo& aElement, |
|
1035 const RAttributeArray& aAttributes, |
|
1036 TInt /*aErrorCode*/ ) |
|
1037 { |
|
1038 TBool tagRecognized( EFalse ); |
|
1039 |
|
1040 if ( iUnknownTag ) |
|
1041 { |
|
1042 return; |
|
1043 } |
|
1044 if ( iContent ) |
|
1045 { |
|
1046 delete iContent; |
|
1047 iContent = NULL; |
|
1048 iContent = HBufC8::NewL( 0 ); |
|
1049 } |
|
1050 |
|
1051 for ( TInt i( 0 ); i < KMaxElementCount; i++ ) |
|
1052 { |
|
1053 if ( aElement.LocalName() == iElements[ i ] ) |
|
1054 { |
|
1055 tagRecognized = ETrue; |
|
1056 iElementStack[ iElementStackDepth ] = |
|
1057 static_cast< TElementEnum >( i ); |
|
1058 iElementStackDepth++; |
|
1059 if ( iElementStackDepth == KMaxElementNesting ) |
|
1060 { |
|
1061 User::Leave( EXmlUnexpectedState ); |
|
1062 } |
|
1063 break; |
|
1064 } |
|
1065 } |
|
1066 if ( tagRecognized ) |
|
1067 { |
|
1068 TLex8 lex; |
|
1069 HBufC8* b( NULL ); |
|
1070 TInt n( 0 ); |
|
1071 |
|
1072 switch ( MatchStackState() ) |
|
1073 { |
|
1074 case ETopLevelConstraintState: |
|
1075 iRights->iCurrentPermission->SetCurrentConstraint( |
|
1076 ERightsTopLevel ); |
|
1077 iRights->iCurrentConstraint = |
|
1078 iRights->iCurrentPermission->iTopLevel; |
|
1079 break; |
|
1080 case EDisplayConstraintState: |
|
1081 iRights->iCurrentPermission->SetCurrentConstraint( |
|
1082 ERightsDisplay ); |
|
1083 iRights->iCurrentConstraint = |
|
1084 iRights->iCurrentPermission->iDisplay; |
|
1085 break; |
|
1086 case EPlayConstraintState: |
|
1087 iRights->iCurrentPermission->SetCurrentConstraint( |
|
1088 ERightsPlay ); |
|
1089 iRights->iCurrentConstraint = |
|
1090 iRights->iCurrentPermission->iPlay; |
|
1091 break; |
|
1092 case EPrintConstraintState: |
|
1093 iRights->iCurrentPermission->SetCurrentConstraint( |
|
1094 ERightsPrint ); |
|
1095 iRights->iCurrentConstraint = |
|
1096 iRights->iCurrentPermission->iPrint; |
|
1097 break; |
|
1098 case EExecuteConstraintState: |
|
1099 iRights->iCurrentPermission->SetCurrentConstraint( |
|
1100 ERightsExecute ); |
|
1101 iRights->iCurrentConstraint = |
|
1102 iRights->iCurrentPermission->iExecute; |
|
1103 break; |
|
1104 case EExportConstraintState: |
|
1105 iRights->iCurrentPermission->SetCurrentConstraint( |
|
1106 ERightsExport ); |
|
1107 iRights->iCurrentConstraint = |
|
1108 iRights->iCurrentPermission->iExport; |
|
1109 break; |
|
1110 case EAgreementAssetState: |
|
1111 iRights->iCurrentAsset = CParsedAsset::NewL(); |
|
1112 iRights->iCurrentAsset->iId = |
|
1113 GetAttributeValueL( aAttributes, KIdAttribute ); |
|
1114 iRights->iCurrentAsset->iIdRef = |
|
1115 GetAttributeValueL( aAttributes, KIdRefAttribute ); |
|
1116 iRights->iAssets.Append( iRights->iCurrentAsset ); |
|
1117 break; |
|
1118 case EPermissionAssetState: |
|
1119 iRights->iCurrentAsset = CParsedAsset::NewL(); |
|
1120 iRights->iCurrentAsset->iId = |
|
1121 GetAttributeValueL( aAttributes, KIdAttribute ); |
|
1122 iRights->iCurrentAsset->iIdRef = |
|
1123 GetAttributeValueL( aAttributes, KIdRefAttribute ); |
|
1124 iRights->iCurrentPermission->iAssets.Append( |
|
1125 iRights->iCurrentAsset ); |
|
1126 break; |
|
1127 case EPermissionState: |
|
1128 iRights->iCurrentPermission = CParsedPermission::NewL(); |
|
1129 iRights->iPermissions.Append( |
|
1130 iRights->iCurrentPermission ); |
|
1131 iRights->iCurrentPermission->iOnExpiredUrl = |
|
1132 GetAttributeValueL( aAttributes, KOnExpiredUrlAttribute ); |
|
1133 break; |
|
1134 case ESoftwareState: |
|
1135 b = GetAttributeValueL( aAttributes, KSchemaAttribute ); |
|
1136 if ( !b ) |
|
1137 { |
|
1138 b = GetAttributeValueL( aAttributes, KSchemeAttribute ); |
|
1139 } |
|
1140 if ( !b ) |
|
1141 { |
|
1142 User::Leave( KErrArgument ); |
|
1143 } |
|
1144 CleanupStack::PushL( b ); |
|
1145 if ( b->CompareF( KSchemaSymbianSid ) == 0 && |
|
1146 iRights->iCurrentConstraint->iSecureId == |
|
1147 TUid::Null() ) |
|
1148 { |
|
1149 iSoftwareSchemeType = ESymbianSid; |
|
1150 } |
|
1151 else if ( b->CompareF( KSchemaSymbianVid ) == 0 && |
|
1152 iRights->iCurrentConstraint->iVendorId == |
|
1153 TUid::Null() ) |
|
1154 { |
|
1155 iSoftwareSchemeType = ESymbianVid; |
|
1156 } |
|
1157 else |
|
1158 { |
|
1159 User::Leave( KErrNotSupported ); |
|
1160 } |
|
1161 CleanupStack::PopAndDestroy( b ); |
|
1162 break; |
|
1163 case ETimedCountState: |
|
1164 b = GetAttributeValueL( aAttributes, KTimerAttribute ); |
|
1165 if ( !b ) |
|
1166 { |
|
1167 User::Leave( KErrArgument ); |
|
1168 } |
|
1169 CleanupStack::PushL( b ); |
|
1170 lex = *b; |
|
1171 lex.Val( n ); |
|
1172 if ( n < 0 ) |
|
1173 { |
|
1174 User::Leave( KErrArgument ); |
|
1175 } |
|
1176 iRights->iCurrentConstraint->iTimedInterval = n; |
|
1177 CleanupStack::PopAndDestroy( b ); |
|
1178 break; |
|
1179 case EKeyInfoState: |
|
1180 b = GetAttributeValueL( aAttributes, KIdAttrUpperCase ); |
|
1181 if ( b && b->Right( KAuthSeed().Length() ).Compare( |
|
1182 KAuthSeed ) == 0 ) |
|
1183 { |
|
1184 iRights->iKeyIsCek = EFalse; |
|
1185 delete b; |
|
1186 } |
|
1187 else |
|
1188 { |
|
1189 iRights->iKeyIsCek = ETrue; |
|
1190 } |
|
1191 break; |
|
1192 #ifdef RD_DRM_METERING |
|
1193 case ETrackRequirementState: |
|
1194 if ( !iRights->iCurrentConstraint || |
|
1195 !iRights->iCurrentPermission || |
|
1196 iRights->iCurrentConstraint == |
|
1197 iRights->iCurrentPermission->iTopLevel ) |
|
1198 { |
|
1199 User::Leave( KErrArgument ); |
|
1200 } |
|
1201 if ( !iRights->iCurrentConstraint->iDrmMeteringInfo ) |
|
1202 { |
|
1203 iRights->iCurrentConstraint->iDrmMeteringInfo = |
|
1204 new ( ELeave ) CDRMConstraint::TDrmMeteringInfo; |
|
1205 } |
|
1206 b = GetAttributeValueL( aAttributes, KTimedAttribute ); |
|
1207 if ( b ) |
|
1208 { |
|
1209 CleanupStack::PushL( b ); |
|
1210 lex = *b; |
|
1211 if ( lex.Val( n ) != KErrNone ) |
|
1212 { |
|
1213 // given input does not fit to TInt |
|
1214 User::Leave( KErrArgument ); |
|
1215 } |
|
1216 iRights->iCurrentConstraint->iDrmMeteringInfo->iGraceTime = n; |
|
1217 |
|
1218 CleanupStack::PopAndDestroy( b ); |
|
1219 b = NULL; |
|
1220 } |
|
1221 b = GetAttributeValueL( aAttributes, KContentAccessGrantedAttribute ); |
|
1222 // put value to content access granted without metering |
|
1223 if ( b && !b->CompareF( KContentAccessGrantedValueTrue ) ) |
|
1224 { |
|
1225 iRights->iCurrentConstraint->iDrmMeteringInfo->iAllowUseWithoutMetering = ETrue; |
|
1226 } |
|
1227 else |
|
1228 { |
|
1229 iRights->iCurrentConstraint->iDrmMeteringInfo->iAllowUseWithoutMetering = EFalse; |
|
1230 } |
|
1231 delete b; |
|
1232 break; |
|
1233 #endif // RD_DRM_METERING |
|
1234 } |
|
1235 } |
|
1236 if ( !tagRecognized && iElementStackDepth > 0 && |
|
1237 iElementStack[ 0 ] == ::ERights ) |
|
1238 { |
|
1239 //Found unrecognised tag in <(o-ex:)rights>. Let's ignore its content. |
|
1240 iUnknownTag = aElement.LocalName().DesC().AllocL(); |
|
1241 if ( iRights && iRights->iCurrentPermission ) |
|
1242 { |
|
1243 iRights->iCurrentPermission->iInvalidConstraints |= |
|
1244 iRights->iCurrentPermission->iCurrentConstraint; |
|
1245 if ( iRights->iCurrentPermission->iCurrentConstraint |
|
1246 == ERightsTopLevel ) |
|
1247 { |
|
1248 iRights->iCurrentPermission->iInvalid = ETrue; |
|
1249 } |
|
1250 } |
|
1251 } |
|
1252 } |
|
1253 |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // CDrmRightsParser::OnEndElementL |
|
1256 // ----------------------------------------------------------------------------- |
|
1257 // |
|
1258 void CDrmRightsParser::OnEndElementL( |
|
1259 const RTagInfo& aElement, |
|
1260 TInt /*aErrorCode*/ ) |
|
1261 { |
|
1262 if ( iUnknownTag ) |
|
1263 { |
|
1264 if ( !iUnknownTag->Compare( aElement.LocalName().DesC() ) ) |
|
1265 { |
|
1266 delete iUnknownTag; |
|
1267 iUnknownTag = NULL; |
|
1268 } |
|
1269 return; |
|
1270 } |
|
1271 |
|
1272 for ( TInt i ( 0 ); i < KMaxElementCount; i++ ) |
|
1273 { |
|
1274 if ( aElement.LocalName() == iElements[ i ] ) |
|
1275 { |
|
1276 switch ( MatchStackState() ) |
|
1277 { |
|
1278 case ERoUidState: |
|
1279 iContent->Des().Trim(); // remove ignorable white spaces |
|
1280 iRights->iRightsObjectId = iContent->AllocL(); |
|
1281 break; |
|
1282 case EDateTimeStartState: |
|
1283 if ( iRights->iCurrentConstraint ) |
|
1284 { |
|
1285 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1286 EConstraintStartTime; |
|
1287 iRights->iCurrentConstraint->iStartTime = |
|
1288 ParseRelTimeL( *iContent ); |
|
1289 } |
|
1290 break; |
|
1291 case EDateTimeEndState: |
|
1292 if ( iRights->iCurrentConstraint ) |
|
1293 { |
|
1294 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1295 EConstraintEndTime; |
|
1296 iRights->iCurrentConstraint->iEndTime = |
|
1297 ParseRelTimeL( *iContent ); |
|
1298 } |
|
1299 break; |
|
1300 case EIntervalState: |
|
1301 if ( iRights->iCurrentConstraint ) |
|
1302 { |
|
1303 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1304 EConstraintInterval; |
|
1305 iRights->iCurrentConstraint->iInterval = |
|
1306 ParseRelInterval( *iContent ); |
|
1307 iRights->iCurrentConstraint->iIntervalStart = |
|
1308 Time::NullTTime(); |
|
1309 if ( iRights->iCurrentConstraint->iInterval.Int() |
|
1310 <= 0 ) |
|
1311 { |
|
1312 User::Leave( KErrArgument ); |
|
1313 } |
|
1314 } |
|
1315 break; |
|
1316 case EAccumulatedState: |
|
1317 #ifndef __DRM_OMA2 |
|
1318 User::Leave( KErrArgument ); |
|
1319 #endif |
|
1320 if ( iRights->iCurrentConstraint ) |
|
1321 { |
|
1322 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1323 EConstraintAccumulated; |
|
1324 iRights->iCurrentConstraint->iAccumulatedTime = |
|
1325 ParseRelInterval( *iContent ).Int(); |
|
1326 if ( iRights->iCurrentConstraint-> |
|
1327 iAccumulatedTime.Int() <= 0 ) |
|
1328 { |
|
1329 User::Leave( KErrArgument ); |
|
1330 } |
|
1331 } |
|
1332 break; |
|
1333 case ECountState: |
|
1334 if ( iRights->iCurrentConstraint ) |
|
1335 { |
|
1336 TLex8 lex( *iContent ); |
|
1337 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1338 EConstraintCounter; |
|
1339 lex.Val( iRights->iCurrentConstraint-> |
|
1340 iOriginalCounter ); |
|
1341 iRights->iCurrentConstraint->iCounter = |
|
1342 iRights->iCurrentConstraint->iOriginalCounter; |
|
1343 if ( iRights->iCurrentConstraint->iCounter <= 0 || |
|
1344 iRights->iCurrentConstraint->iCounter > |
|
1345 KDRMCounterMax ) |
|
1346 { |
|
1347 User::Leave( KErrArgument ); |
|
1348 } |
|
1349 } |
|
1350 break; |
|
1351 case ETimedCountState: |
|
1352 #ifndef __DRM_OMA2 |
|
1353 User::Leave( KErrArgument ); |
|
1354 #endif |
|
1355 if ( iRights->iCurrentConstraint ) |
|
1356 { |
|
1357 CDRMConstraint* c( iRights->iCurrentConstraint ); |
|
1358 TLex8 lex( *iContent ); |
|
1359 lex.Val( c->iOriginalTimedCounter ); |
|
1360 if ( c->iOriginalTimedCounter <= 0 || |
|
1361 c->iOriginalTimedCounter > KDRMCounterMax ) |
|
1362 { |
|
1363 User::Leave( KErrArgument ); |
|
1364 } |
|
1365 if ( c->iTimedInterval.Int() > 0 ) |
|
1366 { |
|
1367 c->iActiveConstraints |= EConstraintTimedCounter; |
|
1368 c->iTimedCounter = c->iOriginalTimedCounter; |
|
1369 } |
|
1370 else |
|
1371 { |
|
1372 c->iActiveConstraints |= EConstraintCounter; |
|
1373 c->iOriginalCounter = c->iOriginalTimedCounter; |
|
1374 c->iCounter = c->iOriginalCounter; |
|
1375 c->iOriginalTimedCounter = 0; |
|
1376 } |
|
1377 } |
|
1378 break; |
|
1379 case ESystemState: |
|
1380 #ifndef __DRM_OMA2 |
|
1381 User::Leave( KErrArgument ); |
|
1382 #endif |
|
1383 if ( iRights->iCurrentConstraint ) |
|
1384 { |
|
1385 HBufC8* b( iContent->AllocLC() ); |
|
1386 iRights->iCurrentConstraint->iSystem.AppendL( b ); |
|
1387 CleanupStack::Pop( b ); |
|
1388 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1389 EConstraintSystem; |
|
1390 } |
|
1391 break; |
|
1392 case EAssetUidState: |
|
1393 iContent->Des().Trim(); // remove ignorable white spaces |
|
1394 if ( !iRights->iCurrentAsset ) |
|
1395 { |
|
1396 User::Leave( KErrArgument ); |
|
1397 } |
|
1398 iRights->iCurrentAsset->iUid = iContent->AllocL(); |
|
1399 break; |
|
1400 case EAssetDigestState: |
|
1401 if ( iParserType == EXmlParser ) |
|
1402 { |
|
1403 DecodeAndDeleteUndecodedL( iContent ); |
|
1404 } |
|
1405 CopyOrLeaveL( iRights->iCurrentAsset->iDigest, *iContent ); |
|
1406 break; |
|
1407 case EAssetKeyState: |
|
1408 if ( iParserType == EXmlParser ) |
|
1409 { |
|
1410 DecodeAndDeleteUndecodedL( iContent ); |
|
1411 } |
|
1412 CopyOrLeaveL( iRights->iCurrentAsset->iKey, *iContent ); |
|
1413 break; |
|
1414 case EEncryptedKeyState: |
|
1415 if ( iParserType == EXmlParser ) |
|
1416 { |
|
1417 DecodeAndDeleteUndecodedL( iContent ); |
|
1418 } |
|
1419 if ( iRights->iKeyIsCek ) |
|
1420 { |
|
1421 CopyOrLeaveL( |
|
1422 iRights->iCurrentAsset->iProtectedKey, *iContent ); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 CopyOrLeaveL( |
|
1427 iRights->iCurrentAsset->iProtectedAuthSeed, |
|
1428 *iContent ); |
|
1429 } |
|
1430 break; |
|
1431 case EAssetInheritUidState: |
|
1432 iContent->Des().Trim(); // remove ignorable white spaces |
|
1433 iRights->iCurrentAsset->iInherit = iContent->AllocL(); |
|
1434 break; |
|
1435 case EIndividualState: |
|
1436 #ifndef __DRM_OMA2 |
|
1437 User::Leave( KErrArgument ); |
|
1438 #endif |
|
1439 if ( iRights->iCurrentConstraint ) |
|
1440 { |
|
1441 HBufC8* b( NULL ); |
|
1442 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1443 EConstraintIndividual; |
|
1444 iContent->Des().Trim(); // remove ignorable white spaces |
|
1445 b = iContent->AllocLC(); |
|
1446 iRights->iCurrentConstraint->iIndividual.AppendL( b ); |
|
1447 CleanupStack::Pop( b ); |
|
1448 } |
|
1449 break; |
|
1450 case ESoftwareState: |
|
1451 #ifndef __DRM_OMA2 |
|
1452 User::Leave( KErrArgument ); |
|
1453 #endif |
|
1454 if ( iRights->iCurrentConstraint ) |
|
1455 { |
|
1456 TUint32 n( 0 ); |
|
1457 TLex8 lex( *iContent ); |
|
1458 User::LeaveIfError( lex.Val( n, EHex ) ); |
|
1459 if ( iSoftwareSchemeType == ESymbianSid ) |
|
1460 { |
|
1461 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1462 EConstraintSoftware; |
|
1463 iRights->iCurrentConstraint->iSecureId = |
|
1464 TUid::Uid( n ); |
|
1465 } |
|
1466 else |
|
1467 { |
|
1468 iRights->iCurrentConstraint->iActiveConstraints |= |
|
1469 EConstraintVendor; |
|
1470 iRights->iCurrentConstraint->iVendorId = |
|
1471 TUid::Uid( n ); |
|
1472 } |
|
1473 } |
|
1474 break; |
|
1475 case EExportConstraintState: |
|
1476 case ETopLevelConstraintState: |
|
1477 #ifndef __DRM_OMA2 |
|
1478 User::Leave( KErrArgument ); |
|
1479 #endif |
|
1480 case EDisplayConstraintState: |
|
1481 case EPlayConstraintState: |
|
1482 case EPrintConstraintState: |
|
1483 case EExecuteConstraintState: |
|
1484 iRights->iCurrentConstraint = NULL; |
|
1485 iRights->iCurrentPermission->iCurrentConstraint = 0; |
|
1486 break; |
|
1487 case EPermissionState: |
|
1488 iRights->iCurrentPermission->RemoveInvalidL(); |
|
1489 iRights->iCurrentPermission = NULL; |
|
1490 break; |
|
1491 |
|
1492 } |
|
1493 iElementStackDepth--; |
|
1494 if ( iElementStackDepth < 0 ) |
|
1495 { |
|
1496 User::Leave( EXmlUnexpectedState ); |
|
1497 } |
|
1498 break; // no need to iterate after element name matched |
|
1499 } |
|
1500 } |
|
1501 } |
|
1502 |
|
1503 // ----------------------------------------------------------------------------- |
|
1504 // CDrmRightsParser::OnContentL |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // |
|
1507 void CDrmRightsParser::OnContentL( |
|
1508 const TDesC8& aBytes, |
|
1509 TInt /*aErrorCode*/ ) |
|
1510 { |
|
1511 if ( iUnknownTag ) |
|
1512 { |
|
1513 return; |
|
1514 } |
|
1515 if ( !iContent ) |
|
1516 { |
|
1517 iContent = HBufC8::NewL( aBytes.Size() ); |
|
1518 *iContent = aBytes; |
|
1519 } |
|
1520 else |
|
1521 { |
|
1522 iContent = iContent->ReAllocL( iContent->Size() + aBytes.Size() ); |
|
1523 TPtr8 c( iContent->Des() ); |
|
1524 c.Append( aBytes ); |
|
1525 } |
|
1526 } |
|
1527 |
|
1528 // ----------------------------------------------------------------------------- |
|
1529 // CDrmRightsParser::OnStartPrefixMappingL |
|
1530 // ----------------------------------------------------------------------------- |
|
1531 // |
|
1532 void CDrmRightsParser::OnStartPrefixMappingL( |
|
1533 const RString& /*aPrefix*/, |
|
1534 const RString& /*aUri*/, |
|
1535 TInt /*aErrorCode*/ ) |
|
1536 { |
|
1537 } |
|
1538 |
|
1539 // ----------------------------------------------------------------------------- |
|
1540 // CDrmRightsParser::OnEndPrefixMappingL |
|
1541 // ----------------------------------------------------------------------------- |
|
1542 // |
|
1543 void CDrmRightsParser::OnEndPrefixMappingL( |
|
1544 const RString& /*aPrefix*/, |
|
1545 TInt /*aErrorCode*/ ) |
|
1546 { |
|
1547 } |
|
1548 |
|
1549 // ----------------------------------------------------------------------------- |
|
1550 // CDrmRightsParser::OnIgnorableWhiteSpaceL |
|
1551 // ----------------------------------------------------------------------------- |
|
1552 // |
|
1553 void CDrmRightsParser::OnIgnorableWhiteSpaceL( |
|
1554 const TDesC8& /*aBytes*/, |
|
1555 TInt /*aErrorCode*/ ) |
|
1556 { |
|
1557 } |
|
1558 |
|
1559 // ----------------------------------------------------------------------------- |
|
1560 // CDrmRightsParser::OnSkippedEntityL |
|
1561 // ----------------------------------------------------------------------------- |
|
1562 // |
|
1563 void CDrmRightsParser::OnSkippedEntityL( |
|
1564 const RString& /*aName*/, |
|
1565 TInt /*aErrorCode*/ ) |
|
1566 { |
|
1567 } |
|
1568 |
|
1569 // ----------------------------------------------------------------------------- |
|
1570 // CDrmRightsParser::OnProcessingInstructionL |
|
1571 // ----------------------------------------------------------------------------- |
|
1572 // |
|
1573 void CDrmRightsParser::OnProcessingInstructionL( |
|
1574 const TDesC8& /*aTarget*/, |
|
1575 const TDesC8& /*aData*/, |
|
1576 TInt /*aErrorCode*/ ) |
|
1577 { |
|
1578 } |
|
1579 |
|
1580 // ----------------------------------------------------------------------------- |
|
1581 // CDrmRightsParser::OnOutOfData |
|
1582 // ----------------------------------------------------------------------------- |
|
1583 // |
|
1584 void CDrmRightsParser::OnOutOfData() |
|
1585 { |
|
1586 } |
|
1587 |
|
1588 // ----------------------------------------------------------------------------- |
|
1589 // CDrmRightsParser::OnError |
|
1590 // ----------------------------------------------------------------------------- |
|
1591 // |
|
1592 void CDrmRightsParser::OnError( |
|
1593 TInt /*aErrorCode*/ ) |
|
1594 { |
|
1595 } |
|
1596 |
|
1597 // ----------------------------------------------------------------------------- |
|
1598 // CDrmRightsParser::GetExtendedInterface |
|
1599 // ----------------------------------------------------------------------------- |
|
1600 // |
|
1601 TAny* CDrmRightsParser::GetExtendedInterface( |
|
1602 const TInt32 /*aUid*/ ) |
|
1603 { |
|
1604 return NULL; |
|
1605 } |
|
1606 |
|
1607 // ----------------------------------------------------------------------------- |
|
1608 // CDrmRightsParser::MatchStackState |
|
1609 // ----------------------------------------------------------------------------- |
|
1610 // |
|
1611 TInt CDrmRightsParser::MatchStackState( void ) |
|
1612 { |
|
1613 TParserStackState r( EUnknownState ); |
|
1614 |
|
1615 for ( TInt i( 0 ); |
|
1616 r == EUnknownState && |
|
1617 i < ELEMENT_COUNT( KParserStackStates ); i++ ) |
|
1618 { |
|
1619 TInt j( 0 ); |
|
1620 TInt k( 0 ); |
|
1621 for ( j = iElementStackDepth - 1, k = 0; |
|
1622 j > 0 && KParserStackStates[ i ].iStack[ k ] != ELast; |
|
1623 j--, k++ ) |
|
1624 { |
|
1625 if ( iElementStack[ j ] != KParserStackStates[ i ].iStack[ k ] ) |
|
1626 { |
|
1627 break; |
|
1628 } |
|
1629 } |
|
1630 if ( ( j == 0 && |
|
1631 iElementStack[ j ] == KParserStackStates[ i ].iStack[ k ] && |
|
1632 KParserStackStates[ i ].iStack[ k + 1 ] == ELast ) || |
|
1633 KParserStackStates[ i ].iStack[ k ] == ELast ) |
|
1634 { |
|
1635 r = KParserStackStates[ i ].iState; |
|
1636 } |
|
1637 } |
|
1638 return r; |
|
1639 } |
|
1640 |
|
1641 // ----------------------------------------------------------------------------- |
|
1642 // CDrmRightsParser::TransformRightsObjectL |
|
1643 // ----------------------------------------------------------------------------- |
|
1644 // |
|
1645 void CDrmRightsParser::TransformRightsObjectL( |
|
1646 RPointerArray< CDRMRights >& aResult ) |
|
1647 { |
|
1648 CParsedAsset* asset( NULL ); |
|
1649 CDRMRights* rights( NULL ); |
|
1650 CParsedPermission* permission( NULL ); |
|
1651 CDRMPermission *ro( CDRMPermission::NewLC() ); |
|
1652 CDRMAsset* a( NULL ); |
|
1653 HBufC8* id( NULL ); |
|
1654 HBufC8* idRef( NULL ); |
|
1655 |
|
1656 // If no permissions are given, create an empty RO. |
|
1657 // The procedure is quite different |
|
1658 // than processing the permissions |
|
1659 if ( iRights->iInvalid ) |
|
1660 { |
|
1661 //The RO is invalid. Let's leave |
|
1662 User::Leave( KErrArgument ); |
|
1663 } |
|
1664 if ( iRights->iPermissions.Count() == 0 ) |
|
1665 { |
|
1666 for ( TInt i( 0 ); i < iRights->iAssets.Count(); i++ ) |
|
1667 { |
|
1668 asset = iRights->iAssets[ i ]; |
|
1669 // No uid for the asset, it's an invalid asset |
|
1670 if( !asset->iUid ) |
|
1671 { |
|
1672 continue; |
|
1673 } |
|
1674 |
|
1675 rights = CDRMRights::NewL(); |
|
1676 CleanupStack::PushL( rights ); |
|
1677 |
|
1678 a = CDRMAsset::NewLC(); |
|
1679 a->iDigest.Copy( asset->iDigest ); |
|
1680 a->iKey.Copy( asset->iKey ); |
|
1681 a->iProtectedKey.Copy( asset->iProtectedKey ); |
|
1682 a->iAuthenticationSeed.Copy( asset->iAuthenticationSeed ); |
|
1683 a->iProtectedAuthSeed.Copy( asset->iProtectedAuthSeed ); |
|
1684 |
|
1685 // guaranteed not to be NULL UID in this phase |
|
1686 a->iUid = asset->iUid->AllocL(); |
|
1687 |
|
1688 if ( ro->iParentUID ) |
|
1689 { |
|
1690 delete ro->iParentUID; |
|
1691 ro->iParentUID = NULL; |
|
1692 } |
|
1693 if ( asset->iInherit ) |
|
1694 { |
|
1695 a->iParentRights = asset->iInherit->AllocL(); |
|
1696 ro->iParentUID = asset->iInherit->AllocL(); |
|
1697 } |
|
1698 rights->SetAssetL( *a ); |
|
1699 CleanupStack::PopAndDestroy( a ); |
|
1700 |
|
1701 // by default, set the RO version as OMA 1.0 |
|
1702 ro->iRightsObjectVersion.iVersionMain = EOma1Rights; |
|
1703 rights->SetPermissionL( *ro ); |
|
1704 |
|
1705 // Warning: assuming RPointerArray |
|
1706 // does not put its argument to clenaupstack |
|
1707 aResult.AppendL( rights ); |
|
1708 CleanupStack::Pop( rights ); |
|
1709 } |
|
1710 } |
|
1711 else for ( TInt i( 0 ); i < iRights->iPermissions.Count(); i++ ) |
|
1712 { |
|
1713 permission = iRights->iPermissions[ i ]; |
|
1714 if ( permission->iInvalid ) |
|
1715 { |
|
1716 // The permission under test is invalid, so let's move forward |
|
1717 continue; |
|
1718 } |
|
1719 if ( permission->iAssets.Count() > 0 ) |
|
1720 { |
|
1721 // The permission refers to asset elements in the RO, |
|
1722 // add all referenced assets to the permission |
|
1723 for ( TInt j( 0 ); j < permission->iAssets.Count(); j++ ) |
|
1724 { |
|
1725 TInt k( 0 ); |
|
1726 for ( ; k < iRights->iAssets.Count(); k++ ) |
|
1727 { |
|
1728 id = iRights->iAssets[ k ]->iId; |
|
1729 idRef = permission->iAssets[ j ]->iIdRef; |
|
1730 if ( id && idRef && *id == *idRef ) |
|
1731 { |
|
1732 break; |
|
1733 } |
|
1734 } |
|
1735 if ( k < iRights->iAssets.Count() ) |
|
1736 { |
|
1737 asset = permission->iAssets[ j ]; |
|
1738 permission->iAssets[ j ] = iRights->iAssets[ k ]; |
|
1739 delete asset; |
|
1740 permission->iNotOwned++; |
|
1741 } |
|
1742 } |
|
1743 } |
|
1744 else |
|
1745 { |
|
1746 // The permission does not refer to an asset explictly, |
|
1747 // link all assets in the RO to this permission |
|
1748 for ( TInt j( 0 ); j < iRights->iAssets.Count(); j++ ) |
|
1749 { |
|
1750 permission->iAssets.Append( iRights->iAssets[ j ] ); |
|
1751 permission->iNotOwned++; |
|
1752 } |
|
1753 } |
|
1754 |
|
1755 for ( TInt j( 0 ); j < permission->iAssets.Count(); j++ ) |
|
1756 { |
|
1757 asset = permission->iAssets[ j ]; |
|
1758 // No uid for the asset, it's an invalid asset |
|
1759 if( !asset->iUid ) |
|
1760 { |
|
1761 continue; |
|
1762 } |
|
1763 |
|
1764 rights = CDRMRights::NewL(); |
|
1765 CleanupStack::PushL( rights ); |
|
1766 |
|
1767 a = CDRMAsset::NewLC(); |
|
1768 a->iDigest.Copy( asset->iDigest ); |
|
1769 a->iKey.Copy( asset->iKey ); |
|
1770 a->iProtectedKey.Copy( asset->iProtectedKey ); |
|
1771 a->iAuthenticationSeed.Copy( asset->iAuthenticationSeed ); |
|
1772 a->iProtectedAuthSeed.Copy( asset->iProtectedAuthSeed ); |
|
1773 |
|
1774 // guaranteed not to be NULL UID in this phase |
|
1775 a->iUid = asset->iUid->AllocL(); |
|
1776 |
|
1777 if ( ro->iParentUID ) |
|
1778 { |
|
1779 delete ro->iParentUID; |
|
1780 ro->iParentUID = NULL; |
|
1781 } |
|
1782 if ( asset->iInherit ) |
|
1783 { |
|
1784 a->iParentRights = asset->iInherit->AllocL(); |
|
1785 ro->iParentUID = asset->iInherit->AllocL(); |
|
1786 } |
|
1787 rights->SetAssetL( *a ); |
|
1788 CleanupStack::PopAndDestroy( a ); |
|
1789 |
|
1790 |
|
1791 // ( == iOnExpiredUrl must not be referred elsewhere) |
|
1792 ro->iOnExpiredUrl = permission->iOnExpiredUrl; |
|
1793 permission->iOnExpiredUrl = NULL; |
|
1794 |
|
1795 ro->iAvailableRights = permission->iAvailableRights; |
|
1796 ro->iDisplay->DuplicateL( *permission->iDisplay ); |
|
1797 ro->iPlay->DuplicateL( *permission->iPlay ); |
|
1798 ro->iPrint->DuplicateL( *permission->iPrint ); |
|
1799 ro->iExecute->DuplicateL( *permission->iExecute ); |
|
1800 ro->iExport->DuplicateL( *permission->iExport ); |
|
1801 ro->iTopLevel->DuplicateL( *permission->iTopLevel ); |
|
1802 // by default, set the RO version as OMA 1.0 |
|
1803 ro->iRightsObjectVersion.iVersionMain = EOma1Rights; |
|
1804 rights->SetPermissionL( *ro ); |
|
1805 |
|
1806 aResult.AppendL( rights ); |
|
1807 CleanupStack::Pop( rights ); |
|
1808 } |
|
1809 } |
|
1810 CleanupStack::PopAndDestroy( ro ); |
|
1811 } |
|
1812 |
|
1813 // ----------------------------------------------------------------------------- |
|
1814 // CDrmRightsParser::GetAttributeValueL |
|
1815 // ----------------------------------------------------------------------------- |
|
1816 // |
|
1817 HBufC8* CDrmRightsParser::GetAttributeValueL( |
|
1818 const RAttributeArray& aAttrList, |
|
1819 const TDesC8& aAttrName ) |
|
1820 { |
|
1821 HBufC8* r( NULL ); |
|
1822 RAttribute a; |
|
1823 |
|
1824 for ( TInt i( 0 ); !r && i < aAttrList.Count(); i++ ) |
|
1825 { |
|
1826 a = aAttrList[ i ]; |
|
1827 if ( a.Attribute().LocalName().DesC().Compare( aAttrName ) == 0 ) |
|
1828 { |
|
1829 r = a.Value().DesC().AllocL(); |
|
1830 } |
|
1831 } |
|
1832 return r; |
|
1833 } |
|
1834 |
|
1835 // End of File |