blob: e7c496bd67389b28f5d538dc37fb2fbf4f53d865 [file]
#include "redfish_privileges.h"
#include <string>
#include <string_view>
#include <unordered_set>
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
namespace milotic::authz {
const std::unordered_set<std::string>& RedfishPrivileges::GetPrivileges()
const {
return privileges_;
}
bool RedfishPrivileges::IsSupersetOf(const RedfishPrivileges& other) const {
if (other.GetPrivileges().size() > privileges_.size()) {
return false;
}
// Iterate through the smaller set
for (const std::string& privilege : other.GetPrivileges()) {
if (privileges_.find(privilege) == privileges_.end()) {
return false;
}
}
return true;
}
void RedfishPrivileges::InsertPrivilege(std::string_view privilege) {
privileges_.insert(std::string(privilege));
}
std::string RedfishPrivileges::GetDebugString() const {
return absl::StrCat("|PeerPrivileges|={", absl::StrJoin(privileges_, ", "),
"}");
}
bool RedfishPrivileges::operator==(const RedfishPrivileges& other) const {
return privileges_ == other.privileges_;
}
} // namespace milotic::authz