javaextensions/satsa/apdu/src.s60/cstsacie.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 "cstsacie.h"
       
    22 #include "cstspath.h"
       
    23 
       
    24 namespace java
       
    25 {
       
    26 namespace satsa
       
    27 {
       
    28 
       
    29 // CONSTANTS
       
    30 const TInt KSTSMinNumberOfSubModules = 1;
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSTSAcie::CSTSAcie
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CSTSAcie::CSTSAcie()
       
    41 {
       
    42 }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSTSAcie::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CSTSAcie::ConstructL()
       
    50 {
       
    51     // creating with empty values
       
    52     iAid = KNullDesC8().AllocL();
       
    53     iACFPath = CSTSPath::NewL();
       
    54 }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSTSAcie::NewL
       
    58 // Two-phased constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CSTSAcie* CSTSAcie::NewLC()
       
    62 {
       
    63     CSTSAcie* self = new(ELeave) CSTSAcie();
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL();
       
    66     return self;
       
    67 }
       
    68 
       
    69 // Destructor
       
    70 CSTSAcie::~CSTSAcie()
       
    71 {
       
    72     delete iAid;
       
    73     delete iACFPath;
       
    74 }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CSTSAcie::DecodeL
       
    78 // Decrypts raw data to this instance
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------------------------
       
    81 void CSTSAcie::DecodeL(const TDesC8& aRawData)
       
    82 {
       
    83     CArrayPtr<TASN1DecGeneric>* itemsData = DecodeSequenceLC(ETrue, //must be sequence
       
    84                                             aRawData, KSTSMinNumberOfSubModules);
       
    85 
       
    86     // we would not get this far if there is not 1 element at minimum
       
    87     TInt pos = 0;
       
    88     //decoding optional aid (octet string)
       
    89     if ((pos < itemsData->Count()) && (itemsData->At(0)->Tag()
       
    90                                        == EASN1OctetString))
       
    91     {
       
    92         TASN1DecOctetString aid;
       
    93         HBufC8* tmp = aid.DecodeDERL(*itemsData->At(pos++));
       
    94         delete iAid;
       
    95         iAid = tmp;
       
    96     }
       
    97     CSTSPath* acfPath = CSTSPath::NewLC();
       
    98     acfPath->DecodeL(itemsData->At(pos)->Encoding());
       
    99     CleanupStack::Pop(acfPath);
       
   100     delete iACFPath;
       
   101     iACFPath = acfPath;
       
   102     CleanupStack::PopAndDestroy(itemsData);
       
   103 
       
   104 }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CSTSAcie::AID
       
   108 // Getter for aid
       
   109 // (other items were commented in a header).
       
   110 // -----------------------------------------------------------------------------
       
   111 const TDesC8& CSTSAcie::AID() const
       
   112 {
       
   113     return *iAid;
       
   114 }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CSTSAcie::ACFPath
       
   118 // Getter for ACF path
       
   119 // (other items were commented in a header).
       
   120 // -----------------------------------------------------------------------------
       
   121 const CSTSPath& CSTSAcie::ACFPath() const
       
   122 {
       
   123     return *iACFPath;
       
   124 }
       
   125 
       
   126 } // namespace satsa
       
   127 } // namespace java
       
   128 //  End of File