williamr@2: /* williamr@2: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Name : siphttpdigest.h williamr@2: * Part of : SIP Client williamr@2: * Interface : SDK API, SIP Client API williamr@2: * Version : 2.0 williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef CSIPHTTPDIGEST_H williamr@2: #define CSIPHTTPDIGEST_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include "_sipcodecdefs.h" williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CSIP; williamr@2: class MSIPHttpDigestChallengeObserver; williamr@2: class MSIPHttpDigestChallengeObserver2; williamr@2: class CSIPClientTransaction; williamr@2: class CSIPRefresh; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: * williamr@2: * Class for managing SIP HTTP Digest security settings. williamr@2: * Class provides functions for setting/removing williamr@2: * HTTP Digest security mechanism related parameters. williamr@2: * If the user does not use the class for the providing credentials for the williamr@2: * received challenges, an error will be returned to the original request in williamr@2: * case it was challenged. williamr@2: * williamr@2: * Note that the user will be asked to provide credentials one realm williamr@2: * at the time. williamr@2: * williamr@2: * @lib sipclient.lib williamr@2: */ williamr@2: class CSIPHttpDigest : public CBase williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * @param aSIP a handle to SIP server williamr@2: * @param aObserver an observer for the received challenges williamr@2: * @return New object, ownership is transferred. williamr@2: */ williamr@2: IMPORT_C static CSIPHttpDigest* williamr@2: NewL(CSIP& aSIP, williamr@2: MSIPHttpDigestChallengeObserver& aObserver); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * @param aSIP a handle to SIP server williamr@2: * @param aObserver an observer for the received challenges williamr@2: * @return New object, ownership is transferred. williamr@2: */ williamr@2: IMPORT_C static CSIPHttpDigest* williamr@2: NewLC(CSIP& aSIP, williamr@2: MSIPHttpDigestChallengeObserver& aObserver); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * @param aSIP a handle to SIP server williamr@2: * @param aObserver2 an observer for the received challenges williamr@2: * @return New object, ownership is transferred. williamr@2: */ williamr@2: IMPORT_C static CSIPHttpDigest* williamr@2: NewL(CSIP& aSIP, williamr@2: MSIPHttpDigestChallengeObserver2& aObserver2); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * @param aSIP a handle to SIP server williamr@2: * @param aObserver2 an observer for the received challenges williamr@2: * @return New object, ownership is transferred. williamr@2: */ williamr@2: IMPORT_C static CSIPHttpDigest* williamr@2: NewLC(CSIP& aSIP, williamr@2: MSIPHttpDigestChallengeObserver2& aObserver2); williamr@2: williamr@2: IMPORT_C ~CSIPHttpDigest(); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Sets credentials for the realm of the outbound proxy. williamr@2: * Must be used in case the realm is the realm of the outbound proxy and williamr@2: * the request for credentials was received from callback williamr@2: * MSIPHttpDigestChallengeObserver::ChallengeReceived. williamr@2: * The user can set credentials only upon request from the williamr@2: * SIP implementation. williamr@2: * @pre aOutboundProxy, aRealm, aUsername and aPasswd must not be empty williamr@2: * descriptors. williamr@2: * @param aOutboundProxy an outbound proxy (FQDN or IP address) williamr@2: * @param aRealm servers's realm williamr@2: * @param aUsername user's name williamr@2: * @param aPasswd user's password for the given server's realm williamr@2: * @leave KErrNoMemory if out of memory williamr@2: * @leave KErrArgument if some of the parameters is an empty descriptor williamr@2: * @leave KErrSIPResourceNotAvailable if a required object has been williamr@2: * deleted williamr@2: */ williamr@2: IMPORT_C void SetCredentialsL(const TDesC8& aOutboundProxy, williamr@2: const TDesC8& aRealm, williamr@2: const TDesC8& aUsername, williamr@2: const TDesC8& aPasswd); williamr@2: /** williamr@2: * Sets parameters for the realm. williamr@2: * Should be used in case the realm is not a realm of an outbound proxy williamr@2: * and the request for credentials was received from callback williamr@2: * MSIPHttpDigestChallengeObserver::ChallengeReceived. williamr@2: * The user can set credentials only upon request from the williamr@2: * SIP implementation. williamr@2: * @pre aRealm, aUsername and aPasswd must not be empty descriptors. williamr@2: * @param aRealm servers's realm williamr@2: * @param aUsername user's name williamr@2: * @param aPasswd user's password for the given server's realm williamr@2: * @leave KErrNoMemory if out of memory williamr@2: * @leave KErrArgument if some of the parameters is an empty descriptor williamr@2: * @leave KErrSIPResourceNotAvailable if a required object has been williamr@2: * deleted williamr@2: */ williamr@2: IMPORT_C void SetCredentialsL(const TDesC8& aRealm, williamr@2: const TDesC8& aUsername, williamr@2: const TDesC8& aPasswd); williamr@2: williamr@2: /** williamr@2: * Sets credentials for the realm for the specific transaction. williamr@2: * Must be used when the request for credentials was received williamr@2: * from callback MSIPHttpDigestChallengeObserver2::ChallengeReceived with williamr@2: * CSIPClientTransaction as the parameter. williamr@2: * @pre aRealm, aUsername and aPasswd must not be empty descriptors. williamr@2: * @param aTransaction the transaction that was passed as a parameter williamr@2: * to MSIPHttpDigestChallengeObserver2::ChallengeReceived williamr@2: * @param aOutboundProxy an outbound proxy (FQDN or IP address) if williamr@2: * the challenge received had Proxy-Authenticate-header(s). williamr@2: * Otherwise KNullDesC8 should passed. williamr@2: * @param aRealm servers's realm williamr@2: * @param aUsername user's name williamr@2: * @param aPasswd user's password for the given server's realm williamr@2: * @leave KErrNoMemory if out of memory williamr@2: * @leave KErrArgument if some of the parameters is an empty descriptor williamr@2: * @leave KErrSIPResourceNotAvailable if a required object has been williamr@2: * deleted williamr@2: */ williamr@2: IMPORT_C void SetCredentialsL(const CSIPClientTransaction& aTransaction, williamr@2: const TDesC8& aOutboundProxy, williamr@2: const TDesC8& aRealm, williamr@2: const TDesC8& aUsername, williamr@2: const TDesC8& aPasswd); williamr@2: williamr@2: /** williamr@2: * Sets credentials for the realm for the specific refresh. williamr@2: * Must be used when the request for credentials was received williamr@2: * from callback MSIPHttpDigestChallengeObserver2::ChallengeReceived with williamr@2: * CSIPRefresh as the parameter. williamr@2: * @pre aRealm, aUsername and aPasswd must not be empty descriptors. williamr@2: * @param aRefresh the refresh that was passed as a parameter williamr@2: * to MSIPHttpDigestChallengeObserver2::ChallengeReceived williamr@2: * @param aOutboundProxy an outbound proxy (FQDN or IP address) if williamr@2: * the challenge received had Proxy-Authenticate-header(s). williamr@2: * Otherwise KNullDesC8 should passed. williamr@2: * @param aRealm servers's realm williamr@2: * @param aUsername user's name williamr@2: * @param aPasswd user's password for the given server's realm williamr@2: * @leave KErrNoMemory if out of memory williamr@2: * @leave KErrArgument if some of the parameters is an empty descriptor williamr@2: * @leave KErrSIPResourceNotAvailable if a required object has been williamr@2: * deleted williamr@2: */ williamr@2: IMPORT_C void SetCredentialsL(const CSIPRefresh& aRefresh, williamr@2: const TDesC8& aOutboundProxy, williamr@2: const TDesC8& aRealm, williamr@2: const TDesC8& aUsername, williamr@2: const TDesC8& aPasswd); williamr@2: williamr@2: /** williamr@2: * Removes all set credentials for the realm. williamr@2: * Must not be used if the user implements williamr@2: * MSIPHttpDigestChallengeObserver2. williamr@2: * @pre aRealm must not be an empty descriptor williamr@2: * @param aRealm servers's realm williamr@2: * @return KErrNone if no error williamr@2: * KErrArgument if aRealm is an empty descriptor williamr@2: * KErrNoMemory if out of memory williamr@2: * KErrNotFound if the given realm was not found williamr@2: */ williamr@2: IMPORT_C TInt RemoveCredentials(const TDesC8& aRealm); williamr@2: williamr@2: /** williamr@2: * Removes all set credentials by the user. williamr@2: * Must not be used if the user implements williamr@2: * MSIPHttpDigestChallengeObserver2. williamr@2: * @return KErrNone if succesful; KErrNoMemory if out of memory williamr@2: */ williamr@2: IMPORT_C TInt RemoveCredentials(); williamr@2: williamr@2: /** williamr@2: * Sets the observer to listen for the possible received challenges. williamr@2: * Replaces the existing MSIPHttpDigestChallengeObserver or williamr@2: * MSIPHttpDigestChallengeObserver2. williamr@2: * @param aObserver an observer for the received challenges. williamr@2: */ williamr@2: IMPORT_C void SetObserver(MSIPHttpDigestChallengeObserver& aObserver); williamr@2: williamr@2: /** williamr@2: * Sets the observer to listen for the possible received challenges. williamr@2: * Replaces the existing MSIPHttpDigestChallengeObserver or williamr@2: * MSIPHttpDigestChallengeObserver2. williamr@2: * @param aObserver an observer for the received challenges. williamr@2: */ williamr@2: IMPORT_C void SetObserver(MSIPHttpDigestChallengeObserver2& aObserver); williamr@2: williamr@2: /** williamr@2: * Ignores the challenge for the realm. As a result the error will be williamr@2: * generated to the original SIP request. williamr@2: * @pre aRealm must not be an empty descriptor williamr@2: * @param aRealm a realm for which the challenge was ignored williamr@2: * @return KErrNone if no error williamr@2: * KErrNotFound if the given realm was not found williamr@2: * KErrArgument if aRealm is an empty descriptor williamr@2: */ williamr@2: IMPORT_C TInt IgnoreChallenge(const TDesC8& aRealm); williamr@2: williamr@2: /** williamr@2: * Ignores the challenge for the realm for the specific transaction. williamr@2: * As a result KErrForbidden will be generated williamr@2: * to the original SIP request. williamr@2: * @pre aRealm must not be an empty descriptor williamr@2: * @param aTransaction the transaction that was passed as a parameter williamr@2: * to MSIPHttpDigestChallengeObserver2::ChallengeReceived williamr@2: * @param aRealm a realm for which the challenge was ignored williamr@2: * @return KErrNone if no error williamr@2: * KErrNotFound if the given realm was not found williamr@2: * KErrArgument if aRealm is an empty descriptor williamr@2: */ williamr@2: IMPORT_C TInt IgnoreChallenge(const CSIPClientTransaction& aTransaction, williamr@2: const TDesC8& aRealm); williamr@2: williamr@2: /** williamr@2: * Ignores the challenge for the realm for the specific refresh. williamr@2: * As a result the error will be generated williamr@2: * to the original SIP request. williamr@2: * @pre aRealm must not be an empty descriptor williamr@2: * @param aRefresh the refresh that was passed as a parameter williamr@2: * to MSIPHttpDigestChallengeObserver2::ChallengeReceived williamr@2: * @param aRealm a realm for which the challenge was ignored williamr@2: * @return KErrNone if no error williamr@2: * KErrNotFound if the given realm was not found williamr@2: * KErrArgument if aRealm is an empty descriptor williamr@2: */ williamr@2: IMPORT_C TInt IgnoreChallenge(const CSIPRefresh& aRefresh, williamr@2: const TDesC8& aRealm); williamr@2: williamr@2: public: // New functions, for internal use williamr@2: williamr@2: void CSIPDeleted(); williamr@2: williamr@2: private: // Constructors williamr@2: williamr@2: CSIPHttpDigest(CSIP& aSIP); williamr@2: CSIPHttpDigest(const CSIPHttpDigest& aHttpDigest); williamr@2: CSIPHttpDigest& operator=(const CSIPHttpDigest& aHttpDigest); williamr@2: williamr@2: void ConstructL(MSIPHttpDigestChallengeObserver& aObserver); williamr@2: williamr@2: void ConstructL(MSIPHttpDigestChallengeObserver2& aObserver2); williamr@2: williamr@2: private: // New functions williamr@2: williamr@2: TInt RemoveCredentialParams(const TDesC8& aRealm) const; williamr@2: williamr@2: void SetCredentialParamsL(TUint32 aRequestId, williamr@2: TUint32 aRefreshId, williamr@2: const TDesC8& aOutboundProxy, williamr@2: const TDesC8& aRealm, williamr@2: const TDesC8& aUsername, williamr@2: const TDesC8& aPasswd) const; williamr@2: williamr@2: TInt IgnoreChallenge(TUint32 aRequestId, williamr@2: TUint32 aRefreshId, williamr@2: const TDesC8& aRealm); williamr@2: williamr@2: private: // Data williamr@2: williamr@2: CSIP* iSIP; williamr@2: williamr@2: private: // For testing purposes williamr@2: williamr@2: UNIT_TEST(CSIP_Test) williamr@2: }; williamr@2: williamr@2: #endif // CSIPHTTPDIGEST_H