webservices/idwsfplugin/inc/idwsfservicesession.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 IDWSF_SERVICE_SESSION_H
       
    26 #define IDWSF_SERVICE_SESSION_H
       
    27 
       
    28 // INCLUDES
       
    29 #include "msenremoteserviceconsumer.h"
       
    30 #include "msenserviceinvocationframework.h"
       
    31 #include "midwsfsessionvalidator.h"
       
    32 #include "senidwsfplugin.h"
       
    33 #include "senwebservicesession.h"
       
    34 #include "idwsfserviceprovider.h"
       
    35 #include "idwsfserviceinstance.h"
       
    36 #include "idwsfsessionconsumer.h"
       
    37 #include "idwsfsiuheader.h"
       
    38 #include "idwsfmessage.h"
       
    39 
       
    40 // CONSTANTS
       
    41 _LIT8(KSecNullNull,     "urn:liberty:security:2003-08:null:null"); // IOP
       
    42 _LIT8(KSecNullBearer,   "urn:liberty:security:2004-04:null:Bearer");
       
    43 _LIT8(KSecTlsNull,      "urn:liberty:security:2003-08:TLS:null"); // IOP
       
    44 _LIT8(KSecTlsBearer,    "urn:liberty:security:2004-04:TLS:Bearer");
       
    45 
       
    46 // ID-WSF 1.1 namespaces
       
    47 _LIT8(KSecNullBearer11, "urn:liberty:security:2005-02:null:Bearer");
       
    48 _LIT8(KSecTlsBearer11,  "urn:liberty:security:2005-02:TLS:Bearer");
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 class CIdWsfSessionConsumer;
       
    52 class CIdWsfServiceInstance;
       
    53 class MIdWsfSessionValidator;
       
    54 
       
    55 // CLASS DECLARATION
       
    56 class CIdWsfServiceSession : public CSenWebServiceSession
       
    57     {
       
    58     public: // Constructors and destructor
       
    59     
       
    60         static CIdWsfServiceSession* NewL(MSIF& aFramework);
       
    61         static CIdWsfServiceSession* NewLC(MSIF& aFramework);
       
    62 
       
    63         virtual ~CIdWsfServiceSession();
       
    64 
       
    65         // New functions
       
    66         
       
    67         virtual TBool Matches(MSenServiceDescription& aPattern);
       
    68         virtual TInt ConstructSecurityTokenL(const TDesC& aToken,
       
    69                                              HBufC8*& aSecurityToken);
       
    70 
       
    71         virtual TInt InitializeFromL(CIdWsfServiceInstance& aServiceInstance);
       
    72         virtual TBool IsSAMLL(const TDesC8& aSecMechURI);
       
    73         virtual TBool IsBearerL(const TDesC8& aSecMechURI);
       
    74         TPtrC8 ProviderId();
       
    75         TPtrC8 ServiceType();
       
    76         TInt UpdateFromL(CIdWsfSiuHeader& aHeader);
       
    77         void SetProviderL(CIdWsfServiceProvider *aProvider);
       
    78         CIdWsfServiceProvider* Provider();
       
    79         void SetResourceIdL(const TDesC8& aURI);
       
    80         TPtrC8 ResourceId();
       
    81         void SetServiceTypeL(const TDesC8& aServiceType);
       
    82         void SetTrustAnchorL(const TDesC8& aProviderId);
       
    83         virtual TInt CanHandleErrorL(CIdWsfMessage& aSOAPMessage);
       
    84     
       
    85         /**
       
    86         * Read the facets of the given pattern ServiceDescription.
       
    87         * Take on those facets that we understand.
       
    88         * @param pattern
       
    89         */
       
    90         virtual void CopyFacetsFromL(MSenServiceDescription& aPattern);
       
    91     
       
    92         void SetValidator(MIdWsfSessionValidator* aValidator);
       
    93         MIdWsfSessionValidator* Validator();
       
    94 
       
    95         // Functions from base classes
       
    96         
       
    97         // From SenServiceSession
       
    98         virtual MSenRemoteServiceConsumer* RemoteConsumerL(
       
    99                                                     const TDesC8& aSenderID);
       
   100         virtual void StartTransaction();
       
   101         virtual void TransactionCompleted();
       
   102         virtual TInt SetStatusL();
       
   103 
       
   104         // From SenWebServiceSession
       
   105         virtual TInt RemoveConsumerL(MSenRemoteServiceConsumer& aConsumer);
       
   106         virtual TInt AddConsumerL(MSenRemoteServiceConsumer& aConsumer);
       
   107         virtual TPtrC8 FrameworkId();
       
   108         virtual TInt MessageForSendingL(const TDesC8& aBody,
       
   109                                         const TDesC8& aSenderID,
       
   110                                         CSenSoapMessage*& aMessage);
       
   111 
       
   112         virtual TInt NewMessageL(CSenSoapMessage*& aMessage);
       
   113         virtual TInt InitializeFromL(MSenServiceDescription& aServiceDescription);
       
   114         virtual TInt ParseMessageL(CSenSoapMessage& aSOAPMessage);
       
   115 
       
   116         virtual TInt SendSoapMessageToConsumerL( CSenSoapMessage* apMessage,
       
   117                                                  const TInt aTxnId,
       
   118                                                  MSenRemoteServiceConsumer& aConsumer,
       
   119                                                  MSenProperties* aResponseTransportProperties );
       
   120 
       
   121         virtual void SetEndPointL(const TDesC8& aURI);
       
   122         virtual void SetFrameworkHeadersL(CSenSoapMessage& aMsg);
       
   123         virtual TPtrC8 TrustAnchor();
       
   124         
       
   125         virtual TInt SendL( const TDesC8& aMessage, 
       
   126                             const TDesC8& aTransportProperties,
       
   127                             MSenRemoteServiceConsumer& aConsumer,
       
   128                             TInt& aTxnId,
       
   129                             HBufC8*& aRevalidationError );
       
   130         
       
   131         virtual TInt SubmitL( const TDesC8& aMessage, 
       
   132                               const TDesC8& aTransportProperties,
       
   133                               MSenRemoteServiceConsumer& aConsumer,
       
   134                               HBufC8*& aResponse );
       
   135                               
       
   136         TInt SendSoapL( const TDesC8& aSoapMessage, 
       
   137                         const TDesC8& aTransportProperties,
       
   138                         MSenRemoteServiceConsumer& aConsumer,
       
   139                         TInt& aTxnId,
       
   140                         HBufC8*& /*aRevalidationError*/ );
       
   141       
       
   142                               
       
   143         TInt SubmitSoapL( const TDesC8& aSoapMessage, 
       
   144                           const TDesC8& aTransportProperties,
       
   145                           MSenRemoteServiceConsumer& aConsumer,
       
   146                           HBufC8*& aResponse );
       
   147 
       
   148         /**
       
   149         * Method checks if ID-WSF framework can handle this fault, if not, then
       
   150         * error is delivered to session consumer
       
   151         *
       
   152         * @param apSoapMessage is the SOAP message representing fault.
       
   153         * @param aResponse is where either SOAP fault OR - if ID-WSF
       
   154         *        framework was able to handle this fault (recover)
       
   155         *        - the valid response from the service, achieved
       
   156         *        by re-submitted request (for example to new endpoint,
       
   157         *        if the handled fault was "endpoint moved" -type fault.
       
   158         *        
       
   159         * 
       
   160         * @return KErrSenSoapFault, if this error (fault) could not be handled.
       
   161         *         In this case, aResponse contains (extracted) SOAP fault
       
   162         *         element.
       
   163         *         KErrNone, if recovery was possible and successful, and
       
   164         *                   then aResponse contains valid response from 
       
   165         *                   the service. The SOAP fault, which was taken
       
   166         *                   care here - between (remote) service and ID-WSF 
       
   167         *                   framework - remains thus "hidden" from actual 
       
   168         *                   web service consumer.
       
   169         *         KErrSenSoapFault, if fault could not be handled. Now
       
   170         *                   aResponse will contain the extracted SOAP
       
   171         *                   fault element as UTF-8 descriptor (TDesC8)
       
   172         *         KErrSenInternal, the SOAP fault could not be found from
       
   173         *                   aSoapMessage.
       
   174         *         KErrNotFound - the consumer could not be found.
       
   175         */
       
   176         virtual TInt HandleSoapFaultL( CSenSoapMessage* apSOAPMessage,
       
   177                                        HBufC8*& aResponse );
       
   178 
       
   179         /**
       
   180         * Method checks if ID-WSF framework can handle this fault, if not, then
       
   181         * error is delivered to session consumer
       
   182         *
       
   183         * @param apSoapMessage is the SOAP message representing fault.
       
   184         * @param aErrorCode, is the error code received from transport
       
   185         * @param aTxnId is the transaaction id from transport, which 
       
   186         *        can be used to map this error response to consumer's 
       
   187         *        request.
       
   188         * @param aConsumer is the consumer which was calling the transport
       
   189         *        and originally sent the request.
       
   190         * @param aResponseTransportProperties includes response properties
       
   191         *        from transport.
       
   192         * @return KErrNone, if error was either succesfully handled or
       
   193         *         processed (delivered to consumer) The SOAP fault, which was taken care between (remote)
       
   194         *         service and ID-WSF framework is hereby "hidden" from
       
   195         *         actual web service consumer.
       
   196         */
       
   197         virtual TInt HandleSoapFaultL(CSenSoapMessage* apSOAPMessage,
       
   198                                       const TInt aErrorCode,
       
   199                                       const TInt aTxnId,
       
   200                                       MSenRemoteServiceConsumer& aConsumer,
       
   201                                       MSenProperties* aResponseTransportProperties);
       
   202 
       
   203         virtual void WriteExtensionsAsXMLToL(RWriteStream& aWriteStream);
       
   204 
       
   205         /**
       
   206         * @see CSenWSDescription
       
   207         */
       
   208         virtual TBool HasSuperClass( TDescriptionClassType aType );
       
   209         
       
   210         virtual void FillCredentialIdentifierL(CSenCredentialIdentifier& aIdentifier);
       
   211 
       
   212     private: 
       
   213         
       
   214         /**
       
   215         * C++ default constructor.
       
   216         */
       
   217         CIdWsfServiceSession(TDescriptionClassType aType, MSIF& aFramework);
       
   218     
       
   219         /**
       
   220         * By default Symbian 2nd phase constructor is private.
       
   221         */
       
   222         void ConstructL();
       
   223         
       
   224         // New functions
       
   225         
       
   226         TInt SessionConsumerL(  CIdWsfMessage& aMessage,
       
   227                                 CIdWsfSessionConsumer*& aSessionConsumer);
       
   228         
       
   229         TInt SessionConsumerL(  const TDesC8& aSenderID,
       
   230                                 CIdWsfSessionConsumer*& aSessionConsumer);
       
   231                                 
       
   232         // NOTE: this is temporary method which MUST be removed when message context is made available in SendL/SubmitL                                
       
   233         TInt SetFrameworkPropertiesL(MSenTransport& aTransport);                                
       
   234     
       
   235         void SetSenSecurityMechanismL(const TDesC8& aSenSecurityMechanism);
       
   236         TPtrC8 SenSecurityMechanism();
       
   237         TInt SetOptionsFromL(MSenServiceDescription& aServiceDescription);
       
   238 
       
   239     private: // Data
       
   240         CIdWsfServiceProvider*  iProvider;
       
   241         HBufC8* ipResourceId;
       
   242         HBufC8* ipTrustAnchor;
       
   243         HBufC8* ipReceivedMessageId;
       
   244         HBufC8* ipSenSecurityMechanism;
       
   245         //no need to store received message IDs;
       
   246         TBool  iMessageThread; 
       
   247         MIdWsfSessionValidator* ipValidator; // not owned
       
   248         TInt iSubmitState;
       
   249     };
       
   250     
       
   251 #endif // IDWSF_SERVICE_SESSION_H
       
   252 
       
   253 // End of File
       
   254