os/security/cryptoservices/filebasedcertificateandkeystores/test/thwkeystore/client/thwtokenclient.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/thwkeystore/client/thwtokenclient.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,88 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "thwtokenclient.h"
    1.23 +#include "thwkeystoreclient.h"
    1.24 +
    1.25 +_LIT(KTokenString, "Hardware plugin implementation");
    1.26 +
    1.27 +
    1.28 +MCTToken* CHardwareTokenClient::NewL(MCTTokenType* aTokenType)
    1.29 +	{
    1.30 +	CHardwareTokenClient* self = new (ELeave) CHardwareTokenClient(aTokenType);
    1.31 +	return static_cast<MCTToken*>(self);
    1.32 +	}
    1.33 +
    1.34 +CHardwareTokenClient::CHardwareTokenClient(MCTTokenType* aTokenType)
    1.35 +			:	iTokenType(aTokenType),
    1.36 +				iRefCount(0)
    1.37 +	{
    1.38 +	}
    1.39 +
    1.40 +MCTTokenType& CHardwareTokenClient::TokenType()
    1.41 +	{
    1.42 +	return *iTokenType;
    1.43 +	}
    1.44 +
    1.45 +const TDesC& CHardwareTokenClient::Label()
    1.46 +	{
    1.47 +	return KTokenString();
    1.48 +	}
    1.49 +
    1.50 +TCTTokenHandle CHardwareTokenClient::Handle()
    1.51 +	{
    1.52 +	return (TCTTokenHandle(iTokenType->Type(), 0));
    1.53 +	}
    1.54 +
    1.55 +TInt& CHardwareTokenClient::ReferenceCount()
    1.56 +	{
    1.57 +	return iRefCount;
    1.58 +	}
    1.59 +
    1.60 +void CHardwareTokenClient::DoGetInterface(TUid aRequiredInterface, MCTTokenInterface*& aReturnedInterface, TRequestStatus& aStatus)
    1.61 +	{
    1.62 +	// No longer calls server to get the interface - just creates a client object of the appropriate type
    1.63 +	TUid userUid = {0x101F7334};
    1.64 +	TUid managerUid = {0x101F7335};
    1.65 +
    1.66 +	aReturnedInterface = NULL;
    1.67 +	TInt err = KErrGeneral;
    1.68 +	
    1.69 +	if( userUid == aRequiredInterface || managerUid == aRequiredInterface )
    1.70 +		{
    1.71 +		TRAP(err, aReturnedInterface = CHardwareKeyStoreClient::NewKeyStoreInterfaceL(*this));
    1.72 +		}
    1.73 +						
    1.74 +	if (NULL == aReturnedInterface)
    1.75 +		{
    1.76 +		Release();
    1.77 +		}
    1.78 +	
    1.79 +	TRequestStatus* status = &aStatus;
    1.80 +	User::RequestComplete(status, err);		
    1.81 +	}
    1.82 +
    1.83 +TBool CHardwareTokenClient::DoCancelGetInterface()
    1.84 +	{//	Not an asynchronous call for current file store, so nothing to do
    1.85 +	return EFalse;
    1.86 +	}
    1.87 +
    1.88 +const TDesC& CHardwareTokenClient::Information(TTokenInformation /*aRequiredInformation*/)
    1.89 +	{
    1.90 +	return KNullDesC;
    1.91 +	}