os/security/cryptoservices/certificateandkeymgmt/tpkcs10/tpkcs10serverv2.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/tpkcs10/tpkcs10serverv2.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,155 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* tpkcs10minortests.cpp
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include "tpkcs10serverv2.h"
    1.24 +#include "tcertrequeststep.h"
    1.25 +#include "tpkcs10negatives.h"
    1.26 +#include "tpkcs10minortests.h"
    1.27 +
    1.28 +_LIT(KServerName,"tpkcs10serverv2");
    1.29 +CTPKCS10Server* CTPKCS10Server::NewL()
    1.30 +/**
    1.31 + * @return - Instance of the test server
    1.32 + * Same code for Secure and non-secure variants
    1.33 + * Called inside the MainL() function to create and start the
    1.34 + * CTestServer derived server.
    1.35 + */
    1.36 +	{
    1.37 +	CTPKCS10Server * server = new (ELeave) CTPKCS10Server();
    1.38 +	CleanupStack::PushL(server);
    1.39 +
    1.40 +	server->ConstructL(KServerName);
    1.41 +	CleanupStack::Pop(server);
    1.42 +	return server;
    1.43 +	}
    1.44 +
    1.45 +
    1.46 +// Secure variants much simpler
    1.47 +// For EKA2, just an E32Main and a MainL()
    1.48 +LOCAL_C void MainL()
    1.49 +/**
    1.50 + * Secure variant
    1.51 + * Much simpler, uses the new Rendezvous() call to sync with the client
    1.52 + */
    1.53 +	{
    1.54 +	// Leave the hooks in for platform security
    1.55 +#if (defined __DATA_CAGING__)
    1.56 +	RProcess().DataCaging(RProcess::EDataCagingOn);
    1.57 +	RProcess().DataCaging(RProcess::ESecureApiOn);
    1.58 +#endif
    1.59 +	CActiveScheduler* sched=NULL;
    1.60 +	sched=new(ELeave) CActiveScheduler;
    1.61 +	CActiveScheduler::Install(sched);
    1.62 +	CTPKCS10Server* server = NULL;
    1.63 +	// Create the CTestServer derived server
    1.64 +	TRAPD(err,server = CTPKCS10Server::NewL());
    1.65 +	if(!err)
    1.66 +		{
    1.67 +		// Sync with the client and enter the active scheduler
    1.68 +		RProcess::Rendezvous(KErrNone);
    1.69 +		sched->Start();
    1.70 +		}
    1.71 +	delete server;
    1.72 +	delete sched;
    1.73 +	}
    1.74 +
    1.75 +
    1.76 +
    1.77 +GLDEF_C TInt E32Main()
    1.78 +/**
    1.79 + * @return - Standard Epoc error code on process exit
    1.80 + * Secure variant only
    1.81 + * Process entry point. Called by client using RProcess API
    1.82 + */
    1.83 +	{
    1.84 +	__UHEAP_MARK;
    1.85 +	CTrapCleanup* cleanup = CTrapCleanup::New();
    1.86 +	if(cleanup == NULL)
    1.87 +		{
    1.88 +		return KErrNoMemory;
    1.89 +		}
    1.90 +	TRAPD(err,MainL());
    1.91 +	delete cleanup;
    1.92 +	__UHEAP_MARKEND;
    1.93 +	return err;
    1.94 +    }
    1.95 +
    1.96 +
    1.97 +CTestStep* CTPKCS10Server::CreateTestStep(const TDesC& aStepName)
    1.98 +/**
    1.99 + * @return - A CTestStep derived instance
   1.100 + * Secure and non-secure variants
   1.101 + * Implementation of CTestServer pure virtual
   1.102 + */
   1.103 +	{
   1.104 +	CTestStep* testStep = NULL;
   1.105 +              if(aStepName == KCertificateRequestStep)
   1.106 +              {
   1.107 +              	testStep = new CCertificateRequestStep();
   1.108 +              	return testStep;	
   1.109 +              }
   1.110 +              else if(aStepName == KPKCS10ReuseAttributeStep)
   1.111 +              {
   1.112 +              	testStep = new CPKCS10ReuseAttributeStep();
   1.113 +              	return testStep;
   1.114 +              }
   1.115 +              else if(aStepName == KPKCS10ReuseChallengePasswordAttr)
   1.116 +              {
   1.117 +              	testStep = new CPKCS10ReuseChallengePasswordAttrStep();
   1.118 +              	return testStep;
   1.119 +              }
   1.120 +              else if(aStepName == KPKCS10ReuseExtensionAttr)
   1.121 +              {
   1.122 +              	testStep = new CPKCS10ReuseExtensionAttrStep();
   1.123 +              	return testStep;
   1.124 +              }
   1.125 +              else if(aStepName == KPKCS10NegPKCS10GenericAttr)
   1.126 +              {
   1.127 +              	testStep = new CPKCS10NegPKCS10GenericAttr();
   1.128 +              	return testStep;
   1.129 +              }
   1.130 +              else if (aStepName == KPKCS10NegPKCS9ChallengePasswordAttr)
   1.131 +              {
   1.132 +                testStep = new CPKCS10NegPKCS9ChallengePasswordAttr();
   1.133 +                return testStep;
   1.134 +              }
   1.135 +			  else if (aStepName == KPKCS10NegPKCS9ExtensionRequestAttr)
   1.136 +			  {
   1.137 +                testStep = new CPKCS10NegPKCS9ExtensionRequestAttr();
   1.138 +                return testStep;
   1.139 +			  }
   1.140 +			  else if (aStepName == KPKCS10NegPKCS10Attributes)
   1.141 +			  {
   1.142 +                testStep = new CPKCS10NegPKCS10Attributes();
   1.143 +                return testStep;
   1.144 +			  }
   1.145 +			  else if (aStepName == KPKCS10NegPKCS10Request)
   1.146 +			  {
   1.147 +                testStep = new CPKCS10NegPKCS10Request();
   1.148 +                return testStep;
   1.149 +			  }
   1.150 +			  else if (aStepName == KPKCS10CancelRequestA)
   1.151 +			  {
   1.152 +                testStep = new CPKCS10CancelRequestAStep();
   1.153 +                return testStep;
   1.154 +			  }
   1.155 +
   1.156 +		
   1.157 +	return testStep;
   1.158 +	}