live
DigestAuthentication.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// A class used for digest authentication.
19// C++ header
20
21#ifndef _DIGEST_AUTHENTICATION_HH
22#define _DIGEST_AUTHENTICATION_HH
23
24#ifndef _BOOLEAN_HH
25#include <Boolean.hh>
26#endif
27
28// A class used for digest authentication.
29// The "realm", and "nonce" fields are supplied by the server
30// (in a "401 Unauthorized" response).
31// The "username" and "password" fields are supplied by the client.
33public:
35 Authenticator(char const* username, char const* password, Boolean passwordIsMD5 = False);
36 // If "passwordIsMD5" is True, then "password" is actually the value computed
37 // by md5(<username>:<realm>:<actual-password>)
40 Boolean operator<(const Authenticator* rightSide);
41 virtual ~Authenticator();
42
43 void reset();
44 void setRealmAndNonce(char const* realm, char const* nonce);
45 void setRealmAndRandomNonce(char const* realm);
46 // as above, except that the nonce is created randomly.
47 // (This is used by servers.)
48 void setUsernameAndPassword(char const* username, char const* password, Boolean passwordIsMD5 = False);
49 // If "passwordIsMD5" is True, then "password" is actually the value computed
50 // by md5(<username>:<realm>:<actual-password>)
51
52 char const* realm() const { return fRealm; }
53 char const* nonce() const { return fNonce; }
54 char const* username() const { return fUsername; }
55 char const* password() const { return fPassword; }
56
57 char const* computeDigestResponse(char const* cmd, char const* url) const;
58 // The returned string from this function must later be freed by calling:
59 void reclaimDigestResponse(char const* responseStr) const;
60
61private:
64 void assignRealmAndNonce(char const* realm, char const* nonce);
65 void assignUsernameAndPassword(char const* username, char const* password, Boolean passwordIsMD5);
66 void assign(char const* realm, char const* nonce,
67 char const* username, char const* password, Boolean passwordIsMD5);
68
69private:
70 char* fRealm; char* fNonce;
71 char* fUsername; char* fPassword;
73};
74
75#endif
const Boolean False
Definition: Boolean.hh:28
unsigned char Boolean
Definition: Boolean.hh:25
void setRealmAndNonce(char const *realm, char const *nonce)
void setRealmAndRandomNonce(char const *realm)
Authenticator(const Authenticator &orig)
virtual ~Authenticator()
void setUsernameAndPassword(char const *username, char const *password, Boolean passwordIsMD5=False)
void reclaimDigestResponse(char const *responseStr) const
void assignUsernameAndPassword(char const *username, char const *password, Boolean passwordIsMD5)
char const * nonce() const
char const * computeDigestResponse(char const *cmd, char const *url) const
Boolean operator<(const Authenticator *rightSide)
char const * username() const
void assignRealmAndNonce(char const *realm, char const *nonce)
void resetRealmAndNonce()
char const * realm() const
void assign(char const *realm, char const *nonce, char const *username, char const *password, Boolean passwordIsMD5)
char const * password() const
Authenticator(char const *username, char const *password, Boolean passwordIsMD5=False)
Authenticator & operator=(const Authenticator &rightSide)
void resetUsernameAndPassword()