diff options
author | sangwan.kwon <sangwan.kwon@samsung.com> | 2016-02-25 14:19:12 +0900 |
---|---|---|
committer | sangwan.kwon <sangwan.kwon@samsung.com> | 2016-02-25 15:31:59 +0900 |
commit | 43cb8a8eeb0819e1b1fe25d142187075b25237b0 (patch) | |
tree | 5754cd0980d35c316025e3953414dfac09dbc067 /src/db | |
parent | a49b608fe94e1c8f6a16f721a24f605967948867 (diff) | |
download | cert-checker-43cb8a8eeb0819e1b1fe25d142187075b25237b0.tar.gz cert-checker-43cb8a8eeb0819e1b1fe25d142187075b25237b0.tar.bz2 cert-checker-43cb8a8eeb0819e1b1fe25d142187075b25237b0.zip |
Delete unuse data, function
* key-manager uses only a chain for OCSP Check
* url is no longer needed
Change-Id: I8fb1e8baa6834c79a487ff865c0c6452b34078f1
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sql_query.cpp | 80 |
1 files changed, 9 insertions, 71 deletions
diff --git a/src/db/sql_query.cpp b/src/db/sql_query.cpp index b171bf5..800c144 100644 --- a/src/db/sql_query.cpp +++ b/src/db/sql_query.cpp @@ -27,16 +27,15 @@ namespace { #define DB_ISSUER 101 - #define DB_URL 102 - #define DB_DATE 103 - #define DB_APP_ID 104 - #define DB_PKG_ID 105 - #define DB_UID 106 - #define DB_CHECK_ID 107 - #define DB_CERTIFICATE 108 - #define DB_VERIFIED 109 - #define DB_CHAIN_ID 110 - #define DB_CERT_ORDER 111 + #define DB_DATE 102 + #define DB_APP_ID 103 + #define DB_PKG_ID 104 + #define DB_UID 105 + #define DB_CHECK_ID 106 + #define DB_CERTIFICATE 107 + #define DB_VERIFIED 108 + #define DB_CHAIN_ID 109 + #define DB_CERT_ORDER 110 // This changes define into question mark and a number in quotes // e.g. _(DB_ISSUER) -> "?" "101" @@ -48,16 +47,6 @@ namespace { const char *DB_CMD_GET_LAST_INSERTED_ROW = "SELECT last_insert_rowid();"; - // urls - const char *DB_CMD_GET_URL = - "SELECT url, date FROM ocsp_urls WHERE issuer = " _(DB_ISSUER) ";"; - - const char *DB_CMD_SET_URL = - "INSERT INTO ocsp_urls(issuer, url, date) VALUES(" _(DB_ISSUER) ", " _(DB_URL) ", " _(DB_DATE) ");"; - - const char *DB_CMD_UPDATE_URL = - "UPDATE ocsp_urls SET url=" _(DB_URL) ", date=" _(DB_DATE) " WHERE issuer=" _(DB_ISSUER) ";"; // Issuer should be unique - // apps const char *DB_CMD_ADD_APP = "INSERT INTO to_check(app_id, pkg_id, uid, verified) VALUES(" _(DB_APP_ID) ", " _(DB_PKG_ID) ", " _(DB_UID) ", " _(DB_VERIFIED) ");"; @@ -130,57 +119,6 @@ SqlQuery::~SqlQuery() delete m_connection; } -bool SqlQuery::get_url(const std::string &issuer, std::string &url) -{ - SqlConnection::DataCommandAutoPtr getUrlCommand = - m_connection->PrepareDataCommand(DB_CMD_GET_URL); - getUrlCommand->BindString(DB_ISSUER, issuer.c_str()); - - if (getUrlCommand->Step()) { - url = getUrlCommand->GetColumnString(0); - LogDebug("Url for " << issuer << " found in databse: " << url); - return true; - } - - LogDebug("No url for " << issuer << " in databse."); - return false; -} - -void SqlQuery::set_url(const std::string &issuer, const std::string &url, const int64_t &date) -{ - m_connection->BeginTransaction(); - SqlConnection::DataCommandAutoPtr getUrlCommand = - m_connection->PrepareDataCommand(DB_CMD_GET_URL); - getUrlCommand->BindString(DB_ISSUER, issuer.c_str()); - - if (getUrlCommand->Step()) { // This means that url already exists in database for this issuer - // There's need to check the date - LogDebug("Url for " << issuer << " already exists. Checking the date"); - int64_t db_date = getUrlCommand->GetColumnInt64(1); - if (db_date < date) { - LogDebug("Url for " << issuer << " in database is older. Update is needed"); - // Url in DB is older - update is needed - SqlConnection::DataCommandAutoPtr updateUrlCommand = - m_connection->PrepareDataCommand(DB_CMD_UPDATE_URL); - updateUrlCommand->BindString(DB_ISSUER, issuer.c_str()); - updateUrlCommand->BindString(DB_URL, url.c_str()); - updateUrlCommand->BindInt64(DB_DATE, date); - updateUrlCommand->Step(); - } else // Url in DB is up-to-date, no need for update - LogDebug("Url for " << issuer << " in databse is up-to-date. No update needed"); - - } else { // No url in database for this issuer, add the new one - LogDebug("No url for "<< issuer << " in databse. Adding the new one."); - SqlConnection::DataCommandAutoPtr setUrlCommand = - m_connection->PrepareDataCommand(DB_CMD_SET_URL); - setUrlCommand->BindString(DB_ISSUER, issuer.c_str()); - setUrlCommand->BindString(DB_URL, url.c_str()); - setUrlCommand->BindInt64(DB_DATE, date); - setUrlCommand->Step(); - } - m_connection->CommitTransaction(); -} - bool SqlQuery::check_if_app_exists(const app_t &app) { int32_t check_id; |