vpnengine/ikev2lib/src/Ikev2EapInterface.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-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:   Implementation of classes CIkev2EapIf.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <eap_vpn_if.h>
       
    19 #include "ikedebug.h"
       
    20 #include "ikev2EapInterface.h"
       
    21 #include "ikev2payloads.h"
       
    22 #include "ikev2const.h"
       
    23 #include "ikepolparser.h"
       
    24 #include "ikev2plugin.h"
       
    25 
       
    26 CIkev2EapIf* CIkev2EapIf::NewL(MIkev2EapIfObserver& aEapIfObserver, TUint8 aEapType, CIkeData* aIkeData, MIkeDebug& aDebug)
       
    27     {
       
    28     CIkev2EapIf* eapIf = new (ELeave)CIkev2EapIf(aEapIfObserver, aEapType, aDebug);
       
    29     CleanupStack::PushL(eapIf); 
       
    30     eapIf->ConstructL(aIkeData);
       
    31     CleanupStack::Pop(eapIf);    
       
    32     return eapIf;
       
    33     }
       
    34 
       
    35 CIkev2EapIf::CIkev2EapIf(MIkev2EapIfObserver& aEapIfObserver, TUint8 aEapType, MIkeDebug& aDebug)
       
    36 :iEapIfObserver(aEapIfObserver), iEapType(aEapType), iDebug(aDebug)
       
    37       {
       
    38       }
       
    39 
       
    40 void CIkev2EapIf::ConstructL(CIkeData* aIkeData)
       
    41     {
       
    42     //
       
    43     // Construct EAP ECOM plug-in library.
       
    44     // If ECOM plug-in loading fails return an error instead of leaving
       
    45     //
       
    46     DEBUG_LOG(_L("Constructing CEappluginInterface"));   
       
    47     iEapPlugin = CEapVpnInterface::NewL(this, ETrue);
       
    48     DEBUG_LOG(_L("Starting CEappluginInterface"));    
       
    49     iEapPlugin->StartL(iEapType);
       
    50 
       
    51     HBufC8* RealmPrefixBfr    = NULL;
       
    52     HBufC8* ManualRealmBfr    = NULL;
       
    53     HBufC8* ManualUserNameBfr = NULL;   
       
    54     TPtrC8 RealmPrefix(NULL,0);
       
    55     TPtrC8 ManualRealm(NULL,0);
       
    56     TPtrC8 ManualUserName(NULL,0);
       
    57     TBool HideIdentity(EFalse);
       
    58     if ( aIkeData )
       
    59         {
       
    60         HideIdentity = aIkeData->iEAPHideIdentity;
       
    61         if ( aIkeData->iEAPRealmPrefix )
       
    62             {    
       
    63             RealmPrefixBfr = aIkeData->iEAPRealmPrefix->GetAsciiDataL();
       
    64             if ( RealmPrefixBfr )
       
    65                 RealmPrefix.Set(RealmPrefixBfr->Des()); 
       
    66             }
       
    67         if ( aIkeData->iEAPManualRealm )
       
    68             {    
       
    69             ManualRealmBfr = aIkeData->iEAPManualRealm->GetAsciiDataL();
       
    70             if ( ManualRealmBfr )
       
    71                 ManualRealm.Set(ManualRealmBfr->Des()); 
       
    72             }   
       
    73         if ( aIkeData->iEAPManualUserName )
       
    74             {    
       
    75             ManualUserNameBfr = aIkeData->iEAPManualUserName->GetAsciiDataL();
       
    76             if ( ManualUserNameBfr )
       
    77                 ManualUserName.Set(ManualUserNameBfr->Des()); 
       
    78             }   
       
    79         } 
       
    80 
       
    81     DEBUG_LOG(_L("Calling CEappluginInterface::EapConfigure"));       
       
    82     iErrorStatus = iEapPlugin->EapConfigure(
       
    83       ManualUserName, ManualRealm, RealmPrefix, HideIdentity);
       
    84 
       
    85     delete RealmPrefixBfr;
       
    86     delete ManualRealmBfr;
       
    87     delete ManualUserNameBfr;   
       
    88     }
       
    89 
       
    90 CIkev2EapIf::~CIkev2EapIf()
       
    91     {
       
    92     delete iEapPlugin;
       
    93     delete iIdentity;
       
    94     delete iMSK;
       
    95     }
       
    96 
       
    97 void CIkev2EapIf::EapDataInbound(TPayloadIkev2* aEapPayload)
       
    98     {
       
    99     ASSERT(aEapPayload);
       
   100     //
       
   101     // Pass EAP payload data to EAP plug-in as inbound data
       
   102     //
       
   103     TInt Lth = (TInt)aEapPayload->PlDataLen();
       
   104     TPtrC8 EapData(aEapPayload->PayloadData(), Lth);
       
   105 
       
   106     DEBUG_LOG(_L("Calling CEappluginInterface::EapInbound"));         
       
   107     iEapPlugin->EapInbound(EapData);
       
   108     }
       
   109 
       
   110 void CIkev2EapIf::QueryIdentity()
       
   111     {
       
   112     //
       
   113     // Query identity information from EAP plugin for IKE Id
       
   114     //
       
   115     DEBUG_LOG(_L("Calling CEappluginInterface::QueryIdentity"));        
       
   116     iEapPlugin->QueryIdentity();
       
   117     }
       
   118 
       
   119 void CIkev2EapIf::EapOutboundL(HBufC8* aResponse)
       
   120     {
       
   121     //
       
   122     // Pass outgoing EAP data to IKEv2 plug-in 
       
   123     //
       
   124     DEBUG_LOG(_L("Data received from CEappluginInterface"));          
       
   125     iEapIfObserver.SendEapDataL(aResponse);
       
   126     }
       
   127 
       
   128 void CIkev2EapIf::EapIdentityResponseL(HBufC8* aResponse)
       
   129     {
       
   130     //
       
   131     // Pass Identity data to IKEv2 plug-in 
       
   132     //
       
   133     DEBUG_LOG(_L("Identity received from CEappluginInterface"));
       
   134     
       
   135     delete iIdentity; 
       
   136     iIdentity = aResponse;
       
   137     
       
   138     iEapIfObserver.EapEventL(KEapEventGetIdentity);
       
   139     }
       
   140 
       
   141 void CIkev2EapIf::EapSharedKeyL(HBufC8* aResponse)
       
   142     {
       
   143     //
       
   144     // Pass pre-shared key material to IKEv2 plug-in 
       
   145     //
       
   146     DEBUG_LOG(_L("MSK received from CEappluginInterface"));  
       
   147     
       
   148     delete iMSK; 
       
   149     iMSK = aResponse;
       
   150   
       
   151     iEapIfObserver.EapEventL(KEapEventGetPSK);
       
   152     }
       
   153 
       
   154 void CIkev2EapIf::EapIndication(TNotification aNotification) 
       
   155     {
       
   156     //
       
   157     // Pass EAP notification to IKEv2 plug-in 
       
   158     //
       
   159     DEBUG_LOG1(_L("EAP indication received from CEappluginInterface: %d"), aNotification);
       
   160     
       
   161     TRAP_IGNORE( aNotification == ESuccess ? 
       
   162         iEapIfObserver.EapEventL(KEapEventSuccess) :
       
   163         iEapIfObserver.EapEventL(KEapEventFailed) );
       
   164     }
       
   165