os/security/cryptoservices/certificateandkeymgmt/tpkcs7/tpkcs7server.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2002-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 "tpkcs7server.h"
    20 #include "tpkcs7step.h"
    21 #include "tcmsstep.h"
    22 
    23 _LIT(KServerName,"tPKCS7Server");
    24 
    25 CTPKCS7Server* CTPKCS7Server::NewL()
    26 /**
    27  * @return - Instance of the test server
    28  * Called inside the MainL() function to create and start the
    29  * CTestServer derived server.
    30  */
    31 	{
    32 	CTPKCS7Server * server = new (ELeave) CTPKCS7Server();
    33 	CleanupStack::PushL(server);
    34 	// CServer base class call
    35 	server->StartL(KServerName);
    36 	CleanupStack::Pop(server);
    37 	return server;
    38 	}
    39 RFs& CTPKCS7Server::Fs()
    40 		{
    41 		return iFs;
    42 		};
    43 
    44 // EKA2 much simpler
    45 // Just an E32Main and a MainL()
    46 LOCAL_C void MainL()
    47 /**
    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().SecureApi(RProcess::ESecureApiOn);
    55 #endif
    56 	CActiveScheduler* sched=NULL;
    57 	sched=new(ELeave) CActiveScheduler;
    58 	CActiveScheduler::Install(sched);
    59 	CTPKCS7Server* server = NULL;
    60 	// Create the CTestServer derived server
    61 	TRAPD(err,server = CTPKCS7Server::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 // Only a DLL on emulator for typhoon and earlier
    73 
    74 GLDEF_C TInt E32Main()
    75 /**
    76  * @return - Standard Epoc error code on exit
    77  */
    78 	{
    79 	CTrapCleanup* cleanup = CTrapCleanup::New();
    80 	if(cleanup == NULL)
    81 		{
    82 		return KErrNoMemory;
    83 		}
    84 	TRAP_IGNORE(MainL());
    85 	delete cleanup;
    86 	return KErrNone;
    87     }
    88 
    89 // Create a thread in the calling process
    90 // Emulator typhoon and earlier
    91 
    92 CTestStep* CTPKCS7Server::CreateTestStep(const TDesC& aStepName)
    93 /**
    94  * @return - A CTestStep derived instance
    95  * Implementation of CTestServer pure virtual
    96  */
    97 	{
    98      CTPKCS7StepBase* testStep = NULL;
    99 
   100    	  	
   101 	// __EDIT_ME__ - Create your own test steps here
   102 	// This server creates just one step but create as many as you want
   103 	// They are created "just in time" when the worker thread is created
   104 	if(aStepName == KTPKCS7CorruptTest)
   105 		testStep = new CTPKCS7CorruptTest();
   106 	else if(aStepName == KTPKCS7ValidTest)
   107 		testStep = new CTPKCS7ValidTest();
   108 	else if(aStepName == KTPKCS7ContentTest)
   109 		testStep = new CTPKCS7CorruptTest();
   110 	else if(aStepName == KTPKCS7CertificateTest)
   111 		testStep = new CTPKCS7CertificateTest();
   112 	else if(aStepName == KTPKCS7SignerTest)
   113 		testStep = new CTPKCS7SignerTest();
   114 	else if(aStepName == KTPKCS7EncryptedDataTest)
   115 	    testStep = new CTPKCS7EncryptedDataTest();
   116 	else if(aStepName == KTPKCS7DigestInfoTest)
   117 	    testStep = new CTPKCS7DigestInfoTest();
   118 	else if(aStepName == KTPKCS7EncryptedDataCorruptTest)
   119 	    testStep = new CTPKCS7EncryptedDataCorruptTest();
   120 	else if(aStepName == KTPKCS7DigestInfoCorruptTest)
   121 	    testStep = new CTPKCS7DigestInfoCorruptTest();
   122 	else if(aStepName == KTPKCS7OOMTest)
   123 	   testStep = new CTPKCS7OOMTest();
   124 			
   125  	if (testStep)
   126  		{
   127  		testStep->SetServer(this);
   128  		}
   129  	
   130  	CTestStep* cmsTestStep(NULL);	
   131  	if (aStepName == KTCmsSignedDataTest)
   132 	 	{
   133 	 	cmsTestStep = new CTCmsSignedDataStep();
   134 	 	return cmsTestStep;
   135 	 	}
   136 	 else if (aStepName == KTCmsSignedDataDecodingTest)
   137 				{
   138 				cmsTestStep = new CTCmsSignedDataDecodingStep();
   139 				return cmsTestStep;		 	
   140 				}
   141 		   else if (aStepName == KTCmsDataTest)
   142 				    {
   143 					cmsTestStep = new CTCmsDataStep();
   144 					return cmsTestStep;			   	
   145 				    }
   146 			    else if (aStepName == KTCmsDataDecodingTest)
   147 					    {
   148 						cmsTestStep = new CTCmsDataDecodingStep();
   149 						return cmsTestStep;			   	
   150 					    }
   151 					 else if (aStepName == KTCmsContentInfoDecodingTest)
   152 								{
   153 								cmsTestStep = new CTCmsContentInfoDecodingStep();
   154 								return cmsTestStep;			   	
   155 							 	}
   156 					 
   157 				
   158 /*	 	
   159 	else if (aStepName == KTPKCS7SignedDataTest)
   160 			{
   161 		 	cmsTestStep = new CTPKCS7SignedDataStep();
   162 		 	return cmsTestStep;
   163 			}
   164 */	
   165 	 	
   166 	return testStep;
   167 	}
   168