williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: CSenWsSecurityHeader represents security header functionality
|
williamr@2
|
15 |
* according to oasis wss spesifications (2004/01)
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
*/
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
|
williamr@2
|
25 |
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#ifndef SEN_WS_SECURITY_HEADER_H
|
williamr@2
|
28 |
#define SEN_WS_SECURITY_HEADER_H
|
williamr@2
|
29 |
|
williamr@2
|
30 |
// INCLUDES
|
williamr@2
|
31 |
#include <SenBaseFragment.h>
|
williamr@2
|
32 |
#include <SenSoapConstants.h>
|
williamr@2
|
33 |
|
williamr@2
|
34 |
|
williamr@2
|
35 |
// FORWARD DECLARATIONS
|
williamr@2
|
36 |
class CSenIdentityProvider;
|
williamr@2
|
37 |
|
williamr@2
|
38 |
// CLASS DECLARATION
|
williamr@2
|
39 |
|
williamr@2
|
40 |
/**
|
williamr@2
|
41 |
* CSenWsSecurityHeader represents security header functionality according to
|
williamr@2
|
42 |
* oasis web services security (WSS) specifications (2004/01) or older (2003/06)
|
williamr@2
|
43 |
* @lib SenUtils.lib
|
williamr@2
|
44 |
* @since Series60 3.0
|
williamr@2
|
45 |
*/
|
williamr@2
|
46 |
class CSenWsSecurityHeader : public CSenBaseFragment
|
williamr@2
|
47 |
{
|
williamr@2
|
48 |
public: // Constructors and destructor
|
williamr@2
|
49 |
|
williamr@2
|
50 |
/**
|
williamr@2
|
51 |
* PasswordType Enumeration
|
williamr@2
|
52 |
*/
|
williamr@2
|
53 |
enum TPasswordType
|
williamr@2
|
54 |
{
|
williamr@2
|
55 |
EText = 1, // default, wsse:PasswordText
|
williamr@2
|
56 |
EDigest // wsse:Digest
|
williamr@2
|
57 |
};
|
williamr@2
|
58 |
|
williamr@2
|
59 |
|
williamr@2
|
60 |
/**
|
williamr@2
|
61 |
* Basic constructor.
|
williamr@2
|
62 |
* @return a pointer to new CSenWsSecurityHeader class instance.
|
williamr@2
|
63 |
*/
|
williamr@2
|
64 |
IMPORT_C static CSenWsSecurityHeader* NewL();
|
williamr@2
|
65 |
|
williamr@2
|
66 |
/**
|
williamr@2
|
67 |
* Basic constructor.
|
williamr@2
|
68 |
* @return a new CSenWsSecurityHeader class instance, which pointer
|
williamr@2
|
69 |
* is left on cleanup stack.
|
williamr@2
|
70 |
*/
|
williamr@2
|
71 |
IMPORT_C static CSenWsSecurityHeader* NewLC();
|
williamr@2
|
72 |
|
williamr@2
|
73 |
|
williamr@2
|
74 |
/**
|
williamr@2
|
75 |
* Basic constructor.
|
williamr@2
|
76 |
* @param aData Data to be set as header's content.
|
williamr@2
|
77 |
* @return a pointer to new CSenWsSecurityHeader class instance.
|
williamr@2
|
78 |
*/
|
williamr@2
|
79 |
IMPORT_C static CSenWsSecurityHeader* NewL(const TDesC8& aData);
|
williamr@2
|
80 |
|
williamr@2
|
81 |
/**
|
williamr@2
|
82 |
* Basic constructor.
|
williamr@2
|
83 |
* @param aData Data to be set as header's content.
|
williamr@2
|
84 |
* @return a new CSenWsSecurityHeader class instance, which pointer
|
williamr@2
|
85 |
* is left on cleanup stack.
|
williamr@2
|
86 |
*/
|
williamr@2
|
87 |
IMPORT_C static CSenWsSecurityHeader* NewLC(const TDesC8& aData);
|
williamr@2
|
88 |
|
williamr@2
|
89 |
/**
|
williamr@2
|
90 |
* Basic constructor.
|
williamr@2
|
91 |
* @param aData Data to be set as header's content.
|
williamr@2
|
92 |
* @param aSecurityNs A namespace to be set to the header.
|
williamr@2
|
93 |
* @return a pointer to new CSenWsSecurityHeader class instance.
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
IMPORT_C static CSenWsSecurityHeader* NewL(const TDesC8& aData, const TDesC8& aSecurityNs);
|
williamr@2
|
96 |
|
williamr@2
|
97 |
/**
|
williamr@2
|
98 |
* Basic constructor.
|
williamr@2
|
99 |
* @param aData Data to be set as header's content.
|
williamr@2
|
100 |
* @param aSecurityNs A namespace to be set to the header.
|
williamr@2
|
101 |
* @return a new CSenWsSecurityHeader class instance, which pointer
|
williamr@2
|
102 |
* is left on cleanup stack.
|
williamr@2
|
103 |
*/
|
williamr@2
|
104 |
IMPORT_C static CSenWsSecurityHeader* NewLC(const TDesC8& aData, const TDesC8& aSecurityNs);
|
williamr@2
|
105 |
|
williamr@2
|
106 |
/**
|
williamr@2
|
107 |
* Destructor.
|
williamr@2
|
108 |
*/
|
williamr@2
|
109 |
IMPORT_C virtual ~CSenWsSecurityHeader();
|
williamr@2
|
110 |
|
williamr@2
|
111 |
// New functions
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
* Constructs a username token.
|
williamr@2
|
115 |
* @since Series60 3.0
|
williamr@2
|
116 |
* @param aIdentityProvider Identity provider which is used to get
|
williamr@2
|
117 |
* the authorization ID used in username token. Method takes the
|
williamr@2
|
118 |
* AuthzID out from aIdentityProvider, and uses it as username for
|
williamr@2
|
119 |
* this token.
|
williamr@2
|
120 |
* Format of the token is as follows:
|
williamr@2
|
121 |
*
|
williamr@2
|
122 |
* <wsse:UsernameToken>
|
williamr@2
|
123 |
* <wsse:Username>
|
williamr@2
|
124 |
* username
|
williamr@2
|
125 |
* </wsse:Username>
|
williamr@2
|
126 |
* </wsse:UsernameToken>"
|
williamr@2
|
127 |
*
|
williamr@2
|
128 |
* The above token assumes, that wsse namespace is declared in
|
williamr@2
|
129 |
* top level of the security header.
|
williamr@2
|
130 |
* @return a pointer to buffer containing the username token. Does not
|
williamr@2
|
131 |
* return NULL. Ownership is transferred to the caller. Method leaves
|
williamr@2
|
132 |
* with value KErrNotSupported, if a password type is not supported.
|
williamr@2
|
133 |
*/
|
williamr@2
|
134 |
IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider);
|
williamr@2
|
135 |
|
williamr@2
|
136 |
/**
|
williamr@2
|
137 |
* Constructs a username token.
|
williamr@2
|
138 |
* @since Series60 3.0
|
williamr@2
|
139 |
* @param aIdentityProvider Identity provider which is used to get
|
williamr@2
|
140 |
* the authorization ID used in username token. Method takes the
|
williamr@2
|
141 |
* AuthzID out from aIdentityProvider, and uses it as username for
|
williamr@2
|
142 |
* this token. Password is also fetched from aIdentityProvider via
|
williamr@2
|
143 |
* calling Password() getter, which must return a Base64 [XML-Schema]
|
williamr@2
|
144 |
* encoded, SHA-1 hash value, of the UTF8 encoded password.
|
williamr@2
|
145 |
* @param aType Specifies the type of the password, either
|
williamr@2
|
146 |
* wsse:PasswordText or wsse:PasswordDigest
|
williamr@2
|
147 |
*
|
williamr@2
|
148 |
* Format of the token is as follows (if password type is wsse:PasswordText):
|
williamr@2
|
149 |
*
|
williamr@2
|
150 |
* <wsse:UsernameToken>
|
williamr@2
|
151 |
* <wsse:Username>
|
williamr@2
|
152 |
* username
|
williamr@2
|
153 |
* </wsse:Username>
|
williamr@2
|
154 |
* <wsse:Password>
|
williamr@2
|
155 |
* password
|
williamr@2
|
156 |
* </wsse:Password>
|
williamr@2
|
157 |
* </wsse:UsernameToken>"
|
williamr@2
|
158 |
*
|
williamr@2
|
159 |
* If the password type is wsse:Password:Digest, then the password element
|
williamr@2
|
160 |
* will be declared as follows:
|
williamr@2
|
161 |
*
|
williamr@2
|
162 |
* <wsse:Password Type="wsse:PasswordDigest">
|
williamr@2
|
163 |
*
|
williamr@2
|
164 |
* The above token assumes, that wsse namespace is declared in
|
williamr@2
|
165 |
* top level of the security header.
|
williamr@2
|
166 |
* @return a pointer to buffer containing the username token. Does not
|
williamr@2
|
167 |
* return NULL. Ownership is transferred to the caller. Method leaves
|
williamr@2
|
168 |
* with value KErrNotSupported, if a password type is not supported.
|
williamr@2
|
169 |
*/
|
williamr@2
|
170 |
IMPORT_C HBufC8* UsernameTokenL(CSenIdentityProvider &aIdentityProvider,
|
williamr@2
|
171 |
CSenWsSecurityHeader::TPasswordType aType);
|
williamr@2
|
172 |
|
williamr@2
|
173 |
// Static methods:
|
williamr@2
|
174 |
|
williamr@2
|
175 |
/**
|
williamr@2
|
176 |
* Constructs a username token. This method does not add the <Password>
|
williamr@2
|
177 |
* element, since it is optional for basic username tokens.
|
williamr@2
|
178 |
* @since Series60 3.0
|
williamr@2
|
179 |
* @param aUsername User name which is used in the username
|
williamr@2
|
180 |
* token.
|
williamr@2
|
181 |
* @param aToken Ref-to-pointer where the token will be
|
williamr@2
|
182 |
* allocated. Shouldn't contain any data when
|
williamr@2
|
183 |
* called, or that data will be lost.
|
williamr@2
|
184 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
185 |
*/
|
williamr@2
|
186 |
IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
|
williamr@2
|
187 |
HBufC8*& aToken);
|
williamr@2
|
188 |
|
williamr@2
|
189 |
/**
|
williamr@2
|
190 |
* Constructs a username token using a password, too.
|
williamr@2
|
191 |
* @since Series60 5.0
|
williamr@2
|
192 |
* @param aUsername User name which is to be used in new token.
|
williamr@2
|
193 |
* @param aPassword Password which is to be use in new token.
|
williamr@2
|
194 |
* The type will be set to default: wsse:PasswordDigest,
|
williamr@2
|
195 |
* defined in KSecurityAttrTypeText. This is
|
williamr@2
|
196 |
* a Base64 [XML-Schema] encoded, SHA-1 hash value,
|
williamr@2
|
197 |
* of the UTF8 encoded password.
|
williamr@2
|
198 |
* @param aToken Ref-to-pointer in which the token will be
|
williamr@2
|
199 |
* allocated. Shouldn't contain any data when
|
williamr@2
|
200 |
* called, or that data will be lost.
|
williamr@2
|
201 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
202 |
*/
|
williamr@2
|
203 |
IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
|
williamr@2
|
204 |
const TDesC8& aPassword,
|
williamr@2
|
205 |
HBufC8*& aToken);
|
williamr@2
|
206 |
|
williamr@2
|
207 |
/**
|
williamr@2
|
208 |
* Constructs a username token using a password, too.
|
williamr@2
|
209 |
* @since Series60 5.0
|
williamr@2
|
210 |
* @param aUsername User name which is to be used in new token.
|
williamr@2
|
211 |
* @param aPassword Password which is to be use in new token
|
williamr@2
|
212 |
* This is a Base64 [XML-Schema] encoded, SHA-1
|
williamr@2
|
213 |
* hash value, of the UTF8 encoded password.
|
williamr@2
|
214 |
* @param aType Specifies the type of the password:
|
williamr@2
|
215 |
* - EText, being default refers to wsse:PasswordText,
|
williamr@2
|
216 |
* but this method does not add this, since it can
|
williamr@2
|
217 |
* be omitted.
|
williamr@2
|
218 |
* - EDigest: will add wsse:PasswordDigest attribute
|
williamr@2
|
219 |
* to the <Password> -element, as in here:
|
williamr@2
|
220 |
*
|
williamr@2
|
221 |
* <wsse:UsernameToken>
|
williamr@2
|
222 |
* <wsse:Username>
|
williamr@2
|
223 |
* username
|
williamr@2
|
224 |
* </wsse:Username>
|
williamr@2
|
225 |
* <wsse:Password Type="wsse:PasswordDigest">
|
williamr@2
|
226 |
* password
|
williamr@2
|
227 |
* </wsse:Password>
|
williamr@2
|
228 |
* </wsse:UsernameToken>"
|
williamr@2
|
229 |
*
|
williamr@2
|
230 |
* @param aToken Ref-to-pointer where the token will be
|
williamr@2
|
231 |
* allocated. Shouldn't contain any data when
|
williamr@2
|
232 |
* called, or that data will be lost.
|
williamr@2
|
233 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
234 |
*/
|
williamr@2
|
235 |
IMPORT_C static TInt UsernameTokenL(const TDesC8& aUsername,
|
williamr@2
|
236 |
const TDesC8& aPassword,
|
williamr@2
|
237 |
CSenWsSecurityHeader::TPasswordType aType,
|
williamr@2
|
238 |
HBufC8*& aToken);
|
williamr@2
|
239 |
|
williamr@2
|
240 |
|
williamr@2
|
241 |
/**
|
williamr@2
|
242 |
* Constructs a BinarySecurityToken.
|
williamr@2
|
243 |
* @since Series60 5.0
|
williamr@2
|
244 |
*
|
williamr@2
|
245 |
* @param aContent Encoded EncryptedData which is to be used in token.
|
williamr@2
|
246 |
* @param aToken Ref-to-pointer where the token will be
|
williamr@2
|
247 |
* allocated. Shouldn't contain any data when
|
williamr@2
|
248 |
* called, or that data will be lost.
|
williamr@2
|
249 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
250 |
*/
|
williamr@2
|
251 |
IMPORT_C static TInt BinarySecurityTokenL(const TDesC8& aContent,
|
williamr@2
|
252 |
HBufC8*& aToken);
|
williamr@2
|
253 |
/**
|
williamr@2
|
254 |
* Constructs a BinarySecurityToken.
|
williamr@2
|
255 |
* @since Series60 5.0
|
williamr@2
|
256 |
*
|
williamr@2
|
257 |
* @param aContent Encoded EncryptedData which is to be used in token.
|
williamr@2
|
258 |
* @param aValueType Indicates what the security token is
|
williamr@2
|
259 |
* @param aToken Ref-to-pointer where the token will be
|
williamr@2
|
260 |
* allocated. Shouldn't contain any data when
|
williamr@2
|
261 |
* called, or that data will be lost.
|
williamr@2
|
262 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
263 |
*/
|
williamr@2
|
264 |
IMPORT_C static TInt BinarySecurityTokenL(const TDesC8& aContent,
|
williamr@2
|
265 |
const TDesC8& aValueType,
|
williamr@2
|
266 |
HBufC8*& aToken);
|
williamr@2
|
267 |
|
williamr@2
|
268 |
/**
|
williamr@2
|
269 |
* Constructs a timestamp.
|
williamr@2
|
270 |
* @since Series60 5.0
|
williamr@2
|
271 |
* Format of the timestamp is as follows:
|
williamr@2
|
272 |
* <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
|
williamr@2
|
273 |
* <wsu:Created>2001-09-13T08:42:00Z</wsu:Created>
|
williamr@2
|
274 |
* <wsu:Expires>2002-09-13T08:42:00Z</wsu:Expires>
|
williamr@2
|
275 |
* </wsu:Timestamp>
|
williamr@2
|
276 |
* The wsu namespace is declared inside this element.
|
williamr@2
|
277 |
* Based on chapter 10 from WS-Security 2004
|
williamr@2
|
278 |
* @param aCreated - creation time of token
|
williamr@2
|
279 |
* @param aExpires - end of validation time for token
|
williamr@2
|
280 |
* @param aTimestamp - a pointer to buffer containing the timestamp. Does not
|
williamr@2
|
281 |
* return NULL. Ownership is transferred to the caller.
|
williamr@2
|
282 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
283 |
*/
|
williamr@2
|
284 |
IMPORT_C static TInt TimestampL(const TDesC8& aCreated, const TDesC8& aExpires, HBufC8*& aTimestamp);
|
williamr@2
|
285 |
|
williamr@2
|
286 |
/**
|
williamr@2
|
287 |
* Constructs a timestamp.
|
williamr@2
|
288 |
* @since Series60 5.0
|
williamr@2
|
289 |
* Format of the timestamp is as follows:
|
williamr@2
|
290 |
* <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
|
williamr@2
|
291 |
* <wsu:Created>2001-09-13T08:42:00Z</wsu:Created>
|
williamr@2
|
292 |
* </wsu:Timestamp>
|
williamr@2
|
293 |
* The wsu namespace is declared inside this element.
|
williamr@2
|
294 |
* Based on chapter 10 from WS-Security 2004
|
williamr@2
|
295 |
* @param aCreated - creation time of token
|
williamr@2
|
296 |
* @param aTimestamp - a pointer to buffer containing the timestamp. Does not
|
williamr@2
|
297 |
* return NULL. Ownership is transferred to the caller.
|
williamr@2
|
298 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
299 |
*/
|
williamr@2
|
300 |
IMPORT_C static TInt TimestampL(const TDesC8& aCreated, HBufC8*& aTimestamp);
|
williamr@2
|
301 |
|
williamr@2
|
302 |
/**
|
williamr@2
|
303 |
* Constructs a security token reference.
|
williamr@2
|
304 |
* @since Series60 5.0
|
williamr@2
|
305 |
* Format of the token reference is as follows:
|
williamr@2
|
306 |
* <wsse:SecurityTokenReference wsu:Id="...">
|
williamr@2
|
307 |
* <wsse:Reference URI="..."/>
|
williamr@2
|
308 |
* </wsse:SecurityTokenReference>
|
williamr@2
|
309 |
*
|
williamr@2
|
310 |
* The above token assumes, that wsse namespace is declared in
|
williamr@2
|
311 |
* top level of the security header.
|
williamr@2
|
312 |
* @param
|
williamr@2
|
313 |
* @param aSTR - a pointer to buffer containing the token reference. Does not
|
williamr@2
|
314 |
* return NULL. Ownership is transferred to the caller.
|
williamr@2
|
315 |
* @return KErrNone or some system-wide Symbian error code.
|
williamr@2
|
316 |
*/
|
williamr@2
|
317 |
// IMPORT_C static TInt SecurityTokenReferenceL(const TDesC8& aURI, HBufC8*& aSTR);
|
williamr@2
|
318 |
|
williamr@2
|
319 |
|
williamr@2
|
320 |
// Virtual methods:
|
williamr@2
|
321 |
|
williamr@2
|
322 |
/** Basic getter for XML namespace of the WS security header.
|
williamr@2
|
323 |
* Subclasses should override this to use different namespace
|
williamr@2
|
324 |
* @since Series60 3.0
|
williamr@2
|
325 |
* @return the WS security header namespace as string
|
williamr@2
|
326 |
*/
|
williamr@2
|
327 |
IMPORT_C virtual TPtrC8 XmlNs();
|
williamr@2
|
328 |
|
williamr@2
|
329 |
/**
|
williamr@2
|
330 |
* Basic getter for XML namespace prefix of the WS security header.
|
williamr@2
|
331 |
* Subclasses should override this to use different namespace prefix
|
williamr@2
|
332 |
* @since Series60 3.0
|
williamr@2
|
333 |
* @return the WS security header namespace prefix as string
|
williamr@2
|
334 |
*/
|
williamr@2
|
335 |
IMPORT_C virtual TPtrC8 XmlNsPrefix();
|
williamr@2
|
336 |
|
williamr@2
|
337 |
protected:
|
williamr@2
|
338 |
|
williamr@2
|
339 |
/**
|
williamr@2
|
340 |
* C++ default constructor
|
williamr@2
|
341 |
*/
|
williamr@2
|
342 |
IMPORT_C CSenWsSecurityHeader();
|
williamr@2
|
343 |
|
williamr@2
|
344 |
/**
|
williamr@2
|
345 |
* Basic BaseConstructL function
|
williamr@2
|
346 |
*/
|
williamr@2
|
347 |
IMPORT_C void BaseConstructL();
|
williamr@2
|
348 |
|
williamr@2
|
349 |
// Functions from base classes
|
williamr@2
|
350 |
|
williamr@2
|
351 |
/**
|
williamr@2
|
352 |
* From CSenBaseFragment Basic BaseConstructL function
|
williamr@2
|
353 |
* @since Series60 3.0
|
williamr@2
|
354 |
* @param aData will be used as current token (content) of this security
|
williamr@2
|
355 |
* header
|
williamr@2
|
356 |
*/
|
williamr@2
|
357 |
IMPORT_C void BaseConstructL(const TDesC8& aData);
|
williamr@2
|
358 |
IMPORT_C void BaseConstructL(const TDesC8& aData, const TDesC8& aSecurityNs);
|
williamr@2
|
359 |
};
|
williamr@2
|
360 |
|
williamr@2
|
361 |
#endif // SEN_WS_SECURITY_HEADER_H
|
williamr@2
|
362 |
|
williamr@2
|
363 |
// End of File
|