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