1
0
Fork 0
arangodb/UserManager/Role.h

125 lines
4.3 KiB
C++

////////////////////////////////////////////////////////////////////////////////
/// @brief role of a user
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2011, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef BORNHOLM_USERMANAGER_ROLE_H
#define BORNHOLM_USERMANAGER_ROLE_H 1
#include <Basics/Common.h>
#include <Admin/Right.h>
#include <Basics/Logger.h>
namespace triagens {
namespace admin {
////////////////////////////////////////////////////////////////////////////////
/// @brief role of a user
////////////////////////////////////////////////////////////////////////////////
class Role : noncopyable {
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new role
////////////////////////////////////////////////////////////////////////////////
static Role* create (string const& name, right_t manage);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns a role by name
////////////////////////////////////////////////////////////////////////////////
static Role* lookup (string const& name);
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
Role (string const& name, right_t manage);
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the name of a role
////////////////////////////////////////////////////////////////////////////////
string const& getName () const {
return _name;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the rights of a role
////////////////////////////////////////////////////////////////////////////////
set<right_t> const& getRights () const {
return _rights;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief adds a right to a role
////////////////////////////////////////////////////////////////////////////////
void addRight (right_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the rights of a role
////////////////////////////////////////////////////////////////////////////////
void setRights (vector<right_t> const&);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes a right from a role
////////////////////////////////////////////////////////////////////////////////
void removeRight (right_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief clears all rights of a role
////////////////////////////////////////////////////////////////////////////////
void clearRights ();
////////////////////////////////////////////////////////////////////////////////
/// @brief returns right required to manage this role
////////////////////////////////////////////////////////////////////////////////
right_t rightToManage () {
return _rightToManage;
}
private:
string const _name;
set<right_t> _rights;
right_t _rightToManage;
};
}
}
#endif