|
1 // Copyright (c) 2002-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 // This file specifies the "helper" classes that generate the Client responses |
|
15 // for a particular SMTP Auth mechanism. The last Server message is required |
|
16 // to generate the Client response |
|
17 // |
|
18 // |
|
19 |
|
20 |
|
21 #if !defined(_SMTPAUTHHELPERS_H__) |
|
22 #define _SMTPAUTHHELPERS_H__ |
|
23 |
|
24 #include <imcvcodc.h> |
|
25 #include <smtpset.h> |
|
26 #include "csmtpsettings.h" |
|
27 #include <hash.h> //hashing functions for Cramm Md5 |
|
28 #include <imcvcodc.h> |
|
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
30 #include "timrfc822datefield.h" |
|
31 #endif |
|
32 |
|
33 // Base class for SMTP Auth "helper" mechanism |
|
34 class CSmtpAuthMechanismHelper : public CBase |
|
35 /** |
|
36 @internalComponent |
|
37 @released |
|
38 */ |
|
39 { |
|
40 public: |
|
41 enum TSmtpAuthProfileFlag |
|
42 { |
|
43 ENoProfile=0x00, |
|
44 EPlain=0x01, |
|
45 ELogin=0x02, |
|
46 ECramMD5=0x04, |
|
47 EUndefined=0x08, // must be last flag |
|
48 }; |
|
49 protected: |
|
50 CSmtpAuthMechanismHelper(const CSmtpSettings& aSettings); |
|
51 public: |
|
52 virtual void GetNextClientMessageL(TDes8& aNextMessage)=0; |
|
53 virtual void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse)=0; |
|
54 protected: |
|
55 const CSmtpSettings& iSettings; |
|
56 TPtrC8 iLastServerMessage; |
|
57 TBuf8<KImMailMaxBufferSize> iNextClientMessage; |
|
58 }; |
|
59 |
|
60 // Smtp Auth 'PLAIN mechanism helper |
|
61 class CSmtpAuthPlainMechanismHelper : public CSmtpAuthMechanismHelper |
|
62 /** |
|
63 @internalComponent |
|
64 @released |
|
65 */ |
|
66 { |
|
67 public: |
|
68 CSmtpAuthPlainMechanismHelper(const CSmtpSettings& aSettings); |
|
69 public: |
|
70 void GetNextClientMessageL(TDes8& aNextMessage); |
|
71 void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse); |
|
72 private: |
|
73 TImCodecB64 iEncoder; |
|
74 }; |
|
75 |
|
76 // Smtp Auth 'LOGIN' mechanism helper |
|
77 class CSmtpAuthLoginMechanismHelper : public CSmtpAuthMechanismHelper |
|
78 /** |
|
79 @internalComponent |
|
80 @released |
|
81 */ |
|
82 { |
|
83 public: |
|
84 static CSmtpAuthLoginMechanismHelper* NewL(const CSmtpSettings& aSettings); |
|
85 ~CSmtpAuthLoginMechanismHelper(); |
|
86 public: |
|
87 void GetNextClientMessageL(TDes8& aNextMessage); |
|
88 void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse); |
|
89 private: |
|
90 CSmtpAuthLoginMechanismHelper(const CSmtpSettings& aSettings); |
|
91 void ConstructL(); |
|
92 private: |
|
93 enum TLoginState |
|
94 { |
|
95 ESendingAuth=0, |
|
96 ESendingLoginName, |
|
97 ESendingPassword, |
|
98 }; |
|
99 TLoginState iState; |
|
100 TImCodecB64 iEncoder; |
|
101 HBufC8* iBase64LoginName; |
|
102 HBufC8* iBase64Password; |
|
103 }; |
|
104 |
|
105 // Smtp Auth 'CRAM-MD5' mechanism helper |
|
106 class CSmtpAuthCramMd5MechanismHelper : public CSmtpAuthMechanismHelper |
|
107 /** |
|
108 @internalComponent |
|
109 @released |
|
110 */ |
|
111 { |
|
112 public: |
|
113 static CSmtpAuthCramMd5MechanismHelper* NewL(const CSmtpSettings& aSettings); |
|
114 ~CSmtpAuthCramMd5MechanismHelper(); |
|
115 public: |
|
116 void GetNextClientMessageL(TDes8& aNextMessage); |
|
117 void SetLastServerMessageL(const TDesC8& aLastMessage, TBool aIsMultiLineResponse); |
|
118 private: |
|
119 CSmtpAuthCramMd5MechanismHelper(const CSmtpSettings& aSettings); |
|
120 void ConstructL(); |
|
121 private: |
|
122 TPtr8 FormSharedSecret(TPtr8 aPassword); |
|
123 private: |
|
124 TBool iInProgress; |
|
125 TImCodecB64 iEncoder; |
|
126 CMD5* iMd5Hash; |
|
127 }; |
|
128 |
|
129 GLREF_C CSmtpAuthMechanismHelper* CreateSMTPAuthHelperL(CSmtpAuthMechanismHelper::TSmtpAuthProfileFlag aType, const CSmtpSettings& aSettings); //factory function |
|
130 |
|
131 #endif |