|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #if !defined(__PPPAUTH_H__) |
|
17 #define __PPPAUTH_H__ |
|
18 |
|
19 #include "PPPBASE.H" |
|
20 #include "PppProg.h" |
|
21 |
|
22 /** |
|
23 The PPP authentication algorithm number for CHAP with MD5 - RFC |
|
24 1994. |
|
25 @internalComponent |
|
26 */ |
|
27 const TUint KPppChapMd5AlgorithmNumber = 0x05; |
|
28 |
|
29 /** |
|
30 The PPP authentication algorithm number for MS-CHAP (version 1) - |
|
31 RFC 2433. |
|
32 @internalComponent |
|
33 */ |
|
34 const TUint KPppMsChapAlgorithmNumber = 0x80; |
|
35 |
|
36 /** |
|
37 The PPP authentication algorithm number for MS-CHAP-V2 - RFC 2759. |
|
38 @internalComponent |
|
39 */ |
|
40 const TUint KPppMsChap2AlgorithmNumber = 0x81; |
|
41 |
|
42 |
|
43 const TUint KPppApIsClient = 0x01; |
|
44 const TUint KPppApIsServer = 0x02; |
|
45 const TUint KPppApAuthReqDone = 0x04; |
|
46 |
|
47 |
|
48 NONSHARABLE_CLASS(CPppAuthentication) : public CBase, public MPppRecvr |
|
49 /** |
|
50 @internalTechnology |
|
51 Base class for all PPP authentication protocols (PAP, CHAP, etc) |
|
52 */ |
|
53 { |
|
54 friend class CPppAcp; |
|
55 |
|
56 public: |
|
57 /** |
|
58 Destructor. |
|
59 */ |
|
60 virtual ~CPppAuthentication(); |
|
61 |
|
62 /** |
|
63 Second phase initializer. |
|
64 @param aLcp [in] A pointer to the instance of CPppLcp class that |
|
65 will use this object for authentication. |
|
66 @leave Standard Symbian OS error codes. e.g. KErrNoMemory. |
|
67 */ |
|
68 virtual void InitL(CPppLcp* aPppLcp); |
|
69 |
|
70 /** |
|
71 @copydoc MPppRecvr::FrameError() |
|
72 @see MPppRecvr::FrameError() |
|
73 */ |
|
74 virtual void FrameError(); |
|
75 |
|
76 /** |
|
77 @copydoc MPppRecvr::KillProtocol() |
|
78 @see MPppRecvr::KillProtocol() |
|
79 */ |
|
80 virtual void KillProtocol(); |
|
81 |
|
82 void AuthenticateRequest(); |
|
83 void CallAuthenticateComplete(TInt aRes); |
|
84 |
|
85 protected: |
|
86 /** |
|
87 Notifies that NifMan has completed the user authentication request. |
|
88 If the authentication request has been successful, the username and |
|
89 the password have been returned to the NIF. |
|
90 @param aStatus [in] Status code of the authentication attempt. |
|
91 */ |
|
92 virtual void AuthenticateComplete(TInt aStatus)=0; |
|
93 |
|
94 virtual TPppPhase PppPhase() const; |
|
95 |
|
96 /** |
|
97 Returns the PPP protocol number for this authentication protocol. |
|
98 @return The PPP protocol number for this authentication protocol. |
|
99 */ |
|
100 virtual TUint PppId() const = 0; |
|
101 |
|
102 void DoFail(TInt aErrorCode); |
|
103 |
|
104 void DoSucceed(); |
|
105 |
|
106 /* Tests if NifMan has completed the user authentication request. If |
|
107 the authentication request has been successful, the username and |
|
108 the password have been returned to the NIF. |
|
109 @return ETrue if NifMan has completed the user authentication |
|
110 request, EFalse otherwise. |
|
111 */ |
|
112 TBool IsAuthenticateRequestDone() const; |
|
113 |
|
114 /* Tests if the this receiver is inactive and the data frames being |
|
115 received will not be delivered to it. |
|
116 @return ETrue if the current the receiver is inactive, EFalse is |
|
117 the current receiver is active. |
|
118 */ |
|
119 TBool IsInactive() const; |
|
120 |
|
121 protected: |
|
122 |
|
123 TUint iFlags; |
|
124 |
|
125 private: |
|
126 /** Flag that indicates if this instance is inactive, i.e. it will |
|
127 process the data link frames received. */ |
|
128 TBool iDead; |
|
129 }; |
|
130 |
|
131 |
|
132 inline TPppPhase CPppAuthentication::PppPhase() const |
|
133 { |
|
134 return EPppPhaseAuthenticate; |
|
135 } |
|
136 |
|
137 inline TBool CPppAuthentication::IsAuthenticateRequestDone() const |
|
138 { |
|
139 return iFlags & KPppApAuthReqDone; |
|
140 } |
|
141 |
|
142 inline void CPppAuthentication::FrameError() |
|
143 { |
|
144 } |
|
145 |
|
146 inline void CPppAuthentication::KillProtocol() |
|
147 { |
|
148 iDead = ETrue; |
|
149 } |
|
150 |
|
151 inline TBool CPppAuthentication::IsInactive() const |
|
152 { |
|
153 return iDead; |
|
154 } |
|
155 |
|
156 NONSHARABLE_CLASS(CPppAcp) : public CBase, public MPppOptionHandler |
|
157 /** |
|
158 @internalTechnology |
|
159 Option handler for the PPP authentication option. Uses the current |
|
160 authentication mode from CommDb (CHAP, PAP, CHAP with PAP fallback). |
|
161 |
|
162 The handler does not initiate the authentication protocol negotiation, |
|
163 it is expected that the server will propose an authentication protocol |
|
164 if required. |
|
165 */ |
|
166 { |
|
167 public: |
|
168 CPppAcp(CPppLcp* aLcp); |
|
169 virtual ~CPppAcp(); |
|
170 static CPppAcp* NewL(CPppLcp* aLcp); |
|
171 |
|
172 protected: |
|
173 // MPppOptionHandler |
|
174 virtual void OptNegotiationStarted(); |
|
175 virtual void OptNegotiationAborted(); |
|
176 virtual void OptNegotiationComplete(); |
|
177 virtual void OptFillinConfigRequestL(RPppOptionList& aRequestList); |
|
178 virtual TPppOptResponse OptCheckConfigRequest(RPppOption& aOption); |
|
179 virtual void OptApplyConfigRequest(RPppOption& aOption); |
|
180 virtual void OptRecvConfigAck(RPppOption& aOption); |
|
181 virtual void OptRecvConfigNak(RPppOption& aOption, RPppOptionList& aReqList); |
|
182 virtual void OptRecvConfigReject(RPppOption& aOption, RPppOptionList& aReqList); |
|
183 |
|
184 void DeleteProtocols(); |
|
185 TPppOptResponse ProposeChap(RPppOption& aOption); |
|
186 TPppOptResponse ProposePap(RPppOption& aOption); |
|
187 |
|
188 private: |
|
189 TUint iClientId; |
|
190 TUint iServerId; |
|
191 TUint iClientSubId; |
|
192 TUint iServerSubId; |
|
193 TUint8 iCHAPTypeOffered; |
|
194 TUint8 iProtocolOffered; |
|
195 |
|
196 CPppAuthentication* iClientProtocol; |
|
197 CPppAuthentication* iServerProtocol; |
|
198 CPppLcp* iPppLcp; |
|
199 }; |
|
200 |
|
201 #endif |