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.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include "tpkcs7server.h"
sl@0
    20
#include "tpkcs7step.h"
sl@0
    21
#include "tcmsstep.h"
sl@0
    22
sl@0
    23
_LIT(KServerName,"tPKCS7Server");
sl@0
    24
sl@0
    25
CTPKCS7Server* CTPKCS7Server::NewL()
sl@0
    26
/**
sl@0
    27
 * @return - Instance of the test server
sl@0
    28
 * Called inside the MainL() function to create and start the
sl@0
    29
 * CTestServer derived server.
sl@0
    30
 */
sl@0
    31
	{
sl@0
    32
	CTPKCS7Server * server = new (ELeave) CTPKCS7Server();
sl@0
    33
	CleanupStack::PushL(server);
sl@0
    34
	// CServer base class call
sl@0
    35
	server->StartL(KServerName);
sl@0
    36
	CleanupStack::Pop(server);
sl@0
    37
	return server;
sl@0
    38
	}
sl@0
    39
RFs& CTPKCS7Server::Fs()
sl@0
    40
		{
sl@0
    41
		return iFs;
sl@0
    42
		};
sl@0
    43
sl@0
    44
// EKA2 much simpler
sl@0
    45
// Just an E32Main and a MainL()
sl@0
    46
LOCAL_C void MainL()
sl@0
    47
/**
sl@0
    48
 * Much simpler, uses the new Rendezvous() call to sync with the client
sl@0
    49
 */
sl@0
    50
	{
sl@0
    51
	// Leave the hooks in for platform security
sl@0
    52
#if (defined __DATA_CAGING__)
sl@0
    53
	RProcess().DataCaging(RProcess::EDataCagingOn);
sl@0
    54
	RProcess().SecureApi(RProcess::ESecureApiOn);
sl@0
    55
#endif
sl@0
    56
	CActiveScheduler* sched=NULL;
sl@0
    57
	sched=new(ELeave) CActiveScheduler;
sl@0
    58
	CActiveScheduler::Install(sched);
sl@0
    59
	CTPKCS7Server* server = NULL;
sl@0
    60
	// Create the CTestServer derived server
sl@0
    61
	TRAPD(err,server = CTPKCS7Server::NewL());
sl@0
    62
	if(!err)
sl@0
    63
		{
sl@0
    64
		// Sync with the client and enter the active scheduler
sl@0
    65
		RProcess::Rendezvous(KErrNone);
sl@0
    66
		sched->Start();
sl@0
    67
		}
sl@0
    68
	delete server;
sl@0
    69
	delete sched;
sl@0
    70
	}
sl@0
    71
sl@0
    72
// Only a DLL on emulator for typhoon and earlier
sl@0
    73
sl@0
    74
GLDEF_C TInt E32Main()
sl@0
    75
/**
sl@0
    76
 * @return - Standard Epoc error code on exit
sl@0
    77
 */
sl@0
    78
	{
sl@0
    79
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
    80
	if(cleanup == NULL)
sl@0
    81
		{
sl@0
    82
		return KErrNoMemory;
sl@0
    83
		}
sl@0
    84
	TRAP_IGNORE(MainL());
sl@0
    85
	delete cleanup;
sl@0
    86
	return KErrNone;
sl@0
    87
    }
sl@0
    88
sl@0
    89
// Create a thread in the calling process
sl@0
    90
// Emulator typhoon and earlier
sl@0
    91
sl@0
    92
CTestStep* CTPKCS7Server::CreateTestStep(const TDesC& aStepName)
sl@0
    93
/**
sl@0
    94
 * @return - A CTestStep derived instance
sl@0
    95
 * Implementation of CTestServer pure virtual
sl@0
    96
 */
sl@0
    97
	{
sl@0
    98
     CTPKCS7StepBase* testStep = NULL;
sl@0
    99
sl@0
   100
   	  	
sl@0
   101
	// __EDIT_ME__ - Create your own test steps here
sl@0
   102
	// This server creates just one step but create as many as you want
sl@0
   103
	// They are created "just in time" when the worker thread is created
sl@0
   104
	if(aStepName == KTPKCS7CorruptTest)
sl@0
   105
		testStep = new CTPKCS7CorruptTest();
sl@0
   106
	else if(aStepName == KTPKCS7ValidTest)
sl@0
   107
		testStep = new CTPKCS7ValidTest();
sl@0
   108
	else if(aStepName == KTPKCS7ContentTest)
sl@0
   109
		testStep = new CTPKCS7CorruptTest();
sl@0
   110
	else if(aStepName == KTPKCS7CertificateTest)
sl@0
   111
		testStep = new CTPKCS7CertificateTest();
sl@0
   112
	else if(aStepName == KTPKCS7SignerTest)
sl@0
   113
		testStep = new CTPKCS7SignerTest();
sl@0
   114
	else if(aStepName == KTPKCS7EncryptedDataTest)
sl@0
   115
	    testStep = new CTPKCS7EncryptedDataTest();
sl@0
   116
	else if(aStepName == KTPKCS7DigestInfoTest)
sl@0
   117
	    testStep = new CTPKCS7DigestInfoTest();
sl@0
   118
	else if(aStepName == KTPKCS7EncryptedDataCorruptTest)
sl@0
   119
	    testStep = new CTPKCS7EncryptedDataCorruptTest();
sl@0
   120
	else if(aStepName == KTPKCS7DigestInfoCorruptTest)
sl@0
   121
	    testStep = new CTPKCS7DigestInfoCorruptTest();
sl@0
   122
	else if(aStepName == KTPKCS7OOMTest)
sl@0
   123
	   testStep = new CTPKCS7OOMTest();
sl@0
   124
			
sl@0
   125
 	if (testStep)
sl@0
   126
 		{
sl@0
   127
 		testStep->SetServer(this);
sl@0
   128
 		}
sl@0
   129
 	
sl@0
   130
 	CTestStep* cmsTestStep(NULL);	
sl@0
   131
 	if (aStepName == KTCmsSignedDataTest)
sl@0
   132
	 	{
sl@0
   133
	 	cmsTestStep = new CTCmsSignedDataStep();
sl@0
   134
	 	return cmsTestStep;
sl@0
   135
	 	}
sl@0
   136
	 else if (aStepName == KTCmsSignedDataDecodingTest)
sl@0
   137
				{
sl@0
   138
				cmsTestStep = new CTCmsSignedDataDecodingStep();
sl@0
   139
				return cmsTestStep;		 	
sl@0
   140
				}
sl@0
   141
		   else if (aStepName == KTCmsDataTest)
sl@0
   142
				    {
sl@0
   143
					cmsTestStep = new CTCmsDataStep();
sl@0
   144
					return cmsTestStep;			   	
sl@0
   145
				    }
sl@0
   146
			    else if (aStepName == KTCmsDataDecodingTest)
sl@0
   147
					    {
sl@0
   148
						cmsTestStep = new CTCmsDataDecodingStep();
sl@0
   149
						return cmsTestStep;			   	
sl@0
   150
					    }
sl@0
   151
					 else if (aStepName == KTCmsContentInfoDecodingTest)
sl@0
   152
								{
sl@0
   153
								cmsTestStep = new CTCmsContentInfoDecodingStep();
sl@0
   154
								return cmsTestStep;			   	
sl@0
   155
							 	}
sl@0
   156
					 
sl@0
   157
				
sl@0
   158
/*	 	
sl@0
   159
	else if (aStepName == KTPKCS7SignedDataTest)
sl@0
   160
			{
sl@0
   161
		 	cmsTestStep = new CTPKCS7SignedDataStep();
sl@0
   162
		 	return cmsTestStep;
sl@0
   163
			}
sl@0
   164
*/	
sl@0
   165
	 	
sl@0
   166
	return testStep;
sl@0
   167
	}
sl@0
   168