authenticationservices/authenticationserver/test/tAuthSvr/miscPlugins/tPluginBase.h
changeset 29 ece3df019add
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
       
     1 /*
       
     2 * Copyright (c) 2005-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 * tMiscAuthPlugin.h
       
    16 * CTPluginUnknown and CTPluginBase are interface implementations for
       
    17 * CAuthPluginInterface
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 #ifndef T_PLUGIN_BASE_H
       
    24 #define T_PLUGIN_BASE_H
       
    25 
       
    26 //#include <ImplementationInformation.h>
       
    27 //#include <TestExecuteStepBase.h>
       
    28 //#include <TestExecuteServerBase.h>
       
    29 //#include <TestExecuteStepBase.h>
       
    30 
       
    31 #include "authPluginInterface.h"	//'authserver' folder is included in mmp file
       
    32 
       
    33 
       
    34 //An implementation of the CAuthPluginInterface definition
       
    35 
       
    36 using namespace AuthServer;
       
    37 
       
    38 class CTPluginUnknown : public CBase, public MAuthPluginInterface
       
    39 	{
       
    40 public:
       
    41 	// Two phase constructor
       
    42 	// Standardised safe construction which leaves nothing the cleanup stack.
       
    43 	static CTPluginUnknown* NewL();
       
    44 	// Destructor
       
    45 	~CTPluginUnknown();
       
    46 
       
    47 	virtual void Identify(TIdentityId& aId,  HBufC8*& aResult, TRequestStatus& aRequest);	
       
    48 	virtual void Cancel();
       
    49 	virtual void Train(TIdentityId aId, HBufC8*& aResult, TRequestStatus& aRequest);		
       
    50 
       
    51 	virtual TBool IsActive() const;
       
    52 	virtual TInt Forget(TIdentityId aId);
       
    53 	virtual TInt DefaultData(TIdentityId aId, HBufC8*& aOutputBuf);
       
    54 	virtual TPluginId Id() const;
       
    55 	
       
    56 		
       
    57 private:
       
    58 	CTPluginUnknown();
       
    59 	void ConstructL();
       
    60 	
       
    61 	// Data read from file determining if this plugin supports default data
       
    62 	TBool iSupportsDefaultData;
       
    63 	TInt iNumTimesTrained;
       
    64 	};
       
    65 
       
    66 //=========================================================================
       
    67 
       
    68 //=========================================================================	
       
    69 //implementation_uid = 0x11113000 to 0x11113031 	//(50 of them)
       
    70 
       
    71 class CTPluginBase : public CBase, public MAuthPluginInterface
       
    72 	{
       
    73 public:
       
    74 
       
    75 	// Destructor
       
    76 	~CTPluginBase();
       
    77 	
       
    78 	//Implementation of CAuthPluginInterface definitions using a PIN system
       
    79 	virtual void Identify(TIdentityId& aId,  HBufC8*& aResult, TRequestStatus& aRequest);	
       
    80 	virtual void Cancel();	
       
    81 	virtual void Train(TIdentityId aId, HBufC8*& aResult, TRequestStatus& aRequest);		
       
    82 
       
    83 	virtual TBool IsActive() const;
       
    84 	virtual TInt Forget(TIdentityId aId);
       
    85 	virtual TInt DefaultData(TIdentityId aId, HBufC8*& aOutputBuf);
       
    86 	virtual TPluginId Id() const;
       
    87 	
       
    88 	// Utility functions
       
    89 	//TInt ReadUserInputL(TBuf<32> inputValue);
       
    90 	//TInt CheckForStringPresenceL(TBuf<32> inputValue, TRequestStatus& requestValue);
       
    91 	//TInt CheckForNewStringPresenceL(TIdentityId aId, TBuf<32> inputValue, TRequestStatus& requestValue);
       
    92 	//TInt FindStringAndRemoveL(TIdentityId aId);
       
    93 
       
    94 	virtual TPluginId GetId() const = 0;
       
    95 	virtual TAuthPluginType GetType() const = 0;
       
    96 		
       
    97 //private:
       
    98 	//CTPluginBase(const TPluginId aPluginId);
       
    99 	CTPluginBase();
       
   100 	void ConstructL();
       
   101 	
       
   102 	// Data read from file determining if this plugin supports default data
       
   103 	TBool iSupportsDefaultData;	
       
   104 	// Can be used to generate results that are multiples of the plugin IDs
       
   105 	TInt iNumTimesTrained;
       
   106 	};
       
   107 
       
   108 
       
   109 // Constants used in the utility functions -File locations, etc
       
   110 //_LIT(KInitInfoFile, "c:\\tAuthSvr\\initialisation_Info.ini");
       
   111 //_LIT(KPinInputFile, "c:\\tAuthSvr\\pin_Input.ini");
       
   112 //_LIT(KPinContentsFile, "c:\\tAuthSvr\\pin_Contents.ini");
       
   113 //_LIT8(KDefaultData, "0000");
       
   114 _LIT8(KDefaultData, "CCCCCCCCCCCCCCCCCCCC");
       
   115 
       
   116 // Provide a consistent naming structure
       
   117 typedef CTPluginUnknown CTPlugin11112FFF ;
       
   118 
       
   119 
       
   120 //=========================================================================	
       
   121 // The various classes that are spawned from this base class by inheriting the implementations besides
       
   122 // the identify() function
       
   123 
       
   124 // number is hex, type is one of the TAuthPluginType enums
       
   125 #define DEF_PLUGIN(number, type) class CTPlugin##number : public CTPluginBase\
       
   126 	{                                        \
       
   127 public:                                      \
       
   128 	typedef CTPlugin##number TMyType;        \
       
   129 	TIdentityId GetId() const                \
       
   130 	{ return 0x##number; }                   \
       
   131 	TAuthPluginType GetType() const          \
       
   132 	{ return type; }                         \
       
   133     static TMyType* NewL()                   \
       
   134     {										 \
       
   135 	  TMyType* r = new (ELeave) TMyType();   \
       
   136 	  r->ConstructL();						 \
       
   137 	  return r;                              \
       
   138 	}                                        \
       
   139 private:                                     \
       
   140 	}         
       
   141 
       
   142 DEF_PLUGIN(11113000, EAuthKnowledge);
       
   143 DEF_PLUGIN(11113001, EAuthKnowledge);
       
   144 DEF_PLUGIN(11113002, EAuthKnowledge);
       
   145 DEF_PLUGIN(11113003, EAuthBiometric);
       
   146 DEF_PLUGIN(11113004, EAuthBiometric);
       
   147 DEF_PLUGIN(11113005, EAuthBiometric);
       
   148 DEF_PLUGIN(11113006, EAuthToken);
       
   149 DEF_PLUGIN(11113007, EAuthToken);
       
   150 DEF_PLUGIN(11113008, EAuthToken);
       
   151 DEF_PLUGIN(11113009, EAuthToken);
       
   152 
       
   153 #endif	/* T_PLUGIN_BASE_H */
       
   154