zoneminder/src/zm_rtsp_auth.h

70 lines
2.0 KiB
C
Raw Normal View History

2014-04-29 05:37:31 +08:00
//
// ZoneMinder RTSP Authentication Class Interface, $Date$, $Revision$
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ZM_RTSP_AUTH_H
#define ZM_RTSP_AUTH_H
#if HAVE_GNUTLS_OPENSSL_H
#include <gnutls/openssl.h>
#endif
#if HAVE_GNUTLS_GNUTLS_H
#include <gnutls/gnutls.h>
#endif
#if HAVE_GCRYPT_H
#include <gcrypt.h>
#elif HAVE_LIBCRYPTO
#include <openssl/md5.h>
#endif // HAVE_GCRYPT_H || HAVE_LIBCRYPTO
namespace zm {
enum AuthMethod { AUTH_UNDEFINED = 0, AUTH_BASIC = 1, AUTH_DIGEST = 2 };
class Authenticator {
2014-04-29 05:37:31 +08:00
public:
Authenticator(std::string &username, std::string password);
virtual ~Authenticator();
void reset();
std::string realm() { return fRealm; }
std::string nonce() { return fNonce; }
std::string username() { return fUsername; }
AuthMethod auth_method() const { return fAuthMethod; }
2014-04-29 05:37:31 +08:00
std::string computeDigestResponse( std::string &cmd, std::string &url );
void authHandleHeader( std::string headerData );
std::string getAuthHeader( std::string method, std::string path );
void checkAuthResponse(std::string &response);
2014-04-29 05:37:31 +08:00
private:
std::string password() { return fPassword; }
AuthMethod fAuthMethod;
2014-04-29 05:37:31 +08:00
std::string fRealm;
std::string fNonce;
std::string fCnonce;
std::string fQop;
2014-04-29 05:37:31 +08:00
std::string fUsername;
std::string fPassword;
std::string quote( std::string src );
int nc;
2014-04-29 05:37:31 +08:00
};
} // namespace zm
2014-04-29 05:37:31 +08:00
#endif // ZM_RTSP_AUTH_H