xmlsecurityengine/xmlsecwrapper/src/xmlsecwkeymanager.cpp
changeset 0 e35f40988205
child 24 74f0b3eb154c
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 /*
       
     2 * Copyright (c) 2009 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: Key manager functionality       
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 
       
    21 #include <libxml2_globals.h>
       
    22 #include <xmlengmem.h>
       
    23 
       
    24 #include "xmlsec_crypto.h"
       
    25 #include "xmlsec_xmlsec.h"
       
    26 
       
    27 #include "xmlsecwkeymanager.h"
       
    28 #include "xmlsecwerrors.h"
       
    29 #include "xmlsecwglobalstate.h"
       
    30 #include "xmlsecwinternalutils.h"
       
    31     
       
    32 // ---------------------------------------------------------------------------
       
    33 // Get instance of key manager.
       
    34 // ---------------------------------------------------------------------------
       
    35 // 
       
    36 CXmlSecKeyManager* CXmlSecKeyManager::GetInstanceL()
       
    37     {
       
    38     XmlSecGlobalState* gs = XmlSecGetTls();
       
    39     CXmlSecKeyManager* self = gs->iKeyManager;
       
    40     if(!self)
       
    41         {
       
    42         self = new (ELeave) CXmlSecKeyManager;
       
    43         CleanupStack::PushL(self);
       
    44         self->ConstructL();
       
    45         CleanupStack::Pop(self);
       
    46         gs->iKeyManager = self;
       
    47         }
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Return pointer to key manager (XMLSEC)
       
    53 // ---------------------------------------------------------------------------
       
    54 //  
       
    55 xmlSecKeysMngr* CXmlSecKeyManager::GetKeyManagerPtr()
       
    56     {
       
    57     return iKeyManager;
       
    58     }
       
    59     
       
    60 // ---------------------------------------------------------------------------
       
    61 // Destructor
       
    62 // ---------------------------------------------------------------------------
       
    63 // 
       
    64 CXmlSecKeyManager::~CXmlSecKeyManager()
       
    65     {
       
    66     if(iKeyManager)
       
    67         {
       
    68         xmlSecKeysMngrDestroy(iKeyManager);
       
    69         }
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Second phase constructor
       
    74 // ---------------------------------------------------------------------------
       
    75 // 
       
    76 void CXmlSecKeyManager::ConstructL()
       
    77     {
       
    78     iKeyManager = xmlSecKeysMngrCreate();
       
    79     if(!iKeyManager) 
       
    80         {
       
    81         XmlEngOOMTestL();
       
    82         XmlSecErrorFlagTestL();
       
    83         User::Leave(KErrKeyManagerInit);
       
    84         }
       
    85 
       
    86     if(xmlSecCryptoAppDefaultKeysMngrInit(iKeyManager) < 0)
       
    87         {
       
    88     	xmlSecKeysMngrDestroy(iKeyManager);
       
    89     	iKeyManager = NULL;
       
    90         XmlEngOOMTestL();
       
    91         XmlSecErrorFlagTestL();
       
    92     	User::Leave(KErrKeyManagerInit);
       
    93         }    
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // Constructor
       
    98 // ---------------------------------------------------------------------------
       
    99 // 
       
   100 CXmlSecKeyManager::CXmlSecKeyManager()
       
   101     {
       
   102     }