|
1 /* |
|
2 * Copyright (c) 2002-2004 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 #include "base64.h" |
|
23 #include "LeaveDomainReq.h" |
|
24 |
|
25 using namespace Roap; |
|
26 |
|
27 // LOCAL CONSTANTS AND MACROS |
|
28 _LIT8(KReqHeader, "<roap:leaveDomainRequest xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\""); |
|
29 _LIT8(KReqNonceTrigger, " triggerNonce=\""); |
|
30 _LIT8(KReqNonceTriggerEnd, "\""); |
|
31 _LIT8(KReqHeaderEnd, ">"); |
|
32 _LIT8(KReqNonce, "<nonce>"); |
|
33 _LIT8(KReqNonceEnd, "</nonce>"); |
|
34 _LIT8(KReqTime, "<time>"); |
|
35 _LIT8(KReqTimeEnd, "</time>"); |
|
36 _LIT8(KReqDeviceId, "<deviceID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\ |
|
37 algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>"); |
|
38 _LIT8(KReqDeviceIdEnd, "</hash></keyIdentifier></deviceID>"); |
|
39 _LIT8(KReqRiId, "<riID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\ |
|
40 algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>"); |
|
41 _LIT8(KReqRiIdEnd, "</hash></keyIdentifier></riID>"); |
|
42 _LIT8(KReqDomainId, "<domainID>"); |
|
43 _LIT8(KReqDomainIdEnd, "</domainID>"); |
|
44 _LIT8(KReqCertChain, "<certificateChain>"); |
|
45 _LIT8(KReqCert, "<certificate>"); |
|
46 _LIT8(KReqCertEnd, "</certificate>"); |
|
47 _LIT8(KReqCertChainEnd, "</certificateChain>"); |
|
48 _LIT8(KReqNotDomainMember, "<extensions><extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\ |
|
49 xsi:type=\"roap:NotDomainMember\"></extension></extensions>"); |
|
50 _LIT8(KReqSig, "<signature>"); |
|
51 _LIT8(KReqSigEnd, "</signature></roap:leaveDomainRequest>"); |
|
52 |
|
53 // ============================ MEMBER FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CLeaveDomainReq::CLeaveDomainReq |
|
57 // C++ default constructor can NOT contain any code, that |
|
58 // might leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CLeaveDomainReq::CLeaveDomainReq(): |
|
62 iDomainId(NULL), |
|
63 iNonce(NULL), |
|
64 iSignature(NULL), |
|
65 iTriggerNonce(NULL) |
|
66 { |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CLeaveDomainReq::ConstructL |
|
71 // Symbian 2nd phase constructor can leave. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CLeaveDomainReq::ConstructL() |
|
75 { |
|
76 iTime.UniversalTime(); |
|
77 iNotMember = EFalse; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CLeaveDomainReq::NewL |
|
82 // Two-phased constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CLeaveDomainReq* CLeaveDomainReq::NewL() |
|
86 { |
|
87 CLeaveDomainReq* self = new( ELeave ) CLeaveDomainReq; |
|
88 |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop(); |
|
92 |
|
93 return self; |
|
94 } |
|
95 |
|
96 |
|
97 // Destructor |
|
98 CLeaveDomainReq::~CLeaveDomainReq() |
|
99 { |
|
100 iCertificateChain.ResetAndDestroy(); |
|
101 delete iDomainId; |
|
102 delete iSignature; |
|
103 delete iTriggerNonce; |
|
104 } |
|
105 |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CLeaveDomainReq::?member_function |
|
109 // ?implementation_description |
|
110 // (other items were commented in a header). |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 HBufC8* CLeaveDomainReq::MessageAsXmlL(void) |
|
114 { |
|
115 HBufC8* r = NULL; |
|
116 CBufFlat* b = NULL; |
|
117 TInt i; |
|
118 |
|
119 b = CBufFlat::NewL(128); |
|
120 CleanupStack::PushL(b); |
|
121 BufAppendL(b, KReqHeader); |
|
122 if (iTriggerNonce) |
|
123 { |
|
124 BufAppendL(b, KReqNonceTrigger); |
|
125 BufAppendL(b, *iTriggerNonce); |
|
126 BufAppendL(b, KReqNonceTriggerEnd); |
|
127 } |
|
128 BufAppendL(b, KReqHeaderEnd); |
|
129 |
|
130 BufAppendL(b, KReqDeviceId); |
|
131 BufAppendBase64L(b, iDeviceId); |
|
132 BufAppendL(b, KReqDeviceIdEnd); |
|
133 |
|
134 BufAppendL(b, KReqRiId); |
|
135 BufAppendBase64L(b, iRiId); |
|
136 BufAppendL(b, KReqRiIdEnd); |
|
137 |
|
138 BufAppendL(b, KReqNonce); |
|
139 BufAppendBase64L(b, iNonce); |
|
140 BufAppendL(b, KReqNonceEnd); |
|
141 |
|
142 BufAppendL(b, KReqTime); |
|
143 BufAppendTimeL(b, iTime); |
|
144 BufAppendL(b, KReqTimeEnd); |
|
145 |
|
146 BufAppendL(b, KReqDomainId); |
|
147 BufAppendL(b, *iDomainId); |
|
148 BufAppendL(b, KReqDomainIdEnd); |
|
149 |
|
150 if (iCertificateChain.Count() > 0) |
|
151 { |
|
152 BufAppendL(b, KReqCertChain); |
|
153 for (i = 0; i < iCertificateChain.Count(); i++) |
|
154 { |
|
155 BufAppendL(b, KReqCert); |
|
156 BufAppendBase64L(b, *iCertificateChain[i]); |
|
157 BufAppendL(b, KReqCertEnd); |
|
158 } |
|
159 BufAppendL(b, KReqCertChainEnd); |
|
160 } |
|
161 |
|
162 if ( iNotMember ) |
|
163 { |
|
164 BufAppendL(b, KReqNotDomainMember); |
|
165 } |
|
166 |
|
167 BufAppendL(b, KReqSig); |
|
168 BufAppendL(b, KReqSigEnd); |
|
169 |
|
170 r = b->Ptr(0).AllocL(); |
|
171 CleanupStack::PopAndDestroy(b); |
|
172 return r; |
|
173 } |