]> WPIA git - cassiopeia.git/blobdiff - src/mysql.cpp
add: Aim for initial interoperatibility with Gigi
[cassiopeia.git] / src / mysql.cpp
index 66c24427411664c1aceb23605e5679aa63520611..67fc49ecc65bae1122a196242c41a2380e194ac8 100644 (file)
@@ -155,7 +155,7 @@ std::shared_ptr<Job> MySQLJobProvider::fetchJob() {
     return job;
 }
 
-std::string MySQLJobProvider::escape_string( const std::string & target ) {
+std::string MySQLJobProvider::escape_string( const std::string& target ) {
     if( !conn ) {
         throw "Not connected!";
     }
@@ -243,3 +243,17 @@ std::shared_ptr<TBSCertificate> MySQLJobProvider::fetchTBSCert( std::shared_ptr<
 
     return cert;
 }
+
+void MySQLJobProvider::writeBack( std::shared_ptr<Job> job, std::shared_ptr<SignedCertificate> res ) {
+    if( !conn ) {
+        throw "Error while writing back";
+    }
+
+    std::string q = "UPDATE certs SET crt_name='" + this->escape_string( res->crt_name ) + "', serial='" + this->escape_string( std::to_string( res->serial ) ) + "' WHERE id='" + this->escape_string( job->id ) + "' LIMIT 1";
+
+    // TODO write more thingies back
+
+    if( query( q ).first ) {
+        throw "Error while writing back";
+    }
+}