authenticationservices/authenticationserver/test/tAuthSvr/src/tPinAuthPlugin.h
changeset 102 deec7e509f66
parent 94 0e6c5a9328b5
child 108 ca9a0fc2f082
equal deleted inserted replaced
94:0e6c5a9328b5 102:deec7e509f66
     1 /*
       
     2 * Copyright (c) 2006-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 * CTPinAuthPlugin is an interface implementation for CAuthPluginInterface
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef TPINAUTHPLUGIN_H
       
    22 #define TPINAUTHPLUGIN_H
       
    23 
       
    24 #include "authserver_client.h"
       
    25 #include <authserver/authplugininterface.h>
       
    26 
       
    27 
       
    28 
       
    29 //An implementation of the CAuthPluginInterface definition
       
    30 
       
    31 using namespace AuthServer;
       
    32 	
       
    33 //implementation_uid = 0x10204F10
       
    34 class CTPinAuthPlugin : public CAuthPluginInterface
       
    35 	{
       
    36 public:
       
    37 	// Two phase constructor
       
    38 	static CTPinAuthPlugin* NewL();
       
    39 	// Destructor
       
    40 	virtual ~CTPinAuthPlugin();
       
    41 	//Implementation of CAuthPluginInterface definitions using a PIN system
       
    42 	virtual void Identify(TIdentityId& aId, const TDesC& aClientMessage, HBufC8*& aResult, TRequestStatus& aRequest);	
       
    43 	virtual void Cancel();	
       
    44 	virtual void Train(TIdentityId aId, HBufC8*& aResult, TRequestStatus& aRequest);		
       
    45 	virtual TBool IsActive() const;
       
    46 	virtual TInt Forget(TIdentityId aId);
       
    47 	virtual TInt DefaultData(TIdentityId aId, HBufC8*& aOutputBuf);
       
    48 	virtual TInt Reset(TIdentityId aId, const TDesC& aRegistrationData, HBufC8*& aResult);
       
    49 	//virtual TPluginId Id() const;
       
    50 	virtual const TPtrC& Name() const;
       
    51 	virtual const TPtrC& Description() const;
       
    52 	virtual AuthServer::TEntropy MinEntropy() const;
       
    53 	virtual AuthServer::TPercentage FalsePositiveRate() const;
       
    54 	virtual AuthServer::TPercentage FalseNegativeRate() const;
       
    55 	virtual AuthServer::TAuthPluginType Type() const;
       
    56 		
       
    57 	// Utility functions
       
    58 	TInt IdReadUserInput(TBuf8<32>& inputValue);
       
    59 	TInt TrainReadUserInput(TBuf8<32>& inputValue);
       
    60 	TInt CheckForStringPresence(TIdentityId& aId, TBuf8<32> aInputValue, TRequestStatus& aRequestValue);
       
    61 	TInt CheckForNewStringPresenceL(TIdentityId aId, TBuf8<32> aInputValue, TRequestStatus& aRequestValue);
       
    62 	TInt FindStringAndRemoveL(TIdentityId aId);
       
    63 	TInt AddToGlobalDb (TIdentityId aId, TBuf8<32> aInputValue);
       
    64 	TInt RemoveFromGlobalDb (TIdentityId aId);
       
    65 	const HBufC* ClientMessage ();
       
    66 	
       
    67 
       
    68 public:
       
    69 	mutable TBuf<70> iFileToRead;
       
    70 	void ConstructL();
       
    71 	CTPinAuthPlugin();
       
    72 	void ReloadAllFromIniFile();
       
    73 	void ReloadActiveStateFromIniFile() const;
       
    74 protected:
       
    75  	/// The name of the plugin. Derived classes should set this member.
       
    76  	TPtrC iName;
       
    77  	/// The plugin's description. Derived classes should set this member.
       
    78  	TPtrC iDescription;
       
    79  	/// The minumum entropy provided by the plugin. Derived classes should set
       
    80  	/// this member.
       
    81  	AuthServer::TEntropy iMinEntropy;
       
    82  	/// The false positive rate of the plugin. Derived classes should set this
       
    83  	/// member.
       
    84  	AuthServer::TPercentage iFalsePositiveRate;
       
    85  	/// The false negative rate of the plugin. Derived classes should set this
       
    86  	/// member.
       
    87  	AuthServer::TPercentage iFalseNegativeRate;
       
    88   	/// The type of the plugin. Derived classes should set this member.
       
    89  	AuthServer::TAuthPluginType iType;
       
    90 
       
    91 private:
       
    92 	// Data read from file determining if this plugin supports default data
       
    93 	TBool iSupportsDefaultData;
       
    94 	mutable TBool iActiveState;
       
    95 	HBufC* iClientMessage;
       
    96 	};
       
    97 
       
    98 
       
    99 //=========================================================================	
       
   100 // The various classes that are spawned from this base class by inheriting the implementations besides
       
   101 // the Id() function (Uses the #define macro)
       
   102 
       
   103 // number is hex, type is one of the TAuthPluginType enums
       
   104 // Id() returns the Id of the plugin
       
   105 
       
   106 
       
   107 #define NClass(id,type) class CTPinAuthPlugin##id : public CTPinAuthPlugin\
       
   108 	{                                        		\
       
   109 public:                                      		\
       
   110 	typedef CTPinAuthPlugin##id TMyPinType;	    	\
       
   111 	TPluginId Id() const 		               		\
       
   112 		{ return 0x##id; }  	               		\
       
   113 		const TPtrC& Name() const					\
       
   114 		  {											\
       
   115 		  return iName;								\
       
   116 		  }											\
       
   117 		const TPtrC& Description() const			\
       
   118 		  {											\
       
   119 		  return iDescription;						\
       
   120 		  }											\
       
   121 		AuthServer::TAuthPluginType Type() const 	\
       
   122 		  {											\
       
   123 		  return iType;								\
       
   124 		  }											\
       
   125 		AuthServer::TEntropy MinEntropy() const		\
       
   126 		  {											\
       
   127 		  return iMinEntropy;						\
       
   128 		  }											\
       
   129 		AuthServer::TPercentage FalsePositiveRate() const \
       
   130 		  {												  \
       
   131 		  return iFalsePositiveRate;					  \
       
   132 		  }												  \
       
   133 		AuthServer::TPercentage FalseNegativeRate() const \
       
   134 		  {												  \
       
   135 		  return iFalseNegativeRate;					  \
       
   136 		  }												  \
       
   137 	static TMyPinType* NewL()                   	\
       
   138     	{										 	\
       
   139         TMyPinType* r = new (ELeave) TMyPinType();	\
       
   140         CleanupStack::PushL(r);						\
       
   141 	  	r->ConstructL();						 	\
       
   142 	  	CleanupStack::Pop(r);						\
       
   143         r->iType = type;                            \
       
   144 	  	return r;                              		\
       
   145 		}											\
       
   146 	}
       
   147 
       
   148 NClass(11113100, EAuthKnowledge);
       
   149 NClass(11113101, EAuthKnowledge);
       
   150 NClass(11113102, EAuthKnowledge);
       
   151 NClass(11113103, EAuthBiometric);
       
   152 NClass(11113104, EAuthToken);
       
   153 
       
   154 //=========================================================================		
       
   155 // Constants used in the utility functions -File locations, etc
       
   156 _LIT8(KDefaultData, "0000");
       
   157 _LIT(KInitInfoFile, "\\tAuth\\tAuthSvr\\testdata\\initialisation_Info.ini");
       
   158 _LIT(KPolicyFile, 	"\\tAuth\\tAuthSvr\\testdata\\AuthSvrPolicy.ini");
       
   159 
       
   160 _LIT(KPluginNamePin, "Pin1");
       
   161 _LIT(KPluginDescriptionPin, "Pin Plugin, can store and return known id and training data for each identity.");
       
   162 
       
   163 static const TInt KEntropyPin = 999;
       
   164 static const TInt KFalsePosPin = 100;
       
   165 static const TInt KFalseNegPin = 10;
       
   166 
       
   167 //From Step_Base.cpp
       
   168 _LIT(KPluginIniSection,			"SectionOne");
       
   169 _LIT(KAuthSvrPolicyFile, 		"\\tAuth\\tAuthSvr\\testdata\\AuthSvrPolicy.ini");
       
   170 _LIT(KDefaultPluginTag, 		"DefaultPlugin");
       
   171 _LIT(KEnteredPinTag, 			"EnteredPinValue");
       
   172 _LIT(KPinDbTag,					"Identity&PinValues");
       
   173 _LIT(KTotalDbTag,				"AllUserID&PinValues");
       
   174 _LIT(KInitPinDatabaseValue,		",");
       
   175 
       
   176 
       
   177 
       
   178 #endif	/* TPINAUTHPLUGIN_H */