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