本文整理汇总了C++中Principal::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Principal::getName方法的具体用法?C++ Principal::getName怎么用?C++ Principal::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Principal
的用法示例。
在下文中一共展示了Principal::getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookup
Principal* PrincipalSet::lookup(const UserName& name) const {
Principal* principal = lookupByDBName(name.getDB());
if (principal && principal->getName() == name) {
return principal;
}
return NULL;
}
示例2: logoutDatabase
void AuthorizationManager::logoutDatabase(const std::string& dbname) {
Principal* principal = _authenticatedPrincipals.lookupByDBName(dbname);
if (!principal)
return;
_acquiredPrivileges.revokePrivilegesFromPrincipal(principal->getName());
_authenticatedPrincipals.removeByDBName(dbname);
}
示例3: logoutDatabase
void AuthorizationSession::logoutDatabase(const std::string& dbname) {
Principal* principal = _authenticatedPrincipals.lookupByDBName(dbname);
if (!principal)
return;
_acquiredPrivileges.revokePrivilegesFromUser(principal->getName());
_authenticatedPrincipals.removeByDBName(dbname);
_externalState->onLogoutDatabase(dbname);
}
示例4: grantInternalAuthorization
void AuthorizationManager::grantInternalAuthorization(const std::string& principalName) {
Principal* principal = new Principal(PrincipalName(principalName, "local"));
ActionSet actions;
actions.addAllActions();
addAuthorizedPrincipal(principal);
fassert(16581, acquirePrivilege(Privilege(PrivilegeSet::WILDCARD_RESOURCE, actions),
principal->getName()).isOK());
}
示例5: grantInternalAuthorization
void AuthorizationSession::grantInternalAuthorization(const UserName& userName) {
Principal* principal = new Principal(userName);
ActionSet actions;
actions.addAllActions();
addAuthorizedPrincipal(principal);
fassert(16581, acquirePrivilege(Privilege(PrivilegeSet::WILDCARD_RESOURCE, actions),
principal->getName()).isOK());
}
示例6: lookupByDBName
Principal* PrincipalSet::lookupByDBName(const StringData& dbname) const {
for (std::vector<Principal*>::const_iterator it = _principals.begin();
it != _principals.end(); ++it) {
Principal* current = *it;
if (current->getName().getDB() == dbname) {
return current;
}
}
return NULL;
}
示例7: _authorizePrincipal
void _authorizePrincipal(const std::string& principalName, bool readOnly) {
Principal* principal = new Principal(PrincipalName(principalName, "local"));
ActionSet actions = AuthorizationManager::getActionsForOldStyleUser(
"admin", readOnly);
AuthorizationManager* authorizationManager = cc().getAuthorizationManager();
authorizationManager->addAuthorizedPrincipal(principal);
Status status = authorizationManager->acquirePrivilege(
Privilege(PrivilegeSet::WILDCARD_RESOURCE, actions), principal->getName());
verify (status == Status::OK());
}
示例8: removeByDBName
void PrincipalSet::removeByDBName(const StringData& dbname) {
for (std::vector<Principal*>::iterator it = _principals.begin();
it != _principals.end(); ++it) {
Principal* current = *it;
if (current->getName().getDB() == dbname) {
delete current;
_principals.erase(it);
break;
}
}
}
示例9: add
void PrincipalSet::add(Principal* principal) {
for (std::vector<Principal*>::iterator it = _principals.begin();
it != _principals.end(); ++it) {
Principal* current = *it;
if (current->getName().getDB() == principal->getName().getDB()) {
// There can be only one principal per database.
delete current;
*it = principal;
return;
}
}
_principals.push_back(principal);
}
示例10: _probeForPrivilege
Status AuthorizationManager::_probeForPrivilege(const Privilege& privilege) {
Privilege modifiedPrivilege = _modifyPrivilegeForSpecialCases(privilege);
if (_acquiredPrivileges.hasPrivilege(modifiedPrivilege))
return Status::OK();
std::string dbname = nsToDatabase(modifiedPrivilege.getResource());
for (PrincipalSet::iterator iter = _authenticatedPrincipals.begin(),
end = _authenticatedPrincipals.end();
iter != end; ++iter) {
Principal* principal = *iter;
if (!principal->isImplicitPrivilegeAcquisitionEnabled())
continue;
if (principal->isDatabaseProbed(dbname))
continue;
_acquirePrivilegesForPrincipalFromDatabase(dbname, principal->getName());
principal->markDatabaseAsProbed(dbname);
if (_acquiredPrivileges.hasPrivilege(modifiedPrivilege))
return Status::OK();
}
return Status(ErrorCodes::Unauthorized, "unauthorized", 0);
}