javaextensions/satsa/apdu/src.s60/cstsmidletinfo.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     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 "cstsmidletinfo.h"
       
    21 
       
    22 namespace java
       
    23 {
       
    24 namespace satsa
       
    25 {
       
    26 
       
    27 //CONSTANTS
       
    28 
       
    29 // Domain category OID value
       
    30 _LIT(KSTSDomainOperator, "1.3.6.1.4.1.42.2.110.2.2.2.1");
       
    31 const TInt KSTSDomainOperatorLength = 16;
       
    32 _LIT(KDom, "OPD");
       
    33 const TInt KSTSDomNameLength = 6;
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CSTSMidletInfo::CSTSMidletInfo
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CSTSMidletInfo::CSTSMidletInfo()
       
    43 {
       
    44 }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSTSMidletInfo::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CSTSMidletInfo::ConstructL(const TDesC& aName, const TDesC& aVendor,
       
    52                                 const TDesC& aVersion, const TDesC& aDomain, const TDesC& aRoot,
       
    53                                 const TDesC& aEnd)
       
    54 {
       
    55 
       
    56     iName = aName.AllocL();
       
    57     iVendor = aVendor.AllocL();
       
    58     iVersion = aVersion.AllocL();
       
    59     iDomain = aDomain.AllocL();
       
    60     iRootCert = aRoot.AllocL();
       
    61     iSignCert = aEnd.AllocL();
       
    62     iDomainOID = KNullDesC().AllocL();
       
    63 }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CSTSMidletInfo::NewLC
       
    67 // Two-phased constructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CSTSMidletInfo* CSTSMidletInfo::NewLC(const TDesC& aName, const TDesC& aVendor,
       
    71                                       const TDesC& aVersion, const TDesC& aDomain, const TDesC& aRoot,
       
    72                                       const TDesC& aEnd)
       
    73 {
       
    74     CSTSMidletInfo* self = new(ELeave) CSTSMidletInfo();
       
    75     CleanupStack::PushL(self);
       
    76     self->ConstructL(aName, aVendor, aVersion, aDomain, aRoot, aEnd);
       
    77     return self;
       
    78 }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CSTSMidletInfo::NewL
       
    82 // Two-phased constructor.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CSTSMidletInfo* CSTSMidletInfo::NewL(const TDesC& aName, const TDesC& aVendor,
       
    86                                      const TDesC& aVersion, const TDesC& aDomain, const TDesC& aRoot,
       
    87                                      const TDesC& aEnd)
       
    88 {
       
    89     CSTSMidletInfo* self = CSTSMidletInfo::NewLC(aName, aVendor, aVersion,
       
    90                            aDomain, aRoot, aEnd);
       
    91 
       
    92     CleanupStack::Pop(self);
       
    93 
       
    94     return self;
       
    95 }
       
    96 
       
    97 // Destructor
       
    98 CSTSMidletInfo::~CSTSMidletInfo()
       
    99 {
       
   100     delete iName;
       
   101     delete iVendor;
       
   102     delete iVersion;
       
   103     delete iDomain;
       
   104     delete iRootCert;
       
   105     delete iSignCert;
       
   106     delete iDomainOID;
       
   107     iRootIds.ResetAndDestroy();
       
   108     iRootIds.Close();
       
   109     iEndEntityIds.ResetAndDestroy();
       
   110     iEndEntityIds.Close();
       
   111 }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CSTSMidletInfo::Name
       
   115 // Getter for Name
       
   116 // -----------------------------------------------------------------------------
       
   117 const TDesC& CSTSMidletInfo::Name() const
       
   118 {
       
   119     return *iName;
       
   120 }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CSTSMidletInfo::Vendor
       
   124 // Getter for Vendor
       
   125 // -----------------------------------------------------------------------------
       
   126 const TDesC& CSTSMidletInfo::Vendor() const
       
   127 {
       
   128     return *iVendor;
       
   129 }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CSTSMidletInfo::Version
       
   133 // Getter for Version
       
   134 // -----------------------------------------------------------------------------
       
   135 const TDesC& CSTSMidletInfo::Version() const
       
   136 {
       
   137     return *iVersion;
       
   138 }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CSTSMidletInfo::Version
       
   142 // Getter for Version
       
   143 // -----------------------------------------------------------------------------
       
   144 const TDesC& CSTSMidletInfo::Domain() const
       
   145 {
       
   146     return *iDomain;
       
   147 }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CSTSMidletInfo::DomainOIDL
       
   151 // Getter for domain OID value
       
   152 // -----------------------------------------------------------------------------
       
   153 const TDesC& CSTSMidletInfo::DomainOID()
       
   154 {
       
   155 
       
   156     TBufC16<KSTSDomNameLength> buf1(KDom);
       
   157     HBufC* domain = buf1.AllocLC();
       
   158 
       
   159     if (domain->Compare(iDomain->Des()))
       
   160     {
       
   161         TBufC<KSTSDomainOperatorLength> buf2(KSTSDomainOperator);
       
   162         HBufC* tmp = buf2.AllocL();
       
   163         delete iDomainOID;
       
   164         iDomainOID = tmp;
       
   165     }
       
   166     else
       
   167     {
       
   168         //at this point this is not needed, because oid value is not
       
   169         //specified anywhere
       
   170     }
       
   171 
       
   172     return *iDomainOID;
       
   173 }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CSTSMidletInfo::RootID
       
   177 // Getter for root ID values (hash of the root certificate)
       
   178 // -----------------------------------------------------------------------------
       
   179 const TDesC& CSTSMidletInfo::RootID() const
       
   180 {
       
   181     return *iRootCert;
       
   182 }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CSTSMidletInfo::EndEntityID
       
   186 // Getter for end entity ID value (hash of the end entity certificate)
       
   187 // -----------------------------------------------------------------------------
       
   188 const TDesC& CSTSMidletInfo::EndEntityID() const
       
   189 {
       
   190     return *iSignCert;
       
   191 }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CSTSMidletInfo::SetDomainOIDL
       
   195 //
       
   196 // -----------------------------------------------------------------------------
       
   197 void CSTSMidletInfo::SetDomainOIDL(const TDesC& aDomainOID)
       
   198 {
       
   199 
       
   200     HBufC* tmp = aDomainOID.AllocL();
       
   201     delete iDomainOID;
       
   202     iDomainOID = tmp;
       
   203 
       
   204 }
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CSTSMidletInfo::AppendEndEntityIdL
       
   208 // Appends end entity ID value (hash of the end entity certificate) to array
       
   209 // -----------------------------------------------------------------------------
       
   210 void CSTSMidletInfo::AppendEndEntityIdL(const TDesC8& aEndEntityId)
       
   211 {
       
   212     HBufC8* endEntityBuf = aEndEntityId.AllocLC();
       
   213     //array takes the ownership
       
   214     User::LeaveIfError(iEndEntityIds.Append(endEntityBuf));
       
   215     CleanupStack::Pop(endEntityBuf);
       
   216 
       
   217 }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // CSTSMidletInfo::AppendRootIdL
       
   221 // Appends end entity ID value (hash of the end entity certificate) to array
       
   222 // -----------------------------------------------------------------------------
       
   223 void CSTSMidletInfo::AppendRootIdL(const TDesC8& aRootId)
       
   224 {
       
   225     HBufC8* rootBuf = aRootId.AllocLC();
       
   226     //array takes the ownership
       
   227     User::LeaveIfError(iRootIds.Append(rootBuf));
       
   228     CleanupStack::Pop(rootBuf);
       
   229 
       
   230 }
       
   231 
       
   232 } // namespace satsa
       
   233 } // namespace java
       
   234 //  End of File