|
1 /* |
|
2 * Copyright (c) 2002-2005 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include <SenCredential2.h> |
|
27 #include <SenFacet.h> |
|
28 #include <SenDateUtils.h> |
|
29 #include <SenXmlElement.h> // check if this include is needed(?) |
|
30 #include <SenXmlUtils.h> |
|
31 #include <SenXmlServiceDescription.h> |
|
32 |
|
33 |
|
34 #ifdef SYMBIAN_SECURE_ECOM |
|
35 // for S60 FP3 (2.8) platform or newer (3.0 and above) |
|
36 #include <xml/attribute.h> // needed for RAttributeArray |
|
37 //#else // for S60 FP2 platform (2.6) or older |
|
38 //#include "Attribute.h" |
|
39 #endif |
|
40 |
|
41 using namespace Xml; |
|
42 |
|
43 namespace |
|
44 { |
|
45 // _LIT8(KSenCredentialIdentifierLocalname, "CredentialIdentifier"); |
|
46 |
|
47 // Identifiers which are accepted (and searched after) |
|
48 _LIT8(KId, "ID"); |
|
49 _LIT8(Kwsu_ns_plus_Id, "wsu:Id"); |
|
50 _LIT8(KAssertionId, "AssertionID"); |
|
51 |
|
52 _LIT8(KConditions, "Conditions"); |
|
53 _LIT8(KVal_NotOnOrAfter, "NotOnOrAfter"); |
|
54 |
|
55 // _LIT8(KSenCredentialId, "SenCredentialId"); |
|
56 // _LIT8(KProviderIdLocalName, "ProviderID"); |
|
57 |
|
58 // const TInt KCredIdBufSize = 128; |
|
59 } |
|
60 |
|
61 EXPORT_C CSenCredential2* CSenCredential2::NewL() |
|
62 { |
|
63 CSenCredential2* pNew = NewLC(); |
|
64 CleanupStack::Pop(); // pNew; |
|
65 return pNew; |
|
66 } |
|
67 |
|
68 EXPORT_C CSenCredential2* CSenCredential2::NewLC() |
|
69 { |
|
70 CSenCredential2* pNew = new (ELeave) CSenCredential2; |
|
71 CleanupStack::PushL(pNew); |
|
72 pNew->ConstructL(KNullDesC8); |
|
73 return pNew; |
|
74 } |
|
75 |
|
76 EXPORT_C CSenCredential2* CSenCredential2::NewL( |
|
77 const TDesC8& aNsUri, |
|
78 const TDesC8& aLocalName, |
|
79 const TDesC8& aQName, |
|
80 const RAttributeArray& aAttributes) |
|
81 { |
|
82 CSenCredential2* pNew = NewLC(aNsUri, aLocalName, aQName, aAttributes); |
|
83 CleanupStack::Pop(); // pNew; |
|
84 return pNew; |
|
85 } |
|
86 |
|
87 EXPORT_C CSenCredential2* CSenCredential2::NewLC( |
|
88 const TDesC8& aNsUri, |
|
89 const TDesC8& aLocalName, |
|
90 const TDesC8& aQName, |
|
91 const RAttributeArray& aAttributes) |
|
92 { |
|
93 CSenCredential2* pNew = new (ELeave) CSenCredential2; |
|
94 CleanupStack::PushL(pNew); |
|
95 pNew->BaseConstructL(aNsUri, aLocalName, aQName, aAttributes); |
|
96 return pNew; |
|
97 } |
|
98 |
|
99 EXPORT_C CSenCredential2* CSenCredential2::NewL( |
|
100 const TDesC8& aNsUri, |
|
101 const TDesC8& aLocalName, |
|
102 const TDesC8& aQName, |
|
103 const RAttributeArray& aAttributes, |
|
104 TXmlEngElement& aParent) |
|
105 { |
|
106 CSenCredential2* pNew = NewLC(aNsUri, aLocalName, |
|
107 aQName, aAttributes, aParent); |
|
108 CleanupStack::Pop(); // pNew; |
|
109 return pNew; |
|
110 } |
|
111 |
|
112 EXPORT_C CSenCredential2* CSenCredential2::NewLC( |
|
113 const TDesC8& aNsUri, |
|
114 const TDesC8& aLocalName, |
|
115 const TDesC8& aQName, |
|
116 const RAttributeArray& aAttributes, |
|
117 TXmlEngElement& aParent) |
|
118 { |
|
119 CSenCredential2* pNew = new (ELeave) CSenCredential2; |
|
120 CleanupStack::PushL(pNew); |
|
121 pNew->BaseConstructL(aNsUri, aLocalName, aQName, aAttributes, aParent); |
|
122 return pNew; |
|
123 } |
|
124 |
|
125 EXPORT_C CSenCredential2* CSenCredential2::NewL( |
|
126 const TDesC8& aNsUri, |
|
127 const TDesC8& aLocalName, |
|
128 const TDesC8& aQName, |
|
129 const RAttributeArray& aAttributes, |
|
130 TXmlEngElement& aParent, |
|
131 RSenDocument& aOwnerDocument) |
|
132 { |
|
133 CSenCredential2* pNew = NewLC(aNsUri, aLocalName, |
|
134 aQName, aAttributes, |
|
135 aParent, aOwnerDocument); |
|
136 CleanupStack::Pop(); // pNew; |
|
137 return pNew; |
|
138 } |
|
139 |
|
140 EXPORT_C CSenCredential2* CSenCredential2::NewLC( |
|
141 const TDesC8& aNsUri, |
|
142 const TDesC8& aLocalName, |
|
143 const TDesC8& aQName, |
|
144 const RAttributeArray& aAttributes, |
|
145 TXmlEngElement& aParent, |
|
146 RSenDocument& aOwnerDocument) |
|
147 { |
|
148 CSenCredential2* pNew = new (ELeave) CSenCredential2; |
|
149 CleanupStack::PushL(pNew); |
|
150 pNew->BaseConstructL(aNsUri, aLocalName, aQName, aAttributes, aParent, |
|
151 aOwnerDocument); |
|
152 return pNew; |
|
153 } |
|
154 |
|
155 EXPORT_C CSenCredential2* CSenCredential2::NewL( |
|
156 const CSenCredential2& aCredential) |
|
157 { |
|
158 CSenCredential2* pNew = NewLC(aCredential); |
|
159 CleanupStack::Pop(); // pNew; |
|
160 return pNew; |
|
161 } |
|
162 |
|
163 EXPORT_C CSenCredential2* CSenCredential2::NewLC( |
|
164 const CSenCredential2& aCredential) |
|
165 { |
|
166 CSenCredential2* pNew = new (ELeave) CSenCredential2; |
|
167 CleanupStack::PushL(pNew); |
|
168 pNew->BaseConstructL((CSenCredential2&)aCredential); |
|
169 return pNew; |
|
170 } |
|
171 |
|
172 EXPORT_C void CSenCredential2::ConstructL(const TDesC8& aLocalName) |
|
173 { |
|
174 CSenFragmentBase::BaseConstructL(aLocalName); |
|
175 } |
|
176 |
|
177 EXPORT_C void CSenCredential2::BaseConstructL(CSenCredential2& aCredential) |
|
178 { |
|
179 CSenFragmentBase::BaseConstructL(aCredential.AsElementL()); |
|
180 if (aCredential.ValidUntil() != Time::NullTTime()) |
|
181 { |
|
182 SetValidUntil(aCredential.ValidUntil()); |
|
183 } |
|
184 SetIdL(aCredential.Id()); |
|
185 } |
|
186 |
|
187 EXPORT_C void CSenCredential2::BaseConstructL( |
|
188 const TDesC8& aNsUri, |
|
189 const TDesC8& aLocalName, |
|
190 const TDesC8& aQName, |
|
191 const RAttributeArray& aAttributes, |
|
192 TXmlEngElement& aParent) |
|
193 { |
|
194 CSenFragmentBase::BaseConstructL(aNsUri, aLocalName, aQName, aAttributes, |
|
195 aParent); |
|
196 |
|
197 // we want to save its ID and validity |
|
198 TPtrC8 identifier = SenXmlUtils::AttrValue(aAttributes, KId); |
|
199 if(identifier.Length()>0) |
|
200 { |
|
201 SetIdL(identifier); |
|
202 } |
|
203 |
|
204 TPtrC8 identifier2 = SenXmlUtils::AttrValue(aAttributes, Kwsu_ns_plus_Id); |
|
205 if(identifier2.Length()>0) |
|
206 { |
|
207 SetIdL(identifier2); |
|
208 } |
|
209 |
|
210 TPtrC8 identifier3 = SenXmlUtils::AttrValue(aAttributes, KAssertionId); |
|
211 if(identifier3.Length()>0) |
|
212 { |
|
213 SetIdL(identifier3); |
|
214 } |
|
215 } |
|
216 |
|
217 EXPORT_C void CSenCredential2::BaseConstructL(const TDesC8& aNsUri, |
|
218 const TDesC8& aLocalName, |
|
219 const TDesC8& aQName, |
|
220 const RAttributeArray& aAttributes, |
|
221 TXmlEngElement& aParent, |
|
222 RSenDocument& aOwnerDocument) |
|
223 { |
|
224 CSenFragmentBase::BaseConstructL(aNsUri, aLocalName, aQName, aAttributes, |
|
225 aParent, aOwnerDocument); |
|
226 |
|
227 // we want to save its ID and validity |
|
228 TPtrC8 identifier = SenXmlUtils::AttrValue(aAttributes, KId); |
|
229 if(identifier.Length()>0) |
|
230 { |
|
231 SetIdL(identifier); |
|
232 } |
|
233 |
|
234 TPtrC8 identifier2 = SenXmlUtils::AttrValue(aAttributes, Kwsu_ns_plus_Id); |
|
235 if(identifier2.Length()>0) |
|
236 { |
|
237 SetIdL(identifier2); |
|
238 } |
|
239 |
|
240 TPtrC8 identifier3 = SenXmlUtils::AttrValue(aAttributes, KAssertionId); |
|
241 if(identifier3.Length()>0) |
|
242 { |
|
243 SetIdL(identifier3); |
|
244 } |
|
245 } |
|
246 |
|
247 EXPORT_C void CSenCredential2::BaseConstructL(const TDesC8& aNsUri, |
|
248 const TDesC8& aLocalName, |
|
249 const TDesC8& aQName, |
|
250 const RAttributeArray& aAttributes) |
|
251 { |
|
252 CSenFragmentBase::BaseConstructL(aNsUri, aLocalName, aQName, aAttributes); |
|
253 |
|
254 TPtrC8 identifier = SenXmlUtils::AttrValue(aAttributes, KId); |
|
255 if(identifier.Length()>0) |
|
256 { |
|
257 SetIdL(identifier); |
|
258 } |
|
259 |
|
260 TPtrC8 identifier2 = SenXmlUtils::AttrValue(aAttributes, Kwsu_ns_plus_Id); |
|
261 if(identifier2.Length()>0) |
|
262 { |
|
263 SetIdL(identifier2); |
|
264 } |
|
265 |
|
266 TPtrC8 identifier3 = SenXmlUtils::AttrValue(aAttributes, KAssertionId); |
|
267 if(identifier3.Length()>0) |
|
268 { |
|
269 SetIdL(identifier3); |
|
270 } |
|
271 } |
|
272 |
|
273 EXPORT_C CSenCredential2::CSenCredential2() |
|
274 : |
|
275 iId(NULL), |
|
276 iNotOnOrAfter(Time::NullTTime()) |
|
277 { |
|
278 } |
|
279 |
|
280 EXPORT_C CSenCredential2::~CSenCredential2() |
|
281 { |
|
282 delete iId; |
|
283 } |
|
284 |
|
285 EXPORT_C void CSenCredential2::SetIdL(const TDesC8& aNewId) |
|
286 { |
|
287 HBufC8* pNew = aNewId.AllocL(); |
|
288 delete iId; |
|
289 iId = pNew; |
|
290 } |
|
291 |
|
292 EXPORT_C const TDesC8& CSenCredential2::Id() |
|
293 { |
|
294 if(iId) |
|
295 { |
|
296 return *iId; |
|
297 } |
|
298 else |
|
299 { |
|
300 return KNullDesC8(); |
|
301 } |
|
302 } |
|
303 |
|
304 |
|
305 EXPORT_C void CSenCredential2::OnStartElementL(const RTagInfo& aElement, |
|
306 const RAttributeArray& aAttributes, |
|
307 TInt aErrorCode) |
|
308 { |
|
309 if ( aElement.LocalName().DesC().Compare(KConditions) == 0) |
|
310 { |
|
311 // we should save the notOnOrAfter attribute value |
|
312 TPtrC8 ptr = SenXmlUtils::AttrValue(aAttributes, KVal_NotOnOrAfter ); |
|
313 |
|
314 // Convert dateTime (from XML schema) to Symbian TTime. |
|
315 // The returned time will be in UTC. |
|
316 if (ptr.Length() > 0) |
|
317 { |
|
318 iNotOnOrAfter = SenDateUtils::FromXmlDateTimeL(ptr); |
|
319 } |
|
320 } |
|
321 CSenFragmentBase::OnStartElementL(aElement, aAttributes, aErrorCode); |
|
322 } |
|
323 |
|
324 EXPORT_C TTime& CSenCredential2::ValidUntil() |
|
325 { |
|
326 return iNotOnOrAfter; |
|
327 } |
|
328 |
|
329 |
|
330 EXPORT_C void CSenCredential2::SetValidUntil(TTime& aTime) |
|
331 { |
|
332 iNotOnOrAfter = aTime; |
|
333 } |
|
334 |
|
335 // END OF FILE |