email/imap4mtm/imapsession/inc/cimapauthhelpers.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 // IMAPAUTHHELPERS.H
       
    15 // This file specifies the "helper" classes that generate the Client responses 
       
    16 // for a particular Imap Auth mechanism. The last Server message is required 
       
    17 // to generate the Client response
       
    18 // 
       
    19 //
       
    20 
       
    21 #if !defined(_IMAPAUTHHELPERS_H__)
       
    22 #define _IMAPAUTHHELPERS_H__
       
    23 
       
    24 #include <imcvcodc.h>
       
    25 #include <imapset.h>
       
    26 #include "cimapsettings.h"
       
    27 #include <hash.h>				//hashing functions for Cramm Md5
       
    28 #include <imcvcodc.h>
       
    29 #include <timrfc822datefield.h>
       
    30 #include "cimapcommand.h"
       
    31 
       
    32 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    33 #include "timrfc822datefield.h"	
       
    34 #endif
       
    35 
       
    36 class MOutputStream;
       
    37 
       
    38 /**
       
    39 CImapAuthMechanismHelper is the base class for IMAP4 AUTH command.
       
    40 Using this class SASL (Simple Authentication and Security Layer) mechanisms 
       
    41 can be exteneded.
       
    42 Right now CRAM-MD5, PLAIN and LOGIN authentication mechanisms are supported.
       
    43 
       
    44 @internalComponent
       
    45 @prototype
       
    46 */
       
    47 NONSHARABLE_CLASS ( CImapAuthMechanismHelper) : public CImapCommandEx
       
    48 {
       
    49 public:
       
    50 	enum TImapAuthProfileFlag
       
    51 		{
       
    52 		ENoProfile=0x00,
       
    53 		EPlain=0x01,
       
    54 		ELogin=0x02,
       
    55 		ECramMD5=0x04,
       
    56 		EUndefined=0x08, // must be last flag
       
    57 		};
       
    58 protected:
       
    59 	CImapAuthMechanismHelper(const CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
    60 	const CImapSettings& iSettings;
       
    61 	TBuf8<KImMailMaxBufferSize> iNextClientMessage;
       
    62 	};
       
    63 
       
    64 /**
       
    65 CImapAuthPlainMechanismHelper class is extended to support the AUTH command as 
       
    66 specified in RFC2195, to indicate PLAIN authentication mechanism to the server.
       
    67 
       
    68 @internalComponent
       
    69 @prototype
       
    70 */
       
    71 NONSHARABLE_CLASS ( CImapAuthPlainMechanismHelper) : public CImapAuthMechanismHelper
       
    72 
       
    73 	{
       
    74 public:
       
    75 	static CImapAuthPlainMechanismHelper* NewL(const CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
    76 public:
       
    77 	void SendMessageL(TInt aTagId, MOutputStream& aStream);
       
    78 	void ParseContinuationResponseL();
       
    79 private:
       
    80 	CImapAuthPlainMechanismHelper(const  CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
    81 	void ConstructL();
       
    82 	TImCodecB64 iEncoder;
       
    83 	MOutputStream* iStream;
       
    84 	};
       
    85 
       
    86 /**
       
    87 CImapAuthLoginMechanismHelper class is extended to support the AUTH command as 
       
    88 specified in RFC2195, to indicate LOGIN authentication mechanism to the server.
       
    89 
       
    90 @internalComponent
       
    91 @prototype
       
    92 */
       
    93 NONSHARABLE_CLASS (CImapAuthLoginMechanismHelper) : public CImapAuthMechanismHelper
       
    94 
       
    95 	{
       
    96 public:
       
    97 	static CImapAuthLoginMechanismHelper* NewL(const CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
    98 	~CImapAuthLoginMechanismHelper();
       
    99 public:
       
   100 	void SendMessageL(TInt aTagId, MOutputStream& aStream);
       
   101 	void ParseContinuationResponseL();
       
   102 private:
       
   103 	CImapAuthLoginMechanismHelper(const  CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
   104 	void ConstructL();
       
   105 	
       
   106 private:
       
   107 	enum TLoginState
       
   108 		{
       
   109 		ESendingLoginName=0,
       
   110 		ESendingPassword,
       
   111 		};
       
   112 	TLoginState iState;
       
   113 	TImCodecB64 iEncoder;
       
   114 	HBufC8* iBase64LoginName;
       
   115 	HBufC8* iBase64Password;
       
   116 	MOutputStream* iStream;
       
   117 	};
       
   118 
       
   119 /**
       
   120 CImapAuthCramMd5MechanismHelper class is extended to support the AUTH command as 
       
   121 specified in RFC2195, to indicate CRAM-MD5 authentication mechanism to the server.
       
   122 
       
   123 @internalComponent
       
   124 @prototype
       
   125 */
       
   126 NONSHARABLE_CLASS ( CImapAuthCramMd5MechanismHelper) : public CImapAuthMechanismHelper
       
   127 {
       
   128 public:
       
   129 	static CImapAuthCramMd5MechanismHelper* NewL(const CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
   130 	~CImapAuthCramMd5MechanismHelper();
       
   131 public:
       
   132 	void SendMessageL(TInt aTagId, MOutputStream& aStream);
       
   133 	void ParseContinuationResponseL();
       
   134 private:
       
   135 	CImapAuthCramMd5MechanismHelper(const CImapSettings& aSettings,CImapFolderInfo* aSelectedFolderData, TInt aLogId);
       
   136 	void ConstructL();
       
   137 private:
       
   138 	TPtr8 FormSharedSecret(TPtr8 aPassword);
       
   139 private:
       
   140 	TImCodecB64 iEncoder;
       
   141 	CMD5* iMd5Hash;
       
   142 	MOutputStream* iStream;
       
   143 	};
       
   144 #endif
       
   145