]> WPIA git - cassiopeia.git/blob - src/db/database.h
31687b13ce43242e68ab14babba87ae25e2908f6
[cassiopeia.git] / src / db / database.h
1 #pragma once
2
3 #include <string>
4 #include <memory>
5 #include <vector>
6
7 struct Job {
8     std::string id;
9     std::string warning;
10     std::string target;
11     std::string task;
12     std::string from;
13     std::string to;
14 };
15
16 struct SAN {
17     std::string content;
18     std::string type;
19 };
20
21 struct AVA {
22     std::string name;
23     std::string value;
24 };
25
26 struct TBSCertificate {
27     std::string md;
28     std::string profile;
29
30     /**
31      * CSR path
32      */
33     std::string csr;
34     std::string csr_type;
35     std::string csr_content;
36     std::vector<std::shared_ptr<SAN>> SANs;
37     std::vector<std::shared_ptr<AVA>> AVAs;
38
39     std::string wishFrom;
40     std::string wishTo;
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 crt_name;
51     std::string log;
52     std::string ca_name;
53 };
54
55 class JobProvider {
56 public:
57     virtual ~JobProvider() = default;
58     virtual std::shared_ptr<Job> fetchJob() = 0;
59     virtual void finishJob( std::shared_ptr<Job> job ) = 0;
60     virtual void failJob( std::shared_ptr<Job> job ) = 0;
61     virtual std::shared_ptr<TBSCertificate> fetchTBSCert( std::shared_ptr<Job> job ) = 0;
62     virtual void writeBack( std::shared_ptr<Job> job, std::shared_ptr<SignedCertificate> res ) = 0;
63     virtual std::pair<std::string, std::string> getRevocationInfo( std::shared_ptr<Job> job ) = 0;
64     virtual void writeBackRevocation( std::shared_ptr<Job> job, std::string date ) = 0;
65 };