|
1 /* |
|
2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Datatype for the Common Rights Database Data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DRMDOMAINCONTEXT_H |
|
20 #define DRMDOMAINCONTEXT_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "RoapMessage.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class RReadStream; |
|
35 class RWriteStream; |
|
36 class CRSAPublicKey; |
|
37 |
|
38 // TYPE DEFINITIONS |
|
39 |
|
40 // FUNCTION PROTOTYPES |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 using namespace Roap; |
|
45 |
|
46 /** |
|
47 * CDRMDomainContext implements a datatype for the common data for a single |
|
48 * content identifier |
|
49 * |
|
50 * @lib RightsServer.dll |
|
51 * @since 3.0 |
|
52 */ |
|
53 |
|
54 class CDRMDomainContext : public CBase |
|
55 { |
|
56 |
|
57 public: // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * NewLC |
|
61 * |
|
62 * Creates an instance of the CDRMDomainContext class and returns a pointer |
|
63 * to it. The function leaves the object into the cleanup stack |
|
64 * |
|
65 * @since 3.0 |
|
66 * @param aDomainID : Domain Identifier |
|
67 * @param aExpiryTime : Domain expiration time |
|
68 * @param aHashChained : Does the domain support hash chaining |
|
69 * @param aDomainKeys : a pointer array of the domain keys |
|
70 * @param aRiId : the rights issuer ID |
|
71 * @param aRightsIssuerURL : the rights issuer URL |
|
72 * @return Functional CDRMDomainContext object, Function leaves if an error |
|
73 * occurs. |
|
74 */ |
|
75 IMPORT_C static CDRMDomainContext* NewLC( const TDesC8& aDomainID, |
|
76 const TTime& aExpiryTime, |
|
77 const TBool aHashChained, |
|
78 const RPointerArray< HBufC8 >& aDomainKeys, |
|
79 const TDesC8& aRiId, |
|
80 const TDesC8& aRightsIssuerURL ); |
|
81 |
|
82 /** |
|
83 * NewL |
|
84 * |
|
85 * Creates an instance of the CDRMDomainContext class and returns a pointer |
|
86 * to it. |
|
87 * |
|
88 * @since 3.0 |
|
89 * @param aDomainID : Domain Identifier |
|
90 * @param aExpiryTime : Domain expiration time |
|
91 * @param aHashChained : Does the domain support hash chaining |
|
92 * @param aDomainKeys : a pointer array of the domain keys |
|
93 * @param aRiId : the rights issuer ID |
|
94 * @param aRightsIssuerURL : the rights issuer URL |
|
95 * @return Functional CDRMDomainContext object, Function leaves if an error |
|
96 * occurs. |
|
97 */ |
|
98 IMPORT_C static CDRMDomainContext* NewL( const TDesC8& aDomainID, |
|
99 const TTime& aExpiryTime, |
|
100 const TBool aHashChained, |
|
101 const RPointerArray< HBufC8 >& aDomainKeys, |
|
102 const TDesC8& aRiId, |
|
103 const TDesC8& aRightsIssuerURL ); |
|
104 |
|
105 |
|
106 /** |
|
107 * NewLC |
|
108 * |
|
109 * Creates an instance of the CDRMDomainContext class and returns a pointer |
|
110 * to it. The function leaves the object into the cleanup stack |
|
111 * |
|
112 * @since 3.0 |
|
113 * @return Functional CDRMDomainContext object, Function leaves if an error |
|
114 * occurs. |
|
115 */ |
|
116 IMPORT_C static CDRMDomainContext* NewLC(); |
|
117 |
|
118 /** |
|
119 * NewL |
|
120 * |
|
121 * Creates an instance of the CDRMDomainContext class and returns a pointer |
|
122 * to it. |
|
123 * |
|
124 * @since 3.0 |
|
125 * @return Functional CDRMDomainContext object, Function leaves if an error |
|
126 * occurs. |
|
127 */ |
|
128 IMPORT_C static CDRMDomainContext* NewL(); |
|
129 |
|
130 /** |
|
131 * Default Constructor - First phase. |
|
132 * Can be used by itself to generate an empty object |
|
133 */ |
|
134 CDRMDomainContext(); |
|
135 |
|
136 /** |
|
137 * Destructor |
|
138 */ |
|
139 IMPORT_C virtual ~CDRMDomainContext(); |
|
140 |
|
141 |
|
142 /** |
|
143 * DomainID |
|
144 * |
|
145 * Returns a constant TDesC8& reference to the domain id |
|
146 * |
|
147 * @since 3.0 |
|
148 * @return a pointer to the content id or null |
|
149 */ |
|
150 IMPORT_C const TPtrC8 DomainID() const; |
|
151 |
|
152 /** |
|
153 * ExpiryTime |
|
154 * |
|
155 * Returns a constant TTime reference to the expiry time |
|
156 * |
|
157 * @since 3.0 |
|
158 * @return a pointer to the content hash or null |
|
159 */ |
|
160 IMPORT_C const TTime ExpiryTime() const; |
|
161 |
|
162 /** |
|
163 * HashChained |
|
164 * |
|
165 * Returns a constant TBool reference to the hash chained boolean |
|
166 * |
|
167 * @since 3.0 |
|
168 * @return a pointer to the rights issuer or null |
|
169 */ |
|
170 IMPORT_C TBool HashChained() const; |
|
171 |
|
172 /** |
|
173 * DomainKeys |
|
174 * |
|
175 * Return a constant RPointerArray reference to the domain keys |
|
176 * |
|
177 * @since 3.0 |
|
178 * @return a pointer to the content name or null |
|
179 */ |
|
180 IMPORT_C const RPointerArray< HBufC8 >& DomainKeys() const; |
|
181 |
|
182 /** |
|
183 * DomainKeyL |
|
184 * |
|
185 * Return a pointer of the domain key specified by the parameter |
|
186 * Note: pointer ownership goes to caller. I.e. Caller is responsible |
|
187 * of freeing memory reserved for the pointer. |
|
188 * |
|
189 * @since 3.0 |
|
190 * @leave KErrAgument if aGeneration is not valid |
|
191 * @return a reference to the key |
|
192 */ |
|
193 IMPORT_C HBufC8* DomainKeyL( const TInt aGeneration ) const; |
|
194 |
|
195 /** |
|
196 * Generation |
|
197 * |
|
198 * Returns a constant TInt reference to the domain generation |
|
199 * |
|
200 * @since 3.0 |
|
201 * @return a pointer to the rights issuer or null |
|
202 */ |
|
203 IMPORT_C TInt DomainGeneration() const; |
|
204 |
|
205 |
|
206 /** |
|
207 * PublicKey |
|
208 * |
|
209 * Returns a constant reference to rights issuer ID |
|
210 * |
|
211 * @since 3.0 |
|
212 * @return the rights issuer ID |
|
213 */ |
|
214 IMPORT_C const TDesC8& RightsIssuerID() const; |
|
215 |
|
216 /** |
|
217 * RightsIssuerURL |
|
218 * |
|
219 * Returns a constant TDesC8& reference to the rights issuer url |
|
220 * |
|
221 * @since 3.0 |
|
222 * @return a pointer to the content id or null |
|
223 */ |
|
224 IMPORT_C const TDesC8& RightsIssuerURL() const; |
|
225 |
|
226 |
|
227 |
|
228 /** |
|
229 * SetDomainIDL |
|
230 * |
|
231 * Sets the domain id, deletes the previous one if one |
|
232 * exits |
|
233 * |
|
234 * @since 3.0 |
|
235 * @param aDomainID : Domain identifier |
|
236 * @return The function leaves with Symbian OS error code if an |
|
237 * error occurs |
|
238 */ |
|
239 IMPORT_C void SetDomainIDL( const TDesC8& aDomainID ); |
|
240 |
|
241 /** |
|
242 * SetExpiryTimeL |
|
243 * |
|
244 * Sets the expiration time |
|
245 * |
|
246 * @since 3.0 |
|
247 * @param aExpiryTime : expiration time |
|
248 * @return The function leaves with Symbian OS error code if an |
|
249 * error occurs |
|
250 */ |
|
251 IMPORT_C void SetExpiryTimeL( const TTime& aExpiryTime ); |
|
252 |
|
253 /** |
|
254 * SetHashChainedL |
|
255 * |
|
256 * Sets the hash chained status |
|
257 * |
|
258 * @since 3.0 |
|
259 * @param aHashChained : hash chained status boolean value |
|
260 * @return The function leaves with Symbian OS error code if an |
|
261 * error occurs |
|
262 */ |
|
263 IMPORT_C void SetHashChainedL( const TBool& aHashChained ); |
|
264 |
|
265 |
|
266 /** |
|
267 * SetDomainKeysL |
|
268 * |
|
269 * Sets the domain keys, deletes the old ones if they exist |
|
270 * |
|
271 * @since 3.0 |
|
272 * @param aDomainKeys : pointer array with the domain keys |
|
273 * @return The function leaves with Symbian OS error code if an |
|
274 * error occurs |
|
275 */ |
|
276 IMPORT_C void SetDomainKeysL( const RPointerArray< HBufC8 >& aDomainKeys ); |
|
277 |
|
278 /** |
|
279 * SetPublicKeyL |
|
280 * |
|
281 * Sets the public key, deletes the old one if one exist |
|
282 * |
|
283 * @since 3.0 |
|
284 * @param aRightsIsserID : rights issuer ID |
|
285 * @return The function leaves with Symbian OS error code if an |
|
286 * error occurs |
|
287 */ |
|
288 IMPORT_C void SetRightsIssuerIDL( const TDesC8& aRightsIssuerID ); |
|
289 |
|
290 /** |
|
291 * SetRightsIssuerURLL |
|
292 * |
|
293 * Sets the rights issuer url, deletes the previous one if one |
|
294 * exits |
|
295 * |
|
296 * @since 3.0 |
|
297 * @param aRightsIssuerURL : rights issuer url |
|
298 * @return The function leaves with Symbian OS error code if an |
|
299 * error occurs |
|
300 */ |
|
301 IMPORT_C void SetRightsIssuerURLL( const TDesC8& aRightsIssuerURL ); |
|
302 |
|
303 |
|
304 /** |
|
305 * ExternalizeL |
|
306 * |
|
307 * Writes the data of the object into the stream |
|
308 * |
|
309 * @since 3.0 |
|
310 * @param aStream : the output stream to write to |
|
311 * @return The function leaves with Symbian OS error code if an |
|
312 * error occurs |
|
313 */ |
|
314 IMPORT_C void ExternalizeL( RWriteStream& aStream ) const; |
|
315 |
|
316 /** |
|
317 * InternalizeL |
|
318 * |
|
319 * Reads the data of the object from the stream |
|
320 * |
|
321 * @since 3.0 |
|
322 * @param aStream : the output stream to write to |
|
323 * @return The function leaves with Symbian OS error code if an |
|
324 * error occurs |
|
325 */ |
|
326 IMPORT_C void InternalizeL( RReadStream& aStream ); |
|
327 |
|
328 /** |
|
329 * ImportL |
|
330 * |
|
331 * Reads the data of the object from the descriptor and initialized the |
|
332 * object accordingly |
|
333 * |
|
334 * @since 3.0 |
|
335 * @param aBuffer : the buffer containing the data of the imported object |
|
336 * @return None, The function leaves with Symbian OS error code if an |
|
337 * error occurs |
|
338 */ |
|
339 IMPORT_C void ImportL( const TDesC8& aBuffer ); |
|
340 |
|
341 /** |
|
342 * ExportL |
|
343 * |
|
344 * Writes the data of the object into an HBufC8 and returns a pointer |
|
345 * to it. The caller is responsible for deleting the object. |
|
346 * |
|
347 * @since 3.0 |
|
348 * @return Returns an HBufC8* containing the data of the object, |
|
349 * The function leaves with Symbian OS error code if an |
|
350 * error occurs |
|
351 */ |
|
352 IMPORT_C HBufC8* ExportL() const; |
|
353 |
|
354 |
|
355 /** |
|
356 * Size |
|
357 * |
|
358 * Returns the size of the externalized object |
|
359 * |
|
360 * @since 3.0 |
|
361 * @return the amount of bytes the externalize object occupies |
|
362 */ |
|
363 IMPORT_C TInt Size() const; |
|
364 |
|
365 protected: |
|
366 /** |
|
367 * Constructor |
|
368 */ |
|
369 CDRMDomainContext( const TTime& aExpiryTime, |
|
370 const TBool aHashChained ); |
|
371 |
|
372 private: |
|
373 |
|
374 |
|
375 /** |
|
376 * ConstructL |
|
377 * |
|
378 * Second phase constructor |
|
379 * |
|
380 * @since 3.0 |
|
381 * @param aContentID : Content Identifier |
|
382 * @param aContentHash : Content Hash |
|
383 * @param aRightsIssuer : Rights Issuer for this content |
|
384 * @return Functional CDRMDomainContext object, Function leaves if an error |
|
385 * occurs. |
|
386 */ |
|
387 void ConstructL( const TDesC8& aDomainID, |
|
388 const RPointerArray< HBufC8 > aDomainKeys, |
|
389 const TDesC8& aRightsIssuerID, |
|
390 const TDesC8& aRightsIssuerURL ); |
|
391 |
|
392 /** |
|
393 * Assignment operator - Prevented |
|
394 */ |
|
395 CDRMDomainContext& operator =( const CDRMDomainContext& ); |
|
396 |
|
397 /** |
|
398 * Copy constructor - Prevented |
|
399 */ |
|
400 CDRMDomainContext( const CDRMDomainContext& ); |
|
401 |
|
402 /** |
|
403 * WriteInt64L |
|
404 * |
|
405 * Writes the 64 bit integer to the stream |
|
406 * |
|
407 * @since 3.0 |
|
408 * @param aWrite : the 64 bit integer to write |
|
409 * @param aStream : the output stream to write to |
|
410 * @return The function leaves with Symbian OS error code if an |
|
411 * error occurs |
|
412 */ |
|
413 void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const; |
|
414 |
|
415 /** |
|
416 * ReadInt64L |
|
417 * |
|
418 * Reads the 64 bit integer from the stream |
|
419 * |
|
420 * @since 3.0 |
|
421 * @param aRead : the 64 bit integer read |
|
422 * @param aStream : the output stream to write to |
|
423 * @return The function leaves with Symbian OS error code if an |
|
424 * error occurs |
|
425 */ |
|
426 void ReadInt64L( TInt64& aRead, RReadStream& aStream ); |
|
427 |
|
428 private: // Internal Data |
|
429 |
|
430 // Domain identifier |
|
431 TBuf8< KDomainIdLength > iDomainID; |
|
432 |
|
433 // Expiry time |
|
434 TTime iExpiryTime; |
|
435 |
|
436 // Has chained domain key support |
|
437 TBool iHashChained; |
|
438 |
|
439 // Domain keys |
|
440 RPointerArray< HBufC8 > iDomainKeys; |
|
441 |
|
442 TBuf8< SHA1_HASH > iRightsIssuerID; |
|
443 |
|
444 // Rights issuer URL |
|
445 HBufC8* iRightsIssuerURL; |
|
446 }; |
|
447 |
|
448 #endif // DRMCOMMONDATA_H |
|
449 |
|
450 // End of File |