|
1 /* |
|
2 * Copyright (c) 2008-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 "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 * Name : CSIPSecChallenge.h |
|
16 * Part of : SIPSec/DigestPlugin |
|
17 * Version : SIP/6.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef __CSIPSEC_CHALLENGE_H__ |
|
29 #define __CSIPSEC_CHALLENGE_H__ |
|
30 |
|
31 // INCLUDES |
|
32 #include "CSIPSecDigest.h" |
|
33 #include "sipsecrequestdata.h" |
|
34 #include "CSIPSecUserRecord.h" |
|
35 #include "SipStackServerDefs.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CSIPAuthenticateHeaderBase; |
|
39 class MSIPSecAlgorithm; |
|
40 class TSIPSecDigestCtxSetup; |
|
41 class MSIPSecUser; |
|
42 |
|
43 |
|
44 // CLASS DECLARATION |
|
45 |
|
46 /** |
|
47 * @brief Class representing challenge received in 401/407 response |
|
48 * |
|
49 * @class CSIPSecChallenge CSIPSecChallenge.h "CSIPSecChallenge.h" |
|
50 * |
|
51 * This class is a base class for challenge, whose inherited classes implement |
|
52 * functionality of algotithm defined in challenge. |
|
53 * Class provides functions for populating common values to credentials |
|
54 * (created from this challenge) |
|
55 * This class also provides functions for resolving type of challenge, realm |
|
56 * and content (SIP authenticate header) |
|
57 * |
|
58 * Inherited class must implement methods: |
|
59 * - Algorithm, which provides digest calculation interface |
|
60 * - VerifyType, that checks the challenge type is correct |
|
61 */ |
|
62 class CSIPSecChallenge : public CBase |
|
63 { |
|
64 public: // Constructors and destructor |
|
65 |
|
66 /** |
|
67 * Destructor |
|
68 */ |
|
69 virtual ~CSIPSecChallenge(); |
|
70 |
|
71 public: // New pure virtual functions |
|
72 |
|
73 /** |
|
74 * Returns algorithm |
|
75 * @return Algorithm |
|
76 */ |
|
77 virtual MSIPSecAlgorithm& Algorithm() = 0; |
|
78 |
|
79 /** |
|
80 * Checks that the type is correct. |
|
81 * @param aType Record type |
|
82 * @leave KErrPermissionDenied if aType is not correct. |
|
83 */ |
|
84 virtual void VerifyTypeL( CSIPSecUserRecord::TType aType ) const = 0; |
|
85 |
|
86 /** |
|
87 * Creates a new CSIPSecUserRecord. |
|
88 * @param aRealm Realm |
|
89 * @param aUser SIPSec user who is processing the SIP response that leads to |
|
90 * creating a new user record. |
|
91 * @param aRegistrationId Registration id |
|
92 * @param aTransactionId Transaction id of the SIP response |
|
93 * @param aResponseCode Response code of SIP response |
|
94 */ |
|
95 virtual CSIPSecUserRecord* |
|
96 CreateUserRecordL( const TDesC8& aRealm, |
|
97 const MSIPSecUser& aUser, |
|
98 TRegistrationId aRegistrationId, |
|
99 TTransactionId aTransactionId, |
|
100 TUint aResponseCode ) const = 0; |
|
101 |
|
102 public: // New functions |
|
103 |
|
104 /** |
|
105 * Populates credentials |
|
106 * @param aContext Digest context |
|
107 */ |
|
108 void PopulateCredentialsL( TSIPSecDigestCtxSetup& aContext ) const; |
|
109 |
|
110 /** |
|
111 * Returns the type of challenge |
|
112 * @return Type of challenge |
|
113 */ |
|
114 CSIPSecDigest::TChallengeType Type() const; |
|
115 |
|
116 /** |
|
117 * Returns the realm of challenge |
|
118 * @return Realm |
|
119 */ |
|
120 const TDesC8& Realm() const; |
|
121 |
|
122 /** |
|
123 * Returns a modifiable content of the challenge (SIP authenticate header). |
|
124 * @return Content of challenge |
|
125 */ |
|
126 CSIPAuthenticateHeaderBase& Content(); |
|
127 |
|
128 /** |
|
129 * Returns a non-modifiable content of the challenge (SIP authenticate |
|
130 * header). |
|
131 * @return Content of challenge |
|
132 */ |
|
133 const CSIPAuthenticateHeaderBase& Content() const; |
|
134 |
|
135 /** |
|
136 * Check if the qop exists |
|
137 * @return ETrue if qop exists, EFalse otherwise |
|
138 */ |
|
139 TBool HasQop() const; |
|
140 |
|
141 /** |
|
142 * Gets the qop as descriptor. |
|
143 * @return qop as descriptor, or empty descriptor if qop doesn't exist |
|
144 */ |
|
145 const TDesC8& QopDescriptor() const; |
|
146 |
|
147 /** |
|
148 * Gets the owner of this challenge |
|
149 * @return Owner of the challenge. Ownership is not transferred. |
|
150 */ |
|
151 const MSIPSecUser* Owner() const; |
|
152 |
|
153 /** |
|
154 * Sets the owner of this challenge |
|
155 * @return Owner. Ownership is not transferred. |
|
156 */ |
|
157 void SetOwner( const MSIPSecUser* aOwner ); |
|
158 |
|
159 protected: //methods |
|
160 |
|
161 /** |
|
162 * Constructor |
|
163 * @param aType the type of challenge |
|
164 * @param aQop qop of the challenge |
|
165 */ |
|
166 CSIPSecChallenge( CSIPSecDigest::TChallengeType aType, |
|
167 CSIPSecRequestData::TQop aQop ); |
|
168 |
|
169 /** |
|
170 * Second phase constructor |
|
171 * @param aAuthenticateHeader authenticate header |
|
172 */ |
|
173 void ConstructL( CSIPAuthenticateHeaderBase& aAuthenticateHeader ); |
|
174 |
|
175 /** |
|
176 * Gets the qop value. |
|
177 * @return qop value |
|
178 */ |
|
179 CSIPSecRequestData::TQop Qop() const; |
|
180 |
|
181 private: |
|
182 |
|
183 /** |
|
184 * Copies the parameter from challenge to authorization header. |
|
185 * @param aContext Digest context |
|
186 * @param aParam String pool constant of the parameter name |
|
187 */ |
|
188 void FillCredentialParamL( TSIPSecDigestCtxSetup& aContext, |
|
189 TInt aParam ) const; |
|
190 |
|
191 private: // Data |
|
192 |
|
193 // Owned |
|
194 CSIPAuthenticateHeaderBase* iAuthenticateHeader; |
|
195 |
|
196 CSIPSecDigest::TChallengeType iType; |
|
197 |
|
198 // Qop to be used for the challenge. |
|
199 CSIPSecRequestData::TQop iQop; |
|
200 |
|
201 // Owner of this challenge. Not owned. |
|
202 const MSIPSecUser* iOwner; |
|
203 |
|
204 // For testing purposes |
|
205 #ifdef CPPUNIT_TEST |
|
206 friend class CSIPSecChallengeTest; |
|
207 #endif |
|
208 }; |
|
209 |
|
210 #endif //end of __CSIPSEC_CHALLENGE_H__ |
|
211 |
|
212 // End of File |