|
1 /* |
|
2 * Copyright (c) 2007-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 * tpkcs10minortests.cpp |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "tpkcs10serverv2.h" |
|
21 #include "tcertrequeststep.h" |
|
22 #include "tpkcs10negatives.h" |
|
23 #include "tpkcs10minortests.h" |
|
24 |
|
25 _LIT(KServerName,"tpkcs10serverv2"); |
|
26 CTPKCS10Server* CTPKCS10Server::NewL() |
|
27 /** |
|
28 * @return - Instance of the test server |
|
29 * Same code for Secure and non-secure variants |
|
30 * Called inside the MainL() function to create and start the |
|
31 * CTestServer derived server. |
|
32 */ |
|
33 { |
|
34 CTPKCS10Server * server = new (ELeave) CTPKCS10Server(); |
|
35 CleanupStack::PushL(server); |
|
36 |
|
37 server->ConstructL(KServerName); |
|
38 CleanupStack::Pop(server); |
|
39 return server; |
|
40 } |
|
41 |
|
42 |
|
43 // Secure variants much simpler |
|
44 // For EKA2, just an E32Main and a MainL() |
|
45 LOCAL_C void MainL() |
|
46 /** |
|
47 * Secure variant |
|
48 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
49 */ |
|
50 { |
|
51 // Leave the hooks in for platform security |
|
52 #if (defined __DATA_CAGING__) |
|
53 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
54 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
55 #endif |
|
56 CActiveScheduler* sched=NULL; |
|
57 sched=new(ELeave) CActiveScheduler; |
|
58 CActiveScheduler::Install(sched); |
|
59 CTPKCS10Server* server = NULL; |
|
60 // Create the CTestServer derived server |
|
61 TRAPD(err,server = CTPKCS10Server::NewL()); |
|
62 if(!err) |
|
63 { |
|
64 // Sync with the client and enter the active scheduler |
|
65 RProcess::Rendezvous(KErrNone); |
|
66 sched->Start(); |
|
67 } |
|
68 delete server; |
|
69 delete sched; |
|
70 } |
|
71 |
|
72 |
|
73 |
|
74 GLDEF_C TInt E32Main() |
|
75 /** |
|
76 * @return - Standard Epoc error code on process exit |
|
77 * Secure variant only |
|
78 * Process entry point. Called by client using RProcess API |
|
79 */ |
|
80 { |
|
81 __UHEAP_MARK; |
|
82 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
83 if(cleanup == NULL) |
|
84 { |
|
85 return KErrNoMemory; |
|
86 } |
|
87 TRAPD(err,MainL()); |
|
88 delete cleanup; |
|
89 __UHEAP_MARKEND; |
|
90 return err; |
|
91 } |
|
92 |
|
93 |
|
94 CTestStep* CTPKCS10Server::CreateTestStep(const TDesC& aStepName) |
|
95 /** |
|
96 * @return - A CTestStep derived instance |
|
97 * Secure and non-secure variants |
|
98 * Implementation of CTestServer pure virtual |
|
99 */ |
|
100 { |
|
101 CTestStep* testStep = NULL; |
|
102 if(aStepName == KCertificateRequestStep) |
|
103 { |
|
104 testStep = new CCertificateRequestStep(); |
|
105 return testStep; |
|
106 } |
|
107 else if(aStepName == KPKCS10ReuseAttributeStep) |
|
108 { |
|
109 testStep = new CPKCS10ReuseAttributeStep(); |
|
110 return testStep; |
|
111 } |
|
112 else if(aStepName == KPKCS10ReuseChallengePasswordAttr) |
|
113 { |
|
114 testStep = new CPKCS10ReuseChallengePasswordAttrStep(); |
|
115 return testStep; |
|
116 } |
|
117 else if(aStepName == KPKCS10ReuseExtensionAttr) |
|
118 { |
|
119 testStep = new CPKCS10ReuseExtensionAttrStep(); |
|
120 return testStep; |
|
121 } |
|
122 else if(aStepName == KPKCS10NegPKCS10GenericAttr) |
|
123 { |
|
124 testStep = new CPKCS10NegPKCS10GenericAttr(); |
|
125 return testStep; |
|
126 } |
|
127 else if (aStepName == KPKCS10NegPKCS9ChallengePasswordAttr) |
|
128 { |
|
129 testStep = new CPKCS10NegPKCS9ChallengePasswordAttr(); |
|
130 return testStep; |
|
131 } |
|
132 else if (aStepName == KPKCS10NegPKCS9ExtensionRequestAttr) |
|
133 { |
|
134 testStep = new CPKCS10NegPKCS9ExtensionRequestAttr(); |
|
135 return testStep; |
|
136 } |
|
137 else if (aStepName == KPKCS10NegPKCS10Attributes) |
|
138 { |
|
139 testStep = new CPKCS10NegPKCS10Attributes(); |
|
140 return testStep; |
|
141 } |
|
142 else if (aStepName == KPKCS10NegPKCS10Request) |
|
143 { |
|
144 testStep = new CPKCS10NegPKCS10Request(); |
|
145 return testStep; |
|
146 } |
|
147 else if (aStepName == KPKCS10CancelRequestA) |
|
148 { |
|
149 testStep = new CPKCS10CancelRequestAStep(); |
|
150 return testStep; |
|
151 } |
|
152 |
|
153 |
|
154 return testStep; |
|
155 } |