Leosac
0.8.0
Open Source Access Control
WSAPICallSerializer.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2016 Leosac
3
4
This file is part of Leosac.
5
6
Leosac is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Affero General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Leosac is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Affero General Public License for more details.
15
16
You should have received a copy of the GNU Affero General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include "
WSAPICallSerializer.hpp
"
21
#include "
AuditSerializer.hpp
"
22
#include "
core/audit/IWSAPICall.hpp
"
23
#include "
tools/log.hpp
"
24
25
namespace
Leosac
26
{
27
namespace
Audit
28
{
29
namespace
Serializer
30
{
31
json
WSAPICallJSON::serialize
(
const
Audit::IWSAPICall
&in,
const
SecurityContext
&sc)
32
{
33
auto
serialized =
Audit::Serializer::AuditJSON::serialize
(in, sc);
34
// Now we override the type.
35
ASSERT_LOG
(serialized.at(
"type"
).is_string(),
36
"Base audit serialization did something unexpected."
);
37
serialized[
"type"
] =
"audit-wsapicall-event"
;
38
39
serialized[
"attributes"
][
"uuid"
] = in.
uuid
();
40
serialized[
"attributes"
][
"method"
] = in.
method
();
41
serialized[
"attributes"
][
"status-string"
] = in.
status_string
();
42
serialized[
"attributes"
][
"status-code"
] =
static_cast<
int
>
(in.
status_code
());
43
serialized[
"attributes"
][
"source-endpoint"
] = in.
source_endpoint
();
44
return
serialized;
45
}
46
}
47
}
48
}
Leosac::json
nlohmann::json json
Definition:
AuditSerializer.hpp:29
AuditSerializer.hpp
ASSERT_LOG
#define ASSERT_LOG(cond, msg)
Definition:
log.hpp:190
Leosac::Audit::IWSAPICall::status_code
virtual void status_code(APIStatusCode)=0
Set the status_code of the reponse.
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
Leosac::Audit::Serializer::WSAPICallJSON::serialize
static json serialize(const Audit::IWSAPICall &in, const SecurityContext &sc)
Definition:
WSAPICallSerializer.cpp:31
Leosac::Audit::Serializer::AuditJSON::serialize
static json serialize(const Audit::IAuditEntry &in, const SecurityContext &sc)
Definition:
AuditSerializer.cpp:30
Leosac::Audit::IWSAPICall::uuid
virtual void uuid(const std::string &)=0
Set the UUID of the request.
log.hpp
Leosac::Audit::IWSAPICall::status_string
virtual void status_string(const std::string &)=0
Set the status string of the response.
IWSAPICall.hpp
Leosac::Audit::IWSAPICall::method
virtual void method(const std::string &)=0
Set the API method that was targeted by the call.
Leosac::Audit::IWSAPICall::source_endpoint
virtual void source_endpoint(const std::string &)=0
Set the source endpoint.
Leosac::SecurityContext
A SecurityContext is used to query permission while doing an operation.
Definition:
SecurityContext.hpp:40
WSAPICallSerializer.hpp
Leosac::Audit::IWSAPICall
An audit entry dedicated to tracing API call.
Definition:
IWSAPICall.hpp:39
src
core
audit
serializers
WSAPICallSerializer.cpp
Generated on Tue Mar 22 2022 10:48:17 for Leosac by
1.8.17