os/security/cryptoservices/filebasedcertificateandkeystores/test/thwkeystore/client/thwtokenclient.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 the License "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 "thwtokenclient.h"
    20 #include "thwkeystoreclient.h"
    21 
    22 _LIT(KTokenString, "Hardware plugin implementation");
    23 
    24 
    25 MCTToken* CHardwareTokenClient::NewL(MCTTokenType* aTokenType)
    26 	{
    27 	CHardwareTokenClient* self = new (ELeave) CHardwareTokenClient(aTokenType);
    28 	return static_cast<MCTToken*>(self);
    29 	}
    30 
    31 CHardwareTokenClient::CHardwareTokenClient(MCTTokenType* aTokenType)
    32 			:	iTokenType(aTokenType),
    33 				iRefCount(0)
    34 	{
    35 	}
    36 
    37 MCTTokenType& CHardwareTokenClient::TokenType()
    38 	{
    39 	return *iTokenType;
    40 	}
    41 
    42 const TDesC& CHardwareTokenClient::Label()
    43 	{
    44 	return KTokenString();
    45 	}
    46 
    47 TCTTokenHandle CHardwareTokenClient::Handle()
    48 	{
    49 	return (TCTTokenHandle(iTokenType->Type(), 0));
    50 	}
    51 
    52 TInt& CHardwareTokenClient::ReferenceCount()
    53 	{
    54 	return iRefCount;
    55 	}
    56 
    57 void CHardwareTokenClient::DoGetInterface(TUid aRequiredInterface, MCTTokenInterface*& aReturnedInterface, TRequestStatus& aStatus)
    58 	{
    59 	// No longer calls server to get the interface - just creates a client object of the appropriate type
    60 	TUid userUid = {0x101F7334};
    61 	TUid managerUid = {0x101F7335};
    62 
    63 	aReturnedInterface = NULL;
    64 	TInt err = KErrGeneral;
    65 	
    66 	if( userUid == aRequiredInterface || managerUid == aRequiredInterface )
    67 		{
    68 		TRAP(err, aReturnedInterface = CHardwareKeyStoreClient::NewKeyStoreInterfaceL(*this));
    69 		}
    70 						
    71 	if (NULL == aReturnedInterface)
    72 		{
    73 		Release();
    74 		}
    75 	
    76 	TRequestStatus* status = &aStatus;
    77 	User::RequestComplete(status, err);		
    78 	}
    79 
    80 TBool CHardwareTokenClient::DoCancelGetInterface()
    81 	{//	Not an asynchronous call for current file store, so nothing to do
    82 	return EFalse;
    83 	}
    84 
    85 const TDesC& CHardwareTokenClient::Information(TTokenInformation /*aRequiredInformation*/)
    86 	{
    87 	return KNullDesC;
    88 	}