realtimenetprots/sipfw/SIP/SIPSec/DigestPlugin/inc/sipsecdigestcontext.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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:
       
    15 * Name          : sipsecdigestcontext.h
       
    16 * Part of       : SIPSec/DigestPlugin
       
    17 * Version       : SIP/6.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef __SIPSEC_DIGESTCONTEXT_H__
       
    29 #define __SIPSEC_DIGESTCONTEXT_H__
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32std.h>
       
    33 #include "sipsecplugincontext.h"
       
    34 #include "sipsecrequestdata.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CSIPSecCredentials;
       
    38 class CSIPSecDigest;
       
    39 class CSIPAuthHeaderBase;
       
    40 class CSIPSecRequestData;
       
    41 class TSIPSecPluginContext;
       
    42 class TSIPSecPluginCtxResponse;
       
    43 class TSIPSecPluginCtxVerify;
       
    44 class CSIPSecUserRecord;
       
    45 
       
    46 
       
    47 /**
       
    48  * @brief Class is base class for digest context
       
    49  * 
       
    50  * @class TSIPSecDigestContext sipsecdigestcontext.h "sipsecdigestcontext.h"
       
    51  *
       
    52  * Class provides common digest context and plugin context
       
    53  */
       
    54 class TSIPSecDigestContext
       
    55 	{
       
    56 public: // Constructor and destructor
       
    57 
       
    58 	/**
       
    59     * constructor
       
    60 	* @param aCredentials credentials
       
    61 	* @param aParent parent context, if any
       
    62     */
       
    63 	TSIPSecDigestContext( CSIPSecCredentials& aCredentials, 
       
    64 	                      TSIPSecPluginContext* aParent = NULL );
       
    65 	
       
    66 	/**
       
    67     * Destructor
       
    68     */
       
    69     inline virtual ~TSIPSecDigestContext() 
       
    70         {
       
    71         }
       
    72     
       
    73 public: // Digest related methods
       
    74 
       
    75     /**
       
    76     * returns mechanism
       
    77     * @return mechanism
       
    78     */
       
    79     CSIPSecDigest& Mechanism() const;
       
    80 
       
    81     /**
       
    82     * returns parent context
       
    83 	* @return parent context
       
    84     */
       
    85     TSIPSecPluginContext& Parent();
       
    86 
       
    87     /**
       
    88     * returns user data
       
    89 	* @return user data
       
    90     */
       
    91 	CSIPSecUserRecord& UserData();
       
    92 
       
    93     /**
       
    94     * Sets user data
       
    95 	* @return user data
       
    96     */
       
    97 	void SetUserData( CSIPSecUserRecord& aUserData );
       
    98 
       
    99 public: // General parameter methods
       
   100 
       
   101     /**
       
   102     * Gets any parameter
       
   103     * @param aHeader SIP header
       
   104     * @param aParam Parameter
       
   105     * @return parameter value
       
   106     */
       
   107     static const TDesC8& GetParam( const CSIPAuthHeaderBase& aHeader,
       
   108     							   TInt aParam );
       
   109 
       
   110 	/**
       
   111     * Gets a parameter that is accessed using DesParamValue
       
   112     * @param aHeader SIP header
       
   113     * @param aParam Parameter
       
   114     * @return parameter value
       
   115     */
       
   116     static const TDesC8& GetDesParam( const CSIPAuthHeaderBase& aHeader,
       
   117     								  TInt aParam );
       
   118 
       
   119     /**
       
   120     * Sets any parameter
       
   121     * @param aHeader SIP header
       
   122     * @param aParam Parameter
       
   123     * @param aValue Parameter's value
       
   124     */
       
   125     static void SetParamValueL( CSIPAuthHeaderBase& aHeader,
       
   126     							TInt aParam,
       
   127     							const TDesC8& aValue );
       
   128 
       
   129 	/**
       
   130     * Sets a parameter that is accessed using SetDesParamL.
       
   131     * @param aHeader SIP header
       
   132     * @param aParam Parameter
       
   133     * @param aValue Parameter's value
       
   134     */
       
   135 	static void SetDesParamValueL( CSIPAuthHeaderBase& aHeader,
       
   136 							   	   TInt aParam,
       
   137 							       const TDesC8& aValue );
       
   138 
       
   139     /**
       
   140     * Gets any parameter
       
   141     * @param aParam Parameter
       
   142     * @return Parameter's value
       
   143     */
       
   144     const TDesC8& GetParam( TInt aParam ) const;
       
   145 
       
   146 	/**
       
   147     * Gets a parameter that is accessed using DesParamValue
       
   148     * @param aParam Parameter
       
   149     * @return Parameter's value
       
   150     */
       
   151     const TDesC8& GetDesParam( TInt aParam ) const;
       
   152 
       
   153     /**
       
   154     * Sets any parameter
       
   155     * @param aParam Parameter
       
   156     * @param aValue Parameter's value
       
   157     */
       
   158     void SetParamValueL( TInt aParam, const TDesC8& aValue );
       
   159 
       
   160 	/**
       
   161     * Sets a parameter that is accessed using SetDesParamL.
       
   162     * @param aParam Parameter
       
   163     * @param aValue Parameter's value
       
   164     */
       
   165     void SetDesParamValueL( TInt aParam, const TDesC8& aValue );
       
   166 
       
   167 	/**
       
   168     * Sets a parameter to have empty value in quotes (e.g. response="").
       
   169     * @param aParam Parameter    
       
   170     */
       
   171 	void SetParamWithEmptyValueL( TInt aParam );
       
   172 
       
   173 public: // Credentials parameters
       
   174 
       
   175     /**
       
   176     * Returns nonce
       
   177 	* @return Nonce value
       
   178     */
       
   179 	const TDesC8& Nonce() const;
       
   180 
       
   181     /**
       
   182     * Returns nonce count
       
   183 	* @return Nonce count value
       
   184     */
       
   185 	const TDesC8& NonceCount() const;
       
   186 
       
   187 	/**
       
   188     * Returns cnonce
       
   189 	* @return Cnonce value
       
   190     */
       
   191 	const TDesC8& CNonce() const;
       
   192 
       
   193     /**
       
   194     * Returns Request-URI
       
   195     * @return Request-URI value
       
   196     */
       
   197     virtual const TDesC8& DigestURI() const;
       
   198 
       
   199 protected: // Data
       
   200 
       
   201     // Credentials
       
   202     CSIPSecCredentials& iCredentials;
       
   203 
       
   204     // Parent context, not owned
       
   205 	TSIPSecPluginContext* iParent;
       
   206 	};
       
   207 
       
   208 
       
   209 
       
   210 /**
       
   211  * @brief Class is for 'setuping' digest 
       
   212  * 
       
   213  * @class TSIPSecDigestCtxSetup sipsecdigestcontext.h "sipsecdigestcontext.h"
       
   214  *
       
   215  */
       
   216 class TSIPSecDigestCtxSetup : public TSIPSecDigestContext
       
   217 	{	
       
   218 public: // Constructor
       
   219 
       
   220 	/**
       
   221     * Constructor
       
   222 	* @param aCredentials Credentials
       
   223 	* @param aTransactionId Transaction id
       
   224 	* @param aParent Parent context, ownership is not transferred
       
   225     */
       
   226 	TSIPSecDigestCtxSetup( CSIPSecCredentials& aCredentials,
       
   227 						   TTransactionId aTransactionId,
       
   228 	                       TSIPSecPluginCtxResponse* aParent = NULL );
       
   229 
       
   230 public: // New functions
       
   231 
       
   232     /**
       
   233     * Requests user credentials
       
   234     * @return ETrue If the credentials for the challenge(s) present in the
       
   235     *		  current SIP response, must be asked now.
       
   236     *		  EFalse If there is no need to ask the credentials. Maybe they are
       
   237     * 	      already being asked for due to some earlier SIP response.
       
   238     */
       
   239     TBool RequestUserCredentialsL();
       
   240 
       
   241     /**
       
   242     * Sets cnonce
       
   243 	* @param aCnonce Cnonce
       
   244     */
       
   245 	void SetCNonceL( const TDesC8& aCnonce );
       
   246 
       
   247 	/**
       
   248     * Get transaction id.
       
   249 	* @return Transaction id
       
   250     */
       
   251 	TTransactionId TransactionId() const;
       
   252 
       
   253 private: // Data
       
   254 
       
   255 	TTransactionId iTransactionId;
       
   256 	};
       
   257 
       
   258 
       
   259 
       
   260 
       
   261 /**
       
   262  * @brief Class is for processing digest 
       
   263  * 
       
   264  * @class TSIPSecDigestCtxProcess sipsecdigestcontext.h "sipsecdigestcontext.h"
       
   265  *
       
   266  */
       
   267 class TSIPSecDigestCtxProcess : public TSIPSecDigestContext
       
   268 	{
       
   269 public: // Constructor
       
   270 
       
   271 	/**
       
   272     * constructor
       
   273 	* @param aCredentials credentials
       
   274 	* @param aParent parent context
       
   275     */
       
   276     TSIPSecDigestCtxProcess( CSIPSecCredentials& aCredentials, 
       
   277 	                         TSIPSecPluginContext* aParent = NULL );
       
   278 	
       
   279 public: // Digest related methods
       
   280 
       
   281     /**
       
   282     * Returns request data
       
   283     * @param aQop QOP value
       
   284     * @return aRequestData Request data, ownership is transferred
       
   285     */
       
   286     virtual CSIPSecRequestData* RequestDataL( CSIPSecRequestData::TQop aQop );
       
   287     
       
   288     /**
       
   289     * Sets response parameter
       
   290     * @param aResponse Response
       
   291     */
       
   292     virtual void SetResponseL( const TDesC8& aResponse );
       
   293 
       
   294     /**
       
   295     * Returns method
       
   296     * @return Method
       
   297     */
       
   298     virtual const TDesC8& Method();
       
   299 
       
   300     /**
       
   301     * Returns SIP message
       
   302     * @return SIP message
       
   303     */
       
   304     virtual const TDesC8& Message();
       
   305     };
       
   306 
       
   307 
       
   308 
       
   309 
       
   310 /**
       
   311  * @brief Class is for handling digest verify
       
   312  * 
       
   313  * @class TSIPSecDigestVerifyContext sipsecdigestcontext.h
       
   314  *		  "sipsecdigestcontext.h"
       
   315  */
       
   316 class TSIPSecDigestVerifyContext : public TSIPSecDigestCtxProcess
       
   317 	{
       
   318 public: // Constructor
       
   319 
       
   320 	/**
       
   321     * Constructor
       
   322 	* @param aCredentials Credentials
       
   323 	* @param aUri Request-URI
       
   324 	* @param aParent Parent context, ownership is not transferred
       
   325     */
       
   326 	TSIPSecDigestVerifyContext( CSIPSecCredentials& aCredentials,
       
   327 	                            const TDesC8& aUri, 
       
   328 	                            TSIPSecPluginCtxVerify* aParent );
       
   329 
       
   330 public: // From TSIPSecDigestContext
       
   331     
       
   332     const TDesC8& DigestURI() const;
       
   333 
       
   334 public: // From TSIPSecDigestCtxProcess
       
   335 
       
   336     CSIPSecRequestData* RequestDataL( CSIPSecRequestData::TQop aQop );
       
   337 	
       
   338     void SetResponseL( const TDesC8& aResponse );
       
   339     
       
   340 public: // New functions
       
   341 
       
   342     /**
       
   343     * Returns SIP combined security server header
       
   344     * @return SIP combined security server header
       
   345     */
       
   346     HBufC8* SecurityServerHeaderL();
       
   347 
       
   348 public: // Data
       
   349 
       
   350     // URI
       
   351     const TDesC8& iUri;
       
   352     };
       
   353 
       
   354 
       
   355 
       
   356 /**
       
   357  * @brief Class is for handling authentication info
       
   358  * 
       
   359  * @class TSIPSecDigestAuthInfoContext sipsecdigestcontext.h
       
   360  *		  "sipsecdigestcontext.h"
       
   361  */
       
   362 class TSIPSecDigestAuthInfoContext : public TSIPSecDigestCtxProcess
       
   363 	{
       
   364 	
       
   365 public:// Constructor
       
   366 
       
   367 	/**
       
   368     * Constructor
       
   369 	* @param aCredentials Credentials
       
   370 	* @param aResponse Response place holder
       
   371 	* @param aParent Parent context, ownership is not transferred
       
   372 	*/
       
   373 	TSIPSecDigestAuthInfoContext( CSIPSecCredentials& aCredentials,
       
   374 	                              TDes8& aResponse,
       
   375 	                              TSIPSecPluginCtxResponse* aParent );
       
   376 
       
   377 public: // From TSIPSecDigestCtxProcess
       
   378     
       
   379     void SetResponseL( const TDesC8& aResponse );
       
   380 
       
   381     const TDesC8& Method();
       
   382     
       
   383     const TDesC8& Message();
       
   384 
       
   385 public: // Data
       
   386 
       
   387     // Response    
       
   388     TDes8& iResponse;
       
   389     };
       
   390 
       
   391 #endif //end of __SIPSEC_DIGESTCONTEXT_H__
       
   392 
       
   393 // End of File