liveMedia/include/DigestAuthentication.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2013 Live Networks, Inc.  All rights reserved.
00018 // A class used for digest authentication.
00019 // C++ header
00020 
00021 #ifndef _DIGEST_AUTHENTICATION_HH
00022 #define _DIGEST_AUTHENTICATION_HH
00023 
00024 #ifndef _BOOLEAN_HH
00025 #include <Boolean.hh>
00026 #endif
00027 
00028 // A class used for digest authentication.
00029 // The "realm", and "nonce" fields are supplied by the server
00030 // (in a "401 Unauthorized" response).
00031 // The "username" and "password" fields are supplied by the client.
00032 class Authenticator {
00033 public:
00034   Authenticator();
00035   Authenticator(char const* username, char const* password, Boolean passwordIsMD5 = False);
00036       // If "passwordIsMD5" is True, then "password" is actually the value computed
00037       // by md5(<username>:<realm>:<actual-password>)
00038   Authenticator(const Authenticator& orig);
00039   Authenticator& operator=(const Authenticator& rightSide);
00040   virtual ~Authenticator();
00041 
00042   void reset();
00043   void setRealmAndNonce(char const* realm, char const* nonce);
00044   void setRealmAndRandomNonce(char const* realm);
00045       // as above, except that the nonce is created randomly.
00046       // (This is used by servers.)
00047   void setUsernameAndPassword(char const* username, char const* password, Boolean passwordIsMD5 = False);
00048       // If "passwordIsMD5" is True, then "password" is actually the value computed
00049       // by md5(<username>:<realm>:<actual-password>)
00050 
00051   char const* realm() const { return fRealm; }
00052   char const* nonce() const { return fNonce; }
00053   char const* username() const { return fUsername; }
00054   char const* password() const { return fPassword; }
00055 
00056   char const* computeDigestResponse(char const* cmd, char const* url) const;
00057   void reclaimDigestResponse(char const* responseStr) const;
00058 
00059 private:
00060   void resetRealmAndNonce();
00061   void resetUsernameAndPassword();
00062   void assignRealmAndNonce(char const* realm, char const* nonce);
00063   void assignUsernameAndPassword(char const* username, char const* password, Boolean passwordIsMD5);
00064   void assign(char const* realm, char const* nonce,
00065               char const* username, char const* password, Boolean passwordIsMD5);
00066 
00067 private:
00068   char* fRealm; char* fNonce;
00069   char* fUsername; char* fPassword;
00070   Boolean fPasswordIsMD5;
00071 };
00072 
00073 #endif

Generated on Mon Apr 29 13:28:01 2013 for live by  doxygen 1.5.2