libreoffice-online/wsd/ServerAuditUtil.cpp
Szymon Kłos 7a28a27604 Server audit: add guard for setting new value
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Icdf91e101e83b02e3dd0b71ce9ceb5ddc99cb63a
2024-06-17 17:07:52 +02:00

45 lines
1.1 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* Copyright the Collabora Online contributors.
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "ServerAuditUtil.hpp"
ServerAuditUtil::ServerAuditUtil()
: disabled(false)
{
set("is_admin", "ok");
set("certwarning", "ok");
}
std::string ServerAuditUtil::getResultsJSON() const
{
std::string result = "{\"serverAudit\": [";
bool bFirst = true;
for (auto entry : entries)
{
if (!bFirst)
result += ", ";
bFirst = false;
result += "{\"code\": \"" + entry.first + "\", \"status\": \"" + entry.second + "\"}";
}
result += "]}";
return result;
}
void ServerAuditUtil::set(std::string code, std::string status)
{
std::lock_guard<std::mutex> lock(mapMutex);
entries[code] = std::move(status);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */