summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/user.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-07-28 18:16:39 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-07-28 18:27:27 -0400
commitb66e993f1c742518d9b5e93b0d8a5f8255a4127c (patch)
tree55e6fed05333d2d37f34586726a342ed7f7dbc29 /src/mongo/db/auth/user.cpp
parent314a22e93f283ab80e650618cbd3ed8babb8510f (diff)
downloadmongo-b66e993f1c742518d9b5e93b0d8a5f8255a4127c.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/auth/user.cpp')
-rw-r--r--src/mongo/db/auth/user.cpp228
1 files changed, 112 insertions, 116 deletions
diff --git a/src/mongo/db/auth/user.cpp b/src/mongo/db/auth/user.cpp
index 4fcfaf883cb..4bdcba801b6 100644
--- a/src/mongo/db/auth/user.cpp
+++ b/src/mongo/db/auth/user.cpp
@@ -41,123 +41,119 @@
namespace mongo {
- User::User(const UserName& name) :
- _name(name),
- _refCount(0),
- _isValid(1) {}
+User::User(const UserName& name) : _name(name), _refCount(0), _isValid(1) {}
- User::~User() {
- dassert(_refCount == 0);
- }
-
- const UserName& User::getName() const {
- return _name;
- }
-
- RoleNameIterator User::getRoles() const {
- return makeRoleNameIteratorForContainer(_roles);
- }
-
- RoleNameIterator User::getIndirectRoles() const {
- return makeRoleNameIteratorForContainer(_indirectRoles);
- }
-
- bool User::hasRole(const RoleName& roleName) const {
- return _roles.count(roleName);
- }
-
- const User::CredentialData& User::getCredentials() const {
- return _credentials;
- }
-
- bool User::isValid() const {
- return _isValid.loadRelaxed() == 1;
- }
-
- uint32_t User::getRefCount() const {
- return _refCount;
- }
-
- const ActionSet User::getActionsForResource(const ResourcePattern& resource) const {
- unordered_map<ResourcePattern, Privilege>::const_iterator it = _privileges.find(resource);
- if (it == _privileges.end()) {
- return ActionSet();
- }
- return it->second.getActions();
- }
-
- User* User::clone() const {
- std::auto_ptr<User> result(new User(_name));
- result->_privileges = _privileges;
- result->_roles = _roles;
- result->_credentials = _credentials;
- return result.release();
- }
+User::~User() {
+ dassert(_refCount == 0);
+}
- void User::setCredentials(const CredentialData& credentials) {
- _credentials = credentials;
- }
-
- void User::setRoles(RoleNameIterator roles) {
- _roles.clear();
- while (roles.more()) {
- _roles.insert(roles.next());
- }
- }
-
- void User::setIndirectRoles(RoleNameIterator indirectRoles) {
- _indirectRoles.clear();
- while (indirectRoles.more()) {
- _indirectRoles.push_back(indirectRoles.next());
- }
- }
+const UserName& User::getName() const {
+ return _name;
+}
- void User::setPrivileges(const PrivilegeVector& privileges) {
- _privileges.clear();
- for (size_t i = 0; i < privileges.size(); ++i) {
- const Privilege& privilege = privileges[i];
- _privileges[privilege.getResourcePattern()] = privilege;
- }
- }
-
- void User::addRole(const RoleName& roleName) {
- _roles.insert(roleName);
- }
-
- void User::addRoles(const std::vector<RoleName>& roles) {
- for (std::vector<RoleName>::const_iterator it = roles.begin(); it != roles.end(); ++it) {
- addRole(*it);
- }
- }
+RoleNameIterator User::getRoles() const {
+ return makeRoleNameIteratorForContainer(_roles);
+}
- void User::addPrivilege(const Privilege& privilegeToAdd) {
- ResourcePrivilegeMap::iterator it = _privileges.find(privilegeToAdd.getResourcePattern());
- if (it == _privileges.end()) {
- // No privilege exists yet for this resource
- _privileges.insert(std::make_pair(privilegeToAdd.getResourcePattern(), privilegeToAdd));
- } else {
- dassert(it->first == privilegeToAdd.getResourcePattern());
- it->second.addActions(privilegeToAdd.getActions());
- }
- }
-
- void User::addPrivileges(const PrivilegeVector& privileges) {
- for (PrivilegeVector::const_iterator it = privileges.begin();
- it != privileges.end(); ++it) {
- addPrivilege(*it);
- }
- }
-
- void User::invalidate() {
- _isValid.store(0);
- }
-
- void User::incrementRefCount() {
- ++_refCount;
- }
-
- void User::decrementRefCount() {
- dassert(_refCount > 0);
- --_refCount;
- }
-} // namespace mongo
+RoleNameIterator User::getIndirectRoles() const {
+ return makeRoleNameIteratorForContainer(_indirectRoles);
+}
+
+bool User::hasRole(const RoleName& roleName) const {
+ return _roles.count(roleName);
+}
+
+const User::CredentialData& User::getCredentials() const {
+ return _credentials;
+}
+
+bool User::isValid() const {
+ return _isValid.loadRelaxed() == 1;
+}
+
+uint32_t User::getRefCount() const {
+ return _refCount;
+}
+
+const ActionSet User::getActionsForResource(const ResourcePattern& resource) const {
+ unordered_map<ResourcePattern, Privilege>::const_iterator it = _privileges.find(resource);
+ if (it == _privileges.end()) {
+ return ActionSet();
+ }
+ return it->second.getActions();
+}
+
+User* User::clone() const {
+ std::auto_ptr<User> result(new User(_name));
+ result->_privileges = _privileges;
+ result->_roles = _roles;
+ result->_credentials = _credentials;
+ return result.release();
+}
+
+void User::setCredentials(const CredentialData& credentials) {
+ _credentials = credentials;
+}
+
+void User::setRoles(RoleNameIterator roles) {
+ _roles.clear();
+ while (roles.more()) {
+ _roles.insert(roles.next());
+ }
+}
+
+void User::setIndirectRoles(RoleNameIterator indirectRoles) {
+ _indirectRoles.clear();
+ while (indirectRoles.more()) {
+ _indirectRoles.push_back(indirectRoles.next());
+ }
+}
+
+void User::setPrivileges(const PrivilegeVector& privileges) {
+ _privileges.clear();
+ for (size_t i = 0; i < privileges.size(); ++i) {
+ const Privilege& privilege = privileges[i];
+ _privileges[privilege.getResourcePattern()] = privilege;
+ }
+}
+
+void User::addRole(const RoleName& roleName) {
+ _roles.insert(roleName);
+}
+
+void User::addRoles(const std::vector<RoleName>& roles) {
+ for (std::vector<RoleName>::const_iterator it = roles.begin(); it != roles.end(); ++it) {
+ addRole(*it);
+ }
+}
+
+void User::addPrivilege(const Privilege& privilegeToAdd) {
+ ResourcePrivilegeMap::iterator it = _privileges.find(privilegeToAdd.getResourcePattern());
+ if (it == _privileges.end()) {
+ // No privilege exists yet for this resource
+ _privileges.insert(std::make_pair(privilegeToAdd.getResourcePattern(), privilegeToAdd));
+ } else {
+ dassert(it->first == privilegeToAdd.getResourcePattern());
+ it->second.addActions(privilegeToAdd.getActions());
+ }
+}
+
+void User::addPrivileges(const PrivilegeVector& privileges) {
+ for (PrivilegeVector::const_iterator it = privileges.begin(); it != privileges.end(); ++it) {
+ addPrivilege(*it);
+ }
+}
+
+void User::invalidate() {
+ _isValid.store(0);
+}
+
+void User::incrementRefCount() {
+ ++_refCount;
+}
+
+void User::decrementRefCount() {
+ dassert(_refCount > 0);
+ --_refCount;
+}
+} // namespace mongo