webservices/wsstar/wsstarplugin/inc/wsstarservicesession.h
changeset 0 62f9d29f7211
child 23 a1df79fa35b4
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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 
       
    26 
       
    27 
       
    28 #ifndef WSSTAR_SERVICE_SESSION_H
       
    29 #define WSSTAR_SERVICE_SESSION_H
       
    30 
       
    31 // INCLUDES
       
    32 #include "msenremoteserviceconsumer.h"
       
    33 #include "msenserviceinvocationframework.h"
       
    34 
       
    35 #include "wsstarplugin.h"
       
    36 #include "senwebservicesession.h"
       
    37 #include "wsstarsessionconsumer.h"
       
    38 #include <xmlengfilecontainer.h>
       
    39 #include <xmlengchunkcontainer.h>
       
    40 #include <xmlengelement.h>
       
    41 #include "sensoapmessagedom2.h"
       
    42 
       
    43 class CWSStarCredentialObserver;
       
    44 // CONSTANTS
       
    45 namespace WSStarSession
       
    46     {
       
    47     _LIT8(KProviderIDTag,                  "<ProviderID>");
       
    48     _LIT8(KProviderIDEndTag,               "</ProviderID>");
       
    49     _LIT8(KTrustAnchorTag,                 "<TrustAnchor>");
       
    50     _LIT8(KTrustAnchorEndTag,              "</TrustAnchor>");
       
    51     _LIT8(KPOPBase64Tag,                   "<POP>");
       
    52     _LIT8(KPOPBase64EndTag,                "</POP>");
       
    53     _LIT8(KTokenTypeTag,                   "<TokenType>");
       
    54     _LIT8(KTokenTypeEndTag,                "</TokenType>");
       
    55     _LIT8(KSTRTag,                          "<STR>");
       
    56     _LIT8(KSTREndTag,                       "</STR>");
       
    57     _LIT8(KBinaryTypeTag,                   "<BinaryType>");
       
    58     _LIT8(KBinaryTypeEndTag,                "</BinaryType>");
       
    59     
       
    60     _LIT8(KClusterTypeTag,                   "<Cluster>");
       
    61     _LIT8(KClusterEndTypeTag,                "</Cluster>");
       
    62     
       
    63     _LIT8(KServiceInterval,             "<ServiceInterval>");
       
    64     _LIT8(KServiceIntervalEnd,          "</ServiceInterval>");
       
    65 
       
    66     
       
    67     //related to ticket
       
    68     _LIT8(KPhoneTimeWhenMTResolvedTag,        "<PhoneTimeWhenMTResolved>");
       
    69     _LIT8(KPhoneTimeWhenMTResolvedEndTag,        "</PhoneTimeWhenMTResolved>");
       
    70     _LIT8(KCreatedTag,        "<Created>");
       
    71     _LIT8(KCreatedEndTag,        "</Created>");  
       
    72     //_LIT8(KProviderIdElementLocalName,  "ProviderID");
       
    73     _LIT8(KPOPBase64LocalName,  "POP");
       
    74     _LIT8(KSTRLocalName,  "STR");
       
    75     _LIT8(KBinaryTypeLocalName,  "BinaryType");
       
    76     _LIT8(KTrustAnchorElementLocalName,  "TrustAnchor");
       
    77     _LIT8(KClusterLocalName,        "Cluster");
       
    78     _LIT8(KPhoneTimeWhenMTResolvedLocalName,        "PhoneTimeWhenMTResolved");
       
    79     _LIT8(KCreatedLocalName,        "Created");
       
    80     _LIT8(KTokenType,        "TokenType");
       
    81     }
       
    82 
       
    83 
       
    84 
       
    85 // CLASS DECLARATION
       
    86 /**
       
    87  * WSStar Service Session.
       
    88  * Represent session between client and service in ws* framework.
       
    89  */
       
    90 class CWSStarServiceSession : public CSenWebServiceSession
       
    91     {
       
    92 
       
    93 friend class CWSStarPlugin;
       
    94 
       
    95 public: // Constructors and destructor
       
    96 
       
    97     static CWSStarServiceSession* NewL(MSIF& aFramework);
       
    98     static CWSStarServiceSession* NewLC(MSIF& aFramework);
       
    99 
       
   100     virtual ~CWSStarServiceSession();
       
   101 
       
   102     // From SenServiceSession
       
   103     virtual MSenRemoteServiceConsumer* RemoteConsumerL(
       
   104                                                 const TDesC8& aSenderID);
       
   105     
       
   106     virtual TBool Matches(MSenServiceDescription& aPattern);
       
   107     virtual TInt ScoreMatchL(MSenServiceDescription& aPattern);
       
   108     
       
   109     virtual void WriteExtensionsAsXMLToL(RWriteStream& aWriteStream);
       
   110 
       
   111 
       
   112     //From SenWebServiceSession
       
   113     virtual TInt SendL( const TDesC8& aMessage, 
       
   114                         const TDesC8& aTransportProperties,
       
   115                         MSenRemoteServiceConsumer& aConsumer,
       
   116                         TInt& aTxnId,
       
   117                         HBufC8*& aRevalidationError );
       
   118                         
       
   119     virtual TInt SubmitL(const TDesC8& aMessage, 
       
   120                          const TDesC8& aTransportProperties,
       
   121                          MSenRemoteServiceConsumer& aConsumer,
       
   122                          HBufC8*& aResponse);
       
   123 
       
   124     virtual TInt SubmitSoapL(const TDesC8& aSoapMessage, 
       
   125                              const TDesC8& aTransportProperties,
       
   126                              MSenRemoteServiceConsumer& aConsumer,
       
   127                              HBufC8*& aResponse);
       
   128 
       
   129     virtual TInt SendSoapL( const TDesC8& aSoapMessage, 
       
   130                             const TDesC8& aTransportProperties,
       
   131                             MSenRemoteServiceConsumer& aConsumer,
       
   132                             TInt& aTxnId,
       
   133                             HBufC8*& aRevalidationError );
       
   134     
       
   135     virtual void StartTransaction();                             
       
   136     virtual void TransactionCompleted();
       
   137     virtual TInt InitializeFromL(MSenServiceDescription& aDescription, CWSStarPolicyHandler* aPolicyHandler = NULL);
       
   138 
       
   139 
       
   140     
       
   141     /**
       
   142     add consumer. Eeach session has multiple consumers.From 3rd parties point of view
       
   143     its mean 2 connection per the same service description.Consumers are distinguished by addressing id (MessagesID and RelatesTo)
       
   144     */
       
   145     virtual TInt AddConsumerL(MSenRemoteServiceConsumer& aConsumer);
       
   146     
       
   147     /**
       
   148     remove consumer
       
   149     */
       
   150     virtual TInt RemoveConsumerL(MSenRemoteServiceConsumer& aConsumer);
       
   151     
       
   152     /**
       
   153     Framework specific method. Process message before sending to network
       
   154             In other words add specific headers, and store correlation info in proper consumer
       
   155     */
       
   156     virtual TInt MessageForSendingL( const TDesC8& aBody,
       
   157                                      const TDesC8& aSenderID,
       
   158                                      CSenSoapMessage*& aMessage ); //out param
       
   159 
       
   160     /**
       
   161     During parsing Inbound new SoapMessage is created, based on active soap version.
       
   162     Method is called by framework
       
   163     */
       
   164     virtual TInt NewMessageL( CSenSoapMessage*& aMessage );
       
   165     
       
   166     
       
   167     //virtual TInt ParseResponseL(const TDesC8& aResponse,CSenSoapMessage*& aMessage);
       
   168     
       
   169     virtual TInt ParseMessageL( CSenSoapMessage& aSOAPMessage );
       
   170 
       
   171 
       
   172     //aConsumer is not used, becouse session holds many consumers, and first has to establish correct one
       
   173     virtual TInt SendSoapMessageToConsumerL( CSenSoapMessage* apMessage, 
       
   174                                              const TInt aTxnId,
       
   175                                              MSenRemoteServiceConsumer& aConsumer,
       
   176                                              MSenProperties* aResponseTransportProperties );
       
   177     
       
   178 
       
   179     virtual TInt SetTransportPropertiesL( const TDesC8& aProperties,
       
   180                                           MSenRemoteServiceConsumer& aConsumer );
       
   181 
       
   182     //in WS* and SCHarF methiod disabled.
       
   183     //virtual void SetFrameworkHeadersL(CSenSoapMessage& aMsg);
       
   184     
       
   185     
       
   186     virtual TInt HandleSoapFaultL( CSenSoapMessage* apSOAPMessage,
       
   187                                    HBufC8*& aResponse);
       
   188 
       
   189     virtual TInt HandleSoapFaultL( CSenSoapMessage* apSOAPMessage,
       
   190                                    const TInt aErrorCode,
       
   191                                    const TInt aTxnId,
       
   192                                    MSenRemoteServiceConsumer& aConsumer,
       
   193                                    MSenProperties* aTransportProperties );
       
   194 
       
   195     virtual TBool IsExpiredL();
       
   196     /**
       
   197      * Clear credential for current session , make it invalid.
       
   198      * @since S60 5.0
       
   199      */
       
   200     void ClearCredentialL();
       
   201     
       
   202     
       
   203     /**
       
   204      * Share token. Copy SCT and MT into new star session
       
   205      * @since S60 5.0
       
   206      */
       
   207     TInt ShareTokenWithL(CWSStarServiceSession* aWSStarSessionDst, TBool& aMTwasReplaceBySCT, TBool aSeekSCT);
       
   208     
       
   209     
       
   210     /**
       
   211      * Getter of Provider ID (STS which represents this session)
       
   212      *
       
   213      * @return TDesC8 id of provider
       
   214      * @since S60 5.0
       
   215      */
       
   216     
       
   217     /**
       
   218     * Overload addcredential from WebServiceSession. Calucate also state, 
       
   219     * @since S60 5.0
       
   220     */
       
   221     void AddCredentialL(const TDesC8& aSecurity, TTime aValidUntil);
       
   222     void AddCredentialL(RSenCredentialPtr aCredentialPtr, TTime aValidUntil);
       
   223     TPtrC8 ProviderID();
       
   224     void SetTrustAnchorL(const TDesC8& aURI);
       
   225     TPtrC8 TrustAnchor();
       
   226     TInt ComputeStatusL();
       
   227     void SetSessionContext(CWSStarSessionContext* aContext);
       
   228     CWSStarSessionContext* SessionContext();
       
   229     TInt UpdatePolicyL(CWSStarPolicyHandler* aPolicyHandler, MSenServiceDescription* aSD);
       
   230     
       
   231     void AddSecurityTokenToContextL();
       
   232 
       
   233     void AddPropertiesFromSessionContextToCredentialL();
       
   234     
       
   235     virtual void CredentialChanged(TSenCredentialChange aChange, TAny* aPointer);
       
   236     void ActiveTicketObserverL();
       
   237     //virtual TInt RefreshMTL(HBufC8*& aErrorMessage);
       
   238     TInt RevalidateMobileTicketIfExpiredL(HBufC8*& aErrorMessage);
       
   239     TBool ExistConsumerL();
       
   240 
       
   241     // Add ProviderID to primary keys (in addition to Endpoint, Contract and FrameworkID):
       
   242     TBool HasEqualPrimaryKeysL( MSenServiceDescription& aCandidate ); 
       
   243 
       
   244 	/**
       
   245 	 * DetachCredentialL
       
   246 	 *
       
   247 	 * This function  invalidates the session by deleting the credential
       
   248 	 * This also call setStatusL to recompute the status
       
   249 	 */
       
   250 	void DetachCredentialsL() ;	
       
   251 	TBool AmIHostletSession();
       
   252 
       
   253 private: 
       
   254        
       
   255     /**
       
   256     * C++ default constructor.
       
   257     */
       
   258     CWSStarServiceSession(TDescriptionClassType aType, MSIF& aFramework);
       
   259 
       
   260     /**
       
   261     * By default Symbian 2nd phase constructor is private.
       
   262     */
       
   263     void ConstructL();
       
   264     
       
   265     // New functions
       
   266     
       
   267     
       
   268     /**
       
   269     * To obtain consumer during processing INBOUND. We have to dispatch using wsa:RelatesTo
       
   270     */
       
   271     TInt SessionConsumerL(CWSStarMessageContext*& aMessage,
       
   272                           CWSStarSessionConsumer*& aSessionConsumer);
       
   273     
       
   274     /**
       
   275     * To obtain consumer during processing OUTBOUND.
       
   276     */
       
   277     TInt SessionConsumerL( const TDesC8& aSenderID, CWSStarSessionConsumer*& aSessionConsumer);
       
   278     TInt CanHandleErrorL();
       
   279     void CreateAndParseSoapMessageL(const TDesC8& aSoapMessage, CSenSoapMessage*& aMessage, HBufC8*& aBody);
       
   280     HBufC8* ApplyTransportPropertiesL(const TDesC8& aTransportProperties);
       
   281     void PrepareOutCtxL(const TDesC8& aTransportProperties);
       
   282     TBool HasSuperClass( TDescriptionClassType aType );
       
   283    // TBool AmIHostletSession();
       
   284     void FindAndShareSCTL();
       
   285     
       
   286     
       
   287     
       
   288     
       
   289     void ParseToSoapMessage2L( const TDesC8& aSoapMessage, MSenRemoteServiceConsumer& aConsumer, TInt& aTxnId );
       
   290     
       
   291     TInt ListBinaryElementsL( RArray<TXmlEngElement>& aElementArray, TXmlEngElement& aElement );
       
   292     
       
   293     virtual void FillCredentialIdentifierL(CSenCredentialIdentifier& aIdentifier);
       
   294     
       
   295     CSenIdentityProvider* LookupIdentityProviderL();
       
   296     void VerifyPermissionL();
       
   297     void ClearCredentialPropertiesFromContext();
       
   298     // Add ProviderID to primary keys (in addition to Endpoint, Contract and FrameworkID):
       
   299     //TBool HasEqualPrimaryKeysL( MSenServiceDescription& aCandidate ); 
       
   300 
       
   301 		void ReattachCredentialsL() ;
       
   302     
       
   303 private: // Data
       
   304     
       
   305     CWSStarMessageContext* iOutContext;//owned, live only within one sending
       
   306     CWSStarMessageContext* iInContext;//owned, live only within one sending
       
   307     
       
   308     CWSStarSessionContext* iSessionContext;//owned
       
   309     
       
   310     
       
   311     
       
   312     //trust anchor is a pointer to providerID.
       
   313     //ProviderId identify SD which represent STS, and in order to distinguis who validate whom;
       
   314     //  STS has providerID which is pointed by trustAnchor in validatet WebService
       
   315     //  Unfortuantely webService inherits same classes as STS (it is still XmlSD) so webservice has both TrustAnchor 
       
   316     //  and ProviderId which are equal
       
   317     HBufC8* iTrustAnchor;
       
   318     
       
   319     //to keep transaction chain
       
   320     HBufC8* ipReceivedMessageIdInTrans;//owned
       
   321     
       
   322     TBool  iMessageThread;
       
   323     TInt iSubmitState;
       
   324     TInt iRetryCounter;
       
   325     TInt iRenewCounter;
       
   326     TInt iRedirectCounter;
       
   327     HBufC8* iProviderID;
       
   328     HBufC8* iTransProp;
       
   329     TTime iClientTime; 
       
   330     TTime iServerTime;
       
   331     CWSStarCredentialObserver* iTicketObs;
       
   332     };
       
   333     
       
   334 #endif // WSSTAR_SERVICE_SESSION_H
       
   335 
       
   336 // End of File
       
   337