3 Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "common_irrlicht.h"
27 #include "exceptions.h"
29 // Player privileges. These form a bitmask stored in the privs field
30 // of the player, and define things they're allowed to do. See also
31 // the static methods Player::privsToString and stringToPrivs that
32 // convert these to human-readable form.
33 const u64 PRIV_BUILD = 1; // Can build - i.e. modify the world
34 const u64 PRIV_TELEPORT = 2; // Can teleport
35 const u64 PRIV_SETTIME = 4; // Can set the time
36 const u64 PRIV_PRIVS = 8; // Can grant and revoke privileges
37 const u64 PRIV_SERVER = 16; // Can manage the server (e.g. shutodwn
39 const u64 PRIV_SHOUT = 32; // Can broadcast chat messages to all
41 const u64 PRIV_BAN = 64; // Can ban players
43 // Default privileges - these can be overriden for new players using the
44 // config option "default_privs" - however, this value still applies for
45 // players that existed before the privileges system was added.
46 const u64 PRIV_DEFAULT = PRIV_BUILD|PRIV_SHOUT;
47 const u64 PRIV_ALL = 0x7FFFFFFFFFFFFFFFULL;
48 const u64 PRIV_INVALID = 0x8000000000000000ULL;
50 // Convert a privileges value into a human-readable string,
51 // with each component separated by a comma.
52 std::string privsToString(u64 privs);
54 // Converts a comma-seperated list of privilege values into a
55 // privileges value. The reverse of privsToString(). Returns
56 // PRIV_INVALID if there is anything wrong with the input.
57 u64 stringToPrivs(std::string str);
70 class AuthNotFoundException : public BaseException
73 AuthNotFoundException(const char *s):
81 AuthManager(const std::string &authfilepath);
85 bool exists(const std::string &username);
86 void set(const std::string &username, AuthData ad);
87 void add(const std::string &username);
88 std::string getPassword(const std::string &username);
89 void setPassword(const std::string &username,
90 const std::string &password);
91 u64 getPrivs(const std::string &username);
92 void setPrivs(const std::string &username, u64 privs);
96 std::string m_authfilepath;
97 core::map<std::string, AuthData> m_authdata;