omadrm/drmengine/roapstorage/inc/DRMRIContext.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2004 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 DRMRICONTEXT_H
       
    20 #define DRMRICONTEXT_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <hash.h>
       
    26 #include "RoapMessage.h"
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class RReadStream;
       
    36 class RWriteStream;
       
    37 
       
    38 // TYPE DEFINITIONS
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 *  CDRMRIContext implements a datatype for the common data for a single
       
    46 *  content identifier
       
    47 *
       
    48 *  @lib RightsServer.dll
       
    49 *  @since 3.0
       
    50 */
       
    51 
       
    52 class CDRMRIContext : public CBase 
       
    53     {
       
    54     
       
    55     public: // Constructors and destructor
       
    56         
       
    57         /**
       
    58         * NewLC
       
    59         *
       
    60         * Creates an instance of the CDRMRIContext class and returns a pointer 
       
    61         * to it. The function leaves the object into the cleanup stack
       
    62         *
       
    63         * @since    3.0
       
    64         * @param    aRIID : Rights issue identifier SHA1_HASH
       
    65         * @param    aRiAlias: RI Alias, extracted from RoapTrigger        
       
    66         * @param    aVersion : Selected version KMaxRoapVersionLength
       
    67         * @param    aAlgorithms : Algorithm strings
       
    68         * @param    aRIURLs : Rights issuer urls,
       
    69         * @param    aRightsIssuerURL: An URL that can be used for contactig the RI
       
    70         *                             (e,g, in the case where RI Context is expired)
       
    71         * @param    aExpiryTime : Expiration time
       
    72         * @param    aChain: The RI ceritificate chain
       
    73         * @param    aResponses: The OCSP responses for validating certificates
       
    74         *                       in the RI certificate chain
       
    75         * @param    aSelectedDeviceRoot: The selected certificate chain that is
       
    76         *           used for wrapping the REKs and Domain Keys. Presented as a
       
    77         *           public key hash of the root certificate
       
    78         * @param    aIsMeteringAllowed: Wheter metering is allowed for this RI
       
    79         *  
       
    80         * @return   Functional CDRMRIContext object, Function leaves if an error 
       
    81         *           occurs.
       
    82         */
       
    83         IMPORT_C static CDRMRIContext* NewLC( const TDesC8& aRIID,
       
    84                                               const TDesC8& aRiAlias,
       
    85                                               const TDesC8& aVersion,
       
    86                                               const RPointerArray< HBufC8 >& aAlgorithms,
       
    87                                               const RPointerArray< HBufC8 >& aRIURLs,
       
    88                                               const TDesC8& aRightsIssuerURL,
       
    89                                               const TTime& aExpiryTime,
       
    90                                               const RPointerArray< HBufC8 >& aChain,
       
    91                                               const RPointerArray< HBufC8 >& aResponses,
       
    92                                               const TUint8 aDeviceCertCached,
       
    93                                               const TDesC8& aSelectedDeviceRoot,
       
    94                                               const TUint8 aIsMeteringAllowed = ETrue );
       
    95         
       
    96         /**
       
    97         * NewL
       
    98         *
       
    99         * Creates an instance of the CDRMRIContext class and returns a pointer 
       
   100         * to it.
       
   101         *
       
   102         * @since    3.0
       
   103         * @param    aRIID : Rights issue identifier SHA1_HASH
       
   104         * @param    aRiAlias: RI Alias, extracted from RoapTrigger            
       
   105         * @param    aVersion : Selected version KMaxRoapVersionLength
       
   106         * @param    aAlgorithms : Algorithm strings
       
   107         * @param    aRIURLs : Rights issuer urls
       
   108         * @param    aExpiryTime : Expiration time
       
   109         * @param    aChain: The RI ceritificate chain
       
   110         * @param    aResponses: The OCSP responses for validating certificates
       
   111         *                       in the RI certificate chain        
       
   112         * @param    aSelectedDeviceRoot: The selected certificate chain that is
       
   113         *           used for wrapping the REKs and Domain Keys. Presented as a
       
   114         *           public key hash of the root certificate
       
   115         * @param    aIsMeteringAllowed: Wheter metering is allowed for this RI        
       
   116         *  
       
   117         * @return   Functional CDRMRIContext object, Function leaves if an error 
       
   118         *           occurs.
       
   119         */
       
   120         IMPORT_C static CDRMRIContext* NewL( const TDesC8& aRIID,
       
   121                                              const TDesC8& aRiAlias,        
       
   122                                              const TDesC8& aVersion,
       
   123                                              const RPointerArray< HBufC8 >& aAlgorithms,
       
   124                                              const RPointerArray< HBufC8 >& aRIURLs,
       
   125                                              const TDesC8& aRightsIssuerURL,
       
   126                                              const TTime& aExpiryTime,
       
   127                                              const RPointerArray< HBufC8 >& aChain,
       
   128                                              const RPointerArray< HBufC8 >& aResponses,
       
   129                                              const TUint8 aDeviceCertCached,
       
   130                                              const TDesC8& aSelectedDeviceRoot,
       
   131                                              const TUint8 aIsMeteringAllowed = ETrue );
       
   132 
       
   133         /**
       
   134         * NewLC
       
   135         *
       
   136         * Creates an instance of the CDRMRIContext class and returns a pointer 
       
   137         * to it. The function leaves the object into the cleanup stack
       
   138         *
       
   139         * @since    3.0
       
   140         * @return   Functional CDRMRIContext object, Function leaves if an error 
       
   141         *           occurs.
       
   142         */
       
   143         IMPORT_C static CDRMRIContext* NewLC();
       
   144         
       
   145         /**
       
   146         * NewL
       
   147         *
       
   148         * Creates an instance of the CDRMRIContext class and returns a pointer 
       
   149         * to it.
       
   150         *
       
   151         * @since    3.0
       
   152         * @return   Functional CDRMRIContext object, Function leaves if an error 
       
   153         *           occurs.
       
   154         */
       
   155         IMPORT_C static CDRMRIContext* NewL();
       
   156 
       
   157         /**
       
   158         * Destructor
       
   159         */
       
   160         IMPORT_C virtual ~CDRMRIContext();
       
   161         
       
   162   public: // Get and set functions
       
   163         
       
   164         /**
       
   165         * RIID
       
   166         * 
       
   167         * Returns a constant TDesC8 reference to the rights issuer id
       
   168         *
       
   169         * @since    3.0
       
   170         * @return   a const reference to the rights issuer id
       
   171         */        
       
   172         IMPORT_C const TDesC8& RIID() const;
       
   173         
       
   174         /**
       
   175         * RIAlias
       
   176         * 
       
   177         * Returns a constant TDesC8 reference to the rights issuer alias
       
   178         *
       
   179         * @since    3.2
       
   180         * @return   a const reference to the rights issuer alias
       
   181         */
       
   182         IMPORT_C const TDesC8& RIAlias() const;
       
   183         
       
   184         
       
   185         /**
       
   186         * Version
       
   187         * 
       
   188         * Returns a constant TDesC8 reference to the version
       
   189         *
       
   190         * @since    3.0
       
   191         * @return   a const reference to the rights issuer id
       
   192         */        
       
   193         IMPORT_C const TDesC8& Version() const;
       
   194         
       
   195 
       
   196         /**
       
   197         * Algorithms
       
   198         * 
       
   199         * Returns a constant reference to the algorithm pointer array
       
   200         *
       
   201         * @since    3.0
       
   202         * @return   a const reference to a pointer array with the algorithms
       
   203         */        
       
   204         IMPORT_C const RPointerArray< HBufC8 >& Algorithms() const;  
       
   205 
       
   206 
       
   207         /**
       
   208         * RIURLs
       
   209         * 
       
   210         * Returns a constant reference to the url pointer array
       
   211         *
       
   212         * @since    3.0
       
   213         * @return   a const reference to a pointer array with the right issuer
       
   214         *           urls
       
   215         */        
       
   216         IMPORT_C const RPointerArray< HBufC8 >& RIURLs() const;
       
   217         
       
   218         
       
   219         /**
       
   220         * RIURLs
       
   221         * 
       
   222         * Returns a constant reference to the rights issuer url
       
   223         *
       
   224         * @since    3.0
       
   225         * @return   a const reference to a the rights issuer url
       
   226         */
       
   227         IMPORT_C const TDesC8& RightsIssuerURL() const;
       
   228 
       
   229 
       
   230         /**
       
   231         * ExpiryTime
       
   232         *
       
   233         * Returns a constant reference to the expiration time
       
   234         *
       
   235         * @since    3.0
       
   236         * @return   a cont reference to the expiration time
       
   237         */
       
   238         IMPORT_C const TTime ExpiryTime() const;
       
   239 
       
   240         
       
   241         /**
       
   242         * CertificateChain
       
   243         * 
       
   244         * Returns a constant reference to the algorithm pointer array
       
   245         *
       
   246         * @since    3.0
       
   247         * @return   a const reference to a pointer array with the algorithms
       
   248         */       
       
   249         IMPORT_C const RPointerArray< HBufC8 >& CertificateChain() const;
       
   250 
       
   251 
       
   252         /**
       
   253         * OCSPResponse
       
   254         * 
       
   255         * Returns a constant reference to the algorithm pointer array
       
   256         *
       
   257         * @since    3.0
       
   258         * @return   a const reference to a pointer array with the algorithms
       
   259         */        
       
   260         IMPORT_C const RPointerArray< HBufC8 >& OCSPResponse() const;
       
   261         
       
   262 
       
   263         /**
       
   264         * DeviceCertCached
       
   265         * 
       
   266         * Returns an indication if the RI has stored the Device certificate or not
       
   267         *
       
   268         * @since    3.0
       
   269         * @return   EFalse or ETrue
       
   270         */         
       
   271         IMPORT_C TUint8 DeviceCertCached() const;
       
   272         
       
   273         /**
       
   274         * SelectedDeviceRoot
       
   275         * 
       
   276         * Returns a constant TDesC8 reference to the selected Device root
       
   277         *
       
   278         * @since    3.0
       
   279         * @return   a const reference to the selected Device root
       
   280         */      
       
   281         IMPORT_C const TDesC8& SelectedDeviceRoot() const;
       
   282 
       
   283         /**
       
   284         * IsMeteringAllowed
       
   285         * 
       
   286         * Checks wheter metering is allowed for a this RightsIssuer
       
   287         *
       
   288         * @since    3.2
       
   289         */        
       
   290         IMPORT_C TUint8 IsMeteringAllowed() const; 
       
   291 
       
   292         /**
       
   293         * SetRIIDL
       
   294         * 
       
   295         * Sets the rights issuer identifier, overwrites the previous one 
       
   296         * if one exits
       
   297         *
       
   298         * @since    3.0
       
   299         * @param    aRIID : Rights Issuer Identifier        
       
   300         * @return   The function leaves with Symbian OS error code if an
       
   301         *           error occurs
       
   302         */        
       
   303         IMPORT_C void SetRIIDL( const TDesC8& aRIID );
       
   304 
       
   305 
       
   306         /**
       
   307         * SetRightsIssuerURLL
       
   308         * 
       
   309         * Sets the RI URL, deletes the old one
       
   310         *
       
   311         * @since    3.0
       
   312         * @param    aRightsIssuerURL : a reference to the new rights issuer url
       
   313         */ 
       
   314         IMPORT_C void SetRightsIssuerURLL( const TDesC8& aRightsIssuerURL );        
       
   315         
       
   316          /**
       
   317         * SetVersionL
       
   318         * 
       
   319         * Sets the version, overwrites the previous one if one exits
       
   320         *
       
   321         * @since    3.0
       
   322         * @param    aVersion : version string       
       
   323         * @return   The function leaves with Symbian OS error code if an
       
   324         *           error occurs
       
   325         */        
       
   326         IMPORT_C void SetVersionL( const TDesC8& aRIID );    
       
   327            
       
   328 
       
   329         /**
       
   330         * SetAlgorithmsL
       
   331         * 
       
   332         * Sets the algorithms, deletes the old ones
       
   333         *
       
   334         * @since    3.0
       
   335         * @param    aAlgorithms : a pointer array with the used algorithms
       
   336         * @return   a pointer to the content id or null
       
   337         */        
       
   338         IMPORT_C void SetAlgorithmsL( const RPointerArray< HBufC8 >& aAlgorithms ); 
       
   339         
       
   340         
       
   341         /**
       
   342         * SetRIURLsL
       
   343         * 
       
   344         * Sets the algorithms, deletes the old ones
       
   345         *
       
   346         * @since    3.0
       
   347         * @param    aRIURLs : a pointer array with the rights issuer urls       
       
   348         * @return   a pointer to the content id or null
       
   349         */        
       
   350         IMPORT_C void SetRIURLsL( const RPointerArray< HBufC8 >& aRIURLs );        
       
   351              
       
   352         /**
       
   353         * SetExpiryTimeL
       
   354         * 
       
   355         * Sets the expiration time to the given value
       
   356         *
       
   357         * @since    3.0
       
   358         * @param    aExpiryTime : the expiration time        
       
   359         * @return   The function leaves with Symbian OS error code if an
       
   360         *           error occurs
       
   361         */        
       
   362         IMPORT_C void SetExpiryTimeL( const TTime& aExpiryTime );
       
   363 
       
   364          /**
       
   365         * SetCertificateChainL
       
   366         * 
       
   367         * Sets the certificate chain
       
   368         *
       
   369         * @since    3.0
       
   370         * @param    aChain : the certificate chain        
       
   371         * @return   The function leaves with Symbian OS error code if an
       
   372         *           error occurs
       
   373         */          
       
   374         IMPORT_C void SetCertificateChainL( const RPointerArray< HBufC8 >& aChain );
       
   375         
       
   376          /**
       
   377         * SetOCSPResponseL
       
   378         * 
       
   379         * Sets the OCSP responses
       
   380         *
       
   381         * @since    3.0
       
   382         * @param    aResponses : the OCSP responses      
       
   383         * @return   The function leaves with Symbian OS error code if an
       
   384         *           error occurs
       
   385         */         
       
   386         IMPORT_C void SetOCSPResponseL( const RPointerArray< HBufC8 >& aResponses );
       
   387         
       
   388          /**
       
   389         * SetDeviceCertCached
       
   390         * 
       
   391         * Sets the indication whether the RI has stored the Device public key or not
       
   392         *
       
   393         * @since    3.0
       
   394         * @param    aIsCached : The certificate caching indication (ETrue/EFalse)     
       
   395         */         
       
   396         IMPORT_C void SetDeviceCertCached( TUint8& aIsCached );
       
   397 
       
   398         /**
       
   399         * WhiteListURLExistsL
       
   400         * 
       
   401         * Checks the white list to see if the url is in the list
       
   402         *
       
   403         * @since    3.0
       
   404         * @param    aURL : the URL to look for       
       
   405         * @return   ETrue if the url is in the white list
       
   406         *           EFalse if it is not
       
   407         */    
       
   408         IMPORT_C TBool WhiteListURLExistsL( const TDesC8& aURL ) const;
       
   409         
       
   410         
       
   411         /**
       
   412         * SetSelectedDeviceRoot
       
   413         * 
       
   414         * Sets the selected Device root, overwrites the previous one 
       
   415         * if one exits
       
   416         *
       
   417         * @since    3.0
       
   418         * @param    aSelectedDeviceRoot : Hash of the root certificate public key
       
   419         */        
       
   420         IMPORT_C void SetSelectedDeviceRoot( const TDesC8& aSelectedDeviceRoot );
       
   421 
       
   422         /**
       
   423         * SetMeteringStatus
       
   424         * 
       
   425         * Sets the value for metering to be enabled or disabled
       
   426         *
       
   427         * @since    3.2
       
   428         * @param    aIsAllowed : ETrue if set to allowed, EFalse if not allowed
       
   429         */        
       
   430         IMPORT_C void SetMeteringStatus( const TBool aIsAllowed );               
       
   431                      
       
   432     public: // Storing functions
       
   433         /**
       
   434         * ExternalizeL
       
   435         * 
       
   436         * Writes the data of the object into the stream
       
   437         *
       
   438         * @since    3.0
       
   439         * @param    aStream : the output stream to write to
       
   440         * @return   The function leaves with Symbian OS error code if an
       
   441         *           error occurs
       
   442         */
       
   443         IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
       
   444         
       
   445         /**
       
   446         * InternalizeL
       
   447         * 
       
   448         * Reads the data of the object from the stream
       
   449         *
       
   450         * @since    3.0
       
   451         * @param    aStream : the output stream to write to
       
   452         * @return   The function leaves with Symbian OS error code if an
       
   453         *           error occurs
       
   454         */
       
   455         IMPORT_C void InternalizeL( RReadStream& aStream );   
       
   456 
       
   457 
       
   458         /**
       
   459         * ImportL
       
   460         * 
       
   461         * Reads the data of the object from the descriptor and initialized the 
       
   462         * object accordingly
       
   463         *
       
   464         * @since    3.0
       
   465         * @param    aBuffer : the buffer containing the data of the imported object
       
   466         * @return   None, The function leaves with Symbian OS error code if an
       
   467         *           error occurs
       
   468         */
       
   469         IMPORT_C void ImportL( const TDesC8& aBuffer );
       
   470     
       
   471         /**
       
   472         * ExportL
       
   473         * 
       
   474         * Writes the data of the object into an HBufC8 and returns a pointer
       
   475         * to it. The caller is responsible for deleting the object.
       
   476         *
       
   477         * @since    3.0
       
   478         * @return   Returns an HBufC8* containing the data of the object,
       
   479         *           The function leaves with Symbian OS error code if an
       
   480         *           error occurs
       
   481         */
       
   482         IMPORT_C HBufC8* ExportL() const; 
       
   483        
       
   484         
       
   485         /**
       
   486         * Size
       
   487         *
       
   488         * Returns the size of the externalized object
       
   489         *
       
   490         * @since    3.0
       
   491         * @return   the amount of bytes the externalize object occupies
       
   492         */           
       
   493         IMPORT_C TInt Size() const;
       
   494         
       
   495     private:
       
   496         /**
       
   497         * Default constructor
       
   498         */
       
   499         CDRMRIContext();    
       
   500     
       
   501         /**
       
   502         * ConstructL
       
   503         *
       
   504         * Second phase constructor
       
   505         *
       
   506         * @since    3.0
       
   507         * @param    aRIID : Rights issuer identifier SHA1_HASH
       
   508         * @param    aRiAlias : Rights issuer alias from RoapTrigger        
       
   509         * @param    aVersion : Selected version KMaxRoapVersionLength
       
   510         * @param    aAlgorithms : Algorithm strings
       
   511         * @param    aRIURLs : Rights issuer urls,
       
   512         * @param    aRightsIssuerURL: An URL that can be used for contactig the RI
       
   513         *                             (e,g, in the case where RI Context is expired)
       
   514         * @param    aExpiryTime : Expiration time
       
   515         * @param    aChain: The RI ceritificate chain
       
   516         * @param    aResponses: The OCSP responses for validating certificates
       
   517         *                       in the RI certificate chain
       
   518         * @param    aSelectedDeviceRoot: The selected certificate chain that is
       
   519         *           used for wrapping the REKs and Domain Keys. Presented as a
       
   520         *           public key hash of the root certificate
       
   521         * @param    aIsMeteringAllowed: Wheter metering is allowed for this RI
       
   522         *        
       
   523         * @return   Functional CDRMRIContext object, Function leaves if an error 
       
   524         *           occurs.
       
   525         */  
       
   526         void ConstructL( const TDesC8& aRIID,
       
   527                          const TDesC8& aRiAlias,
       
   528                          const TDesC8& aVersion,
       
   529                          const RPointerArray< HBufC8 >& aAlgorithms,
       
   530                          const RPointerArray< HBufC8 >& aRIURLs,
       
   531                          const TDesC8& aRightsIssuerURL,
       
   532                          const TTime& aExpiryTime,
       
   533                          const RPointerArray< HBufC8 >& aChain,
       
   534                          const RPointerArray< HBufC8 >& aResponses,
       
   535                          const TUint8 aDeviceCertCached,
       
   536                          const TDesC8& aSelectedDeviceRoot,
       
   537                          const TUint8 aIsMeteringAllowed );
       
   538 
       
   539         /**
       
   540         * Assignment operator - Prevented
       
   541         */
       
   542         CDRMRIContext& operator =( const CDRMRIContext& );    
       
   543     
       
   544         /**
       
   545         * Copy constructor - Prevented
       
   546         */
       
   547         CDRMRIContext( const CDRMRIContext& );                
       
   548 
       
   549         /**
       
   550         * WriteInt64L
       
   551         * 
       
   552         * Writes the 64 bit integer to the stream
       
   553         *
       
   554         * @since    3.0
       
   555         * @param    aWrite : the 64 bit integer to write
       
   556         * @param    aStream : the output stream to write to
       
   557         * @return   The function leaves with Symbian OS error code if an
       
   558         *           error occurs
       
   559         */
       
   560         void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
       
   561 
       
   562         /**
       
   563         * ReadInt64L
       
   564         * 
       
   565         * Reads the 64 bit integer from the stream
       
   566         *
       
   567         * @since    3.0
       
   568         * @param    aRead : the 64 bit integer read
       
   569         * @param    aStream : the output stream to write to
       
   570         * @return   The function leaves with Symbian OS error code if an
       
   571         *           error occurs
       
   572         */
       
   573         void ReadInt64L( TInt64& aRead, RReadStream& aStream ); 
       
   574 
       
   575 
       
   576     private: // Internal Data
       
   577     
       
   578         // Rights Issuer identifier
       
   579         TBuf8<SHA1_HASH> iRIID;
       
   580         
       
   581         // Rights Issuer Alias
       
   582         HBufC8* iRiAlias;
       
   583         
       
   584         // Selected Version
       
   585         TBuf8<Roap::KMaxRoapVersionLength> iVersion;
       
   586         
       
   587         // Selected Algorithms
       
   588         RPointerArray< HBufC8 > iAlgorithms;
       
   589         
       
   590         // Domain name white list
       
   591         RPointerArray< HBufC8 > iRIURLs;
       
   592         
       
   593         // Rights issuer URL
       
   594         HBufC8* iRightsIssuerURL;
       
   595         
       
   596         // Rights issuer context expiry time
       
   597         TTime iExpiryTime;
       
   598 
       
   599         // Rights issuer certificate chain        
       
   600         RPointerArray<HBufC8> iCertificateChain;
       
   601 
       
   602         // OCSP responses for validating certificates       
       
   603         RPointerArray<HBufC8> iOcspResponse;
       
   604 
       
   605         // Certificate caching indication (has an RI stored the Device certificate)        
       
   606         TUint8 iDeviceCertCached;
       
   607         
       
   608         // The selected Device certificate chain
       
   609         TBuf8<SHA1_HASH> iSelectedDeviceRoot;
       
   610         
       
   611         // The status of metering allowance
       
   612         TUint8 iIsMeteringAllowed;
       
   613     };
       
   614 
       
   615 #endif      // DRMRICONTEXT_H   
       
   616             
       
   617 // End of File