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