zoneminder/src/zm_rtsp_auth.h

70 lines
2.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2014-04-29 05:37:31 +08:00
//
#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:
2017-11-17 20:52:26 +08:00
Authenticator(const std::string &username, const std::string &password);
virtual ~Authenticator();
void reset();
2014-04-29 05:37:31 +08:00
std::string realm() { return fRealm; }
std::string nonce() { return fNonce; }
std::string username() { return fUsername; }
AuthMethod auth_method() const { return fAuthMethod; }
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;
2017-11-17 20:52:26 +08:00
std::string quote( const 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