os/security/cryptoservices/certificateandkeymgmt/swicertstore/CSWICertStoreToken.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/swicertstore/CSWICertStoreToken.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,125 @@
1.4 +/*
1.5 +* Copyright (c) 2004-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 "CSWICertStoreToken.h"
1.23 +#include "CSWICertStoreTokenType.h"
1.24 +#include <swicertstore.h>
1.25 +
1.26 +_LIT(KSWICertStoreTokenLabel, "SWI cert store");
1.27 +_LIT(KSWICertStoreVersion, "1.00");
1.28 +_LIT(KSWICertStoreSerialNo, "N/A");
1.29 +_LIT(KSWICertStoreManufacturer, "Symbian Software Ltd.");
1.30 +
1.31 +CSWICertStoreToken::CSWICertStoreToken(CCTTokenType& aTokenType) :
1.32 + iTokenType(aTokenType)
1.33 + {
1.34 + }
1.35 +
1.36 +CSWICertStoreToken::~CSWICertStoreToken()
1.37 + {
1.38 + }
1.39 +
1.40 +MCTTokenType& CSWICertStoreToken::TokenType()
1.41 + {
1.42 + return iTokenType;
1.43 + }
1.44 +
1.45 +const TDesC& CSWICertStoreToken::Label()
1.46 + {
1.47 + return KSWICertStoreTokenLabel;
1.48 + }
1.49 +
1.50 +TCTTokenHandle CSWICertStoreToken::Handle()
1.51 + {
1.52 + TUid tokenTypeUid = { KSWICertStoreTokenTypeUid };
1.53 + return TCTTokenHandle(tokenTypeUid, 0);
1.54 + }
1.55 +
1.56 +TInt& CSWICertStoreToken::ReferenceCount()
1.57 + {
1.58 + return iRefCount;
1.59 + }
1.60 +
1.61 +void CSWICertStoreToken::DoGetInterface(TUid aRequiredInterface,
1.62 + MCTTokenInterface*& aReturnedInterface,
1.63 + TRequestStatus& aStatus)
1.64 + {
1.65 + TInt result = KErrNone;
1.66 +
1.67 + if (aRequiredInterface.iUid != KInterfaceCertStore)
1.68 + {
1.69 + result = KErrNotSupported;
1.70 + }
1.71 + else
1.72 + {
1.73 + if (!iCertStore)
1.74 + {
1.75 + TRAP(result, iCertStore = CSWICertStore::NewL(*this, iTokenType.Fs()));
1.76 + }
1.77 + }
1.78 +
1.79 + if (result != KErrNone)
1.80 + {
1.81 + Release();
1.82 + }
1.83 + else
1.84 + {
1.85 + ++iInterfaceRefCount;
1.86 + aReturnedInterface = static_cast<MCTCertStore*>(iCertStore);
1.87 + }
1.88 +
1.89 + TRequestStatus* stat = &aStatus;
1.90 + User::RequestComplete(stat, result);
1.91 + }
1.92 +
1.93 +TBool CSWICertStoreToken::DoCancelGetInterface()
1.94 + {
1.95 + return EFalse;
1.96 + }
1.97 +
1.98 +const TDesC& CSWICertStoreToken::Information(TTokenInformation aRequiredInformation)
1.99 + {
1.100 + //there is no support for localisation here
1.101 + switch (aRequiredInformation)
1.102 + {
1.103 + case EVersion:
1.104 + return KSWICertStoreVersion;
1.105 +
1.106 + case ESerialNo:
1.107 + return KSWICertStoreSerialNo;
1.108 +
1.109 + case EManufacturer:
1.110 + return KSWICertStoreManufacturer;
1.111 +
1.112 + default:
1.113 + return KNullDesC;
1.114 + }
1.115 + }
1.116 +
1.117 +TBool CSWICertStoreToken::ReleaseInterface()
1.118 + {
1.119 + // Decrement the interface's reference count and return whether it should be
1.120 + // deleted. Called by CSWICertStore's DoRelease method.
1.121 +
1.122 + TBool canDelete = --iInterfaceRefCount == 0;
1.123 + if (canDelete)
1.124 + {
1.125 + iCertStore = NULL;
1.126 + }
1.127 + return canDelete;
1.128 + }