pkiutilities/ocsp/test/transport.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test transport object.  May be used in place of the automatically-constructed
       
    15 // transport object from OCSP.DLL
       
    16 // Allows a file to be specified, the contents of which will be returned as the response.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @internalTechnology
       
    23 */
       
    24 
       
    25 #ifndef __TOCSP_TRANSPORT_H__
       
    26 #define __TOCSP_TRANSPORT_H__
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <ocsp.h>
       
    30 #include <s32file.h>
       
    31 
       
    32 #include "ocsprequestandresponse.h"
       
    33 namespace TOCSP
       
    34 	{
       
    35 	// Some test code specific status codes
       
    36 	
       
    37 	enum TStatus
       
    38 		{
       
    39 		ETooManyTransactions = 200, // Client made more requests than we had responses for
       
    40 		EURIMismatch,				// Request URI didn't match expected
       
    41 		ERequestMismatch			// Request data didn't match expectedo		
       
    42 		};
       
    43 	}
       
    44 
       
    45 class CTOCSPTransport : public CBase, public MOCSPTransport
       
    46 	{
       
    47 public:
       
    48 
       
    49 	/**
       
    50 	 * Create a test transport object.
       
    51 	 * @param aResponseFile The filename of the response to return.
       
    52 	 * @param aRequestFile The name of the request file to compare the request
       
    53 	 * data against, or null.
       
    54 	 */
       
    55 	static CTOCSPTransport* NewL(const TDesC& aResponseFile, const TDesC* aRequestFile);
       
    56 
       
    57 private:
       
    58 	// From MOCSPTransport
       
    59 	~CTOCSPTransport();
       
    60 	void SendRequest(const TDesC8& aURI, const TDesC8& aRequest, const TInt aTimeout, TRequestStatus& aStatus);
       
    61 	void CancelRequest();
       
    62 	TPtrC8 GetResponse() const;
       
    63 
       
    64 private:
       
    65 	void DoSendRequestL(const TDesC8& aURI, const TDesC8& aRequest);
       
    66 	void CheckRequestL(const TDesC8& aURI, const TDesC8& aRequest);
       
    67 	void ConstructL(const TDesC& aResponseFile, const TDesC* aRequestFile);
       
    68 	HBufC8* ReadDataLC(RFileReadStream& aStream);
       
    69 
       
    70 private:
       
    71 	RFs				 iFs;
       
    72 	RFileReadStream  iResponseStream;
       
    73 	RFileReadStream* iRequestStream;
       
    74 	TInt			 iTransactions;	
       
    75 	TInt			 iIndex;
       
    76 	HBufC8*			 iResponseData;
       
    77 	TRequestStatus*  iCallBack;
       
    78 	};
       
    79 
       
    80 #endif // __TOCSP_TRANSPORT_H__