os/security/cryptoservices/certificateandkeymgmt/tcertstore/T_certstoreactionshandle.cpp
First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "t_certstoreactionshandle.h"
25 #include "t_certstoredefs.h"
26 #include "t_certstoreout.h"
27 #include <ccertattributefilter.h>
29 CTestAction* CCertStoreHandle::NewL(RFs& aFs, CConsoleBase& aConsole,
31 const TTestActionSpec& aTestActionSpec)
33 CCertStoreHandle* self = new(ELeave) CCertStoreHandle(aFs, aConsole, aOut);
34 CleanupStack::PushL(self);
35 self->ConstructL(aTestActionSpec);
36 CleanupStack::Pop(self);
41 CCertStoreHandle::~CCertStoreHandle()
47 CCertStoreHandle::CCertStoreHandle(RFs& aFs, CConsoleBase& aConsole,
49 : CCertStoreTestAction(aFs, aConsole, aOut), iState(EList)
53 void CCertStoreHandle::ConstructL(const TTestActionSpec& aTestActionSpec)
55 CCertStoreTestAction::ConstructL(aTestActionSpec);
56 // Creates a default filter
57 iFilter = CCertAttributeFilter::NewL();
61 iLabel.Copy(Input::ParseElement(aTestActionSpec.iActionBody, KCertLabelStart, KCertLabelEnd, pos, err));
63 // set the expected result
64 HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
65 TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
66 Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
67 CleanupStack::PopAndDestroy(result);
71 void CCertStoreHandle::PerformAction(TRequestStatus& aStatus)
76 // Get the list of all certificates
77 CertStore().List(iCertInfos, *iFilter, aStatus);
83 // Find the certificate we want
84 TInt end = iCertInfos.Count();
85 for (TInt i = 0; i < end; i++)
87 if (iCertInfos[i]->Label() == iLabel)
89 iHandle = iCertInfos[i]->Handle();
93 if (aStatus == iExpectedResult)
101 if (aStatus == KErrNoMemory)
108 TRequestStatus* status = &aStatus;
109 User::RequestComplete(status, KErrNone);
113 // The initial state is set to EList and the default case would
118 TRequestStatus* status = &aStatus;
119 User::RequestComplete(status, KErrNotSupported);
124 void CCertStoreHandle::PerformCancel()
128 void CCertStoreHandle::Reset()
130 __ASSERT_DEBUG(EFalse, User::Panic(_L("CCertStoreHandle::Reset()"), 1));
133 void CCertStoreHandle::DoReportAction()
135 iOut.writeString(_L("\tLabel = "));
136 iOut.writeString(iLabel);
140 void CCertStoreHandle::DoCheckResult(TInt aError)
144 if (aError == KErrNone)
146 iOut.writeHex(iHandle.iTokenHandle.iTokenTypeUid.iUid);
147 iOut.writeHex(iHandle.iTokenHandle.iTokenId);
148 iOut.writeHex(iHandle.iObjectId);