webservices/idwsfplugin/inc/senidwsfplugin.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef SEN_IDWSF_PLUGIN_H
       
    26 #define SEN_IDWSF_PLUGIN_H
       
    27 
       
    28 // INCLUDES
       
    29 #include <e32std.h>
       
    30 #include <flogger.h>
       
    31 
       
    32 #include <SenXmlUtils.h>
       
    33 #include <SenIdentityProvider.h>
       
    34 
       
    35 #include "idwsfauthenticationserviceclient.h"
       
    36 #include "idwsfserviceinstance.h"
       
    37 
       
    38 #include "senserviceinvocationframework.h" // internal Framework\inc
       
    39 
       
    40 
       
    41 // CONSTANTS
       
    42 _LIT8(KIdWsfFrameworkVersion, "1.0");
       
    43 _LIT8(KIdWsfFrameworkXMLNS, "urn:com.nokia.Sen.idwsf.config.1.0");
       
    44 _LIT8(KIdWsFrameworkCue, "com.nokia.Sen.idwsf.IdentityBasedWebServicesFramework");
       
    45 _LIT8(KIdWsfFrameworkLocalname, "Framework");
       
    46 _LIT8(KIdWsfFrameworkAuthenticationServiceContract, "urn:liberty:as:2004-04");
       
    47 _LIT8(KIdWsfFrameworkDiscoveryServiceContract, "urn:liberty:disco:2003-08");
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 class MSenCoreServiceManager;
       
    51 class CSenBaseFragment;
       
    52 class CIdWsfCoreServiceConsumer;
       
    53 class CIdWsfAuthenticationServiceClient;
       
    54 class CIdWsfDiscoveryServiceClient;
       
    55 class CIdWsfServiceSession;
       
    56 
       
    57 typedef struct
       
    58 {
       
    59     CSenWSDescription*  iSD;
       
    60     TInt                        iScore;
       
    61 } TSDScore;
       
    62 
       
    63 // CLASS DECLARATION 
       
    64 /**
       
    65 * An implementation of the CSIF definition. This is concrete
       
    66 * class, instance of which ECOM framework gives to ECOM clients.
       
    67 */
       
    68 class CSenIdWsfPlugin : public CSIF
       
    69     {
       
    70     public: // Constructors and destructor
       
    71                 
       
    72         /**
       
    73         * Create instance of concrete implementation. Note that ECOM
       
    74         * interface implementations can only have two signatures for
       
    75         * NewL:
       
    76         *   - NewL without parameters (used here)
       
    77         *   - NewL with TAny* pointer, which may provide some client data
       
    78         * Note: The interface, which is abstract base class of this
       
    79         * implementation, also provides NewL method. Normally abstract
       
    80         * classes do not provide NewL, because they cannot create
       
    81         * instances of themselves.
       
    82         * @return Instance of this class.
       
    83         */
       
    84         static CSenIdWsfPlugin* NewL(TAny* aManager);
       
    85 
       
    86         virtual ~CSenIdWsfPlugin();
       
    87 
       
    88         // New functions
       
    89         
       
    90         // Methods implementing CSIF ECOM interface
       
    91     
       
    92         /**
       
    93         * For convenience of components classes
       
    94         */
       
    95         //RFileLogger* Log() const;
       
    96 
       
    97         /**
       
    98         * @return TDesC8 that uniquely identifies this framework.
       
    99         */
       
   100         virtual const TDesC8& Id();
       
   101 
       
   102         /**
       
   103         * Try to find one or more services that match the given
       
   104         * ServiceDescription.
       
   105         * Register ServiceDescriptions for these to the owner of the framework,
       
   106         * i.e. to the ServiceManager. Return the number of ServiceDescriptions
       
   107         * that were added.
       
   108         * @param    aPattern - A ServiceDescriptin that should be treated as a
       
   109         *           pattern
       
   110         * @return (TInt) count of matching ServiceDescriptions that were added
       
   111         */
       
   112         virtual TInt AddServiceDescriptionL( MSenServiceDescription& aPattern,
       
   113                                              MSenRemoteServiceConsumer& aRemoteConsumer, 
       
   114                                              HBufC8*& /* aErrorMsg */ );
       
   115 
       
   116         virtual TInt AddServiceDescriptionL( const TDesC8& aServiceTypeContract,
       
   117                                              MSenRemoteServiceConsumer& aRemoteConsumer,
       
   118                                              HBufC8*& /* aErrorMsg */  );
       
   119 
       
   120         /**
       
   121         * Attempt to register the ServiceDescription to the ServiceManager that
       
   122         * owns the framework.
       
   123         * This is a callback used by the ServiceManager to give frameworks a
       
   124         * chance to replace a generic ServiceDescription into something that is
       
   125         * more specific, and more useful, to the ServiceInvocationFramework.
       
   126         * @param aServiceDescription A ServiceDescription
       
   127         * @return TInt aError - indicates the error or KErrNone if successful
       
   128         */
       
   129         virtual TInt RegisterServiceDescriptionL(
       
   130                                 MSenServiceDescription& aServiceDescription);
       
   131 
       
   132         /**
       
   133         * Attempt to unregister the ServiceDescription from the ServiceManager
       
   134         * that owns the framework.
       
   135         * This is a callback used by the ServiceManager.
       
   136         * @param aServiceDescription A ServiceDescription
       
   137         * @return TInt aError - indicates the error or KErrNone if successful
       
   138         */
       
   139         virtual TInt UnregisterServiceDescriptionL(
       
   140                                 MSenServiceDescription& aServiceDescription);
       
   141 
       
   142         /**
       
   143         * Create a ServiceSession based upon the given ServiceDescription.
       
   144         * The ServiceSession is expected to be "valid", i.e. ready for use
       
   145         * by a client.
       
   146         * @param aServiceDescription A ServiceDescription
       
   147         * @param aNewSession (CSenServiceSession)
       
   148         * @return TInt error or KErrNone if successful
       
   149         */
       
   150         virtual TInt CreateServiceSessionL( MSenServiceDescription& aServiceDescription,
       
   151                                             MSenServiceDescription& aPattern,
       
   152                                             CSenServiceSession*& aNewSession,
       
   153                                             MSenRemoteServiceConsumer& aRemoteConsumer,
       
   154                                             HBufC8*& aErrorMsg );
       
   155 
       
   156         /**
       
   157         * Return a new instance of a framework specific class that
       
   158         * implements the ServiceDesccription interface.
       
   159         * @param new service description 
       
   160         *        (which typically derives from CSenServiceSession)
       
   161         * @return TInt error or KErrNone if successful
       
   162         */
       
   163         virtual CSenWSDescription* NewServiceDescriptionL();
       
   164 
       
   165         /**
       
   166         * @return the ServiceManager for which this instance is working.
       
   167         * This is used by the ServiceSession instances created by this framework.
       
   168         * Note, in WSF, MSenCoreServiceManager IS SINGLETON(!), so all Frameworks
       
   169         * return their "owner" - that is - the only service manager in
       
   170         * WS Framework
       
   171         */
       
   172         virtual MSenCoreServiceManager& Manager();
       
   173 
       
   174         /**
       
   175         * Set the ServiceManager to which this instance reports.
       
   176         * The (singleton) ServiceManager calls this method when
       
   177         * it instantiates a framework.
       
   178         * @param aServiceManager The singleton ServiceManager in the system.
       
   179         */
       
   180         virtual void SetManager(MSenCoreServiceManager& aServiceManager);
       
   181 
       
   182         /** 
       
   183         * @return an object that can do SAX based parsing of a XML fragment
       
   184         * that contains framework specific configuration information.
       
   185         * The ServiceManager asks for this BaseFragment upon startup
       
   186         * in order to give this framework a chance to read its configuration
       
   187         * information from the central ServiceManager configuration document.
       
   188         */
       
   189         virtual CSenBaseFragment& ConfigParser();
       
   190 
       
   191         /**
       
   192         * Write the ServiceInvocationFramework configuration as XML to a HBufC8.
       
   193         * This method is invoked by the ServiceManager when it saves
       
   194         * its state and/or configuration.
       
   195         * Upon startup the chunk of XML that is written will be passed back to
       
   196         * the configuration parser of the framework.
       
   197         * The "schema" that shall be adhered to is:
       
   198         * <pre>
       
   199         * &lt;element name="Framework"&gt;
       
   200         *       &lt;any/&gt;&lt;!-- this is where implementations write additional
       
   201         *       information --&gt;
       
   202         *       &lt;attribute name="class" type="String"&gt;
       
   203         *    &lt;!-- In Symbian the class attribute is used as cue for the
       
   204         *       ECOM Resolver --&gt;
       
   205         * &lt;/element&gt;
       
   206         * </pre>
       
   207         *
       
   208         * @param aTo - a HBufC8 to which the framework should write its
       
   209         *               configuration
       
   210         */
       
   211         virtual HBufC8* AsXmlL();
       
   212 
       
   213         virtual HBufC* AsXmlUnicodeL();
       
   214         virtual void EndElementL(   const TDesC8& aNsUri,
       
   215                                     const TDesC8& aLocalName,
       
   216                                     const TDesC8& aQName);
       
   217 
       
   218         virtual TInt OnEvent(const TInt aEvent,
       
   219                              TAny* /* aArgument */);
       
   220 
       
   221         virtual TAny* ExtendedInterface();
       
   222         
       
   223         // From MSIF:
       
   224         /**
       
   225         * ID-WSF specifies at least following: 
       
   226         * - empty SOAPAction HTTP header value.
       
   227         *   KSenSoapActionHeaderValueEmpty ==  ""
       
   228         * It is forced to BOTH framework and message layer (!)
       
   229         * to prevent breaking the Liberty specs in this
       
   230         * (empty SOAPAction value is MUST)
       
   231         * @return KErrNone on success, system-wide error code otherwise
       
   232         */    
       
   233         virtual TInt SetTransportPropertiesL(MSenTransport& aTransport);        
       
   234 
       
   235     protected:
       
   236     
       
   237         /**
       
   238         * Perform the first phase of two phase construction
       
   239         */
       
   240         CSenIdWsfPlugin(MSenCoreServiceManager& aManager);
       
   241 
       
   242         /**
       
   243         * Perform the second phase construction of a
       
   244         *             CImplementationClassPlus object.
       
   245         */
       
   246         void ConstructL();
       
   247 
       
   248         // New functions
       
   249         
       
   250         TBool ValidateL(CIdWsfServiceSession& aSession,
       
   251                         MSenRemoteServiceConsumer& aRemoteConsumer);
       
   252 
       
   253         CIdWsfDiscoveryServiceClient* DSClientL(
       
   254                                 const TDesC8& aTrustAnchor,
       
   255                                 MSenRemoteServiceConsumer& aRemoteConsumer);
       
   256 
       
   257         CIdWsfDiscoveryServiceClient* DSClientL(
       
   258                                 CSenIdentityProvider* aProvider,
       
   259                                 MSenRemoteServiceConsumer& aRemoteConsumer);
       
   260 
       
   261         CIdWsfAuthenticationServiceClient* ASClientL(
       
   262                                             CSenIdentityProvider* aProvider);
       
   263 
       
   264         TInt CoreServiceDescriptionsL(
       
   265                             RPointerArray<CSenWSDescription>& aMatches,
       
   266                             const TDesC8& aContract,
       
   267                             const TDesC8& aProviderID);
       
   268 
       
   269         TInt AssignSessionValidatorsL();
       
   270 
       
   271     private:
       
   272         
       
   273         // New functions
       
   274         
       
   275         CSenIdentityProvider* IdentityProviderL(const TDesC8& aProviderId);
       
   276         CSenIdentityProvider* IdentityProviderL(MSenServiceDescription *aPattern);
       
   277         TBool ValidateDSL(  CIdWsfDiscoveryServiceClient *aDSClient,
       
   278                             CSenIdentityProvider *aIDP,
       
   279                             MSenRemoteServiceConsumer& aRemoteConsumer);
       
   280 
       
   281         virtual TInt RegisterASClientL(
       
   282                                 MSenServiceDescription* aServiceDescription);
       
   283 
       
   284         virtual TInt RegisterDSClientL(
       
   285                                 MSenServiceDescription* aServiceDescription);
       
   286 
       
   287         virtual TInt UnRegisterASClientL(
       
   288                                 MSenServiceDescription* aServiceDescription);
       
   289 
       
   290         virtual TInt UnRegisterDSClientL(
       
   291                                 MSenServiceDescription* aServiceDescription);
       
   292                                 
       
   293         static TInt CompareSDScore(const TSDScore& aSDScoreLeft,
       
   294                                     const TSDScore& aSDScoreRight);
       
   295 
       
   296     private: // Data
       
   297             MSenCoreServiceManager& iManager;
       
   298     };
       
   299 
       
   300 
       
   301 #endif // SEN_IDWSF_PLUGIN_H
       
   302 
       
   303 // End of File