email/pop3andsmtpmtm/popservermtm/inc/cpopsaslauthhelper.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2008-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 // POPAUTHHELPER.H
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __CPOPSASLAUTHHELPER_H__
       
    19 #define __CPOPSASLAUTHHELPER_H__
       
    20 
       
    21 #include <imcvcodc.h>
       
    22 #include <pop3set.h>
       
    23 #include <hash.h>	
       
    24 #include <imcvcodc.h>
       
    25 #include <timrfc822datefield.h> // needed for KImMailMaxBufferSize 
       
    26 
       
    27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    28 #include "timrfc822datefield.h"				
       
    29 #endif
       
    30 
       
    31 /**
       
    32 CPopAuthMechanismHelper is the base class for POP3 AUTH command.
       
    33 Using this class SASL (Simple Authentication and Security Layer) mechanisms 
       
    34 can be exteneded.
       
    35 Right now CRAM-MD5, PLAIN and LOGIN authentication mechanisms are supported.
       
    36 
       
    37 @internalComponent
       
    38 @prototype
       
    39 */
       
    40 NONSHARABLE_CLASS (CPopAuthMechanismHelper) : public CBase
       
    41 	{
       
    42 public:
       
    43 	enum TPopAuthProfileFlag
       
    44 		{
       
    45 		ENoProfile=0x00,
       
    46 		EPlain=0x01,
       
    47 		ELogin=0x02,
       
    48 		ECramMD5=0x04,
       
    49 		EUndefined=0x08, // must be last flag
       
    50 		};
       
    51 
       
    52 protected:
       
    53 	CPopAuthMechanismHelper(const CImPop3Settings& aSettings);
       
    54 public:
       
    55 	virtual void GetNextClientMessageL(TDes8& aNextMessage)=0;
       
    56 	virtual void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse)=0;
       
    57 protected:
       
    58 	const CImPop3Settings& iSettings;
       
    59 	TPtrC8 iLastServerMessage;
       
    60 	TBuf8<KImMailMaxBufferSize> iNextClientMessage;
       
    61 
       
    62 #if(defined SYMBIAN_SERVERMTM_UNIT_TESTCODE)
       
    63 	friend class CTestPopSaslAuthHelper;
       
    64 #endif	
       
    65 	};
       
    66 
       
    67 
       
    68 /**
       
    69 CPopAuthCramMd5MechanismHelper class is extended to support the AUTH command as 
       
    70 specified in RFC1734, to indicate CRAM-MD5 authentication mechanism to the server.
       
    71 
       
    72 @internalComponent
       
    73 @prototype
       
    74 */
       
    75 NONSHARABLE_CLASS( CPopAuthCramMd5MechanismHelper ) : public CPopAuthMechanismHelper
       
    76 	{
       
    77 public:
       
    78 	static CPopAuthCramMd5MechanismHelper* NewL(const CImPop3Settings& aSettings);
       
    79 	~CPopAuthCramMd5MechanismHelper();
       
    80 public:
       
    81 	void GetNextClientMessageL(TDes8& aNextMessage);
       
    82 	void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse);
       
    83 private:
       
    84 	CPopAuthCramMd5MechanismHelper(const CImPop3Settings& aSettings);
       
    85 	void ConstructL();
       
    86 private:
       
    87 	TPtr8 FormSharedSecret(TPtr8 aPassword);
       
    88 private:
       
    89 	TBool iInProgress;
       
    90 	TImCodecB64 iEncoder;
       
    91 	CMD5* iMd5Hash;
       
    92 
       
    93 #if(defined SYMBIAN_SERVERMTM_UNIT_TESTCODE)
       
    94 	friend class CTestPopSaslAuthHelper;
       
    95 #endif	
       
    96 	};
       
    97 
       
    98 
       
    99 /**
       
   100 CPopAuthPlainMechanismHelper class is extended to support the AUTH command as 
       
   101 specified in RFC1734, to indicate PLAIN authentication mechanism to the server.
       
   102 
       
   103 @internalComponent
       
   104 @prototype
       
   105 */
       
   106 NONSHARABLE_CLASS( CPopAuthPlainMechanismHelper ): public CPopAuthMechanismHelper
       
   107 	{
       
   108 public:
       
   109 	static CPopAuthPlainMechanismHelper* NewL(const CImPop3Settings& aSettings);
       
   110 	CPopAuthPlainMechanismHelper(const CImPop3Settings& aSettings);
       
   111 public:
       
   112 	void GetNextClientMessageL(TDes8& aNextMessage);
       
   113 	void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse);
       
   114 private:
       
   115 	TBool iInProgress;
       
   116 	TImCodecB64 iEncoder;
       
   117 
       
   118 #if(defined SYMBIAN_SERVERMTM_UNIT_TESTCODE)
       
   119 	friend class CTestPopSaslAuthHelper;
       
   120 #endif	
       
   121 
       
   122 	};
       
   123 
       
   124 
       
   125 /**
       
   126 CPopAuthLoginMechanismHelper class is extended to support the AUTH command as 
       
   127 specified in RFC1734, to indicate LOGIN authentication mechanism to the server.
       
   128 
       
   129 @internalComponent
       
   130 @prototype
       
   131 */
       
   132 //class CPopAuthLoginMechanismHelper : public CPopAuthMechanismHelper
       
   133 NONSHARABLE_CLASS( CPopAuthLoginMechanismHelper ): public CPopAuthMechanismHelper
       
   134 	{
       
   135 public:
       
   136 	static CPopAuthLoginMechanismHelper* NewL(const CImPop3Settings& aSettings);
       
   137 	~CPopAuthLoginMechanismHelper();
       
   138 public:
       
   139 	void GetNextClientMessageL(TDes8& aNextMessage);
       
   140 	void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse);
       
   141 private:
       
   142 	CPopAuthLoginMechanismHelper(const CImPop3Settings& aSettings);
       
   143 	void ConstructL();
       
   144 private:
       
   145 	enum TLoginState
       
   146 		{
       
   147 		ESendingAuth=0,
       
   148 		ESendingLoginName,
       
   149 		ESendingPassword,
       
   150 		};
       
   151 	TLoginState iState;
       
   152 	TImCodecB64 iEncoder;
       
   153 	HBufC8* iBase64LoginName;
       
   154 	HBufC8* iBase64Password;
       
   155 
       
   156 #if(defined SYMBIAN_SERVERMTM_UNIT_TESTCODE)
       
   157 	friend class CTestPopSaslAuthHelper;
       
   158 #endif	
       
   159 
       
   160 	};
       
   161 
       
   162 #endif // __CPOPSASLAUTHHELPER_H
       
   163 
       
   164