javaextensions/satsa/apdu/src.s60/cstsapdumaskpermission.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <asn1dec.h>
       
    21 #include "cstsapdumaskpermission.h"
       
    22 
       
    23 namespace java
       
    24 {
       
    25 namespace satsa
       
    26 {
       
    27 
       
    28 // CONSTANTS
       
    29 const TInt KSTSMinNumberOfSubModules = 2;
       
    30 const TInt KSTSMaxNumberOfSubModules = 2;
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSTSAPDUMaskPermission::CSTSAPDUMaskPermission
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CSTSAPDUMaskPermission::CSTSAPDUMaskPermission()
       
    41 {
       
    42 }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSTSAPDUMaskPermission::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CSTSAPDUMaskPermission::ConstructL()
       
    50 {
       
    51     // creating with empty values
       
    52     iApduMask = KNullDesC8().AllocL();
       
    53     iApduHeader = KNullDesC8().AllocL();
       
    54 }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSTSAPDUMaskPermission::NewL
       
    58 // Two-phased constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CSTSAPDUMaskPermission* CSTSAPDUMaskPermission::NewLC()
       
    62 {
       
    63     CSTSAPDUMaskPermission* self = new(ELeave) CSTSAPDUMaskPermission();
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL();
       
    66     return self;
       
    67 }
       
    68 
       
    69 // Destructor
       
    70 CSTSAPDUMaskPermission::~CSTSAPDUMaskPermission()
       
    71 {
       
    72     delete iApduMask;
       
    73     delete iApduHeader;
       
    74 }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CSTSAPDUMaskPermission::DecodeL
       
    78 // Decrypts raw data to this instance
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------------------------
       
    81 void CSTSAPDUMaskPermission::DecodeL(const TDesC8& aRawData)
       
    82 {
       
    83     CArrayPtr<TASN1DecGeneric>* itemsData = DecodeSequenceLC(EFalse, //no need to check sequence tag
       
    84                                             aRawData, KSTSMinNumberOfSubModules, KSTSMaxNumberOfSubModules);
       
    85     // we would not get this far if there is not 2 elements
       
    86     TInt pos = 0;
       
    87 
       
    88     //decoding apdu header (octet string)
       
    89     TASN1DecOctetString apduHeader;
       
    90     HBufC8* tmpHeader = apduHeader.DecodeDERL(*itemsData->At(pos++));
       
    91     CleanupStack::PushL(tmpHeader);
       
    92 
       
    93     //decoding apdu mask (octet string)
       
    94     TASN1DecOctetString apduMask;
       
    95     HBufC8* tmpMask = apduMask.DecodeDERL(*itemsData->At(pos++));
       
    96 
       
    97     CleanupStack::Pop(tmpHeader);
       
    98     delete iApduHeader;
       
    99     iApduHeader = tmpHeader;
       
   100     delete iApduMask;
       
   101     iApduMask = tmpMask;
       
   102 
       
   103     CleanupStack::PopAndDestroy(itemsData);
       
   104 
       
   105 }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CSTSAPDUMaskPermission::ApduMask
       
   109 // Getter for apdu mask
       
   110 // (other items were commented in a header).
       
   111 // -----------------------------------------------------------------------------
       
   112 const TDesC8& CSTSAPDUMaskPermission::ApduMask() const
       
   113 {
       
   114     return *iApduMask;
       
   115 }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CSTSAPDUMaskPermission::ApduHeader
       
   119 // Getter for apdu header
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 const TDesC8& CSTSAPDUMaskPermission::ApduHeader() const
       
   123 {
       
   124     return *iApduHeader;
       
   125 }
       
   126 
       
   127 } // namespace satsa
       
   128 } // namespace java
       
   129 //  End of File