zoneminder/src/zm_user.h

85 lines
2.4 KiB
C
Raw Normal View History

2013-03-17 07:45:21 +08:00
/*
* ZoneMinder User Class Interface, $Date$, $Revision$
* Copyright (C) 2001-2008 Philip Coombes
*
* 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.
2013-03-17 07:45:21 +08:00
*/
#include "zm.h"
#include "zm_db.h"
#ifndef ZM_USER_H
#define ZM_USER_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_L || HAVE_LIBCRYPTO
2017-11-19 05:00:10 +08:00
#include <vector>
class User {
2013-03-17 07:45:21 +08:00
public:
typedef enum { PERM_NONE=1, PERM_VIEW, PERM_EDIT } Permission;
2013-03-17 07:45:21 +08:00
protected:
2018-02-13 18:26:08 +08:00
int id;
char username[32+1];
char password[64+1];
bool enabled;
Permission stream;
Permission events;
Permission control;
Permission monitors;
Permission system;
2017-11-19 05:00:10 +08:00
std::vector<int> monitor_ids;
2013-03-17 07:45:21 +08:00
public:
User();
2017-11-19 05:00:10 +08:00
explicit User( MYSQL_ROW &dbrow );
~User();
2017-11-19 05:00:10 +08:00
User( User &u ) { Copy(u); }
void Copy( const User &u );
2018-04-12 23:29:35 +08:00
User& operator=(const User &u) {
2017-11-19 05:00:10 +08:00
Copy(u); return *this;
}
2013-03-17 07:45:21 +08:00
2018-02-13 18:26:08 +08:00
const int Id() const { return id; }
const char *getUsername() const { return( username ); }
const char *getPassword() const { return( password ); }
bool isEnabled() const { return( enabled ); }
Permission getStream() const { return( stream ); }
Permission getEvents() const { return( events ); }
Permission getControl() const { return( control ); }
Permission getMonitors() const { return( monitors ); }
Permission getSystem() const { return( system ); }
bool canAccess( int monitor_id );
2013-03-17 07:45:21 +08:00
};
User *zmLoadUser( const char *username, const char *password=0 );
User *zmLoadAuthUser( const char *auth, bool use_remote_addr );
User *zmLoadTokenUser( std::string jwt, bool use_remote_addr);
bool checkUser ( const char *username);
bool checkPass (const char *password);
2013-03-17 07:45:21 +08:00
#endif // ZM_USER_H