Aktualizr
C++ SOTA Client
src
libaktualizr
uptane
exceptions.h
1
#ifndef UPTANE_EXCEPTIONS_H_
2
#define UPTANE_EXCEPTIONS_H_
3
4
#include <stdexcept>
5
#include <string>
6
#include <utility>
7
8
namespace
Uptane
{
9
10
class
Exception
:
public
std::logic_error {
11
public
:
12
Exception
(std::string reponame,
const
std::string& what_arg)
13
: std::logic_error(what_arg.c_str()), reponame_(std::move(reponame)) {}
14
~
Exception
() noexcept
override
=
default
;
15
virtual
std::string getName()
const
{
return
reponame_; };
16
17
protected
:
18
std::string reponame_;
19
};
20
21
class
SecurityException
:
public
Exception
{
22
public
:
23
SecurityException
(
const
std::string& reponame,
const
std::string& what_arg) :
Exception
(reponame, what_arg) {}
24
~
SecurityException
() noexcept
override
=
default
;
25
};
26
27
class
TargetHashMismatch
:
public
Exception
{
28
public
:
29
explicit
TargetHashMismatch
(
const
std::string& targetname)
30
:
Exception
(targetname,
"The target's calculated hash did not match the hash in the metadata."
) {}
31
~
TargetHashMismatch
() noexcept
override
=
default
;
32
};
33
34
class
OversizedTarget
:
public
Exception
{
35
public
:
36
explicit
OversizedTarget
(
const
std::string& reponame)
37
:
Exception
(reponame,
"The target's size was greater than the size in the metadata."
) {}
38
~
OversizedTarget
() noexcept
override
=
default
;
39
};
40
41
class
IllegalThreshold
:
public
Exception
{
42
public
:
43
IllegalThreshold
(
const
std::string& reponame,
const
std::string& what_arg) :
Exception
(reponame, what_arg) {}
44
~
IllegalThreshold
() noexcept
override
=
default
;
45
};
46
47
class
MissingRepo
:
public
Exception
{
48
public
:
49
explicit
MissingRepo
(
const
std::string& reponame) :
Exception
(reponame,
"The "
+ reponame +
" repo is missing."
) {}
50
~
MissingRepo
() noexcept
override
=
default
;
51
};
52
53
class
UnmetThreshold
:
public
Exception
{
54
public
:
55
UnmetThreshold
(
const
std::string& reponame,
const
std::string& role)
56
:
Exception
(reponame,
"The "
+ role +
" metadata had an unmet threshold."
) {}
57
~
UnmetThreshold
() noexcept
override
=
default
;
58
};
59
60
class
ExpiredMetadata
:
public
Exception
{
61
public
:
62
ExpiredMetadata
(
const
std::string& reponame,
const
std::string& role)
63
:
Exception
(reponame,
"The "
+ role +
" metadata was expired."
) {}
64
~
ExpiredMetadata
() noexcept
override
=
default
;
65
};
66
67
class
InvalidMetadata
:
public
Exception
{
68
public
:
69
InvalidMetadata
(
const
std::string& reponame,
const
std::string& role,
const
std::string& reason)
70
:
Exception
(reponame,
"The "
+ role +
" metadata failed to parse:"
+ reason) {}
71
~
InvalidMetadata
() noexcept
override
=
default
;
72
};
73
74
class
IllegalRsaKeySize
:
public
Exception
{
75
public
:
76
explicit
IllegalRsaKeySize
(
const
std::string& reponame) :
Exception
(reponame,
"The RSA key had an illegal size."
) {}
77
~
IllegalRsaKeySize
() noexcept
override
=
default
;
78
};
79
80
class
MissMatchTarget
:
public
Exception
{
81
public
:
82
explicit
MissMatchTarget
(
const
std::string& reponame)
83
:
Exception
(reponame,
"The target missmatch between image and director."
) {}
84
~
MissMatchTarget
() noexcept
override
=
default
;
85
};
86
87
class
NonUniqueSignatures
:
public
Exception
{
88
public
:
89
NonUniqueSignatures
(
const
std::string& reponame,
const
std::string& role)
90
:
Exception
(reponame,
"The role "
+ role +
" had non-unique signatures."
) {}
91
~
NonUniqueSignatures
() noexcept
override
=
default
;
92
};
93
94
class
BadKeyId
:
public
Exception
{
95
public
:
96
BadKeyId
(
const
std::string& reponame) :
Exception
(reponame,
"A key has an incorrect associated key ID"
) {}
97
~
BadKeyId
() noexcept
override
=
default
;
98
};
99
100
class
BadEcuId
:
public
Exception
{
101
public
:
102
BadEcuId
(
const
std::string& reponame)
103
:
Exception
(reponame,
"The target had an ECU ID that did not match the client's configured ECU id."
) {}
104
~
BadEcuId
() noexcept
override
=
default
;
105
};
106
107
}
// namespace Uptane
108
109
#endif
Uptane::UnmetThreshold
Definition:
exceptions.h:53
Uptane::NonUniqueSignatures
Definition:
exceptions.h:87
Uptane::MissingRepo
Definition:
exceptions.h:47
Uptane::IllegalThreshold
Definition:
exceptions.h:41
Uptane::Exception
Definition:
exceptions.h:10
Uptane::SecurityException
Definition:
exceptions.h:21
Uptane::OversizedTarget
Definition:
exceptions.h:34
Uptane::InvalidMetadata
Definition:
exceptions.h:67
Uptane::ExpiredMetadata
Definition:
exceptions.h:60
Uptane::TargetHashMismatch
Definition:
exceptions.h:27
Uptane::MissMatchTarget
Definition:
exceptions.h:80
Uptane::BadKeyId
Definition:
exceptions.h:94
Uptane
Base data types that are used in The Update Framework (TUF), part of UPTANE.
Definition:
opcuabridgeclient.h:16
Uptane::BadEcuId
Definition:
exceptions.h:100
Uptane::IllegalRsaKeySize
Definition:
exceptions.h:74
Generated by
1.8.14