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 implements the most common value object used in WSF,
15 * which is used to describe some invocable service.
29 #ifndef SEN_XML_SERVICE_DESCRIPTION_H
30 #define SEN_XML_SERVICE_DESCRIPTION_H
36 #include <MSenServiceDescription.h>
37 #include <MSenProviderPolicy.h>
38 #include <SenDomFragment.h>
41 const TInt KStateParsingCredentials = 12;
42 const TInt KStateParsingSingleCredential = 122;
43 const TInt KStateParsingProviderPolicy = 1222;
44 const TInt KStateParsingServicePolicy = 12222;
46 _LIT8( KSenAttrSoap12, "SOAP12" );
47 _LIT8( KSenAttrAddressing, "Addressing" );
48 _LIT8( KSenAttrClientEntropy, "ClientEntropy" );
49 _LIT8( KSenAttrTokenType, "TokenType" );
50 _LIT8( KSenAttrPassportExtensions, "PassportExtensions" );
51 _LIT8( KSenAttrMetadataEndpoint, "MetadataEndpoint" );
52 _LIT8( KSenAttrUsernameTokenOverTLS, "UsernameTokenOverTLS" );
53 _LIT8( KSenAttrPromptUserInfo, "promptUserInfo" );
55 _LIT8( KSenLocalnameAppInfo, "AppInfo" );
56 _LIT8( KSenLocalnameWAPGW, "WAPGW" );
57 _LIT8( KSenLocalnameMwsNamespace, "MwsNamespace" );
58 // FORWARD DECLARATIONS
60 class CSenProviderPolicy;
61 class CSenServicePolicy;
62 class MSenServicePolicy;
65 typedef RPointerArray<CSenCredential> RCredentialList;
70 * CSenXmlServiceDescription class implements the most
71 * common value object used in WSF, which is used to
72 * describe some invocable service.
74 * Class offers basic properties which describe some
75 * service and methods to manipulate this info. These
76 * properties are stored in XML fragment format and
77 * a class instance can be represented as one XML tree.
79 * The main properties for service description are:
80 * - contract (typically some URI)
81 * - endpoint (typically some URL)
84 * @lib SenServDesc.lib
87 class CSenXmlServiceDescription : public CSenDomFragment,
88 public MSenServiceDescription,
89 public MSenProviderPolicy
91 public: // Constructors and destructor
94 * Standard 2 phase constructor
95 * @return a pointer to a new CSenXmlServiceDescription instance.
97 IMPORT_C static CSenXmlServiceDescription* NewL();
100 * Standard 2 phase constructor
101 * @return a pointer to a new CSenXmlServiceDescription instance,
102 * which is left on cleanup stack.
104 IMPORT_C static CSenXmlServiceDescription* NewLC();
107 * Standard 2 phase constructor
108 * @param aNamespaceURI namespace URI for the service description.
109 * @return a pointer to a new CSenXmlServiceDescription instance
111 IMPORT_C static CSenXmlServiceDescription* NewL(const TDesC8& aNamespaceURI);
114 * Standard 2 phase constructor
115 * @param aNamespaceURI namespace URI for the service description.
116 * @return a pointer to a new CSenXmlServiceDescription instance,
117 * which is left on cleanup stack.
119 IMPORT_C static CSenXmlServiceDescription* NewLC(const TDesC8& aNamespaceURI);
122 * Standard 2 phase constructors
123 * @param aEndpoint the service endpoint. Note that endpoint cannot
124 * include characters which are illegal in XML. If endpoint
125 * is an URL which contains illegal characters (like '&'-char),
126 * those need to be encoded into XML entity form (like &).
127 * EncodeHttpCharactersLC() method from XmlUtils can be used
128 * for encoding of basic XML entities.
129 * @param aContract identifies the service type.
130 * @return a pointer to a new CSenXmlServiceDescription instance
132 IMPORT_C static CSenXmlServiceDescription* NewL(const TDesC8& aEndPoint,
133 const TDesC8& aContract);
136 * Standard 2 phase constructors
137 * @param aEndpoint the service endpoint. Note that endpoint cannot
138 * include characters which are illegal in XML. If endpoint
139 * is an URL which contains illegal characters (like '&'-char),
140 * those need to be encoded into XML entity form (like &).
141 * EncodeHttpCharactersLC() method from XmlUtils can be used
142 * for encoding of basic XML entities.
143 * @param aContract identifies the service type.
144 * @return a pointer to a new CSenXmlServiceDescription instance,
145 * which is left on cleanup stack.
147 IMPORT_C static CSenXmlServiceDescription* NewLC(const TDesC8& aEndPoint,
148 const TDesC8& aContract);
153 IMPORT_C virtual ~CSenXmlServiceDescription();
158 * Setter for the framework ID.
159 * The developer may use a FrameworkID to search for a session of
160 * (i.e. connection to) a certain service invocation framework.
161 * @since Series60 3.0
162 * @param aFrameworkId
163 * If set to KNullDesC8, then any matching framework may be used.
164 * The default frameworkID in WSF is "ID-WSF"
165 * (KDefaultIdWsfFrameworkID).
166 * Note that Basic Web Services MUST use "WS-I"
167 * (KDefaultBasicWebServicesFrameworkID).
169 IMPORT_C void SetFrameworkIdL(const TDesC8& aFrameworkID);
172 * Method returns the localname for this service description.
173 * This is the localname of the element, when this class is
174 * represented as an XML element.
175 * @since Series60 3.0
176 * @return descriptor to XML localname of this service description
178 IMPORT_C virtual const TDesC8& NewElementName();
181 * Returns list of credentials. Ownership is not transferred, any
182 * modifications to the contents of the list modify the real objects.
183 * @since Series60 3.0
184 * @return the list of credentials (CSenCredential objects).
186 IMPORT_C RCredentialList& Credentials();
188 // Functions from base classes
190 // From MSenProviderPolicy
191 IMPORT_C virtual void SetIapIdL(TUint32 aIapId);
192 IMPORT_C virtual TInt IapId(TUint32& aCurrentIapId);
193 IMPORT_C virtual void SetIdentityProviderIdsL(
194 CSenIdentityProviderIdArray8& aList);
195 IMPORT_C TInt SetTransportPropertiesL(const TDesC8& aProperties);
197 IMPORT_C virtual TInt AddIdentityProviderIdL(TDesC8& aProviderId);
198 IMPORT_C virtual TInt RebuildFrom(MSenProviderPolicy& aTemplate);
199 IMPORT_C virtual const CSenIdentityProviderIdArray8&
200 IdentityProviderIds8L();
201 IMPORT_C TInt TransportPropertiesL(HBufC8*& aProperties);
203 IMPORT_C virtual TBool Accepts(MSenProviderPolicy& aPolicyPattern);
205 // From MSenServiceDescription:
206 IMPORT_C TDescriptionClassType DescriptionClassType();
207 IMPORT_C TBool Matches(MSenServiceDescription& aPattern);
208 IMPORT_C TPtrC8 Contract();
212 * Method for checking if service description has a certain facet.
213 * @since Series60 3.0
214 * @param aURI the facet to check, typically some URI.
215 * @param aHasFacet is ETrue if facet is found and EFalse, if not.
216 * @return KErrNone or other system-wide Symbian error codes.
218 IMPORT_C virtual TInt HasFacetL(const TDesC8& aURI, TBool& aHasFacet);
220 // From MSenServiceDescription
221 IMPORT_C virtual TInt FacetValue(TDesC8& aURI, HBufC8*& aValueTo);
222 IMPORT_C virtual TInt AddFacetL(const CSenFacet& aFacet);
223 IMPORT_C virtual TInt SetFacetL(const CSenFacet& aFacet);
224 IMPORT_C virtual TInt RemoveFacet(const TDesC8& aURI);
225 IMPORT_C virtual TInt FacetsL(RFacetArray& aFacetArray);
229 * On success, this method returns a positive integer if this
230 * service description matches with the given pattern in at
231 * least one aspect. Higher numbers mean a closer match.
233 * The bits of information that are in the pattern are read and compared
234 * to corresponding fields in this ServiceDescription. Note that a pattern
235 * may have far fewer fields and that only the non-null fields are compared.
236 * For example, assume that a pattern with only a contract was defined;
237 * with the contract set to "urn:example.com:service".
238 * Each ServiceDescription with the same contract will match the pattern,
239 * even if such a ServiceDescription has non-null fields for other aspects.
240 * @since Series60 3.0
241 * @param aPattern a ServiceDescription, typically with partial
243 * @return the score or error. If nothing matches, returns 0. In case of
244 * any error, a negative value is returned.
246 IMPORT_C virtual TInt ScoreMatchL(MSenServiceDescription& aPattern);
248 // From MSenServiceDescription
250 IMPORT_C TPtrC8 Endpoint();
251 IMPORT_C TPtrC8 FrameworkId();
252 IMPORT_C TPtrC8 FrameworkVersion();
253 IMPORT_C void SetContractL(const TDesC8& aContract);
254 IMPORT_C void SetEndPointL(const TDesC8& aEndPoint);
256 // From CSenBaseFragment
259 * Gets the service description as XML fragment in UTF-8 format.
260 * @since Series60 3.0
261 * @return the service description as XML, which ownership is
262 * transferred to the caller.
264 IMPORT_C virtual HBufC8* AsXmlL();
267 * Gets the service description as XML, in Unicode (UCS-2)
268 * @since Series60 3.0
269 * @return the service description as XML, in Unicode (UCS-2)
272 IMPORT_C virtual HBufC* AsXmlUnicodeL();
275 * Writes this service description as XML, in UTF-8 form to a stream
276 * @since Series60 3.0
277 * @param aWriteStream to write into.
279 IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWriteStream);
282 // From CSenDomFragment
285 * Method looks for FrameworkID attribute from the given XML attribute
286 * array and if one is found, sets its value for this instance. In
287 * addition, all the namespace attributes are copied. All other
288 * attributes are discarded.
289 * @since Series60 3.0
290 * @param aAttributes the attribute list.
292 IMPORT_C void SetAttributesL(const RAttributeArray& aAttributes);
295 * Resumes the parsing. Called by the delegate fragment
296 * in order to notify owner, which needs to regain
297 * (take over) parsing. For example, when a policy fragment
298 * is parsed, the service description fragment should
299 * resume parsing the rest of its own XML document
301 * @since Series60 3.0
302 * @param aNsUri The namespace URI of the current element
303 * @param aLocalName The local name of the current element
304 * @param aQName The qualified name of the current element
306 IMPORT_C void ResumeParsingFromL(const TDesC8& aNsUri,
307 const TDesC8& aLocalName,
308 const TDesC8& aQName);
310 protected: // New functions
313 * C++ default constructor.
314 * @param aType enumeration defining the type of this class.
316 IMPORT_C CSenXmlServiceDescription(TDescriptionClassType aType);
319 * Basic ConstructL function.
321 IMPORT_C void ConstructL();
324 * Basic ConstructL function.
325 * @since Series60 3.0
326 * @param aNamespaceURI for this service description, which is
327 * also an XML element.
329 IMPORT_C void ConstructL(const TDesC8& aNamespaceURI);
332 * Basic ConstructL function.
333 * @since Series60 3.0
334 * @param aEndpoint the service endpoint. Note that endpoint cannot
335 * include characters which are illegal in XML. If endpoint
336 * is an URL which contains illegal characters (like '&'-char),
337 * those need to be encoded into XML entity form (like &).
338 * EncodeHttpCharactersLC() method from XmlUtils can be used
339 * for encoding of basic XML entities.
340 * @param aContract identifies the service type, typically some URN.
342 IMPORT_C void ConstructL(const TDesC8& aEndPoint, const TDesC8& aContract);
344 // Functions from base classes
346 // From CSenDomFragment
349 * Callback function which implements the XML content handler interface.
350 * @since Series60 3.0
351 * @param aNsURI The namespace URI of the new element
352 * @param aLocalName The local name of the new element
353 * @param aQName The qualified name of the new element
354 * @param aAttributes The attributes of the new element
356 IMPORT_C virtual void StartElementL(const TDesC8& aNsUri,
357 const TDesC8& aLocalName,
358 const TDesC8& aQName,
359 const RAttributeArray& aAttributes);
361 // From CSenBaseFragment
363 * Callback function which implement the XML content handler interface.
364 * @since Series60 3.0
365 * @param aNsUri The namespace URI of the new element
366 * @param aLocalName The local name of the new element
367 * @param aQName The qualified name of the new element
369 IMPORT_C virtual void EndElementL(const TDesC8& aNsUri,
370 const TDesC8& aLocalName,
371 const TDesC8& aQName);
375 * Method returns ETrue if the primary keys of this service description
376 * are equal. Definition of primary keys varies on concrete implementations.
378 * In a typical XML sub class implementation the primary keys are Contract
379 * and Endpoint elements.
381 * Difference to Match() method is that primary keys - often descriptors -
382 * MUST be equal both in this service description and in aCandidate, unlike
383 * in Match(), where argument is more like wildcard pattern matching even
384 * in cases where it includes fewer fields (less information).
387 * @param aCandidate is a service description, which primary keys are
388 * checked in this comparison.
390 * @return TBool ETrue if primary keys are equal, EFalse otherwise.
392 IMPORT_C TBool HasEqualPrimaryKeysL(MSenServiceDescription& aCandidate);
395 * Method checks specific pieces of information to determine, whether this
396 * service description is local or not. Typically this is defined by the
397 * endpoint's scheme, which is KSenTransportSchemeLocal in most of the cases,
398 * when this method returns true.
399 * @return boolean indicating whether this endpoint is local or not.
401 IMPORT_C TBool IsLocalL();
405 * Method for binding transport plug-in type with the endpoint in question.
406 * Function adds/sets XML attribute called "cue" for <Endpoint> element:
408 * <ServiceDescription>
409 * <Endpoint cue="com.nokia.wsf.transport.plugin.hostlet">
410 * local://urn:nokia.com.test.hostlet
412 * </ServiceDescription>
414 * In above example, eventhough endpoint scheme "local://" would normally
415 * invoke different type of plug-in (ECOM hostlet), the "cue" attribute
416 * overrides this, and forces hostlet connection transport plug-in to be
419 * Transport plug-in types (cues):
421 * _LIT8(KSenTransportCueHTTP, "com.nokia.wsf.transport.plugin.httpchannel");
422 * _LIT8(KSenTransportCueVirtualTCP, "com.nokia.wsf.transport.plugin.virtualtcp");
423 * _LIT8(KSenTransportCueLocalEcom, "com.nokia.wsf.transport.plugin.local");
424 * _LIT8(KSenTransportCueHostletConnection, "com.nokia.wsf.transport.plugin.hostlet");
427 * Note that this method does not attempt to load the plug-in - it might not
428 * even exist in the system. Neither is this attribute checked when XML service
429 * description is parsed. As a conclusion, if non-existant plug-ins are bind
430 * to endpoints, they will be ignored, and the transport is created in normal
431 * way and plug-in is chosen based on endpoint scheme and/or defaults.
433 * @param aTransportCue is the ECOM cue of CSenTransport implementation.
434 * In ECOM resource files, cue is the value of "default_data" property.
435 * @return KErrNone on success
436 * KErrSenNoEndpoint, if endpoint element does not exist in this XML
437 * service description.
439 IMPORT_C TInt SetTransportCueL(const TDesC8& aTransportCue);
443 * Getter for transport cue, assuming that attribute has been set,
444 * and that has "cue" -attribute.
445 * @return transport plug-in ECOM cue, or KNullDesC8, if it has
446 * not been set in this service description. In each ECOM resource
447 * file the cue is defined by "default_data" property.
449 IMPORT_C TPtrC8 TransportCue();
452 * Getter for (web) service policy
453 * @return pointer to service policy, or NULL, if it is not available
455 IMPORT_C MSenServicePolicy* ServicePolicy();
458 * Method provides convenient way to add a new value in Client Policy
459 * This method will add elements such as <SOAP12> or <UsernameTokenOverTLS>
460 * in the Policy to be used by stack. Infact this method adds a new element
461 * in xml representation of ServicePolicy.
462 * @param aName is the Name of the attribute.
463 * @return KErrNone on success, KErrArgument if any of the arguments
464 * (descriptors) is of zero-length, or one of the system-wide
465 * error codes otherwise.
467 IMPORT_C TInt SetPolicyL(const TDesC8& aName);
470 * Method provides convenient way to add a new value in Client Policy
471 * This method will add elements such as <Addressing>
472 * in the Policy to be used by stack. Infact this method adds a new element
473 * in xml representation of ServicePolicy and adds its value as contents of the element.
474 * <Addressing>http://schemas.xmlsoap.org/ws/2004/03/addressing</Addressing>
475 * @param aName is the Name of the Policy attribute.
476 * @param aValue is the Contents of the Policy attribute.
477 * @return KErrNone on success, KErrArgument if any of the arguments
478 * (descriptors) is of zero-length, or one of the system-wide
479 * error codes otherwise.
481 IMPORT_C TInt SetPolicyL(const TDesC8& aName, const TDesC8& aValue);
484 * Method provides convenient way to add a new value in Client Policy
485 * This method will add elements such as <Addressing>
486 * in the Policy to be used by stack, plus it will add one specified
487 * attribute (name and value) for that element. Infact this method adds
488 * a new element - and it's attribute - in the xml representation of
489 * ServicePolicy element, which is direct child to ServiceDescription
490 * (root element) document.
491 * <MetadataEndpoint method = "GET">http://www.mypolicyendpoint.com/policy2/</MetadataEndpoint>
492 * @param aName is the Name of the Policy attribute.
493 * @param aValue is the Contents of the Policy attribute.
494 * @param aAttribName is the Name of the attribute in element aName
495 * @param aAttribValue is the Contents of the aAttribName attribute.
496 * @return KErrNone on success, KErrArgument if any of the arguments
497 * (descriptors) is of zero-length, or one of the system-wide
498 * error codes otherwise.
500 IMPORT_C TInt SetPolicyL(const TDesC8& aName, const TDesC8& aValue, const TDesC8& aAttribName, const TDesC8& aAttribValue);
503 * Setter for (identity) provider ID
504 * @since Series60 5.0
505 * @param aProviderID the unique identifier of the (identity) provider
506 * @return KErrNone on success, KErrArgument if aProviderID is of zero-length,
507 * or one of the system-wide Symbian error codes otherwise.
509 IMPORT_C TInt SetProviderIdL( const TDesC8& aProviderID );
512 * Getter for (identity) provider ID
513 * @since Series60 5.0
514 * @return the (locally) unique identifier of the (identity) provider
515 * @return KErrNone on success, KErrArgument if aProviderID is of zero-length,
516 * or one of the system-wide Symbian error codes otherwise.
518 IMPORT_C TPtrC8 ProviderId();
521 * Setter for userinfo (KSenAttrPromptUserInfo) attribute, which
522 * - password notifier dialog is shown to end-user or not, when
523 * authentication fails (due wrong, or incomplete userinfo).
524 * @param aPromptUserInfoMode
525 * EFalse dictates that an error must be returned when creating
526 * a service connection and userinfo is not accepted by
527 * (remote) authentication, instead of showing the dialog.
528 * ETrue (or if attribute does not exist in this XML SD) means that
529 * end-user should be prompted (default behaviour). The number
530 * of retry attempts (each showing a dialog) is service invocation
531 * framework spesific; typically 3 retries are permitted.
533 IMPORT_C void CSenXmlServiceDescription::SetPromptUserInfoL( TBool aPromptUserInfoMode );
536 * Getter for current userinfo mode (KSenAttrPromptUserInfo attribute).
537 * @return Boolean that indicates the mode:
538 * EFalse means that end-user prompts (notifier dialogs) have been
539 * explicitely surpressed, and thus will not be shown to end-user:
540 * attribute value is exactly as follows: "false"
541 * ETrue means that attribute named as KSenAttrPromptUserInfo
542 * does not exist (default), or it has ANY value OTHER than "false"
544 IMPORT_C TBool PromptUserInfo();
549 * @param aIapId A TUint32 Snap ID
551 IMPORT_C void SetSnapIdL(TUint32 aIapId);
554 * @param aCurrentSnapId A TUint32 reference to be filled in with the
555 * value of the SNAP ID.
556 * @return KErrNone if no error, or some of the system
559 IMPORT_C TInt SnapId(TUint32& aCurrentIapId);
562 TInt FacetValueL(TDesC8& aURI, HBufC8*& aValueTo);
563 TInt RemoveFacetL(const TDesC8& aURI);
566 // the type of this class instance
567 const TDescriptionClassType iType;
570 CSenServicePolicy* iServicePolicy;
571 CSenCredential* iCredential;
572 RCredentialList iCredentialList;
574 // Timestamp indicating validity of credentials. Using SenDateUtils
575 // FromXmlDateTimeL and ToXmlDateTimeUtf8L is recommended for conversions.
577 CSenProviderPolicy* iProviderPolicy;
580 #endif // SEN_XML_SERVICE_DESCRIPTION_H