epoc32/include/mw/siphttpdigest.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/siphttpdigest.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:
williamr@2
    15
* Name        : siphttpdigest.h
williamr@2
    16
* Part of     : SIP Client
williamr@2
    17
* Interface   : SDK API, SIP Client API
williamr@2
    18
* Version     : 2.0
williamr@2
    19
*
williamr@2
    20
*/
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
#ifndef CSIPHTTPDIGEST_H
williamr@2
    25
#define CSIPHTTPDIGEST_H
williamr@2
    26
williamr@2
    27
// INCLUDES 
williamr@2
    28
#include <e32base.h>
williamr@2
    29
#include "_sipcodecdefs.h"
williamr@2
    30
williamr@2
    31
// FORWARD DECLARATIONS
williamr@2
    32
class CSIP;
williamr@2
    33
class MSIPHttpDigestChallengeObserver;
williamr@2
    34
class MSIPHttpDigestChallengeObserver2;
williamr@2
    35
class CSIPClientTransaction;
williamr@2
    36
class CSIPRefresh;
williamr@2
    37
williamr@2
    38
// CLASS DECLARATION
williamr@2
    39
williamr@2
    40
/**
williamr@2
    41
* @publishedAll
williamr@2
    42
* @released
williamr@2
    43
*
williamr@2
    44
* Class for managing SIP HTTP Digest security settings.
williamr@2
    45
* Class provides functions for setting/removing
williamr@2
    46
* HTTP Digest security mechanism related parameters.
williamr@2
    47
* If the user does not use the class for the providing credentials for the
williamr@2
    48
* received challenges, an error will be returned to the original request in
williamr@2
    49
* case it was challenged.
williamr@2
    50
* 
williamr@2
    51
* Note that the user will be asked to provide credentials one realm
williamr@2
    52
* at the time.
williamr@2
    53
*
williamr@2
    54
*  @lib sipclient.lib
williamr@2
    55
*/
williamr@2
    56
class CSIPHttpDigest : public CBase
williamr@2
    57
	{
williamr@2
    58
	public: // Constructors and destructor
williamr@2
    59
	
williamr@2
    60
		/**
williamr@2
    61
		* Two-phased constructor.
williamr@2
    62
		* @param aSIP a handle to SIP server
williamr@2
    63
		* @param aObserver an observer for the received challenges
williamr@2
    64
		* @return New object, ownership is transferred.
williamr@2
    65
		*/
williamr@2
    66
		IMPORT_C static CSIPHttpDigest*
williamr@2
    67
			NewL(CSIP& aSIP,
williamr@2
    68
				 MSIPHttpDigestChallengeObserver& aObserver);
williamr@2
    69
				 
williamr@2
    70
		/**
williamr@2
    71
		* Two-phased constructor.
williamr@2
    72
		* @param aSIP a handle to SIP server
williamr@2
    73
		* @param aObserver an observer for the received challenges
williamr@2
    74
		* @return New object, ownership is transferred.
williamr@2
    75
		*/
williamr@2
    76
		IMPORT_C static CSIPHttpDigest*
williamr@2
    77
			NewLC(CSIP& aSIP,
williamr@2
    78
				  MSIPHttpDigestChallengeObserver& aObserver);
williamr@2
    79
williamr@2
    80
		/**
williamr@2
    81
		* Two-phased constructor.
williamr@2
    82
		* @param aSIP a handle to SIP server
williamr@2
    83
		* @param aObserver2 an observer for the received challenges
williamr@2
    84
		* @return New object, ownership is transferred.
williamr@2
    85
		*/
williamr@2
    86
		IMPORT_C static CSIPHttpDigest*
williamr@2
    87
			NewL(CSIP& aSIP,
williamr@2
    88
				 MSIPHttpDigestChallengeObserver2& aObserver2);
williamr@2
    89
				 
williamr@2
    90
		/**
williamr@2
    91
		* Two-phased constructor.
williamr@2
    92
		* @param aSIP a handle to SIP server
williamr@2
    93
		* @param aObserver2 an observer for the received challenges
williamr@2
    94
		* @return New object, ownership is transferred.
williamr@2
    95
		*/
williamr@2
    96
		IMPORT_C static CSIPHttpDigest*
williamr@2
    97
			NewLC(CSIP& aSIP,
williamr@2
    98
				  MSIPHttpDigestChallengeObserver2& aObserver2);
williamr@2
    99
				  
williamr@2
   100
		IMPORT_C ~CSIPHttpDigest();
williamr@2
   101
williamr@2
   102
	public: // New functions
williamr@2
   103
williamr@2
   104
        /**
williamr@2
   105
		* Sets credentials for the realm of the outbound proxy.
williamr@2
   106
		* Must be used in case the realm is the realm of the outbound proxy and
williamr@2
   107
		* the request for credentials was received from callback
williamr@2
   108
		* MSIPHttpDigestChallengeObserver::ChallengeReceived.		
williamr@2
   109
		* The user can set credentials only upon request from the
williamr@2
   110
		* SIP implementation.
williamr@2
   111
		* @pre aOutboundProxy, aRealm, aUsername and aPasswd must not be empty
williamr@2
   112
		*	   descriptors.
williamr@2
   113
		* @param aOutboundProxy an outbound proxy (FQDN or IP address)
williamr@2
   114
		* @param aRealm servers's realm
williamr@2
   115
		* @param aUsername user's name
williamr@2
   116
		* @param aPasswd user's password for the given server's realm
williamr@2
   117
		* @leave KErrNoMemory if out of memory
williamr@2
   118
		* @leave KErrArgument if some of the parameters is an empty descriptor
williamr@2
   119
		* @leave KErrSIPResourceNotAvailable if a required object has been
williamr@2
   120
		*		 deleted
williamr@2
   121
		*/
williamr@2
   122
		IMPORT_C void SetCredentialsL(const TDesC8& aOutboundProxy,
williamr@2
   123
			                          const TDesC8& aRealm,
williamr@2
   124
			                          const TDesC8& aUsername,
williamr@2
   125
			                          const TDesC8& aPasswd);
williamr@2
   126
        /**
williamr@2
   127
		* Sets parameters for the realm.
williamr@2
   128
		* Should be used in case the realm is not a realm of an outbound proxy 
williamr@2
   129
		* and the request for credentials was received from callback
williamr@2
   130
		* MSIPHttpDigestChallengeObserver::ChallengeReceived.		
williamr@2
   131
		* The user can set credentials only upon request from the
williamr@2
   132
		* SIP implementation.
williamr@2
   133
		* @pre aRealm, aUsername and aPasswd must not be empty descriptors.
williamr@2
   134
		* @param aRealm servers's realm
williamr@2
   135
		* @param aUsername user's name
williamr@2
   136
		* @param aPasswd user's password for the given server's realm
williamr@2
   137
		* @leave KErrNoMemory if out of memory
williamr@2
   138
		* @leave KErrArgument if some of the parameters is an empty descriptor
williamr@2
   139
		* @leave KErrSIPResourceNotAvailable if a required object has been
williamr@2
   140
		*		 deleted
williamr@2
   141
		*/
williamr@2
   142
		IMPORT_C void SetCredentialsL(const TDesC8& aRealm,
williamr@2
   143
			                          const TDesC8& aUsername,
williamr@2
   144
			                          const TDesC8& aPasswd);
williamr@2
   145
williamr@2
   146
        /**
williamr@2
   147
		* Sets credentials for the realm for the specific transaction.
williamr@2
   148
		* Must be used when the request for credentials was received 
williamr@2
   149
		* from callback MSIPHttpDigestChallengeObserver2::ChallengeReceived with 
williamr@2
   150
		* CSIPClientTransaction as the parameter.
williamr@2
   151
		* @pre aRealm, aUsername and aPasswd must not be empty descriptors.
williamr@2
   152
		* @param aTransaction the transaction that was passed as a parameter
williamr@2
   153
		*        to MSIPHttpDigestChallengeObserver2::ChallengeReceived
williamr@2
   154
		* @param aOutboundProxy an outbound proxy (FQDN or IP address) if
williamr@2
   155
		*        the challenge received had Proxy-Authenticate-header(s).
williamr@2
   156
		*        Otherwise KNullDesC8 should passed.
williamr@2
   157
		* @param aRealm servers's realm
williamr@2
   158
		* @param aUsername user's name
williamr@2
   159
		* @param aPasswd user's password for the given server's realm
williamr@2
   160
		* @leave KErrNoMemory if out of memory
williamr@2
   161
		* @leave KErrArgument if some of the parameters is an empty descriptor
williamr@2
   162
		* @leave KErrSIPResourceNotAvailable if a required object has been
williamr@2
   163
		*		 deleted
williamr@2
   164
		*/
williamr@2
   165
		IMPORT_C void SetCredentialsL(const CSIPClientTransaction& aTransaction,
williamr@2
   166
		                              const TDesC8& aOutboundProxy,
williamr@2
   167
			                          const TDesC8& aRealm,
williamr@2
   168
			                          const TDesC8& aUsername,
williamr@2
   169
			                          const TDesC8& aPasswd);
williamr@2
   170
williamr@2
   171
        /**
williamr@2
   172
		* Sets credentials for the realm for the specific refresh.
williamr@2
   173
		* Must be used when the request for credentials was received 
williamr@2
   174
		* from callback MSIPHttpDigestChallengeObserver2::ChallengeReceived with 
williamr@2
   175
		* CSIPRefresh as the parameter.
williamr@2
   176
		* @pre aRealm, aUsername and aPasswd must not be empty descriptors.
williamr@2
   177
		* @param aRefresh the refresh that was passed as a parameter
williamr@2
   178
		*        to MSIPHttpDigestChallengeObserver2::ChallengeReceived
williamr@2
   179
		* @param aOutboundProxy an outbound proxy (FQDN or IP address) if
williamr@2
   180
		*        the challenge received had Proxy-Authenticate-header(s).
williamr@2
   181
		*        Otherwise KNullDesC8 should passed.
williamr@2
   182
		* @param aRealm servers's realm
williamr@2
   183
		* @param aUsername user's name
williamr@2
   184
		* @param aPasswd user's password for the given server's realm
williamr@2
   185
		* @leave KErrNoMemory if out of memory
williamr@2
   186
		* @leave KErrArgument if some of the parameters is an empty descriptor
williamr@2
   187
		* @leave KErrSIPResourceNotAvailable if a required object has been
williamr@2
   188
		*		 deleted
williamr@2
   189
		*/
williamr@2
   190
		IMPORT_C void SetCredentialsL(const CSIPRefresh& aRefresh,
williamr@2
   191
		                              const TDesC8& aOutboundProxy,
williamr@2
   192
			                          const TDesC8& aRealm,
williamr@2
   193
			                          const TDesC8& aUsername,
williamr@2
   194
			                          const TDesC8& aPasswd);
williamr@2
   195
			            
williamr@2
   196
        /**
williamr@2
   197
		* Removes all set credentials for the realm.
williamr@2
   198
		* Must not be used if the user implements 
williamr@2
   199
		* MSIPHttpDigestChallengeObserver2.
williamr@2
   200
		* @pre aRealm must not be an empty descriptor
williamr@2
   201
		* @param aRealm servers's realm
williamr@2
   202
		* @return KErrNone if no error
williamr@2
   203
		*		  KErrArgument if aRealm is an empty descriptor
williamr@2
   204
		*		  KErrNoMemory if out of memory
williamr@2
   205
		*		  KErrNotFound if the given realm was not found
williamr@2
   206
        */
williamr@2
   207
		IMPORT_C TInt RemoveCredentials(const TDesC8& aRealm);
williamr@2
   208
		
williamr@2
   209
        /**
williamr@2
   210
		* Removes all set credentials by the user.
williamr@2
   211
		* Must not be used if the user implements 
williamr@2
   212
		* MSIPHttpDigestChallengeObserver2.		
williamr@2
   213
		* @return KErrNone if succesful; KErrNoMemory if out of memory 
williamr@2
   214
        */
williamr@2
   215
		IMPORT_C TInt RemoveCredentials();
williamr@2
   216
					                                                        
williamr@2
   217
		/**
williamr@2
   218
		* Sets the observer	to listen for the possible received challenges. 
williamr@2
   219
		* Replaces the existing MSIPHttpDigestChallengeObserver or
williamr@2
   220
		* MSIPHttpDigestChallengeObserver2.
williamr@2
   221
		* @param aObserver an observer for the received challenges. 
williamr@2
   222
		*/
williamr@2
   223
		IMPORT_C void SetObserver(MSIPHttpDigestChallengeObserver& aObserver);
williamr@2
   224
		
williamr@2
   225
		/**
williamr@2
   226
		* Sets the observer	to listen for the possible received challenges. 
williamr@2
   227
		* Replaces the existing MSIPHttpDigestChallengeObserver or
williamr@2
   228
		* MSIPHttpDigestChallengeObserver2.
williamr@2
   229
		* @param aObserver an observer for the received challenges. 
williamr@2
   230
		*/
williamr@2
   231
		IMPORT_C void SetObserver(MSIPHttpDigestChallengeObserver2& aObserver);		
williamr@2
   232
		
williamr@2
   233
		/**
williamr@2
   234
		* Ignores the challenge for the realm. As a result the error will be
williamr@2
   235
		* generated to the original SIP request. 
williamr@2
   236
		* @pre aRealm must not be an empty descriptor
williamr@2
   237
		* @param aRealm a realm for which the challenge was ignored
williamr@2
   238
		* @return KErrNone if no error
williamr@2
   239
		*		  KErrNotFound if the given realm was not found
williamr@2
   240
		*		  KErrArgument if aRealm is an empty descriptor
williamr@2
   241
		*/
williamr@2
   242
		IMPORT_C TInt IgnoreChallenge(const TDesC8& aRealm);
williamr@2
   243
williamr@2
   244
		/**
williamr@2
   245
		* Ignores the challenge for the realm for the specific transaction.
williamr@2
   246
		* As a result KErrForbidden will be generated 
williamr@2
   247
		* to the original SIP request.
williamr@2
   248
		* @pre aRealm must not be an empty descriptor
williamr@2
   249
		* @param aTransaction the transaction that was passed as a parameter
williamr@2
   250
		*        to MSIPHttpDigestChallengeObserver2::ChallengeReceived		
williamr@2
   251
		* @param aRealm a realm for which the challenge was ignored
williamr@2
   252
		* @return KErrNone if no error
williamr@2
   253
		*		  KErrNotFound if the given realm was not found
williamr@2
   254
		*		  KErrArgument if aRealm is an empty descriptor
williamr@2
   255
		*/
williamr@2
   256
		IMPORT_C TInt IgnoreChallenge(const CSIPClientTransaction& aTransaction,
williamr@2
   257
		                              const TDesC8& aRealm);
williamr@2
   258
williamr@2
   259
		/**
williamr@2
   260
		* Ignores the challenge for the realm for the specific refresh.
williamr@2
   261
		* As a result the error will be generated 
williamr@2
   262
		* to the original SIP request.
williamr@2
   263
		* @pre aRealm must not be an empty descriptor
williamr@2
   264
		* @param aRefresh the refresh that was passed as a parameter
williamr@2
   265
		*        to MSIPHttpDigestChallengeObserver2::ChallengeReceived		
williamr@2
   266
		* @param aRealm a realm for which the challenge was ignored
williamr@2
   267
		* @return KErrNone if no error
williamr@2
   268
		*		  KErrNotFound if the given realm was not found
williamr@2
   269
		*		  KErrArgument if aRealm is an empty descriptor
williamr@2
   270
		*/
williamr@2
   271
		IMPORT_C TInt IgnoreChallenge(const CSIPRefresh& aRefresh,
williamr@2
   272
		                              const TDesC8& aRealm);
williamr@2
   273
williamr@2
   274
	public: // New functions, for internal use
williamr@2
   275
williamr@2
   276
		void CSIPDeleted();
williamr@2
   277
williamr@2
   278
	private: // Constructors
williamr@2
   279
williamr@2
   280
        CSIPHttpDigest(CSIP& aSIP);
williamr@2
   281
		CSIPHttpDigest(const CSIPHttpDigest& aHttpDigest);
williamr@2
   282
		CSIPHttpDigest& operator=(const CSIPHttpDigest& aHttpDigest);
williamr@2
   283
williamr@2
   284
		void ConstructL(MSIPHttpDigestChallengeObserver& aObserver);
williamr@2
   285
		
williamr@2
   286
		void ConstructL(MSIPHttpDigestChallengeObserver2& aObserver2);
williamr@2
   287
       
williamr@2
   288
    private: // New functions
williamr@2
   289
    
williamr@2
   290
		TInt RemoveCredentialParams(const TDesC8& aRealm) const;
williamr@2
   291
williamr@2
   292
		void SetCredentialParamsL(TUint32 aRequestId,
williamr@2
   293
		                          TUint32 aRefreshId,
williamr@2
   294
		                          const TDesC8& aOutboundProxy,
williamr@2
   295
		                          const TDesC8& aRealm,
williamr@2
   296
				                  const TDesC8& aUsername,
williamr@2
   297
				                  const TDesC8& aPasswd) const;		
williamr@2
   298
		
williamr@2
   299
		TInt IgnoreChallenge(TUint32 aRequestId,
williamr@2
   300
		                     TUint32 aRefreshId,
williamr@2
   301
		                     const TDesC8& aRealm);       
williamr@2
   302
          
williamr@2
   303
    private: // Data
williamr@2
   304
williamr@2
   305
        CSIP* iSIP;
williamr@2
   306
williamr@2
   307
	private: // For testing purposes
williamr@2
   308
williamr@2
   309
	    UNIT_TEST(CSIP_Test)
williamr@2
   310
	};
williamr@2
   311
williamr@2
   312
#endif // CSIPHTTPDIGEST_H