|
1 // Copyright (c) 2005-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 // Name : CSIPAuthenticationInfoHeaderParams.cpp |
|
15 // Part of : SIP Codec |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "CSIPAuthenticationInfoHeaderParams.h" |
|
23 #include "sipcodecerr.h" |
|
24 #include "SIPSyntaxCheck.h" |
|
25 #include "sipstrings.h" |
|
26 #include "sipstrconsts.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CSIPAuthenticationInfoHeaderParams::NewL |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CSIPAuthenticationInfoHeaderParams* CSIPAuthenticationInfoHeaderParams::NewL( |
|
33 const CSIPAuthenticationInfoHeaderParams& aParams) |
|
34 { |
|
35 CSIPAuthenticationInfoHeaderParams* self = |
|
36 CSIPAuthenticationInfoHeaderParams::NewLC(aParams); |
|
37 CleanupStack::Pop(self); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSIPAuthenticationInfoHeaderParams::NewLC |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CSIPAuthenticationInfoHeaderParams* CSIPAuthenticationInfoHeaderParams::NewLC( |
|
46 const CSIPAuthenticationInfoHeaderParams& aParams) |
|
47 { |
|
48 CSIPAuthenticationInfoHeaderParams* self = |
|
49 new(ELeave)CSIPAuthenticationInfoHeaderParams; |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(aParams); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSIPAuthenticationInfoHeaderParams::CSIPAuthenticationInfoHeaderParams |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CSIPAuthenticationInfoHeaderParams::CSIPAuthenticationInfoHeaderParams () |
|
60 : CSIPParamContainerBase(',') |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CSIPAuthenticationInfoHeaderParams::~CSIPAuthenticationInfoHeaderParams |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CSIPAuthenticationInfoHeaderParams::~CSIPAuthenticationInfoHeaderParams () |
|
69 { |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // CSIPAuthenticationInfoHeaderParams::AddQuotesWhenEncoding |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 TBool CSIPAuthenticationInfoHeaderParams::AddQuotesWhenEncoding( |
|
77 RStringF aParamName) const |
|
78 { |
|
79 if (aParamName == SIPStrings::StringF(SipStrConsts::ENextNonce) || |
|
80 aParamName == SIPStrings::StringF(SipStrConsts::ECNonce) || |
|
81 aParamName == SIPStrings::StringF(SipStrConsts::EResponseAuth)) |
|
82 { |
|
83 return ETrue; |
|
84 } |
|
85 return EFalse; |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CSIPAuthenticationInfoHeaderParams::CheckAndUpdateParamL |
|
90 // ---------------------------------------------------------------------------- |
|
91 // |
|
92 void CSIPAuthenticationInfoHeaderParams::CheckAndUpdateParamL( |
|
93 RStringF aName, |
|
94 TBool /*aHasValue*/, |
|
95 TPtrC8& aValue) const |
|
96 { |
|
97 // nextnonce, cnonce |
|
98 if (aName == SIPStrings::StringF(SipStrConsts::ENextNonce) || |
|
99 aName == SIPStrings::StringF(SipStrConsts::ECNonce)) |
|
100 { |
|
101 RemoveQuotes(aValue); |
|
102 if (!SIPSyntaxCheck::QuotedStringValue(aValue)) |
|
103 { |
|
104 User::Leave(KErrSipCodecAuthenticationInfoHeader); |
|
105 } |
|
106 return; |
|
107 } |
|
108 // message-qop |
|
109 if (aName == SIPStrings::StringF(SipStrConsts::EQop)) |
|
110 { |
|
111 RemoveQuotes(aValue); |
|
112 if (!SIPSyntaxCheck::Token(aValue)) |
|
113 { |
|
114 User::Leave(KErrSipCodecAuthenticationInfoHeader); |
|
115 } |
|
116 return; |
|
117 } |
|
118 // response-auth |
|
119 if (aName == SIPStrings::StringF(SipStrConsts::EResponseAuth)) |
|
120 { |
|
121 RemoveQuotes(aValue); |
|
122 if (!SIPSyntaxCheck::HexValue(aValue)) |
|
123 { |
|
124 User::Leave(KErrSipCodecAuthenticationInfoHeader); |
|
125 } |
|
126 return; |
|
127 } |
|
128 // nonce-count |
|
129 if (aName == SIPStrings::StringF(SipStrConsts::ENonceCount)) |
|
130 { |
|
131 const TInt KNonceCountLength = 8; |
|
132 if (!SIPSyntaxCheck::HexValue(aValue,KNonceCountLength)) |
|
133 { |
|
134 User::Leave(KErrSipCodecAuthenticationInfoHeader); |
|
135 } |
|
136 return; |
|
137 } |
|
138 // The above are the only allowed parameters. No extensions allowed. |
|
139 User::Leave(KErrSipCodecAuthenticationInfoHeader); |
|
140 } |