]> WPIA git - cassiopeia.git/blob - src/db/database.h
fb3b093a341b0ae2fb10669ef8f935c90da5d92f
[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     std::string ocspCA;
43 };
44
45 struct SignedCertificate {
46     std::string certificate;
47     std::string serial;
48     std::string before;
49     std::string after;
50     std::string pkHash;
51     std::string certHash;
52     std::string crt_name;
53     std::string log;
54     std::string ca_name;
55 };
56
57 class JobProvider {
58 public:
59     virtual ~JobProvider() = default;
60     virtual std::shared_ptr<Job> fetchJob() = 0;
61     virtual void finishJob( std::shared_ptr<Job> job ) = 0;
62     virtual void failJob( std::shared_ptr<Job> job ) = 0;
63     virtual std::shared_ptr<TBSCertificate> fetchTBSCert( std::shared_ptr<Job> job ) = 0;
64     virtual void writeBack( std::shared_ptr<Job> job, std::shared_ptr<SignedCertificate> res ) = 0;
65     virtual std::pair<std::string, std::string> getRevocationInfo( std::shared_ptr<Job> job ) = 0;
66     virtual void writeBackRevocation( std::shared_ptr<Job> job, std::string date ) = 0;
67 };