Leosac
0.8.0
Open Source Access Control
Exceptions.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 "
Exceptions.hpp
"
21
#include "
core/auth/Token.hpp
"
22
#include "
core/auth/User.hpp
"
23
24
using namespace
Leosac
;
25
using namespace
Leosac::Module
;
26
using namespace
Leosac::Module::WebSockAPI
;
27
28
SessionAborted::SessionAborted
()
29
:
LEOSACException
(
"Websocket session has been aborted."
)
30
{
31
}
32
33
SessionAborted::SessionAborted
(
Auth::TokenPtr
token)
34
:
LEOSACException
(build_msg(token))
35
{
36
}
37
38
std::string
SessionAborted::build_msg
(
Auth::TokenPtr
token)
const
39
{
40
std::stringstream ss;
41
ss <<
"Websocket session has been aborted."
;
42
43
if
(!token)
44
ss <<
"No associated token found."
;
45
else
46
{
47
ss <<
" Token "
<< token->token();
48
if
(token->owner())
49
ss <<
", owned by user "
<< token->owner()->id();
50
else
51
ss <<
", with no owner "
;
52
ss <<
" expired on "
<< token->expiration();
53
}
54
return
ss.str();
55
}
56
57
MalformedMessage::MalformedMessage
(
const
std::string &detail)
58
:
LEOSACException
(build_msg(detail))
59
{
60
}
61
62
std::string
MalformedMessage::build_msg
(
const
std::string &detail)
const
63
{
64
std::stringstream ss;
65
ss <<
"Malformed message"
;
66
67
if
(detail.size())
68
ss <<
": "
<< detail;
69
else
70
ss <<
"."
;
71
72
return
ss.str();
73
}
Exceptions.hpp
Leosac::Auth::TokenPtr
std::shared_ptr< Token > TokenPtr
Definition:
AuthFwd.hpp:85
User.hpp
Leosac::Module::WebSockAPI::MalformedMessage::build_msg
std::string build_msg(const std::string &detail) const
Definition:
Exceptions.cpp:62
Leosac::Module
All modules that provides features to Leosac shall be in this namespace.
Leosac::Module::WebSockAPI::MalformedMessage::MalformedMessage
MalformedMessage(const std::string &detail="")
Definition:
Exceptions.cpp:57
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition:
APIStatusCode.hpp:22
Leosac::Module::WebSockAPI::SessionAborted::build_msg
std::string build_msg(Auth::TokenPtr token) const
Build an exception message for when the reason of the aborted session is an expired token.
Definition:
Exceptions.cpp:38
LEOSACException
A base class for Leosac specific exception.
Definition:
leosacexception.hpp:40
Leosac::Module::WebSockAPI::SessionAborted::SessionAborted
SessionAborted()
Definition:
Exceptions.cpp:28
Token.hpp
Leosac::Module::WebSockAPI
Definition:
ActionActionParam.hpp:28
src
modules
websock-api
Exceptions.cpp
Generated on Tue Mar 22 2022 10:48:29 for Leosac by
1.8.17