]> WPIA git - cassiopeia.git/blob - src/db/database.h
chg: write future logs to database
[cassiopeia.git] / src / db / database.h
1 #pragma once
2
3 #include <string>
4 #include <memory>
5 #include <vector>
6 #include <sstream>
7
8 struct Job {
9     std::string id;
10     std::string attempt;
11     std::string target;
12     std::string task;
13     std::string from;
14     std::string to;
15     std::stringstream log;
16 };
17
18 struct SAN {
19     std::string content;
20     std::string type;
21 };
22
23 struct AVA {
24     std::string name;
25     std::string value;
26 };
27
28 struct TBSCertificate {
29     std::string md;
30     std::string profile;
31
32     std::string csr_type;
33     std::string csr_content;
34     std::vector<std::shared_ptr<SAN>> SANs;
35     std::vector<std::shared_ptr<AVA>> AVAs;
36
37     std::string wishFrom;
38     std::string wishTo;
39
40     std::string ocspCA;
41 };
42
43 struct SignedCertificate {
44     std::string certificate;
45     std::string serial;
46     std::string before;
47     std::string after;
48     std::string pkHash;
49     std::string certHash;
50     std::string log;
51     std::string ca_name;
52 };
53
54 class JobProvider {
55 public:
56     virtual ~JobProvider() = default;
57     virtual std::shared_ptr<Job> fetchJob() = 0;
58     virtual void finishJob( std::shared_ptr<Job> job ) = 0;
59     virtual void failJob( std::shared_ptr<Job> job ) = 0;
60     virtual std::shared_ptr<TBSCertificate> fetchTBSCert( std::shared_ptr<Job> job ) = 0;
61     virtual void writeBack( std::shared_ptr<Job> job, std::shared_ptr<SignedCertificate> res ) = 0;
62     virtual std::pair<std::string, std::string> getRevocationInfo( std::shared_ptr<Job> job ) = 0;
63     virtual void writeBackRevocation( std::shared_ptr<Job> job, std::string date ) = 0;
64 };