2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Class describes some IdentityProvider service
25 #ifndef SEN_IDENTITY_PROVIDER_H
26 #define SEN_IDENTITY_PROVIDER_H
29 #include <SenXmlServiceDescription.h>
32 const TInt KSenAuthMaxUsernameLength = 32;
33 const TInt KSenAuthMaxPasswordLength = 16;
35 _LIT8(KIdentityProvider8, "IdentityProvider"); //@depricated
36 _LIT8(KFakeIMEI8, "012345678901234"); //@depricated
37 _LIT8(KContract8, "urn:liberty:as:2004-04"); //@depricated
38 _LIT8(KSenIdpLocalname, "IdentityProvider");
39 _LIT8(KSenIdpLibertyIdWsfAsContract, "urn:liberty:as:2004-04");
40 _LIT8(KWSAtomPubAuthenticationServiceContract, "urn:atompub:as");
41 _LIT8(KWSOviAuthenticationServiceContract, "urn:ovi:as");
42 _LIT8(KWSStarSTSContract, "urn:wstar:sts");
43 _LIT8(KImei, "IMEI"); //@depricated
44 _LIT8(KType, "type"); //@depricated
46 _LIT8(KAuthzID8, "AuthzID"); //@depricated
47 _LIT8(KAdvisoryAuthnID8, "AdvisoryAuthnID"); //@depricated
48 _LIT8(KPassword8, "Password"); //@depricated
49 _LIT8(KProviderID8, "ProviderID"); //@depricated
50 _LIT8(KSenIdpAuthzIDLocalname, "AuthzID");
51 _LIT8(KSenIdpAdvisoryAuthnIdLocalname, "AdvisoryAuthnID");
52 _LIT8(KSenIdpPasswordLocalname, "Password");
53 _LIT8(KSenIdpProviderIdLocalname, "ProviderID");
54 _LIT8(KSenAccountExtensions, "AccountExtensions");
55 _LIT8(KSenAccAutoSignIn, "AutoSignIn");
58 class TSenAuthentication
61 TBuf8<KSenAuthMaxUsernameLength> iUsername;
62 TBuf8<KSenAuthMaxPasswordLength> iPassword;
65 // FORWARD DECLARATIONS
66 class MSenIdentityManager;
71 * Class describes some IdentityProvider service
72 * Class is intented to be used when registrating
73 * information about some identity providing service.
74 * In case of ID-WSF framework, the IdentityProvider
75 * and Authentication Service are behind same endpoint.
76 * Typically, ID-WSF service consumers call both
77 * RegisterIdentityProviderL() and
78 * RegisterServiceDescriptionL() methods as defined
79 * in Service Management API (CSenServiceManager).
80 * Basic Web Service consumers use this class to register
81 * BASIC-AUTH credentials to certain pre-known service endpoint.
82 * @lib SenServDesc.lib
85 class CSenIdentityProvider : public CSenXmlServiceDescription
87 public: // Constructors and destructor
90 * Two-phased constructor.
91 * Note: contract defaults here to "urn:liberty:as:2004-04"
93 * @param aEndpoint the service endpoint. Note that endpoint cannot
94 * include characters which are illegal in XML. If endpoint
95 * is an URL which contains illegal characters (like '&'-char),
96 * those need to be encoded into XML entity form (like &).
97 * EncodeHttpCharactersLC() method from XmlUtils can be used
98 * for encoding of basic XML entities.
99 * @return a new CSenIdentityProvider
101 IMPORT_C static CSenIdentityProvider* NewL( const TDesC8& aEndpoint );
104 * Two-phased constructor.
105 * Note: contract defaults here to "urn:liberty:as:2004-04"
106 * @since Series60 3.0
107 * @param aEndpoint the service endpoint. Note that endpoint cannot
108 * include characters which are illegal in XML. If endpoint
109 * is an URL which contains illegal characters (like '&'-char),
110 * those need to be encoded into XML entity form (like &).
111 * EncodeHttpCharactersLC() method from XmlUtils can be used
112 * for encoding of basic XML entities.
113 * @return a new CSenIdentityProvider, which pointer is left on
116 IMPORT_C static CSenIdentityProvider* NewLC( const TDesC8& aEndpoint );
119 * Two-phased constructor.
120 * @since Series60 3.0
121 * @param aEndpoint the service endpoint. Note that endpoint cannot
122 * include characters which are illegal in XML. If endpoint
123 * is an URL which contains illegal characters (like '&'-char),
124 * those need to be encoded into XML entity form (like &).
125 * EncodeHttpCharactersLC() method from XmlUtils can be used
126 * for encoding of basic XML entities.
127 * @param aContract identifies the service type. Typically some URN.
128 * Default is Liberty ID-WSF Authentication Service contract:
129 * -- urn:liberty:as:2004-04
130 * @return a new CSenIdentityProvider
132 IMPORT_C static CSenIdentityProvider* NewL( const TDesC8& aEndpoint,
133 const TDesC8& aContract );
136 * Two-phased constructor.
137 * @since Series60 3.0
138 * @param aEndpoint the service endpoint. Note that endpoint cannot
139 * include characters which are illegal in XML. If endpoint
140 * is an URL which contains illegal characters (like '&'-char),
141 * those need to be encoded into XML entity form (like &).
142 * EncodeHttpCharactersLC() method from XmlUtils can be used
143 * for encoding of basic XML entities.
144 * @param aContract identifies the service type. Typically some URN.
145 * Default is Liberty ID-WSF Authentication Service contract:
146 * -- urn:liberty:as:2004-04
147 * @return a new CSenIdentityProvider, which pointer is left on
150 IMPORT_C static CSenIdentityProvider* NewLC(const TDesC8& aEndpoint,
151 const TDesC8& aContract );
154 * Two-phased constructor.
155 * @since Series60 3.0
156 * @param aEndpoint the service endpoint. Note that endpoint cannot
157 * include characters which are illegal in XML. If endpoint
158 * is an URL which contains illegal characters (like '&'-char),
159 * those need to be encoded into XML entity form (like &).
160 * EncodeHttpCharactersLC() method from XmlUtils can be used
161 * for encoding of basic XML entities.
162 * @param aContract identifies the service type. Typically some URN.
163 * Default is Liberty ID-WSF Authentication Service contract:
164 * -- urn:liberty:as:2004-04
165 * @param aProviderID is identifier of this IdentityProvider. It is a
166 * unique key pointing to some known endpoint.
167 * @return a new CSenIdentityProvider
169 IMPORT_C static CSenIdentityProvider* NewL( const TDesC8& aEndpoint,
170 const TDesC8& aContract,
171 const TDesC8& aProviderID);
174 * Two-phased constructor.
175 * @since Series60 3.0
176 * @param aEndpoint the service endpoint. Note that endpoint cannot
177 * include characters which are illegal in XML. If endpoint
178 * is an URL which contains illegal characters (like '&'-char),
179 * those need to be encoded into XML entity form (like &).
180 * EncodeHttpCharactersLC() method from XmlUtils can be used
181 * for encoding of basic XML entities.
182 * @param aContract identifies the service type. Typically some URN.
183 * Default is Liberty ID-WSF Authentication Service contract:
184 * -- urn:liberty:as:2004-04
185 * @param aProviderID is identifier of this IdentityProvider. It is a
186 * unique key pointing to some known endpoint. Required only
187 * for ID-WSF framework.
188 * @return a new CSenIdentityProvider, which pointer is left on
191 IMPORT_C static CSenIdentityProvider* NewLC(const TDesC8& aEndpoint,
192 const TDesC8& aContract,
193 const TDesC8& aProviderID);
196 * Two-phased constructor.
197 * @since Series60 3.0
198 * @param aEndpoint the service endpoint. Note that endpoint cannot
199 * include characters which are illegal in XML. If endpoint
200 * is an URL which contains illegal characters (like '&'-char),
201 * those need to be encoded into XML entity form (like &).
202 * EncodeHttpCharactersLC() method from XmlUtils can be used
203 * for encoding of basic XML entities.
204 * @param aContract identifies the service type. Typically some URN.
205 * Default is Liberty ID-WSF Authentication Service contract:
206 * -- urn:liberty:as:2004-04
207 * @param aProviderID is identifier of this IdentityProvider. It is a
208 * unique key pointing to some known endpoint. Required only
209 * for ID-WSF framework.
210 * @param aServiceID is a unique contract to some invocable service.
211 * Typically some URN. If this IDP is registered to ID-WSF
212 * framework, this ServiceID will be appended into list of
213 * services which trust this IDP, and the actual IDP "knows".
214 * @return a new CSenIdentityProvider
216 IMPORT_C static CSenIdentityProvider* NewL( const TDesC8& aEndpoint,
217 const TDesC8& aContract,
218 const TDesC8& aProviderID,
219 const TDesC8& aServiceID);
222 * Two-phased constructor.
223 * @since Series60 3.0
224 * @param aEndpoint the service endpoint. Note that endpoint cannot
225 * include characters which are illegal in XML. If endpoint
226 * is an URL which contains illegal characters (like '&'-char),
227 * those need to be encoded into XML entity form (like &).
228 * EncodeHttpCharactersLC() method from XmlUtils can be used
229 * for encoding of basic XML entities.
230 * @param aProviderID is identifier of this IdentityProvider. It is a
231 * unique key pointing to some known endpoint. Required only
232 * for ID-WSF framework.
233 * @param aContract identifies the service type. Typically some URN.
234 * Default is Liberty ID-WSF Authentication Service contract:
235 * -- urn:liberty:as:2004-04
236 * @param aServiceID is a unique contract to some invocable service.
237 * Typically some URN. If this IDP is registered to ID-WSF
238 * framework, this ServiceID will be appended into list of
239 * services which trust this IDP, and the actual IDP "knows".
240 * @return a new CSenIdentityProvider, which pointer is left on
243 IMPORT_C static CSenIdentityProvider* NewLC(const TDesC8& aEndpoint,
244 const TDesC8& aContract,
245 const TDesC8& aProviderID,
246 const TDesC8& aServiceID);
251 IMPORT_C virtual ~CSenIdentityProvider();
257 * @since Series60 3.0
258 * @return a pointer to authorization id
260 IMPORT_C virtual TPtrC8 AuthzID();
264 * @since Series60 3.0
265 * @return a pointer to advisory authentication id
267 IMPORT_C virtual TPtrC8 AdvisoryAuthnID();
271 * @since Series60 3.0
272 * @return a pointer to provider id
274 IMPORT_C TPtrC8 ProviderID();
278 * @since Series60 3.0
279 * @return a pointer to password
281 IMPORT_C virtual TPtrC8 Password();
285 * @since Series60 3.0
286 * @return a pointer to IMEI
288 IMPORT_C const TDesC8& IMEI();
292 * @since Series60 3.0
293 * @return a pointer to username
295 IMPORT_C TPtrC8 UserName();
299 * @since Series60 3.0
300 * @param aProviderID the set id
301 * @return KErrNone or other system-wide Symbian error codes.
303 IMPORT_C TInt SetProviderID( const TDesC8& aProviderID );
306 * Setter for ServiceID. ServiceID is the contract of some
307 * invocable service, typically some URN.
308 * Note, that when registering an IDP the possibly existing
309 * list of ServiceIDs is not cleared, but the ServiceID set
310 * via this method is added as new entry into that list, if
311 * it was non-existent.
312 * @since Series60 3.0
313 * @param aServiceID the set id
314 * @return KErrNone or other system-wide Symbian error codes.
316 IMPORT_C TInt SetServiceID( const TDesC8& aServiceID );
319 * @since Series60 3.0
320 * @param aServiceDescription the service description to check
321 * @return ETrue if the ServiceDescription, i.e. its endpoint
322 * or contract, is associated to this IdentityProvider.
323 * Or if the ServiceDescription is about this
327 IMPORT_C TBool IsTrustedByL( MSenServiceDescription& aServiceDescription );
330 * @since Series60 3.0
331 * @param aProviderIdOrServiceId IdentityProvider ID, or Service ID
332 * which is being checked. Service ID is typically URI
333 * (service contract or service endpoint).
334 * @return ETrue if the ServiceDescription, i.e. its endpoint
335 * or contract, is associated to this IdentityProvider.
336 * Or if the ServiceDescription is about this
340 IMPORT_C TBool IsTrustedByL( const TDesC8& aProviderIdOrServiceId );
343 * Checks if this identity provider is set as default .
344 * @since Series60 3.0
345 * @return ETrue if default-attribute was set, EFalse otherwise
347 IMPORT_C TBool IsDefault();
350 * Sets the user information.
353 * Other codes are system error codes.
354 * @since Series60 3.0
355 * @param aAuthzID Authorization id.
356 * @param aAdvisoryAuthnID Advisory authorization id.
357 * @param aPassword Password.
358 * @return status/error code.
360 IMPORT_C TInt SetUserInfoL( const TDesC8& aAuthzID,
361 const TDesC8& aAdvisoryAuthnID,
362 const TDesC8& aPassword );
365 * @deprecated. This method is no longer in use.
366 * Creates http-credentials by making password-username pair
367 * and encoding it with BASE-64.
368 * @since Series60 3.0
369 * @param aIdMgr Identitymanager which is used to obtain a password
370 * if no password for this identityprovider was set.
371 * @return a newly allocated credentialbuffer. Ownership is transferred
374 IMPORT_C HBufC8* HttpCredentialsL( MSenIdentityManager& aIdMgr );
376 // Functions from base classes
378 // From CSenXmlServiceDescription
381 * @since Series60 3.0
382 * @return Descriptor containing service description local name
383 * for this service description.
384 * This is the localname of the element, when this class is
385 * represented as an XML element.
387 IMPORT_C const TDesC8& NewElementName();
390 * Setter for (identity) provider ID (leaving variant)
391 * @since Series60 4.0
392 * @param aProviderID the unique identifier of the (identity) provider
393 * @return KErrNone on success, KErrArgument if aProviderID is a
394 * zero-length descriptor, or one of the system-wide error codes
397 IMPORT_C TInt SetProviderIdL( const TDesC8& aProviderID );
399 IMPORT_C TInt SetAccountExtensionsL(const TDesC8& aDetail);
401 IMPORT_C TPtrC8 AccountExtensions(CSenElement*& aAccExt);
406 C++ default constructor
408 IMPORT_C CSenIdentityProvider( TDescriptionClassType aType );
411 // Functions from base classes
413 // From CSenXmlServiceDescription
416 * Standard 2nd phase constructor.
417 * @since Series60 3.0
418 * @param aEndpoint the service endpoint. Note that endpoint cannot
419 * include characters which are illegal in XML. If endpoint
420 * is an URL which contains illegal characters (like '&'-char),
421 * those need to be encoded into XML entity form (like &).
422 * EncodeHttpCharactersLC() method from XmlUtils can be used
423 * for encoding of basic XML entities.
425 IMPORT_C void ConstructL(const TDesC8& aEndPoint);
428 * @since Series60 3.0
429 * @param aEndpoint the service endpoint. Note that endpoint cannot
430 * include characters which are illegal in XML. If endpoint
431 * is an URL which contains illegal characters (like '&'-char),
432 * those need to be encoded into XML entity form (like &).
433 * EncodeHttpCharactersLC() method from XmlUtils can be used
434 * for encoding of basic XML entities.
435 * @param aContract identifies the service type. Typically some URN.
436 * Default contract is Liberty ID-WSF Authentication Service
437 * - "urn:liberty:as:2004-04".
439 IMPORT_C void ConstructL(const TDesC8& aEndPoint,
440 const TDesC8& aContract);
443 * @since Series60 3.0
444 * @param aEndpoint the service endpoint. Note that endpoint cannot
445 * include characters which are illegal in XML. If endpoint
446 * is an URL which contains illegal characters (like '&'-char),
447 * those need to be encoded into XML entity form (like &).
448 * EncodeHttpCharactersLC() method from XmlUtils can be used
449 * for encoding of basic XML entities.
450 * @param aContract identifies the service type. Typically some URN.
451 * Default contract is Liberty ID-WSF Authentication Service
452 * - "urn:liberty:as:2004-04".
453 * @param aProviderID is identifier of this IdentityProvider. It is a
454 * unique key pointing to some known endpoint. Required only
455 * for ID-WSF framework.
457 IMPORT_C void ConstructL(const TDesC8& aEndPoint,
458 const TDesC8& aContract,
459 const TDesC8& aProviderID);
462 * @since Series60 3.0
463 * @param aEndpoint the service endpoint. Note that endpoint cannot
464 * include characters which are illegal in XML. If endpoint
465 * is an URL which contains illegal characters (like '&'-char),
466 * those need to be encoded into XML entity form (like &).
467 * EncodeHttpCharactersLC() method from XmlUtils can be used
468 * for encoding of basic XML entities.
469 * @param aContract identifies the service type. Typically some URN.
470 * Default contract is Liberty ID-WSF Authentication Service
471 * - "urn:liberty:as:2004-04".
472 * @param aProviderID is identifier of this IdentityProvider. It is a
473 * unique key pointing to some known endpoint. Required only
474 * for ID-WSF framework.
475 * @param aServiceID is a unique contract to some invocable service.
476 * Typically some URN. If this IDP is registered to ID-WSF
477 * framework, this ServiceID will be appended into list of
478 * services which trust this IDP, and the actual IDP "knows".
480 IMPORT_C void ConstructL( const TDesC8& aEndPoint,
481 const TDesC8& aContract,
482 const TDesC8& aProviderID,
483 const TDesC8& aServiceID );
486 #endif // SEN_IDENTITY_PROVIDER_H