BuildRequires: pkgconfig(key-manager)
BuildRequires: pkgconfig(secure-storage)
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(libsystemd-journal)
BuildRequires: boost-devel
%if 0%{?certsvc_feature_ocsp_crl}
BuildRequires: pkgconfig(vconf)
icu-uc
libsoup-2.4
db-util
+ libsystemd-journal
sqlite3
vconf
icu-uc
libsoup-2.4
db-util
+ libsystemd-journal
)
ENDIF(DEFINED TIZEN_FEAT_CERTSVC_OCSP_CRL)
${VCORE_DPL_LOG_SRC_DIR}/abstract_log_provider.cpp
${VCORE_DPL_LOG_SRC_DIR}/old_style_log_provider.cpp
${VCORE_DPL_LOG_SRC_DIR}/dlog_log_provider.cpp
+ ${VCORE_DPL_LOG_SRC_DIR}/journal_log_provider.cpp
${VCORE_DPL_LOG_SRC_DIR}/log.cpp
)
########### DPL SOURCES ##########
#include <cerrno>
#include <cstdio>
#include <string>
-#include <dpl/log/vcore_log.h>
#include <dpl/scoped_resource.h>
-#include <dpl/errno_string.h>
namespace VcoreDPL {
struct ScopedFClosePolicy
{
if (file != NULL) {
// Try to flush first
- if (TEMP_FAILURE_RETRY(fflush(file)) != 0) {
- std::string errString = GetErrnoString();
- VcoreLogD("Failed to fflush scoped fclose error: %s",
- errString.c_str());
- }
+ if (TEMP_FAILURE_RETRY(fflush(file)) != 0)
+ return;
// fclose cannot be retried, try to close once
- if (fclose(file) != 0) {
- std::string errString = GetErrnoString();
- VcoreLogD("Failed scoped fclose error: %s", errString.c_str());
- }
+ if (fclose(file) != 0)
+ return;
}
}
};
#ifndef DPL_SINGLETON_H
#define DPL_SINGLETON_H
-#include <boost/optional.hpp>
-#include <dpl/thread.h>
-#include <dpl/assert.h>
-
namespace VcoreDPL {
template<typename Class>
class Singleton :
Singleton()
{}
- typedef boost::optional<Thread *> OptionalThreadPtr;
-
static Singleton &InternalInstance();
public:
#ifndef DPL_SINGLETON_IMPL_H
#define DPL_SINGLETON_IMPL_H
+#include <dpl/singleton.h>
+
/*
* WARNING!
*
}
} // namespace VcoreDPL
-#define IMPLEMENT_SINGLETON(Type) \
- template VcoreDPL::Singleton<Type>&VcoreDPL::Singleton<Type>::InternalInstance(); \
+#define IMPLEMENT_SINGLETON(Type) \
+ template VcoreDPL::Singleton<Type>&VcoreDPL::Singleton<Type>::InternalInstance(); \
template Type & VcoreDPL::Singleton<Type>::Instance(); \
#endif // DPL_SINGLETON_IMPL_H
#include <dpl/assert.h>
#include <dpl/colors.h>
#include <dpl/exception.h>
-#include <dpl/log/vcore_log.h>
+#include <dpl/log/log.h>
namespace VcoreDPL {
void AssertProc(const char *condition,
const char *function)
{
-#define INTERNAL_LOG(message) \
-do { \
- std::ostringstream platformLog; \
- platformLog << message; \
- VcoreLogD("%s", platformLog.str().c_str()); \
+#define INTERNAL_LOG(message) \
+do { \
+ std::ostringstream platformLog; \
+ platformLog << message; \
+ LogDebug("" << platformLog.str()); \
} while (0)
// Try to log failed assertion to log system
*/
#include <stddef.h>
#include <dpl/exception.h>
-#include <dpl/log/vcore_log.h>
+#include <dpl/log/log.h>
#include <cstdio>
namespace VcoreDPL {
void LogUnhandledException(const std::string &str)
{
- // Logging to dlog
- VcoreLogD("%s", str.c_str());
+ LogDebug("" << str);
}
void LogUnhandledException(const std::string &str,
int line,
const char *function)
{
- // Logging to dlog
- VcoreLogE("Exception occured on file[%s] line[%d] function[%s] msg[%s]",
- filename, line, function, str.c_str());
+ LogError("Exception occured on file[" << filename
+ << "] line[" << line
+ << "] function[" << function
+ << "] msg[" << str << "]");
}
} // namespace VcoreDPL
* limitations under the License.
*/
/*
- * @file generic_event.cpp
+ * @file singleton.cpp
* @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
* @version 1.0
* @brief This file is the implementation file of singleton
#include <dpl/char_traits.h>
#include <dpl/errno_string.h>
#include <dpl/exception.h>
-#include <dpl/log/vcore_log.h>
+#include <dpl/log/log.h>
#include <string>
#include <vector>
#include <algorithm>
error == U_BUFFER_OVERFLOW_ERROR)
{
// What buffer size is ok ?
- VcoreLogD("ICU: Output buffer size: %i", size);
+ LogDebug("ICU: Output buffer size: " << size);
} else {
ThrowMsg(StringException::ICUInvalidCharacterFound,
"ICU: Failed to retrieve output string size. Error: "
*/
#include <stddef.h>
#include <dpl/thread.h>
-#include <dpl/log/vcore_log.h>
+#include <dpl/log/log.h>
#include <sys/time.h>
#include <algorithm>
#include <dpl/assert.h>
void *Thread::StaticThreadEntry(void *param)
{
- VcoreLogD("Entered static thread entry");
+ LogDebug("Entered static thread entry");
// Retrieve context
Thread *This = static_cast<Thread *>(param);
int result = pthread_setspecific(g_threadSpecific.threadSpecific, This);
if (result)
- VcoreLogE("Failed to set threadSpecific.");
+ LogError("Failed to set threadSpecific.");
// Enter thread proc
// Do not allow exceptions to hit pthread core
// Abandon thread
if (This->m_abandon) {
- VcoreLogD("Thread was abandoned");
+ LogDebug("Thread was abandoned");
This->m_thread.detach();
} else {
- VcoreLogD("Thread is joinable");
+ LogDebug("Thread is joinable");
}
}
int Thread::ThreadEntry()
{
- VcoreLogD("Entered default thread entry");
+ LogDebug("Entered default thread entry");
return Exec();
}
void Thread::ProcessEvents()
{
- VcoreLogD("Processing events");
+ LogDebug("Processing events");
// Steal current event list
InternalEventList stolenEvents;
}
// Process event list
- VcoreLogD("Stolen %u internal events", stolenEvents.size());
+ LogDebug("Stolen " << stolenEvents.size() << " internal events");
for (InternalEventList::iterator iterator = stolenEvents.begin();
iterator != stolenEvents.end();
unsigned long currentTimeMiliseconds = GetCurrentTimeMiliseconds();
// Info
- VcoreLogD("Processing timed events. Time now: %lu ms", currentTimeMiliseconds);
+ LogDebug("Processing timed events. Time now: " << currentTimeMiliseconds << " ms");
// All timed events are sorted chronologically
// Emit timed out events
m_timedEventVector.begin()->dueTimeMiliseconds)
{
// Info
- VcoreLogD("Transforming timed event into immediate event. Absolute due time: %lu ms",
+ LogDebug("Transforming timed event into immediate event. Absolute due time: " <<
(m_timedEventVector.begin()->registerTimeMiliseconds +
- m_timedEventVector.begin()->dueTimeMiliseconds));
+ m_timedEventVector.begin()->dueTimeMiliseconds) << " ms");
// Emit immediate event
PushEvent(m_timedEventVector.begin()->event,
int Thread::Exec()
{
- VcoreLogD("Executing thread event processing");
+ LogDebug("Executing thread event processing");
const std::size_t MIN_HANDLE_LIST_SIZE = 4;
}
// Info
- VcoreLogD("Thread loop minimum wait time: %lu ms", minimumWaitTime);
+ LogDebug("Thread loop minimum wait time: " << minimumWaitTime << " ms");
// Do thread waiting
WaitableHandleIndexList waitableHandleIndexList =
if (waitableHandleIndexList.empty()) {
// Timeout occurred. Process timed events.
- VcoreLogD("Timed event list elapsed invoker");
+ LogDebug("Timed event list elapsed invoker");
ProcessTimedEvents();
continue;
}
{
size_t index = *waitableHandleIndexIterator;
- VcoreLogD("Event loop triggered with index: %u", index);
+ LogDebug("Event loop triggered with index: " << index);
switch (index) {
case 0:
if (m_directInvoke) {
m_directInvoke = false;
- VcoreLogD("Handling direct invoker");
+ LogDebug("Handling direct invoker");
// Update list
while (handleList.size() > MIN_HANDLE_LIST_SIZE) {
case 2:
// Timed event list changed
- VcoreLogD("Timed event list changed invoker");
+ LogDebug("Timed event list changed invoker");
ProcessTimedEvents();
// Reset timed event invoker
case 3:
// Waitable handle watch support invoker
- VcoreLogD("Waitable handle watch invoker event occurred");
+ LogDebug("Waitable handle watch invoker event occurred");
// First, remove all previous handles
while (handleList.size() > MIN_HANDLE_LIST_SIZE) {
// Handle invoker in waitable watch support
WaitableHandleWatchSupport::InvokerFinished();
- VcoreLogD("Waitable handle watch invoker event handled");
+ LogDebug("Waitable handle watch invoker event handled");
// Done
break;
default:
// Waitable event watch list
- VcoreLogD("Waitable handle watch event occurred");
+ LogDebug("Waitable handle watch event occurred");
// Handle event in waitable handle watch
{
if (m_directInvoke) {
m_directInvoke = false;
- VcoreLogD("Handling direct invoker");
+ LogDebug("Handling direct invoker");
// Update list
while (handleList.size() > MIN_HANDLE_LIST_SIZE) {
}
}
- VcoreLogD("Waitable handle watch event handled");
+ LogDebug("Waitable handle watch event handled");
// Done
break;
}
}
- VcoreLogD("Leaving thread event processing");
+ LogDebug("Leaving thread event processing");
return 0;
}
void Thread::Run()
{
- VcoreLogD("Running thread");
+ LogDebug("Running thread");
// Critical section
{
m_running = true;
}
- VcoreLogD("Thread run");
+ LogDebug("Thread run");
}
void Thread::Quit()
return;
}
- VcoreLogD("Quitting thread...");
+ LogDebug("Quitting thread...");
// Do not abandon thread, we will join
m_abandon = false;
Throw(Exception::QuitFailed);
}
- VcoreLogD("Thread quit");
+ LogDebug("Thread quit");
}
void Thread::PushEvent(void *event,
// Trigger invoker
m_eventInvoker.Signal();
- VcoreLogD("Event pushed and invoker signaled");
+ LogDebug("Event pushed and invoker signaled");
}
void Thread::PushTimedEvent(void *event,
// Trigger invoker
m_timedEventInvoker.Signal();
- VcoreLogD("Timed event pushed and invoker signaled: "
- "due time: %lu ms, absolute due time: %lu ms",
- dueTimeMiliseconds, currentTimeMiliseconds + dueTimeMiliseconds);
+ LogDebug("Timed event pushed and invoker signaled: "
+ "due time: " << dueTimeMiliseconds << " ms, absolute due time: " <<
+ (currentTimeMiliseconds + dueTimeMiliseconds) << " ms");
}
Thread *Thread::GetInvokerThread()
#include <stddef.h>
#include <dpl/waitable_handle_watch_support.h>
#include <dpl/thread.h>
-#include <dpl/log/vcore_log.h>
+#include <dpl/log/log.h>
#include <algorithm>
#include <dpl/assert.h>
{
// Developer assertions
if (!m_watchersMap.empty()) {
- VcoreLogW("### Leaked watchers map dump ###");
+ LogWarning("### Leaked watchers map dump ###");
for (WaitableHandleWatchersMap::const_iterator iterator =
m_watchersMap.begin();
iterator != m_watchersMap.end();
++iterator)
{
- VcoreLogW("### Waitable handle: %i", iterator->first);
+ LogWarning("### Waitable handle: " << iterator->first);
- VcoreLogW("### Read listeners: %u", iterator->second.readListenersCount);
- VcoreLogW("### Write listeners: %u", iterator->second.writeListenersCount);
+ LogWarning("### Read listeners: " << iterator->second.readListenersCount);
+ LogWarning("### Write listeners: " << iterator->second.writeListenersCount);
for (WaitableHandleListenerList::const_iterator listenersIterator =
iterator->second.listeners.begin();
listenersIterator != iterator->second.listeners.end();
++listenersIterator)
{
- VcoreLogW("### Mode: %i. Listener: %p",
- listenersIterator->mode, listenersIterator->listener);
+ LogWarning("### Mode: " << listenersIterator->mode
+ << ". Listener: " << listenersIterator->listener);
}
}
}
void WaitableHandleWatchSupport::InvokerFinished()
{
- VcoreLogD("Invoker finished called");
+ LogDebug("Invoker finished called");
// Reset invoker
m_watchersInvoker.Reset();
// Warning: Listeners and/or watcher may also disappear during dispatching
// handlers!
//
- VcoreLogD("Waitable event occurred");
+ LogDebug("Waitable event occurred");
// Critical section for other threads
{
if (m_watchersMap.find(trackedWatchersIterator->first) ==
m_watchersMap.end())
{
- VcoreLogD("Watcher disappeared during watcher handler");
+ LogDebug("Watcher disappeared during watcher handler");
continue;
}
WaitableHandleListenerList trackedListeners =
trackedWatchersIterator->second.listeners;
- VcoreLogD("Calling waitable event listeners (%u)...",
- trackedListeners.size());
+ LogDebug("Calling waitable event listeners (" << trackedListeners.size() << ")...");
// Notice: We must carefully call listeners here as they may
// disappear or be created during each of handler call
if (m_watchersMap.find(trackedWatchersIterator->first) ==
m_watchersMap.end())
{
- VcoreLogD("Watcher disappeared during watcher handler");
+ LogDebug("Watcher disappeared during watcher handler");
break;
}
}
if (!listenerStillExists) {
- VcoreLogD("Watcher listener disappeared during watcher handler");
+ LogDebug("Watcher listener disappeared during watcher handler");
break;
}
}
// Call waitable event watch listener
- VcoreLogD("Before tracker listener call...");
+ LogDebug("Before tracker listener call...");
trackedListenersIterator->listener->OnWaitableHandleEvent(
trackedWatchersIterator->first,
trackedListenersIterator->mode);
- VcoreLogD("After tracker listener call...");
+ LogDebug("After tracker listener call...");
}
// Now call all those listeners who registered during listener calls
// FIXME: Implement! Notice, that scenario may be recursive!
- VcoreLogD("Waitable event listeners called");
+ LogDebug("Waitable event listeners called");
// No more waitable events possible - consistency check
break;
}
}
- VcoreLogD("Adding waitable handle watch: %i", waitableHandle);
+ LogDebug("Adding waitable handle watch : " << waitableHandle);
// Push new waitable event watch
if (mapIterator != m_watchersMap.end()) {
// Trigger waitable event invoker to commit changes
CommitInvoker();
- VcoreLogD("Waitable event watch added and invoker signaled");
+ LogDebug("Waitable event watch added and invoker signaled");
}
void WaitableHandleWatchSupport::RemoveWaitableHandleWatch(
// Same pair listener-mode must exist
Assert(listIterator != mapIterator->second.listeners.end());
- VcoreLogD("Removing waitable handle watch: %i", waitableHandle);
+ LogDebug("Removing waitable handle watch : " << waitableHandle);
// Remove waitable event watch
mapIterator->second.listeners.erase(listIterator);
// Trigger waitable event invoker to commit changes
CommitInvoker();
- VcoreLogD("Waitable event watch removed and invoker signaled");
+ LogDebug("Waitable event watch removed and invoker signaled");
}
void WaitableHandleWatchSupport::CommitInvoker()
{
// Check calling context and execute invoker
if (Thread::GetCurrentThread() == GetInvokerThread()) {
- VcoreLogD("Calling direct invoker");
+ LogDebug("Calling direct invoker");
// Direct invoker call
HandleDirectInvoker();
} else {
- VcoreLogD("Calling indirect invoker");
+ LogDebug("Calling indirect invoker");
// Indirect invoker call
m_watchersInvoker.Signal();
this->m_command = TableDefinition::AllocTableDataCommand(
this->m_commandString.c_str(),
Query<TableDefinition>::m_interface);
- VcoreLogD("Prepared SQL command %s", this->m_commandString.c_str());
+ LogDebug("Prepared SQL command " << this->m_commandString);
}
}
this->m_commandString += " ( " + visitor.m_columnNames + " ) ";
this->m_commandString += "VALUES ( " + visitor.m_values + " )";
- VcoreLogD("Prepared SQL command %s", this->m_commandString.c_str());
+ LogDebug("Prepared SQL command " << this->m_commandString);
this->m_command = TableDefinition::AllocTableDataCommand(
this->m_commandString.c_str(),
Query<TableDefinition>::m_interface);
this->m_commandString.c_str(),
Query<TableDefinition>::m_interface);
- VcoreLogD("Prepared SQL command %s", this->m_commandString.c_str());
+ LogDebug("Prepared SQL command " << this->m_commandString);
}
}
this->m_command = TableDefinition::AllocTableDataCommand(
this->m_commandString.c_str(),
Query<TableDefinition>::m_interface);
- VcoreLogD("Prepared SQL command %s", this->m_commandString.c_str());
+ LogDebug("Prepared SQL command " << this->m_commandString);
}
}
}
// Destroy connection
- VcoreLogD("Destroying thread database connection: %s", m_address.c_str());
+ LogDebug("Destroying thread database connection: " << m_address);
delete *Connection();
void TransactionUnref()
{
- VcoreLogD("Unref transaction");
+ LogDebug("Unref transaction");
if (--(*TransactionDepth()) == 0) {
- VcoreLogD("Transaction is finalized");
+ LogDebug("Transaction is finalized");
if (*TransactionCancel()) {
- VcoreLogD("Transaction will be rolled back");
+ LogDebug("Transaction will be rolled back");
(*Connection())->RollbackTransaction();
} else {
- VcoreLogD("Transaction will be commited");
+ LogDebug("Transaction will be commited");
(*Connection())->CommitTransaction();
}
}
}
// Initialize SQL connection described in traits
- VcoreLogD("Attaching thread database connection: %s", m_address.c_str());
+ LogDebug("Attaching thread database connection: " << m_address);
Connection() = new VcoreDPL::DB::SqlConnection(
m_address.c_str(), m_flags, options);
// It must not be in linger state yet
Assert(*Linger() == false);
- VcoreLogD("Detaching thread database connection: %s", m_address.c_str());
+ LogDebug("Detaching thread database connection: " << m_address);
// Enter linger state
*Linger() = true;
// Calling thread must support thread database connections
Assert(!Connection().IsNull());
- VcoreLogD("Begin transaction");
+ LogDebug("Begin transaction");
// Addref transaction
if (++(*TransactionDepth()) == 1) {
- VcoreLogD("Transaction is initialized");
+ LogDebug("Transaction is initialized");
TransactionCancel() = false;
(*Connection())->BeginTransaction();
// Calling thread must support thread database connections
Assert(!Connection().IsNull());
- VcoreLogD("Commit transaction");
+ LogDebug("Commit transaction");
// Unref transation
TransactionUnref();
#include <memory>
#include <dpl/noncopyable.h>
#include <dpl/assert.h>
+#include <dpl/log/log.h>
#include <unistd.h>
#include <cstdio>
#include <cstdarg>
return;
}
- VcoreLogD("Notifying after successful synchronize");
+ LogDebug("Notifying after successful synchronize");
m_synchronizationObject->NotifyAll();
}
};
&m_stmt, NULL);
if (ret == SQLITE_OK) {
- VcoreLogD("Data command prepared successfuly");
+ LogDebug("Data command prepared successfuly");
break;
} else if (ret == SQLITE_BUSY) {
- VcoreLogD("Collision occurred while preparing SQL command");
+ LogDebug("Collision occurred while preparing SQL command");
// Synchronize if synchronization object is available
if (connection->m_synchronizationObject) {
- VcoreLogD("Performing synchronization");
+ LogDebug("Performing synchronization");
connection->m_synchronizationObject->Synchronize();
continue;
}
// Fatal error
const char *error = sqlite3_errmsg(m_masterConnection->m_connection);
- VcoreLogD("SQL prepare data command failed");
- VcoreLogD(" Statement: %s", buffer);
- VcoreLogD(" Error: %s", error);
+ LogDebug("SQL prepare data command failed");
+ LogDebug(" Statement : " << buffer);
+ LogDebug(" Error : " << error);
ThrowMsg(Exception::SyntaxError, error);
}
- VcoreLogD("Prepared data command: %s", buffer);
+ LogDebug("Prepared data command : " << buffer);
// Increment stored data command count
++m_masterConnection->m_dataCommandsCount;
SqlConnection::DataCommand::~DataCommand()
{
- VcoreLogD("SQL data command finalizing");
+ LogDebug("SQL data command finalizing");
if (sqlite3_finalize(m_stmt) != SQLITE_OK) {
- VcoreLogD("Failed to finalize data command");
+ LogDebug("Failed to finalize data command");
}
// Decrement stored data command count
const char *error = sqlite3_errmsg(
m_masterConnection->m_connection);
- VcoreLogD("Failed to bind SQL statement parameter");
- VcoreLogD(" Error: %s", error);
+ LogDebug("Failed to bind SQL statement parameter");
+ LogDebug(" Error : " << error);
ThrowMsg(Exception::SyntaxError, error);
}
SqlConnection::ArgumentIndex position)
{
CheckBindResult(sqlite3_bind_null(m_stmt, position));
- VcoreLogD("SQL data command bind null: [%i]", position);
+ LogDebug("SQL data command bind null: [" << position << "]");
}
void SqlConnection::DataCommand::BindInteger(
int value)
{
CheckBindResult(sqlite3_bind_int(m_stmt, position, value));
- VcoreLogD("SQL data command bind integer: [%i] -> %i", position, value);
+ LogDebug("SQL data command bind integer: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindInt8(
{
CheckBindResult(sqlite3_bind_int(m_stmt, position,
static_cast<int>(value)));
- VcoreLogD("SQL data command bind int8: [%i] -> %i", position, value);
+ LogDebug("SQL data command bind int8: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindInt16(
{
CheckBindResult(sqlite3_bind_int(m_stmt, position,
static_cast<int>(value)));
- VcoreLogD("SQL data command bind int16: [%i] -> %i", position, value);
-}
+ LogDebug("SQL data command bind int16: [" << position << "] -> " << value);}
void SqlConnection::DataCommand::BindInt32(
SqlConnection::ArgumentIndex position,
{
CheckBindResult(sqlite3_bind_int(m_stmt, position,
static_cast<int>(value)));
- VcoreLogD("SQL data command bind int32: [%i] -> %i", position, value);
+ LogDebug("SQL data command bind int32: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindInt64(
{
CheckBindResult(sqlite3_bind_int64(m_stmt, position,
static_cast<sqlite3_int64>(value)));
- VcoreLogD("SQL data command bind int64: [%i] -> %lli", position, value);
+ LogDebug("SQL data command bind int64: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindFloat(
{
CheckBindResult(sqlite3_bind_double(m_stmt, position,
static_cast<double>(value)));
- VcoreLogD("SQL data command bind float: [%i] -> %f", position, value);
+ LogDebug("SQL data command bind float: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindDouble(
double value)
{
CheckBindResult(sqlite3_bind_double(m_stmt, position, value));
- VcoreLogD("SQL data command bind double: [%i] -> %f", position, value);
+ LogDebug("SQL data command bind double: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindString(
value, strlen(value),
SQLITE_TRANSIENT));
- VcoreLogD("SQL data command bind string: [%i] -> %s", position, value);
+ LogDebug("SQL data command bind string: [" << position << "] -> " << value);
}
void SqlConnection::DataCommand::BindString(
int ret = sqlite3_step(m_stmt);
if (ret == SQLITE_ROW) {
- VcoreLogD("SQL data command step ROW");
+ LogDebug("SQL data command step ROW");
return true;
} else if (ret == SQLITE_DONE) {
- VcoreLogD("SQL data command step DONE");
+ LogDebug("SQL data command step DONE");
return false;
} else if (ret == SQLITE_BUSY) {
- VcoreLogD("Collision occurred while executing SQL command");
+ LogDebug("Collision occurred while executing SQL command");
// Synchronize if synchronization object is available
if (m_masterConnection->m_synchronizationObject) {
- VcoreLogD("Performing synchronization");
+ LogDebug("Performing synchronization");
m_masterConnection->
m_synchronizationObject->Synchronize();
// Fatal error
const char *error = sqlite3_errmsg(m_masterConnection->m_connection);
- VcoreLogD("SQL step data command failed");
- VcoreLogD(" Error: %s", error);
+ LogDebug("SQL step data command failed");
+ LogDebug(" Error : " << error);
ThrowMsg(Exception::InternalError, error);
}
*/
sqlite3_reset(m_stmt);
- VcoreLogD("SQL data command reset");
+ LogDebug("SQL data command reset");
}
void SqlConnection::DataCommand::CheckColumnIndex(
bool SqlConnection::DataCommand::IsColumnNull(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column type: [%i]", column);
+ LogDebug("SQL data command get column type: [" << column << "]");
CheckColumnIndex(column);
return sqlite3_column_type(m_stmt, column) == SQLITE_NULL;
}
int SqlConnection::DataCommand::GetColumnInteger(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column integer: [%i]", column);
+ LogDebug("SQL data command get column integer: [" << column << "]");
CheckColumnIndex(column);
int value = sqlite3_column_int(m_stmt, column);
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return value;
}
int8_t SqlConnection::DataCommand::GetColumnInt8(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column int8: [%i]", column);
+ LogDebug("SQL data command get column int8: [" << column << "]");
CheckColumnIndex(column);
int8_t value = static_cast<int8_t>(sqlite3_column_int(m_stmt, column));
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return value;
}
int16_t SqlConnection::DataCommand::GetColumnInt16(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column int16: [%i]", column);
+ LgDebug("SQL data command get column int16: [" << column << "]");
CheckColumnIndex(column);
int16_t value = static_cast<int16_t>(sqlite3_column_int(m_stmt, column));
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return value;
}
int32_t SqlConnection::DataCommand::GetColumnInt32(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column int32: [%i]", column);
+ LogDebug("SQL data command get column int32: [" << column << "]");
CheckColumnIndex(column);
int32_t value = static_cast<int32_t>(sqlite3_column_int(m_stmt, column));
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return value;
}
int64_t SqlConnection::DataCommand::GetColumnInt64(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column int64: [%i]", column);
+ LogDebug("SQL data command get column int64: [" << column << "]");
CheckColumnIndex(column);
int64_t value = static_cast<int64_t>(sqlite3_column_int64(m_stmt, column));
- VcoreLogD(" Value: %lli", value);
+ LogDebug(" Value : " << value);
return value;
}
float SqlConnection::DataCommand::GetColumnFloat(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column float: [%i]", column);
+ LogDebug("SQL data command get column float: [" << column << "]");
CheckColumnIndex(column);
float value = static_cast<float>(sqlite3_column_double(m_stmt, column));
- VcoreLogD(" Value: %f", value);
+ LogDebug(" Value : " << value);
return value;
}
double SqlConnection::DataCommand::GetColumnDouble(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column double: [%i]", column);
+ LogDebug("SQL data command get column double: [" << column << "]");
CheckColumnIndex(column);
double value = sqlite3_column_double(m_stmt, column);
- VcoreLogD(" Value: %f", value);
+ LogDebug(" Value : " << value);
return value;
}
std::string SqlConnection::DataCommand::GetColumnString(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column string: [%i]", column);
+ LogDebug("SQL data command get column string: [" << column << "]");
CheckColumnIndex(column);
const char *value = reinterpret_cast<const char *>(
sqlite3_column_text(m_stmt, column));
- VcoreLogD(" Value: %s", value);
+ LogDebug(" Value : " << value);
if (value == NULL) {
return std::string();
boost::optional<int> SqlConnection::DataCommand::GetColumnOptionalInteger(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional integer: [%i]", column);
+ LogDebug("SQL data command get column optional integer: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<int>();
}
int value = sqlite3_column_int(m_stmt, column);
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return boost::optional<int>(value);
}
boost::optional<int8_t> SqlConnection::DataCommand::GetColumnOptionalInt8(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional int8: [%i]", column);
+ LogDebug("SQL data command get column optional int8: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<int8_t>();
}
int8_t value = static_cast<int8_t>(sqlite3_column_int(m_stmt, column));
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value: " << value);
return boost::optional<int8_t>(value);
}
boost::optional<int16_t> SqlConnection::DataCommand::GetColumnOptionalInt16(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional int16: [%i]", column);
+ LogDebug("SQL data command get column optional int16: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<int16_t>();
}
int16_t value = static_cast<int16_t>(sqlite3_column_int(m_stmt, column));
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return boost::optional<int16_t>(value);
}
boost::optional<int32_t> SqlConnection::DataCommand::GetColumnOptionalInt32(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional int32: [%i]", column);
+ LogDebug("SQL data command get column optional int32: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<int32_t>();
}
int32_t value = static_cast<int32_t>(sqlite3_column_int(m_stmt, column));
- VcoreLogD(" Value: %i", value);
+ LogDebug(" Value : " << value);
return boost::optional<int32_t>(value);
}
boost::optional<int64_t> SqlConnection::DataCommand::GetColumnOptionalInt64(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional int64: [%i]", column);
+ LogDebug("SQL data command get column optional int64: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<int64_t>();
}
int64_t value = static_cast<int64_t>(sqlite3_column_int64(m_stmt, column));
- VcoreLogD(" Value: %lli", value);
+ LogDebug(" Value : " << value);
return boost::optional<int64_t>(value);
}
boost::optional<float> SqlConnection::DataCommand::GetColumnOptionalFloat(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional float: [%i]", column);
+ LogDebug("SQL data command get column optional float: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<float>();
}
float value = static_cast<float>(sqlite3_column_double(m_stmt, column));
- VcoreLogD(" Value: %f", value);
+ LogDebug(" Value : " << value);
return boost::optional<float>(value);
}
boost::optional<double> SqlConnection::DataCommand::GetColumnOptionalDouble(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional double: [%i]", column);
+ LogDebug("SQL data command get column optional double: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<double>();
}
double value = sqlite3_column_double(m_stmt, column);
- VcoreLogD(" Value: %f", value);
+ LogDebug(" Value : " << value);
return boost::optional<double>(value);
}
boost::optional<String> SqlConnection::DataCommand::GetColumnOptionalString(
SqlConnection::ColumnIndex column)
{
- VcoreLogD("SQL data command get column optional string: [%i]", column);
+ LogDebug("SQL data command get column optional string: [" << column << "]");
CheckColumnIndex(column);
if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
return boost::optional<String>();
}
const char *value = reinterpret_cast<const char *>(
sqlite3_column_text(m_stmt, column));
- VcoreLogD(" Value: %s", value);
+ LogDebug(" Value : " << value);
String s = FromUTF8String(value);
return boost::optional<String>(s);
}
Flag::Option flag)
{
if (m_connection != NULL) {
- VcoreLogD("Already connected.");
+ LogDebug("Already connected.");
return;
}
- VcoreLogD("Connecting to DB: %s...", address.c_str());
+ LogDebug("Connecting to DB: " << address << "...");
// Connect to database
int result;
NULL);
m_usingLucene = true;
- VcoreLogD("Lucene index enabled");
+ LogDebug("Lucene index enabled");
} else {
result = sqlite3_open_v2(
address.c_str(),
NULL);
m_usingLucene = false;
- VcoreLogD("Lucene index disabled");
+ LogDebug("Lucene index disabled");
}
if (result == SQLITE_OK) {
- VcoreLogD("Connected to DB");
+ LogDebug("Connected to DB");
} else {
- VcoreLogD("Failed to connect to DB!");
+ LogDebug("Failed to connect to DB!");
ThrowMsg(Exception::ConnectionBroken, address);
}
void SqlConnection::Disconnect()
{
if (m_connection == NULL) {
- VcoreLogD("Already disconnected.");
+ LogDebug("Already disconnected.");
return;
}
- VcoreLogD("Disconnecting from DB...");
+ LogDebug("Disconnecting from DB...");
// All stored data commands must be deleted before disconnect
AssertMsg(m_dataCommandsCount == 0,
if (result != SQLITE_OK) {
const char *error = sqlite3_errmsg(m_connection);
- VcoreLogD("SQL close failed");
- VcoreLogD(" Error: %s", error);
+ LogDebug("SQL close failed");
+ LogDebug(" Error : " << error);
Throw(Exception::InternalError);
}
m_connection = NULL;
- VcoreLogD("Disconnected from DB");
+ LogDebug("Disconnected from DB");
}
bool SqlConnection::CheckTableExist(const char *tableName)
{
if (m_connection == NULL) {
- VcoreLogD("Cannot execute command. Not connected to DB!");
+ LogDebug("Cannot execute command. Not connected to DB!");
return false;
}
command->BindString(1, tableName);
if (!command->Step()) {
- VcoreLogD("No matching records in table");
+ LogDebug("No matching records in table");
return false;
}
m_dataCommandsCount(0),
m_synchronizationObject(synchronizationObject)
{
- VcoreLogD("Opening database connection to: %s", address.c_str());
+ LogDebug("Opening database connection to : " << address);
// Connect to DB
SqlConnection::Connect(address, flag, option);
if (!m_synchronizationObject) {
- VcoreLogD("No synchronization object defined");
+ LogDebug("No synchronization object defined");
}
}
SqlConnection::~SqlConnection()
{
- VcoreLogD("Closing database connection");
+ LogDebug("Closing database connection");
// Disconnect from DB
Try
}
Catch(Exception::Base)
{
- VcoreLogD("Failed to disconnect from database");
+ LogDebug("Failed to disconnect from database");
}
}
void SqlConnection::ExecCommand(const char *format, ...)
{
if (m_connection == NULL) {
- VcoreLogD("Cannot execute command. Not connected to DB!");
+ LogDebug("Cannot execute command. Not connected to DB!");
return;
}
if (format == NULL) {
- VcoreLogD("Null query!");
+ LogDebug("Null query!");
ThrowMsg(Exception::SyntaxError, "Null statement");
}
std::unique_ptr<char[],free_deleter> buffer(rawBuffer);
if (!buffer) {
- VcoreLogD("Failed to allocate statement string");
+ LogDebug("Failed to allocate statement string");
return;
}
- VcoreLogD("Executing SQL command: %s", buffer.get());
+ LogDebug("Executing SQL command : " << buffer.get());
// Notify all after potentially synchronized database connection access
ScopedNotifyAll notifyAll(m_synchronizationObject.get());
}
if (ret == SQLITE_BUSY) {
- VcoreLogD("Collision occurred while executing SQL command");
+ LogDebug("Collision occurred while executing SQL command");
// Synchronize if synchronization object is available
if (m_synchronizationObject) {
- VcoreLogD("Performing synchronization");
+ LogDebug("Performing synchronization");
m_synchronizationObject->Synchronize();
continue;
}
}
// Fatal error
- VcoreLogD("Failed to execute SQL command. Error: %s", errorMsg.c_str());
+ LogDebug("Failed to execute SQL command. Error : " << errorMsg);
ThrowMsg(Exception::SyntaxError, errorMsg);
}
}
...)
{
if (m_connection == NULL) {
- VcoreLogD("Cannot execute data command. Not connected to DB!");
+ LogDebug("Cannot execute data command. Not connected to DB!");
return DataCommandAutoPtr();
}
std::unique_ptr<char[],free_deleter> buffer(rawBuffer);
if (!buffer) {
- VcoreLogD("Failed to allocate statement string");
+ LogDebug("Failed to allocate statement string");
return DataCommandAutoPtr();
}
- VcoreLogD("Executing SQL data command: %s", buffer.get());
+ LogDebug("Executing SQL data command : " << buffer.get());
return DataCommandAutoPtr(new DataCommand(this, buffer.get()));
}
int mode;
if((pszFilePath == NULL) || (ppDB == NULL)) {
- VcoreLogW("sqlite3 handle null error");
+ LogWarning("sqlite3 handle null error");
return SQLITE_ERROR;
}
if((geteuid() != 0) && (access(pszFilePath, mode))) {
if(errno == EACCES) {
- VcoreLogD("file access permission error");
+ LogDebug("file access permission error");
return SQLITE_PERM;
}
}
/* Open DB */
int rc = sqlite3_open_v2(pszFilePath, ppDB, flags, zVfs);
if (SQLITE_OK != rc) {
- VcoreLogE("sqlite3_open_v2 error(%d)",rc);
+ LogError("sqlite3_open_v2 error(" << rc << ")");
return rc;
}
/* Close DB */
int rc = sqlite3_close(pDB);
if (SQLITE_OK != rc) {
- VcoreLogW("Fail to change journal mode: %s\n", pszErrorMsg);
+ LogWarning("Fail to change journal mode : " << pszErrorMsg);
sqlite3_free(pszErrorMsg);
return rc;
}
namespace Log {
class AbstractLogProvider
{
- public:
+public:
+ enum class LogLevel {
+ None,
+ Error,
+ Warning,
+ Info,
+ Debug,
+ Pedantic
+ };
+
virtual ~AbstractLogProvider() {}
- virtual void Debug(const char *message,
- const char *fileName,
- int line,
- const char *function) = 0;
- virtual void Info(const char *message,
- const char *fileName,
- int line,
- const char *function) = 0;
- virtual void Warning(const char *message,
- const char *fileName,
- int line,
- const char *function) = 0;
- virtual void Error(const char *message,
- const char *fileName,
- int line,
- const char *function) = 0;
- virtual void Pedantic(const char *message,
- const char *fileName,
- int line,
- const char *function) = 0;
+ virtual void SetTag(const char *tag);
+
+ virtual void Log(LogLevel level,
+ const char *message,
+ const char *fileName,
+ int line,
+ const char *function) const = 0;
- protected:
+protected:
static const char *LocateSourceFileName(const char *filename);
};
}
#define DPL_DLOG_LOG_PROVIDER_H
#include <dpl/log/abstract_log_provider.h>
-#include <dpl/scoped_free.h>
-#include <string>
+#include <memory>
namespace VcoreDPL {
namespace Log {
-class DLOGLogProvider :
- public AbstractLogProvider
+class DLOGLogProvider : public AbstractLogProvider
{
- private:
- VcoreDPL::ScopedFree<char> m_tag;
-
- static std::string FormatMessage(const char *message,
- const char *filename,
- int line,
- const char *function);
-
- public:
+public:
DLOGLogProvider();
virtual ~DLOGLogProvider();
- virtual void Debug(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Info(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Warning(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Error(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Pedantic(const char *message,
- const char *fileName,
- int line,
- const char *function);
+ virtual void Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *fileName,
+ int line,
+ const char *function) const;
// Set global Tag according to DLOG
- void SetTag(const char *tag);
+ virtual void SetTag(const char *tag);
+
+private:
+ std::unique_ptr<char[]> m_tag;
+
};
}
} // namespace VcoreDPL
--- /dev/null
+/*
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file journal_log_provider.h
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#pragma once
+
+#include <dpl/log/abstract_log_provider.h>
+
+namespace VcoreDPL {
+namespace Log {
+
+class JournalLogProvider: public AbstractLogProvider
+{
+public:
+ JournalLogProvider();
+ virtual ~JournalLogProvider();
+
+ virtual void Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *fileName,
+ int line,
+ const char *function) const;
+};
+
+} /* namespace Log */
+} /* namespace VcoreDPL */
#ifndef DPL_LOG_H
#define DPL_LOG_H
+#include <sstream>
+#include <list>
+#include <unordered_map>
+#include <string>
+
#include <dpl/singleton.h>
#include <dpl/noncopyable.h>
+
#include <dpl/log/abstract_log_provider.h>
-#include <dpl/log/dlog_log_provider.h>
-#include <dpl/log/old_style_log_provider.h>
-#include <sstream>
-#include <list>
namespace VcoreDPL {
namespace Log {
* To switch logs into old style, export
* DPL_USE_OLD_STYLE_LOGS before application start
*/
-class LogSystem :
- private Noncopyable
+class LogSystem : private Noncopyable
{
- private:
- typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
- AbstractLogProviderPtrList m_providers;
-
- DLOGLogProvider *m_dlogProvider;
- OldStyleLogProvider *m_oldStyleProvider;
-
- bool m_isLoggingEnabled;
-
- public:
- bool IsLoggingEnabled() const;
+public:
LogSystem();
virtual ~LogSystem();
- /**
- * Log debug message
- */
- void Debug(const char *message,
- const char *filename,
- int line,
- const char *function);
-
- /**
- * Log info message
- */
- void Info(const char *message,
- const char *filename,
- int line,
- const char *function);
+ AbstractLogProvider::LogLevel GetLogLevel() const { return m_level; }
- /**
- * Log warning message
- */
- void Warning(const char *message,
- const char *filename,
- int line,
- const char *function);
+ void Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *filename,
+ int line,
+ const char *function) const;
- /**
- * Log error message
- */
- void Error(const char *message,
- const char *filename,
- int line,
- const char *function);
-
- /**
- * Log pedantic message
- */
- void Pedantic(const char *message,
- const char *filename,
- int line,
- const char *function);
/**
* Set default's DLOG provider Tag
* Remove abstract provider from providers list
*/
void RemoveProvider(AbstractLogProvider *provider);
+
+ /**
+ * Selects given provider by name (overwrites environment setting)
+ *
+ * Throws std::out_of_range exception if not found.
+ */
+ void SelectProvider(const std::string& name);
+
+ /**
+ * Sets log level (overwrites environment settings)
+ */
+ void SetLogLevel(const char* level);
+
+private:
+ void RemoveProviders();
+
+ typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
+ AbstractLogProviderPtrList m_providers;
+ AbstractLogProvider::LogLevel m_level;
+
+ typedef AbstractLogProvider *(*ProviderFn)();
+ /*
+ * It cannot be global as it is used in library constructor and we can't be sure which
+ * constructor is called first: library's or new_provider's.
+ */
+ std::unordered_map<std::string, ProviderFn> m_providerCtor;
};
/*
}
} // namespace VcoreDPL
-//
-// Log support
-//
-//
-
-#ifdef DPL_LOGS_ENABLED
- #define DPL_MACRO_FOR_LOGGING(message, function) \
- do \
- { \
- if (VcoreDPL::Log::LogSystemSingleton::Instance().IsLoggingEnabled()) \
- { \
- std::ostringstream platformLog; \
- platformLog << message; \
- VcoreDPL::Log::LogSystemSingleton::Instance().function( \
- platformLog.str().c_str(), \
- __FILE__, __LINE__, __FUNCTION__); \
- } \
- } while (0)
-#else
+
/* avoid warnings about unused variables */
- #define DPL_MACRO_FOR_LOGGING(message, function) \
- do { \
+#define DPL_MACRO_DUMMY_LOGGING(message, level) \
+ do { \
VcoreDPL::Log::NullStream ns; \
- ns << message; \
+ ns << message; \
} while (0)
-#endif
-#define LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug)
-#define LogInfo(message) DPL_MACRO_FOR_LOGGING(message, Info)
-#define LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
-#define LogError(message) DPL_MACRO_FOR_LOGGING(message, Error)
-#define LogPedantic(message) DPL_MACRO_FOR_LOGGING(message, Pedantic)
+#define DPL_MACRO_FOR_LOGGING(message, level) \
+do \
+{ \
+ if (level > VcoreDPL::Log::AbstractLogProvider::LogLevel::None && \
+ VcoreDPL::Log::LogSystemSingleton::Instance().GetLogLevel() >= level) \
+ { \
+ std::ostringstream platformLog; \
+ platformLog << message; \
+ VcoreDPL::Log::LogSystemSingleton::Instance().Log(level, \
+ platformLog.str().c_str(), \
+ __FILE__, \
+ __LINE__, \
+ __FUNCTION__); \
+ } \
+} while (0)
+
+#define LogError(message) DPL_MACRO_FOR_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Error)
+
+#ifdef BUILD_TYPE_DEBUG
+ #define LogDebug(message) DPL_MACRO_FOR_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Debug)
+ #define LogInfo(message) DPL_MACRO_FOR_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Info)
+ #define LogWarning(message) DPL_MACRO_FOR_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Warning)
+ #define LogPedantic(message) DPL_MACRO_FOR_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Pedantic)
+#else
+ #define LogDebug(message) DPL_MACRO_DUMMY_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Debug)
+ #define LogInfo(message) DPL_MACRO_DUMMY_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Info)
+ #define LogWarning(message) DPL_MACRO_DUMMY_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Warning)
+ #define LogPedantic(message) DPL_MACRO_DUMMY_LOGGING(message, VcoreDPL::Log::AbstractLogProvider::LogLevel::Pedantic)
+#endif // BUILD_TYPE_DEBUG
#endif // DPL_LOG_H
#define DPL_OLD_STYLE_LOG_PROVIDER_H
#include <dpl/log/abstract_log_provider.h>
-#include <string>
namespace VcoreDPL {
namespace Log {
-class OldStyleLogProvider :
- public AbstractLogProvider
+class OldStyleLogProvider : public AbstractLogProvider
{
- private:
- bool m_showDebug;
- bool m_showInfo;
- bool m_showWarning;
- bool m_showError;
- bool m_showPedantic;
- bool m_printStdErr;
-
- static std::string FormatMessage(const char *message,
- const char *filename,
- int line,
- const char *function);
-
- public:
- OldStyleLogProvider(bool showDebug,
- bool showInfo,
- bool showWarning,
- bool showError,
- bool showPedantic);
- OldStyleLogProvider(bool showDebug,
- bool showInfo,
- bool showWarning,
- bool showError,
- bool showPedantic,
- bool printStdErr);
+public:
+ OldStyleLogProvider();
virtual ~OldStyleLogProvider() {}
- virtual void Debug(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Info(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Warning(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Error(const char *message,
- const char *fileName,
- int line,
- const char *function);
- virtual void Pedantic(const char *message,
- const char *fileName,
- int line,
- const char *function);
+ virtual void Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *fileName,
+ int line,
+ const char *function) const;
};
}
} // namespace VcoreDPL
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef VCORE_LOG_H
-#define VCORE_LOG_H
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "CERT_SVC_VCORE"
-
-#include <dlog.h>
-
-#define COLOR_ERROR "\033[38;5;160;1m" // bold red
-#define COLOR_WARNING "\033[38;5;202;1m" // bold orange
-#define COLOR_INFO "\033[38;5;243;1m" // bold light gray
-#define COLOR_DEBUG "\033[38;5;243;0m" // normal light gray
-#define COLOR_END "\033[0m"
-
-#define INTERNAL_SECURE_LOG __extension__ SECURE_SLOG
-#define VCORE_LOG(priority, color, format, ...) \
-do { \
- INTERNAL_SECURE_LOG(priority, LOG_TAG, color format "%s", __VA_ARGS__); \
-} while(0)
-
-
-/*
- * Please use following macros
- */
-#define VcoreLogD(...) VCORE_LOG(LOG_DEBUG, COLOR_DEBUG, __VA_ARGS__, COLOR_END)
-#define VcoreLogI(...) VCORE_LOG(LOG_INFO, COLOR_INFO, __VA_ARGS__, COLOR_END)
-#define VcoreLogW(...) VCORE_LOG(LOG_WARN, COLOR_WARNING, __VA_ARGS__, COLOR_END)
-#define VcoreLogE(...) VCORE_LOG(LOG_ERROR, COLOR_ERROR, __VA_ARGS__, COLOR_END)
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef VCORE_WRT_LOG_H
-#define VCORE_WRT_LOG_H
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "CERT_SVC_VCORE"
-
-#include <dlog.h>
-
-#define COLOR_ERROR "\033[38;5;160;1m" // bold red
-#define COLOR_WARNING "\033[38;5;202;1m" // bold orange
-#define COLOR_INFO "\033[38;5;243;1m" // bold light gray
-#define COLOR_DEBUG "\033[38;5;243;0m" // normal light gray
-#define COLOR_END "\033[0m"
-
-#define INTERNAL_SECURE_LOG __extension__ SECURE_SLOG
-#define WRT_LOG(priority, color, format, ...) \
-do { \
- INTERNAL_SECURE_LOG(priority, LOG_TAG, color format "%s", __VA_ARGS__); \
-} while(0)
-
-
-/*
- * Please use following macros
- */
-#define WrtLogD(...) WRT_LOG(LOG_DEBUG, COLOR_DEBUG, __VA_ARGS__, COLOR_END)
-#define WrtLogI(...) WRT_LOG(LOG_INFO, COLOR_INFO, __VA_ARGS__, COLOR_END)
-#define WrtLogW(...) WRT_LOG(LOG_WARN, COLOR_WARNING, __VA_ARGS__, COLOR_END)
-#define WrtLogE(...) WRT_LOG(LOG_ERROR, COLOR_ERROR, __VA_ARGS__, COLOR_END)
-
-#endif
namespace VcoreDPL {
namespace Log {
+
+void AbstractLogProvider::SetTag(const char *) {}
+
const char *AbstractLogProvider::LocateSourceFileName(const char *filename)
{
const char *ptr = strrchr(filename, '/');
* @brief This file is the implementation file of DLOG log provider
*/
#include <stddef.h>
-#include <dpl/log/dlog_log_provider.h>
#include <cstring>
#include <sstream>
-#include <dlog.h>
+#include <map>
+#include <stdexcept>
-#ifdef SECURE_LOG
- #define INTERNAL_DLP_LOG_ SECURE_LOG
-#else
- #define INTERNAL_DLP_LOG_ LOG
-#endif
+#include <dlog.h>
-/*
- * The __extension__ keyword in the following define is required because
- * macros used here from dlog.h use non-standard extension that cause
- * gcc to show unwanted warnings when compiling with -pedantic switch.
- */
-#define INTERNAL_DLP_LOG __extension__ INTERNAL_DLP_LOG_
+#include <dpl/log/dlog_log_provider.h>
namespace VcoreDPL {
namespace Log {
-std::string DLOGLogProvider::FormatMessage(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- std::ostringstream val;
- val << std::string("[") <<
- LocateSourceFileName(filename) << std::string(":") << line <<
- std::string("] ") << function << std::string("(): ") << message;
+namespace {
+typedef void (*dlogMacro)(const char *, const char *);
- return val.str();
+void error(const char *tag, const char *msg)
+{
+ SLOG(LOG_ERROR, tag, "%s", msg);
}
-DLOGLogProvider::DLOGLogProvider()
-{}
-
-DLOGLogProvider::~DLOGLogProvider()
-{}
-
-void DLOGLogProvider::SetTag(const char *tag)
+void warning(const char *tag, const char *msg)
{
- m_tag.Reset(strdup(tag));
+ SLOG(LOG_WARN, tag, "%s", msg);
}
-void DLOGLogProvider::Debug(const char *message,
- const char *filename,
- int line,
- const char *function)
+void info(const char *tag, const char *msg)
{
- INTERNAL_DLP_LOG(LOG_DEBUG, m_tag.Get(), "%s",
- FormatMessage(message, filename, line, function).c_str());
+ SLOG(LOG_INFO, tag, "%s", msg);
}
-void DLOGLogProvider::Info(const char *message,
- const char *filename,
- int line,
- const char *function)
+void debug(const char *tag, const char *msg)
{
- INTERNAL_DLP_LOG(LOG_INFO, m_tag.Get(), "%s",
- FormatMessage(message, filename, line, function).c_str());
+ SLOG(LOG_DEBUG, tag, "%s", msg);
}
-void DLOGLogProvider::Warning(const char *message,
- const char *filename,
- int line,
- const char *function)
+void pedantic(const char *tag, const char *msg)
{
- INTERNAL_DLP_LOG(LOG_WARN, m_tag.Get(), "%s",
- FormatMessage(message, filename, line, function).c_str());
+ SLOG(LOG_VERBOSE, tag, "%s", msg);
}
-void DLOGLogProvider::Error(const char *message,
- const char *filename,
- int line,
- const char *function)
+std::map<AbstractLogProvider::LogLevel, dlogMacro> dlogMacros = {
+ // [](const char* tag, const char* msg) { SLOG(LOG_ERROR, tag, "%s", msg); } won't compile
+ { AbstractLogProvider::LogLevel::Error, error },
+ { AbstractLogProvider::LogLevel::Warning, warning },
+ { AbstractLogProvider::LogLevel::Info, info },
+ { AbstractLogProvider::LogLevel::Debug, debug},
+ { AbstractLogProvider::LogLevel::Pedantic, pedantic}
+};
+
+} // namespace anonymous
+
+DLOGLogProvider::DLOGLogProvider()
+{}
+
+DLOGLogProvider::~DLOGLogProvider()
+{}
+
+void DLOGLogProvider::SetTag(const char *tag)
{
- INTERNAL_DLP_LOG(LOG_ERROR, m_tag.Get(), "%s",
- FormatMessage(message, filename, line, function).c_str());
+ size_t size = strlen(tag)+1;
+ char *buff = new (std::nothrow) char[size];
+ if (buff)
+ memcpy(buff, tag, size);
+ m_tag.reset(buff);
}
-void DLOGLogProvider::Pedantic(const char *message,
- const char *filename,
- int line,
- const char *function)
+void DLOGLogProvider::Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *filename,
+ int line,
+ const char *function) const
{
- INTERNAL_DLP_LOG(LOG_DEBUG, "DPL", "%s",
- FormatMessage(message, filename, line, function).c_str());
+ std::ostringstream val;
+ val << std::string("[") << LocateSourceFileName(filename) << std::string(":") << line <<
+ std::string("] ") << function << std::string("(): ") << message;
+
+ try {
+ dlogMacros.at(level)(m_tag.get(), val.str().c_str());
+ } catch (const std::out_of_range&) {
+ SLOG(LOG_ERROR, m_tag.get(), "Unsupported log level: %d", level);
+ }
}
}
} // namespace VcoreDPL
-
-#undef INTERNAL_DLP_LOG
-#undef INTERNAL_DLP_LOG_
-
--- /dev/null
+/*
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file journal_log_provider.cpp
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#include <dpl/log/journal_log_provider.h>
+#include <systemd/sd-journal.h>
+#include <map>
+#include <stdexcept>
+
+namespace VcoreDPL {
+namespace Log {
+
+namespace {
+std::map<AbstractLogProvider::LogLevel, int> journalLevel = {
+ { AbstractLogProvider::LogLevel::Error, LOG_ERR },
+ { AbstractLogProvider::LogLevel::Warning, LOG_WARNING },
+ { AbstractLogProvider::LogLevel::Info, LOG_INFO },
+ { AbstractLogProvider::LogLevel::Debug, LOG_DEBUG },
+ { AbstractLogProvider::LogLevel::Pedantic, LOG_DEBUG }
+};
+
+} // namespace anonymous
+
+JournalLogProvider::JournalLogProvider()
+{}
+
+JournalLogProvider::~JournalLogProvider()
+{}
+
+void JournalLogProvider::Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *fileName,
+ int line,
+ const char *function) const
+{
+ try {
+ sd_journal_send("PRIORITY=%d", journalLevel.at(level),
+ "CODE_FILE=%s", fileName,
+ "CODE_FUNC=%s", function,
+ "CODE_LINE=%d", line,
+ // add file, line & function info to log message
+ "MESSAGE=[%s:%d] %s(): %s", fileName, line, function, message,
+ NULL);
+ } catch (const std::out_of_range&) {
+ sd_journal_send(
+ "PRIORITY=%d", LOG_ERR,
+ "CODE_FILE=%s", fileName,
+ "CODE_FUNC=%s", function,
+ "CODE_LINE=%d", line,
+ // add file, line & function info to log message
+ "MESSAGE=[%s:%d] %s(): Unsupported log level %d", fileName, line, function, level,
+ NULL);
+ }
+}
+
+} /* namespace Log */
+} /* namespace VcoreDPL */
* @brief This file is the implementation file of log system
*/
#include <stddef.h>
-#include <dpl/log/log.h>
+#include <string.h>
+#include <stdexcept>
+#include <cassert>
+
#include <dpl/singleton_impl.h>
+#include <dpl/log/old_style_log_provider.h>
+#include <dpl/log/dlog_log_provider.h>
+#include <dpl/log/journal_log_provider.h>
+
+#include <dpl/log/log.h>
IMPLEMENT_SINGLETON(VcoreDPL::Log::LogSystem)
namespace Log {
namespace // anonymous
{
-const char *OLD_STYLE_LOGS_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS";
-const char *OLD_STYLE_PEDANTIC_LOGS_ENV_NAME =
- "DPL_USE_OLD_STYLE_PEDANTIC_LOGS";
-const char *OLD_STYLE_LOGS_MASK_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS_MASK";
-const char *DPL_LOG_OFF = "DPL_LOG_OFF";
-} // namespace anonymous
+const char *const CERTSVC_LOG_LEVEL = "CERTSVC_LOG_LEVEL";
+const char *const CERTSVC_LOG_PROVIDER = "CERTSVC_LOG_PROVIDER";
-bool LogSystem::IsLoggingEnabled() const
-{
- return m_isLoggingEnabled;
-}
+const char *const CONSOLE = "CONSOLE";
+const char *const DLOG = "DLOG";
+const char *const JOURNALD = "JOURNALD";
+} // namespace anonymous
-LogSystem::LogSystem() :
- m_dlogProvider(NULL),
- m_oldStyleProvider(NULL),
- m_isLoggingEnabled(!getenv(DPL_LOG_OFF))
+LogSystem::LogSystem()
+ : m_providerCtor({
+#ifdef BUILD_TYPE_DEBUG
+ { CONSOLE, []{ return static_cast<AbstractLogProvider *>(new OldStyleLogProvider()); }},
+#endif
+ { DLOG, []{ return static_cast<AbstractLogProvider *>(new DLOGLogProvider()); }},
+ { JOURNALD, []{ return static_cast<AbstractLogProvider *>(new JournalLogProvider()); }}
+ })
{
- bool oldStyleLogs = false;
- bool oldStyleDebugLogs = true;
- bool oldStyleInfoLogs = true;
- bool oldStyleWarningLogs = true;
- bool oldStyleErrorLogs = true;
- bool oldStylePedanticLogs = false;
-
- // Check environment settings about pedantic logs
- const char *value = getenv(OLD_STYLE_LOGS_ENV_NAME);
-
- if (value != NULL && !strcmp(value, "1")) {
- oldStyleLogs = true;
- }
+ SetLogLevel(getenv(CERTSVC_LOG_LEVEL));
- value = getenv(OLD_STYLE_PEDANTIC_LOGS_ENV_NAME);
-
- if (value != NULL && !strcmp(value, "1")) {
- oldStylePedanticLogs = true;
+ AbstractLogProvider *prv = NULL;
+ try {
+ prv = m_providerCtor.at(getenv(CERTSVC_LOG_PROVIDER))();
+ } catch (const std::exception &) {
+ prv = m_providerCtor[JOURNALD]();
}
- value = getenv(OLD_STYLE_LOGS_MASK_ENV_NAME);
-
- if (value != NULL) {
- size_t len = strlen(value);
-
- if (len >= 1) {
- if (value[0] == '0') {
- oldStyleDebugLogs = false;
- } else if (value[0] == '1') {
- oldStyleDebugLogs = true;
- }
- }
-
- if (len >= 2) {
- if (value[1] == '0') {
- oldStyleInfoLogs = false;
- } else if (value[1] == '1') {
- oldStyleInfoLogs = true;
- }
- }
-
- if (len >= 3) {
- if (value[2] == '0') {
- oldStyleWarningLogs = false;
- } else if (value[2] == '1') {
- oldStyleWarningLogs = true;
- }
- }
-
- if (len >= 4) {
- if (value[3] == '0') {
- oldStyleErrorLogs = false;
- } else if (value[3] == '1') {
- oldStyleErrorLogs = true;
- }
- }
- }
-
- // Setup default DLOG and old style logging
- if (oldStyleLogs) {
- // Old style
- m_oldStyleProvider = new OldStyleLogProvider(oldStyleDebugLogs,
- oldStyleInfoLogs,
- oldStyleWarningLogs,
- oldStyleErrorLogs,
- oldStylePedanticLogs);
- AddProvider(m_oldStyleProvider);
- } else {
- // DLOG
- m_dlogProvider = new DLOGLogProvider();
- AddProvider(m_dlogProvider);
- }
+ AddProvider(prv);
}
LogSystem::~LogSystem()
{
- // Delete all providers
- for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
- iterator != m_providers.end();
- ++iterator)
- {
- delete *iterator;
- }
-
- m_providers.clear();
-
- // And even default providers
- m_dlogProvider = NULL;
- m_oldStyleProvider = NULL;
+ RemoveProviders();
}
void LogSystem::SetTag(const char* tag)
{
- if (m_dlogProvider != NULL) {
- m_dlogProvider->SetTag(tag);
- }
+ for (auto &it : m_providers)
+ it->SetTag(tag);
}
void LogSystem::AddProvider(AbstractLogProvider *provider)
m_providers.remove(provider);
}
-void LogSystem::Debug(const char *message,
- const char *filename,
- int line,
- const char *function)
+void LogSystem::SelectProvider(const std::string &name)
{
- for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
- iterator != m_providers.end();
- ++iterator)
- {
- (*iterator)->Debug(message, filename, line, function);
- }
-}
+ ProviderFn& prv = m_providerCtor.at(name);
-void LogSystem::Info(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
- iterator != m_providers.end();
- ++iterator)
- {
- (*iterator)->Info(message, filename, line, function);
- }
+ RemoveProviders();
+ AddProvider(prv());
}
-void LogSystem::Warning(const char *message,
- const char *filename,
- int line,
- const char *function)
+void LogSystem::SetLogLevel(const char *level)
{
- for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
- iterator != m_providers.end();
- ++iterator)
- {
- (*iterator)->Warning(message, filename, line, function);
+ try {
+ m_level = static_cast<AbstractLogProvider::LogLevel>(std::stoi(level));
+ } catch(const std::exception&) {
+ m_level = AbstractLogProvider::LogLevel::Debug;
}
+
+ if (m_level < AbstractLogProvider::LogLevel::None)
+ m_level = AbstractLogProvider::LogLevel::None;
+ else if (m_level > AbstractLogProvider::LogLevel::Pedantic)
+ m_level = AbstractLogProvider::LogLevel::Pedantic;
+
+#ifndef BUILD_TYPE_DEBUG
+ if (m_level > AbstractLogProvider::LogLevel::Error)
+ m_level = AbstractLogProvider::LogLevel::Error;
+#endif // BUILD_TYPE_DEBUG
}
-void LogSystem::Error(const char *message,
- const char *filename,
- int line,
- const char *function)
+void LogSystem::Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *filename,
+ int line,
+ const char *function) const
{
- for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
- iterator != m_providers.end();
- ++iterator)
- {
- (*iterator)->Error(message, filename, line, function);
- }
+ for (const auto &it : m_providers)
+ it->Log(level, message, filename, line, function);
}
-void LogSystem::Pedantic(const char *message,
- const char *filename,
- int line,
- const char *function)
+void LogSystem::RemoveProviders()
{
- for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
- iterator != m_providers.end();
- ++iterator)
- {
- (*iterator)->Pedantic(message, filename, line, function);
- }
+ for (auto &it : m_providers)
+ delete it;
+
+ m_providers.clear();
}
}
} // namespace VcoreDPL
* @brief This file is the implementation file of old style log provider
*/
#include <stddef.h>
-#include <dpl/log/old_style_log_provider.h>
-#include <dpl/colors.h>
+#include <unistd.h>
+#include <sys/time.h>
#include <cstdio>
#include <cstring>
#include <sstream>
-#include <sys/time.h>
-#include <unistd.h>
+#include <stdexcept>
+#include <map>
+
+#include <dpl/log/old_style_log_provider.h>
+#include <dpl/colors.h>
namespace VcoreDPL {
namespace Log {
static_cast<int>(tv.tv_usec / 1000));
return format;
}
-} // namespace anonymous
-
-std::string OldStyleLogProvider::FormatMessage(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- std::ostringstream val;
-
- val << std::string("[") << GetFormattedTime() << std::string("] [") <<
- static_cast<unsigned long>(pthread_self()) << "/" <<
- static_cast<int>(getpid()) << std::string("] [") <<
- LocateSourceFileName(filename) << std::string(":") << line <<
- std::string("] ") << function << std::string("(): ") << message;
-
- return val.str();
-}
-OldStyleLogProvider::OldStyleLogProvider(bool showDebug,
- bool showInfo,
- bool showWarning,
- bool showError,
- bool showPedantic) :
- m_showDebug(showDebug),
- m_showInfo(showInfo),
- m_showWarning(showWarning),
- m_showError(showError),
- m_showPedantic(showPedantic),
- m_printStdErr(false)
-{}
+struct ColorMark {
+ const char *const begin;
+ const char *const end;
+};
-OldStyleLogProvider::OldStyleLogProvider(bool showDebug,
- bool showInfo,
- bool showWarning,
- bool showError,
- bool showPedantic,
- bool printStdErr) :
- m_showDebug(showDebug),
- m_showInfo(showInfo),
- m_showWarning(showWarning),
- m_showError(showError),
- m_showPedantic(showPedantic),
- m_printStdErr(printStdErr)
-{}
+std::map<AbstractLogProvider::LogLevel, ColorMark> consoleLevel = {
+ { AbstractLogProvider::LogLevel::Error, {ERROR_BEGIN, ERROR_END} },
+ { AbstractLogProvider::LogLevel::Warning, {WARNING_BEGIN, WARNING_END} },
+ { AbstractLogProvider::LogLevel::Info, {INFO_BEGIN, INFO_END} },
+ { AbstractLogProvider::LogLevel::Debug, {DEBUG_BEGIN, DEBUG_END} },
+ { AbstractLogProvider::LogLevel::Pedantic, {PEDANTIC_BEGIN, PEDANTIC_END} }
+};
-void OldStyleLogProvider::Debug(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- if (m_showDebug) {
- if (m_printStdErr) {
- fprintf(stderr, "%s%s%s\n", DEBUG_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), DEBUG_END);
- } else {
- fprintf(stdout, "%s%s%s\n", DEBUG_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), DEBUG_END);
- }
- }
-}
+} // namespace anonymous
-void OldStyleLogProvider::Info(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- if (m_showInfo) {
- if (m_printStdErr) {
- fprintf(stderr, "%s%s%s\n", INFO_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), INFO_END);
- } else {
- fprintf(stdout, "%s%s%s\n", INFO_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), INFO_END);
- }
- }
-}
+OldStyleLogProvider::OldStyleLogProvider() {}
-void OldStyleLogProvider::Warning(const char *message,
- const char *filename,
- int line,
- const char *function)
+void OldStyleLogProvider::Log(AbstractLogProvider::LogLevel level,
+ const char *message,
+ const char *filename,
+ int line,
+ const char *function) const
{
- if (m_showWarning) {
- if (m_printStdErr) {
- fprintf(stderr, "%s%s%s\n", WARNING_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), WARNING_END);
- } else {
- fprintf(stdout, "%s%s%s\n", WARNING_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), WARNING_END);
- }
- }
-}
+ try {
+ const struct ColorMark& mark = consoleLevel.at(level);
-void OldStyleLogProvider::Error(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- if (m_showError) {
- if (m_printStdErr) {
- fprintf(stderr, "%s%s%s\n", ERROR_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), ERROR_END);
- } else {
- fprintf(stdout, "%s%s%s\n", ERROR_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), ERROR_END);
- }
+ std::ostringstream val;
+ val << mark.begin << std::string("[") << GetFormattedTime() << std::string("] [") <<
+ static_cast<unsigned long>(pthread_self()) << "/" << static_cast<int>(getpid()) <<
+ std::string("] [") << LocateSourceFileName(filename) << std::string(":") << line <<
+ std::string("] ") << function << std::string("(): ") << message << mark.end;
+ fprintf(stdout, "%s\n", val.str().c_str());
+ } catch (const std::out_of_range&) {
+ fprintf(stdout, "Unsupported log level: %d\n", level);
}
}
-void OldStyleLogProvider::Pedantic(const char *message,
- const char *filename,
- int line,
- const char *function)
-{
- if (m_showPedantic) {
- if (m_printStdErr) {
- fprintf(stderr, "%s%s%s\n", PEDANTIC_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), PEDANTIC_END);
- } else {
- fprintf(stdout, "%s%s%s\n", PEDANTIC_BEGIN,
- FormatMessage(message, filename, line,
- function).c_str(), PEDANTIC_END);
- }
- }
-}
}
} // namespace VcoreDPL
* @brief This file is the implementation pipe from process
*/
-#include<dpl/test/process_pipe.h>
-#include<dpl/log/vcore_log.h>
+#include <dpl/test/process_pipe.h>
namespace VcoreDPL {
// Save new descriptor
m_file = file;
m_fd = fileno(m_file);
-
- VcoreLogD("Opened pipe: %s", fcommand.c_str());
}
void ProcessPipe::Close()
m_fd = -1;
m_file = NULL;
-
- VcoreLogD("Closed pipe");
}
}
#include <openssl/evp.h>
#include <openssl/buffer.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/scoped_free.h>
void Base64Encoder::append(const std::string &data)
{
if (m_finalized) {
- WrtLogW("Already finalized.");
+ LogWarning("Already finalized.");
VcoreThrowMsg(Exception::AlreadyFinalized, "Already finalized");
}
void Base64Encoder::finalize()
{
if (m_finalized) {
- WrtLogW("Already finalized.");
+ LogWarning("Already finalized.");
VcoreThrowMsg(Exception::AlreadyFinalized, "Already finalized.");
}
m_finalized = true;
std::string Base64Encoder::get()
{
if (!m_finalized) {
- WrtLogW("Not finalized");
+ LogWarning("Not finalized");
VcoreThrowMsg(Exception::NotFinalized, "Not finalized");
}
BUF_MEM *bptr = 0;
BIO_get_mem_ptr(m_b64, &bptr);
if (bptr == 0) {
- WrtLogE("Bio internal error");
+ LogError("Bio internal error");
VcoreThrowMsg(Exception::InternalError, "Bio internal error");
}
m_b64 = BIO_new(BIO_f_base64());
m_bmem = BIO_new(BIO_s_mem());
if (!m_b64 || !m_bmem) {
- WrtLogE("Error during allocation memory in BIO");
+ LogError("Error during allocation memory in BIO");
VcoreThrowMsg(Exception::InternalError,
"Error during allocation memory in BIO");
}
void Base64Decoder::append(const std::string &data)
{
if (m_finalized) {
- WrtLogW("Already finalized.");
+ LogWarning("Already finalized.");
VcoreThrowMsg(Exception::AlreadyFinalized, "Already finalized.");
}
m_input.append(data);
bool Base64Decoder::finalize()
{
if (m_finalized) {
- WrtLogW("Already finalized.");
+ LogWarning("Already finalized.");
VcoreThrowMsg(Exception::AlreadyFinalized, "Already finalized.");
}
{
continue;
}
- WrtLogE("Base64 input contains illegal chars: %c", m_input[i]);
+ LogError("Base64 input contains illegal chars: " << m_input[i]);
return false;
}
VcoreDPL::ScopedFree<char> buffer(static_cast<char*>(malloc(len)));
if (!buffer) {
- WrtLogE("Error in malloc.");
+ LogError("Error in malloc.");
VcoreThrowMsg(Exception::InternalError, "Error in malloc.");
}
memset(buffer.Get(), 0, len);
b64 = BIO_new(BIO_f_base64());
if (!b64) {
- WrtLogE("Couldn't create BIO object.");
+ LogError("Couldn't create BIO object.");
VcoreThrowMsg(Exception::InternalError, "Couldn't create BIO object.");
}
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
if (!bmem) {
BIO_free(b64);
- WrtLogE("Internal error in BIO");
+ LogError("Internal error in BIO");
VcoreThrowMsg(Exception::InternalError, "Internal error in BIO");
}
if (!bmem) {
BIO_free(b64);
- WrtLogE("Internal error in BIO");
+ LogError("Internal error in BIO");
VcoreThrowMsg(Exception::InternalError, "Internal error in BIO");
}
std::string Base64Decoder::get() const
{
if (!m_finalized) {
- WrtLogW("Not finalized.");
+ LogWarning("Not finalized.");
VcoreThrowMsg(Exception::NotFinalized, "Not finalized");
}
return m_output;
#include <openssl/pem.h>
#include <openssl/x509v3.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/assert.h>
#include <dpl/db/orm.h>
#include <dpl/foreach.h>
{
CRL::StringList result = argCert->getCrlUris();
- if (!result.empty()) {
+ if (!result.empty())
return result;
- }
- WrtLogI("No distribution points found. Getting from CA cert.");
+
+ LogInfo("No distribution points found. Getting from CA cert.");
X509_STORE_CTX *ctx = createContext(argCert);
X509_OBJECT obj;
&obj);
X509_STORE_CTX_free(ctx);
if (0 >= retVal) {
- WrtLogE("No dedicated CA certificate available");
+ LogError("No dedicated CA certificate available");
return result;
}
CertificatePtr caCert(new Certificate(obj.data.x509));
{
Assert(m_crlCache != NULL);
- WrtLogI("CRL storage initialization.");
+ LogInfo("CRL storage initialization.");
m_store = X509_STORE_new();
if (!m_store)
VcoreThrowMsg(CRLException::StorageError,
VcoreThrowMsg(CRLException::StorageError,
"Failed to add lookup dir for PEM files");
}
- WrtLogI("CRL storage initialization complete.");
+ LogInfo("CRL storage initialization complete.");
}
CRLImpl::~CRLImpl()
void CRLImpl::cleanup()
{
- WrtLogI("Free CRL storage");
+ LogInfo("Free CRL storage");
// STORE is responsible for LOOKUP release
// X509_LOOKUP_free(m_lookup);
X509_STORE_free(m_store);
FOREACH(it, crlUris) {
CRLDataPtr crl = getCRL(*it);
if (!crl) {
- WrtLogD("CRL not found for URI: %s", (*it).c_str());
+ LogDebug("CRL not found for URI: " << *it);
continue;
}
X509_CRL *crlInternal = convertToInternal(crl);
// If nextUpdate is not set assume it is actual.
retStatus.isCRLValid = true;
}
- WrtLogI("CRL valid: %d", retStatus.isCRLValid);
+ LogInfo("CRL valid: " << retStatus.isCRLValid);
X509_REVOKED rev;
rev.serialNumber = X509_get_serialNumber(argCert->getX509());
// sk_X509_REVOKED_find returns index if serial number is found on list
retVal = sk_X509_REVOKED_find(crlInternal->crl->revoked, &rev);
X509_CRL_free(crlInternal);
retStatus.isRevoked = retVal != -1;
- WrtLogI("CRL revoked: %d", retStatus.isRevoked);
+ LogInfo("CRL revoked: " << retStatus.isRevoked);
if (!retStatus.isRevoked && isOutOfDate(crl)) {
- WrtLogD("Certificate is not Revoked, but CRL is outOfDate.");
+ LogDebug("Certificate is not Revoked, but CRL is outOfDate.");
continue;
}
const CertificateList &certList = certChain.getChain();
FOREACH(it, certList) {
if (!(*it)->isRootCert()) {
- WrtLogI("Certificate common name: %s", (*it)->getCommonName().c_str());
+ LogInfo("Certificate common name: " << (*it)->getCommonName());
CRL::RevocationStatus certResult = checkCertificate(*it);
ret.isCRLValid &= certResult.isCRLValid;
ret.isRevoked |= certResult.isRevoked;
VerificationStatus CRLImpl::checkEndEntity(CertificateCollection &chain)
{
if (!chain.sort() && !chain.empty()) {
- WrtLogI("Could not find End Entity certificate. "
+ LogInfo("Could not find End Entity certificate. "
"Collection does not form chain.");
return VERIFICATION_STATUS_ERROR;
}
bool CRLImpl::updateList(const CertificatePtr &argCert,
const CRL::UpdatePolicy updatePolicy)
{
- WrtLogI("Update CRL for certificate");
+ LogInfo("Update CRL for certificate");
// Retrieve distribution points
CRL::StringList crlUris = getCrlUris(argCert);
FOREACH(it, crlUris) {
// Try to get CRL from database
- WrtLogI("Getting CRL for URI: %s", (*it).c_str());
+ LogInfo("Getting CRL for URI: " << *it);
bool downloaded = false;
}
if (!!crl && isOutOfDate(crl)) {
- WrtLogD("Crl out of date - downloading.");
+ LogDebug("Crl out of date - downloading.");
crl = downloadCRL(*it);
downloaded = true;
}
if (!crl) {
- WrtLogD("Crl not found in cache - downloading.");
+ LogDebug("Crl not found in cache - downloading.");
crl = downloadCRL(*it);
downloaded = true;
}
if (!crl) {
- WrtLogD("Failed to obtain CRL. URL: %s", (*it).c_str());
+ LogDebug("Failed to obtain CRL. URL: " << *it);
continue;
}
if (!!crl && isOutOfDate(crl)) {
- WrtLogE("CRL out of date. Broken URL: %s", (*it).c_str());
+ LogError("CRL out of date. Broken URL: " << *it);
}
// Make X509 internal structure
//Check if CRL is signed
if (!verifyCRL(crlInternal, argCert)) {
- WrtLogE("Failed to verify CRL. URI: %s", (crl->uri).c_str());
+ LogError("Failed to verify CRL. URI: " << (crl->uri).c_str());
X509_CRL_free(crlInternal);
return false;
}
X509_CRL_get_issuer(crl), &obj);
X509_STORE_CTX_free(ctx);
if (0 >= retVal) {
- WrtLogE("Unknown CRL issuer certificate!");
+ LogError("Unknown CRL issuer certificate!");
return false;
}
EVP_PKEY *pkey = X509_get_pubkey(obj.data.x509);
X509_OBJECT_free_contents(&obj);
if (!pkey) {
- WrtLogE("Failed to get issuer's public key.");
+ LogError("Failed to get issuer's public key.");
return false;
}
retVal = X509_CRL_verify(crl, pkey);
EVP_PKEY_free(pkey);
if (0 > retVal) {
- WrtLogE("Failed to verify CRL.");
+ LogError("Failed to verify CRL.");
return false;
} else if (0 == retVal) {
- WrtLogE("CRL is invalid");
+ LogError("CRL is invalid");
return false;
}
- WrtLogI("CRL is valid.");
+ LogInfo("CRL is valid.");
return true;
}
const char *pattern = "-----BEGIN X509 CRL-----";
std::string content(crl->buffer, crl->length);
if (content.find(pattern) != std::string::npos) {
- WrtLogI("CRL is in PEM format.");
+ LogInfo("CRL is in PEM format.");
return true;
}
- WrtLogI("CRL is in DER format.");
+ LogInfo("CRL is in DER format.");
return false;
}
&cpath,
&use_ssl))
{
- WrtLogW("Error in OCSP_parse_url");
+ LogWarning("Error in OCSP_parse_url");
return CRLDataPtr();
}
message.setHeader("Host", host);
if (SoupMessageSendSync::REQUEST_STATUS_OK != message.sendSync()) {
- WrtLogW("Error in sending network request.");
+ LogWarning("Error in sending network request.");
return CRLDataPtr();
}
CRLCachedData cachedCrl;
cachedCrl.distribution_point = uri;
if (!(m_crlCache->getCRLResponse(&cachedCrl))) {
- WrtLogI("CRL not present in database. URI: %s", uri.c_str());
+ LogInfo("CRL not present in database. URI: " << uri);
return CRLDataPtr();
}
std::string body = cachedCrl.crl_body;
- WrtLogI("CRL found in database.");
+ LogInfo("CRL found in database.");
//TODO: remove when ORM::blob available
//Encode buffer to base64 format to store in database
#include <vcore/CachedCRL.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
-#include <dpl/foreach.h>
+#include <dpl/log/log.h>
#include <vcore/CRLImpl.h>
#include <vcore/CertificateCacheDAO.h>
}
if (!allValid) {
// problems with CRL validity
- WrtLogD("Some CRLs not valid");
+ LogDebug("Some CRLs not valid");
}
CRL::RevocationStatus stat;
Try {
return VERIFICATION_STATUS_ERROR;
}
if (stat.isRevoked) {
- WrtLogD("Status REVOKED");
+ LogDebug("Status REVOKED");
return VERIFICATION_STATUS_REVOKED;
}
- WrtLogD("Status GOOD");
+ LogDebug("Status GOOD");
return VERIFICATION_STATUS_GOOD;
}
VerificationStatus CachedCRL::checkEndEntity(CertificateCollection &certs)
{
if (certs.empty()) {
- WrtLogE("Collection empty. This should never happen.");
- WrtLogD("Status ERROR");
+ LogError("Collection empty. This should never happen.");
return VERIFICATION_STATUS_ERROR;
}
if (!certs.sort()) {
- WrtLogE("Could not find End Entity certificate. "
+ LogError("Could not find End Entity certificate. "
"Collection does not form chain.");
- WrtLogD("Status ERROR");
return VERIFICATION_STATUS_ERROR;
}
CRLImpl crl(new CRLCacheDAO);
}
if (!allValid) {
// problems with CRL validity
- WrtLogD("Some CRLs not valid");
+ LogDebug("Some CRLs not valid");
}
CertificateList::const_iterator iter = certs.begin();
CRL::RevocationStatus stat = crl.checkCertificate(*iter);
if (stat.isRevoked) {
- WrtLogD("Status REVOKED");
+ LogDebug("Status REVOKED");
return VERIFICATION_STATUS_REVOKED;
}
- WrtLogD("Status GOOD");
+ LogDebug("Status GOOD");
return VERIFICATION_STATUS_GOOD;
}
}
if (CertificateCacheDAO::getCRLResponse(&cachedCRL)) {
if (now < cachedCRL.next_update_time) {
- WrtLogD("Cached CRL still valid for: %s", uri.c_str());
+ LogDebug("Cached CRL still valid for : " << uri);
return true;
}
}
CRLImpl crl(new CRLCacheDAO);
CRLImpl::CRLDataPtr list = crl.downloadCRL(uri);
if (!list) {
- WrtLogW("Could not retreive CRL from %s", uri.c_str());
+ LogWarning("Could not retreive CRL from " << uri);
return false;
}
crl.updateCRL(list);
#include <time.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
-#include <dpl/foreach.h>
+#include <dpl/log/log.h>
#include <vcore/OCSP.h>
#include <vcore/OCSPImpl.h>
db_status.end_entity_check = false;
if (CertificateCacheDAO::getOCSPStatus(&db_status)) {
- WrtLogD("Found cache entry for OCSP");
+ LogDebug("Found cache entry for OCSP");
if (now < db_status.next_update_time) {
- WrtLogD("Cache response valid");
+ LogDebug("Cache response valid");
return db_status.ocsp_status;
}
}
db_status.end_entity_check = true;
if (CertificateCacheDAO::getOCSPStatus(&db_status)) {
- WrtLogD("Found cache entry for OCSP");
+ LogDebug("Found cache entry for OCSP");
if (now < db_status.next_update_time) {
- WrtLogD("Cache response valid");
+ LogDebug("Cache response valid");
return db_status.ocsp_status;
}
}
CertificateCollection col;
col.load(db_status->cert_chain);
if (!col.sort()) {
- WrtLogE("Certificate collection does not create chain.");
+ LogError("Certificate collection does not create chain.");
continue;
}
const CertificateCollection &certs, CertificateList* clst)
{
if (NULL == clst) {
- WrtLogE("NULL pointer");
+ LogError("NULL pointer");
return;
}
#include <openssl/bn.h>
#include <dpl/assert.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <vcore/Base64.h>
#include <vcore/TimeConversion.h>
base64.reset();
base64.append(der);
if (!base64.finalize()) {
- WrtLogW("Error during decoding");
+ LogWarning("Error during decoding");
}
tmp = base64.get();
ptr = reinterpret_cast<const unsigned char*>(tmp.c_str());
bool Certificate::isSignedBy(const CertificatePtr &parent) const
{
if (!parent) {
- WrtLogD("Invalid certificate parameter.");
+ LogDebug("Invalid certificate parameter.");
return false;
}
return 0 == X509_NAME_cmp(X509_get_subject_name(parent->m_x509),
}
else {
set.insert(std::string(temp));
- WrtLogD("FOUND GEN_DNS: %s", temp);
+ LogDebug("FOUND GEN_DNS: " << temp);
}
} else {
- WrtLogD("FOUND GEN TYPE ID: %d", namePart->type);
+ LogDebug("FOUND GEN TYPE ID: " << namePart->type);
}
}
return set;
NULL,
NULL));
if (!distPoints) {
- WrtLogD("No distribution points in certificate.");
+ LogDebug("No distribution points in certificate.");
return result;
}
for (int i = 0; i < count; ++i) {
DIST_POINT* point = sk_DIST_POINT_value(distPoints, i);
if (!point) {
- WrtLogE("Failed to get distribution point.");
+ LogError("Failed to get distribution point.");
continue;
}
if (point->distpoint != NULL &&
char *crlUri =
reinterpret_cast<char*>(name->d.ia5->data);
if (!crlUri) {
- WrtLogE("Failed to get URI.");
+ LogError("Failed to get URI.");
continue;
}
result.push_back(crlUri);
#include <vcore/VCorePrivate.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/db/orm.h>
#include <orm_generator_vcore.h>
#include <vcore/Database.h>
bool CertificateCacheDAO::getOCSPStatus(OCSPCachedStatus* cached_status)
{
if (NULL == cached_status) {
- WrtLogE("NULL pointer");
+ LogError("NULL pointer");
return false;
}
Try {
return true;
}
- WrtLogD("Cached OCSP status not found");
+ LogDebug("Cached OCSP status not found");
return false;
}
Catch(VcoreDPL::DB::SqlConnection::Exception::Base) {
OCSPCachedStatusList* cached_status_list)
{
if (NULL == cached_status_list) {
- WrtLogE("NULL pointer");
+ LogError("NULL pointer");
return;
}
Try {
bool CertificateCacheDAO::getCRLResponse(CRLCachedData* cached_data)
{
if (NULL == cached_data) {
- WrtLogE("NULL pointer");
+ LogError("NULL pointer");
return false;
}
Try {
return true;
}
- WrtLogD("Cached CRL not found");
+ LogDebug("Cached CRL not found");
return false;
}
Catch(VcoreDPL::DB::SqlConnection::Exception::Base) {
CRLCachedDataList* cached_data_list)
{
if (NULL == cached_data_list) {
- WrtLogE("NULL pointer");
+ LogError("NULL pointer");
return;
}
Try {
#include <vcore/Base64.h>
#include <dpl/binary_queue.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <algorithm>
base64.reset();
base64.append(buffer);
if (!base64.finalize()) {
- WrtLogW("Error during chain decoding");
+ LogWarning("Error during chain decoding");
return false;
}
std::string binaryData = base64.get();
rawDERCert.begin(),
rawDERCert.end()))));
} VcoreCatch (Certificate::Exception::Base) {
- WrtLogW("Error during certificate creation.");
+ LogWarning("Error during certificate creation.");
return false;
}
- WrtLogD("Loading certificate. Certificate common name: %s", list.back()->getCommonName().c_str());
+ LogDebug("Loading certificate. Certificate common name: " << list.back()->getCommonName());
}
load(list);
return true;
}
if (!issTransl.empty()) {
- WrtLogW("Certificates don't form a valid chain.");
+ LogWarning("Certificates don't form a valid chain.");
m_collectionStatus = COLLECTION_CHAIN_BROKEN;
return;
}
*/
#include <dpl/assert.h>
#include <openssl/x509v3.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/noncopyable.h>
#include <openssl/ecdsa.h>
#include <openssl/evp.h>
#include <vcore/Base64.h>
#include <vcore/CertificateLoader.h>
+
#ifdef TIZEN_FEATURE_CERT_SVC_OCSP_CRL
#include <vcore/SSLContainers.h>
#endif
namespace {
const int MIN_RSA_KEY_LENGTH = 1024;
-//const char *OID_CURVE_SECP256R1 = "urn:oid:1.2.840.10045.3.1.7";
} // namespace anonymous
namespace ValidationCore {
-//// COMPARATOR CLASS START ////
-
-//class CertificateLoaderECDSA : public CertificateLoader::CertificateLoaderComparator, VcoreDPL::Noncopyable {
-//public:
-// CertificateLoaderECDSA(const std::string &publicKey)
-// : m_ecPublicKey(NULL)
-// , m_searchKey(NULL)
-// {
-// m_bnCtx = BN_CTX_new(); // if fails we can continue anyway
-// m_tmpPoint = BN_new(); // if fails we can continue anyway
-// m_initialized = CertificateLoader::convertBase64NodeToBigNum(publicKey, &m_searchKey);
-//
-// if(!m_initialized)
-// WrtLogE("Init failed!");
-// }
-//
-// virtual bool compare(X509 *x509cert){
-// if(!m_initialized)
-// return false;
-//
-// EVP_PKEY_free(m_ecPublicKey);
-//
-// m_ecPublicKey = X509_get_pubkey(x509cert);
-//
-// if(m_ecPublicKey == NULL)
-// return false;
-//
-// if(m_ecPublicKey->type != EVP_PKEY_EC){
-// WrtLogE("ecPublicKey has wrong type!");
-// return false;
-// }
-//
-// // Pointer to internal data of ecPublicKey. Do not free!
-// EC_KEY *eckey = m_ecPublicKey->pkey.ec;
-//
-// const EC_POINT *ecpoint = EC_KEY_get0_public_key(eckey);
-// const EC_GROUP *ecgroup = EC_KEY_get0_group(eckey);
-//
-// m_tmpPoint = EC_POINT_point2bn(ecgroup, ecpoint, POINT_CONVERSION_UNCOMPRESSED, m_tmpPoint, m_bnCtx);
-//
-// if(BN_cmp(m_tmpPoint, m_searchKey) == 0)
-// return true;
-//
-// return false;
-// }
-//
-// ~CertificateLoaderECDSA(){
-// BN_CTX_free(m_bnCtx);
-// EVP_PKEY_free(m_ecPublicKey);
-// BN_free(m_searchKey);
-// BN_free(m_tmpPoint);
-// }
-//
-//private:
-// bool m_initialized;
-// EVP_PKEY *m_ecPublicKey;
-// BN_CTX *m_bnCtx;
-// BIGNUM *m_searchKey;
-// BIGNUM *m_tmpPoint;
-//};
-
-///// COMPARETORS CLASS END /////
-
-//// COMPARATOR RSA CLASS START ////
-
-//class CertificateLoaderRSA : public CertificateLoader::CertificateLoaderComparator, VcoreDPL::Noncopyable {
-//public:
-// CertificateLoaderRSA(const std::string &m_modulus,const std::string &m_exponent )
-// : m_rsaPublicKey(NULL)
-// , m_modulus_bn(NULL)
-// , m_exponent_bn(NULL)
-// {
-//
-// m_initialized_modulus = CertificateLoader::convertBase64NodeToBigNum(m_modulus, &m_modulus_bn);
-// m_initialized_exponent = CertificateLoader::convertBase64NodeToBigNum(m_exponent, &m_exponent_bn);
-//
-// if(!m_initialized_modulus || !m_initialized_exponent)
-// WrtLogE("Init failed!");
-// }
-//
-// virtual bool compare(X509 *x509cert){
-//
-// if(!m_initialized_modulus || !m_initialized_exponent)
-// return false;
-//
-// EVP_PKEY_free(m_rsaPublicKey);
-// m_rsaPublicKey = X509_get_pubkey(x509cert);
-//
-// if(m_rsaPublicKey == NULL)
-// return false;
-//
-// if(m_rsaPublicKey->type != EVP_PKEY_RSA){
-// WrtLogI("rsaPublicKey has wrong type!");
-// return false;
-// }
-//
-// RSA *rsa = NULL;
-// rsa = m_rsaPublicKey->pkey.rsa;
-//
-// if (BN_cmp(m_modulus_bn, rsa->n) == 0 &&
-// BN_cmp(m_exponent_bn, rsa->e) == 0 ){
-// WrtLogE ("Compare TRUE");
-// return true;
-// }
-// return false;
-// }
-//
-// ~CertificateLoaderRSA(){
-// EVP_PKEY_free(m_rsaPublicKey);
-// BN_free(m_modulus_bn);
-// BN_free(m_exponent_bn);
-//
-// }
-//
-//private:
-// bool m_initialized_modulus;
-// bool m_initialized_exponent;
-// EVP_PKEY *m_rsaPublicKey;
-// BIGNUM *m_modulus_bn;
-// BIGNUM *m_exponent_bn;
-//};
-
-///// COMPARETORS RSA CLASS END /////
-
CertificateLoader::CertificateLoaderResult CertificateLoader::
loadCertificateBasedOnExponentAndModulus(const std::string &m_modulus,
const std::string &m_exponent)
{
(void) m_modulus;
(void) m_exponent;
- WrtLogE("Not implemented.");
+ LogError("Not implemented.");
return UNKNOWN_ERROR;
- // if (m_exponent.empty() || m_modulus.empty())
- // return WRONG_ARGUMENTS;
- //
- // CertificateLoaderRSA comparator(m_modulus,m_exponent);
- //
- // CertificateLoaderResult result = NO_ERROR;
- // for(int i=0; storeId[i]; ++i){
- // result = loadCertificate(std::string(storeId[i]), &comparator);
- //
- // if(result == ERR_NO_MORE_CERTIFICATES)
- // continue;
- //
- // return result;
- // }
- //
- // return result;
}
CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificate(
{
(void) storageName;
(void) cmp;
- WrtLogE("Not Implemented");
+ LogError("Not Implemented");
return UNKNOWN_ERROR;
- // long int result = OPERATION_SUCCESS;
- //
- // char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE];
- // char type[CERTMGR_MAX_CERT_TYPE_SIZE];
- // certmgr_cert_id certId;
- // certmgr_ctx context;
- // certmgr_mem_buff certRetrieved;
- // unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE];
- //
- // certmgr_cert_descriptor descriptor;
- //
- // certRetrieved.data = buffer;
- // certRetrieved.firstFree = 0;
- // certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE;
- // certId.storeId = storeId;
- // certId.type = type;
- //
- // CERTMGR_INIT_CONTEXT((&context), (sizeof(context)))
- //
- // strncpy(context.storeId, storageName.c_str(), storageName.size());
- //
- // for(certRetrieved.firstFree = 0;
- // OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId));
- // certRetrieved.firstFree = 0)
- // {
- //
- // if(OPERATION_SUCCESS!=certmgr_extract_certificate_data(&certRetrieved, &descriptor)){
- // WrtLogE("Extracting Certificate Data failed ");
- // continue;
- // }
- //
- // const unsigned char *ptr = certRetrieved.data;
- //
- // X509 *x509cert = d2i_X509(NULL, &ptr, certRetrieved.size);
- // if(x509cert == NULL){
- // certmgr_release_certificate_data(&descriptor);
- // WrtLogE("Error extracting certificate (d2i_X509).");
- // return UNKNOWN_ERROR;
- // }
- //
- // WrtLogD("The subject of this certificate is %s", (descriptor.mandatory.subject));
- // if(cmp->compare(x509cert)){
- // WrtLogD("Found match. Coping bytes: %d", certRetrieved.size);
- // m_certificatePtr = CertificatePtr(new Certificate(certRetrieved));
- // certmgr_release_certificate_data(&descriptor);
- // X509_free(x509cert);
- // break;
- // }
- //
- // WrtLogD("Release");
- // X509_free(x509cert);
- // certmgr_release_certificate_data(&descriptor);
- // }
- //
- // if(ERR_NO_MORE_CERTIFICATES == result){
- // WrtLogE("Certificates for given DN not found");
- // return CERTIFICATE_NOT_FOUND;
- // }
- //
- // if(result!= OPERATION_SUCCESS){
- // WrtLogE("Certificate Manager Error");
- // return UNKNOWN_ERROR;
- // }
- //
- // WrtLogD("Exit");
- // return NO_ERROR;
}
-// TODO
CertificateLoader::CertificateLoaderResult CertificateLoader::
loadCertificateBasedOnSubjectName(const std::string &subjectName)
{
(void) subjectName;
- WrtLogE("Not implemented.");
+ LogError("Not implemented.");
return UNKNOWN_ERROR;
- // if(subjectName.empty())
- // {
- // return WRONG_ARGUMENTS;
- // }
- //
- // long int result = OPERATION_SUCCESS;
- //
- // char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE];
- // char type[CERTMGR_MAX_CERT_TYPE_SIZE];
- // certmgr_cert_id certId;
- // certmgr_ctx context;
- // certmgr_mem_buff certRetrieved;
- // unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE];
- //
- // certmgr_cert_descriptor descriptor;
- //
- // certRetrieved.data = buffer;
- // certRetrieved.firstFree = 0;
- // certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE;
- // certId.storeId = storeId;
- // certId.type = type;
- //
- // CERTMGR_INIT_CONTEXT((&context), (sizeof(context)))
- //
- // for(certRetrieved.firstFree = 0;
- // OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId));
- // certRetrieved.firstFree = 0)
- // {
- //
- // if(OPERATION_SUCCESS!=certmgr_extract_certificate_data(&certRetrieved, &descriptor)){
- // WrtLogE("Extracting Certificate Data failed ");
- // continue;
- // }
- //
- // if(!strcmp(subjectName.c_str(), descriptor.mandatory.subject)){
- // WrtLogD("The subject of this certificate is %s", descriptor.mandatory.subject);
- // m_certificatePtr = CertificatePtr(new Certificate(certRetrieved));
- // certmgr_release_certificate_data(&descriptor);
- // break;
- // }
- // WrtLogD("Release");
- // certmgr_release_certificate_data(&descriptor);
- // }
- //
- // if(ERR_NO_MORE_CERTIFICATES == result) {
- // WrtLogE("Certificates for given DN not found");
- // return CERTIFICATE_NOT_FOUND;
- // }
- // if(result!= OPERATION_SUCCESS){
- // WrtLogE("Certificate Manager Error");
- // return UNKNOWN_ERROR;
- // }
- // WrtLogD("Exit");
- // return NO_ERROR;
}
-// KW CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificateBasedOnIssuerName(const std::string &issuerName, const std::string &serialNumber)
-// KW {
-// KW if(issuerName.empty() || serialNumber.empty())
-// KW {
-// KW return WRONG_ARGUMENTS;
-// KW }
-// KW
-// KW if(m_cmBuff.data){
-// KW delete[] m_cmBuff.data;
-// KW memset(&m_cmBuff, 0, sizeof(certmgr_mem_buff));
-// KW }
-// KW
-// KW WrtLogD("IssuerName: %s , serialNumber: %s", issuerName.c_str(), serialNumber.c_str());
-// KW
-// KW //used to check status of retrieved certificate
-// KW long int result = OPERATION_SUCCESS;
-// KW char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE];
-// KW char type[CERTMGR_MAX_CERT_TYPE_SIZE];
-// KW certmgr_cert_id certId;
-// KW certmgr_ctx context;
-// KW certmgr_mem_buff certRetrieved;
-// KW unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE];
-// KW
-// KW certmgr_cert_descriptor descriptor;
-// KW
-// KW certRetrieved.data = buffer;
-// KW certRetrieved.firstFree = 0;
-// KW certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE;
-// KW certId.storeId = storeId;
-// KW certId.type = type;
-// KW
-// KW CERTMGR_INIT_CONTEXT((&context), (sizeof(context)))
-// KW
-// KW for(certRetrieved.firstFree = 0;
-// KW OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId));
-// KW certRetrieved.firstFree = 0)
-// KW {
-// KW
-// KW WrtLogD("Extracting certificate from CertMgr");
-// KW
-// KW if( OPERATION_SUCCESS != certmgr_extract_certificate_data(&certRetrieved, &descriptor) ){
-// KW WrtLogE("Extracting Certificate Data failed ");
-// KW continue;
-// KW }
-// KW
-// KW WrtLogD("Issuer: %s", (descriptor.mandatory.issuer).c_str());
-// KW
-// KW const unsigned char *ptr = certRetrieved.data;
-// KW char *tmp;
-// KW
-// KW X509 *x509cert = d2i_X509(NULL, &ptr, certRetrieved.size);
-// KW std::string serialNO = std::string(tmp = i2s_ASN1_INTEGER(NULL, X509_get_serialNumber(x509cert)));
-// KW OPENSSL_free(tmp);
-// KW X509_free(x509cert);
-// KW
-// KW WrtLogI("Certificate number found: %d", serialNO);
-// KW WrtLogI("Certificate number looking for: %d", serialNumber);
-// KW
-// KW if(!strcmp(issuerName.c_str(), descriptor.mandatory.issuer)
-// KW && serialNumber == serialNO)
-// KW {
-// KW WrtLogE("The issuer of this certificate is %s", (descriptor.mandatory.issuer).c_str());
-// KW
-// KW m_cmBuff.data = new unsigned char[certRetrieved.size];
-// KW m_cmBuff.firstFree = m_cmBuff.size = certRetrieved.size;
-// KW memcpy(m_cmBuff.data, certRetrieved.data, certRetrieved.size);
-// KW certmgr_release_certificate_data(&descriptor);
-// KW break;
-// KW }
-// KW certmgr_release_certificate_data(&descriptor);
-// KW }
-// KW
-// KW if(ERR_NO_MORE_CERTIFICATES == result) {
-// KW WrtLogE("Certificates not found");
-// KW return CERTIFICATE_NOT_FOUND;
-// KW }
-// KW if(result != OPERATION_SUCCESS){
-// KW WrtLogE("Certificate Manager Error");
-// KW return UNKNOWN_ERROR;
-// KW }
-// KW return NO_ERROR;
-// KW }
-
CertificateLoader::CertificateLoaderResult CertificateLoader::
loadCertificateWithECKEY(const std::string &curveName,
const std::string &publicKey)
{
(void) curveName;
(void) publicKey;
- WrtLogE("Not implemented.");
+ LogError("Not implemented.");
return UNKNOWN_ERROR;
- // if(curveName != OID_CURVE_SECP256R1){
- // WrtLogE("Found field id: %s Expected:", curveName.c_str(), OID_CURVE_SECP256R1.c_str());
- // return UNSUPPORTED_CERTIFICATE_FIELD;
- // }
- //
- // CertificateLoaderECDSA comparator(publicKey);
- //
- // CertificateLoaderResult result = NO_ERROR;
- // for(int i=0; storeId[i]; ++i){
- // result = loadCertificate(std::string(storeId[i]), &comparator);
- //
- // if(result == ERR_NO_MORE_CERTIFICATES)
- // continue;
- //
- // return result;
- // }
- //
- // return result;
}
CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificateFromRawData(const std::string &rawData)
VcoreTry {
m_certificatePtr = CertificatePtr(new Certificate(rawData, Certificate::FORM_BASE64));
} VcoreCatch(Certificate::Exception::Base) {
- WrtLogW("Error reading certificate by openssl.");
+ LogWarning("Error reading certificate by openssl.");
return UNKNOWN_ERROR;
}
// key Length (modulus) is in bytes
keyLength <<= 3;
- WrtLogD("RSA key length: %d bits", keyLength);
+ LogDebug("RSA key length: " << keyLength << " bits");
if (keyLength < MIN_RSA_KEY_LENGTH) {
- WrtLogE(
- "RSA key too short! Has only %d bits", keyLength);
- return CERTIFICATE_SECURITY_ERROR;
+ LogError("RSA key too short! Has only " << keyLength << " bits");
+ return CERTIFICATE_SECURITY_ERROR;
}
}
}
return NO_ERROR;
}
-// DEPRACETED FUNCTION
-//CertificateLoader::CertificateLoaderResult CertificateLoader::loadCertificateFromRawData(const std::string &rawData)
-//{
-// certmgr_mem_buff cmBuff = {0,0,0};
-//
-// long int size;
-// cmBuff.data = certmgr_util_base64_decode(const_cast<void*>(static_cast<const void*>(rawData.c_str())), rawData.size(), &size);
-//
-// cmBuff.firstFree = cmBuff.size = size;
-//
-// certmgr_cert_descriptor descriptor;
-//
-// long int result = certmgr_extract_certificate_data(&cmBuff, &descriptor);
-//
-// if (result != OPERATION_SUCCESS)
-// {
-// WrtLogE("Unable to load certificate");
-// return UNKNOWN_ERROR;
-// }
-//
-// certmgr_release_certificate_data(&descriptor);
-//
-// m_certificatePtr = CertificatePtr(new Certificate(cmBuff));
-//
-// // we have to use temp pointer cause d2i_x509 modifies its input
-// const unsigned char* tmpPtr = cmBuff.data;
-// X509* pCertificate = d2i_X509(NULL, &tmpPtr, cmBuff.size);
-//
-// if (pCertificate)
-// {
-// SSLSmartContainer<X509> pX509(pCertificate);
-//
-// // Check the key length if sig algorithm is RSA
-// EVP_PKEY *pKey = X509_get_pubkey(pX509);
-//
-// if (pKey->type == EVP_PKEY_RSA)
-// {
-// RSA* pRSA = pKey->pkey.rsa;
-//
-// if (pRSA)
-// {
-// int keyLength = RSA_size(pRSA);
-//
-// // key Length (modulus) is in bytes
-// keyLength <<= 3;
-// WrtLogD("RSA key length: %d bits", keyLength);
-//
-// if (keyLength < MIN_RSA_KEY_LENGTH)
-// {
-// WrtLogE("RSA key too short! Has only %d bits.", keyLength);
-// return CERTIFICATE_SECURITY_ERROR;
-// }
-// }
-// }
-// }
-//
-// return NO_ERROR;
-//}
-
CertificateLoader::CertificateLoaderResult CertificateLoader::
loadCertificateBasedOnDSAComponents(const std::string& strP,
const std::string& strQ,
(void) strJ;
(void) strSeed;
(void) strPGenCounter;
- WrtLogE("Not implemented.");
+ LogError("Not implemented.");
return UNKNOWN_ERROR;
- // (void)strY;
- // (void)strJ;
- // (void)strSeed;
- // (void)strPGenCounter;
- //
- // long int result = UNKNOWN_ERROR;
- //
- // char storeId[CERTMGR_MAX_PLUGIN_ID_SIZE];
- // char type[CERTMGR_MAX_CERT_TYPE_SIZE];
- // certmgr_cert_id certId;
- // certmgr_ctx context;
- // certmgr_mem_buff certRetrieved;
- //
- // unsigned char buffer[CERTMGR_MAX_BUFFER_SIZE];
- //
- // certmgr_cert_descriptor descriptor;
- //
- // certRetrieved.data = buffer;
- // certRetrieved.firstFree = 0;
- // certRetrieved.size = CERTMGR_MAX_BUFFER_SIZE;
- // certId.storeId = storeId;
- // certId.type = type;
- //
- // CERTMGR_INIT_CONTEXT((&context), (sizeof(context)))
- // std::string strStoreType("Operator");
- // strncpy(context.storeId, strStoreType.c_str(), strStoreType.length());
- //
- // for (certRetrieved.firstFree = 0;
- // OPERATION_SUCCESS == (result = certmgr_retrieve_certificate_from_store(&context, &certRetrieved, &certId));
- // certRetrieved.firstFree = 0)
- // {
- //
- // if (OPERATION_SUCCESS != certmgr_extract_certificate_data(&certRetrieved, &descriptor))
- // {
- // WrtLogD("unable to retrieve cert from storage");
- // continue;
- // }
- //
- // X509* pCertificate = d2i_X509(NULL, (const unsigned char**) &(certRetrieved.data), certRetrieved.size);
- //
- // if (pCertificate)
- // {
- // EVP_PKEY *pKey = X509_get_pubkey(pCertificate);
- //
- // if (pKey->type == EVP_PKEY_DSA)
- // {
- // DSA* pDSA = pKey->pkey.dsa;
- //
- // if (pDSA)
- // {
- // BIGNUM *pDSApBigNum = NULL, *pDSAqBigNum = NULL, *pDSAgBigNum = NULL;
- //
- // convertBase64NodeToBigNum(strP, &pDSApBigNum);
- // convertBase64NodeToBigNum(strQ, &pDSAqBigNum);
- // convertBase64NodeToBigNum(strG, &pDSAgBigNum);
- //
- // if (pDSApBigNum && pDSAqBigNum && pDSAgBigNum &&
- // BN_cmp(pDSApBigNum, pDSA->p) == 0 &&
- // BN_cmp(pDSAqBigNum, pDSA->q) == 0 &&
- // BN_cmp(pDSAgBigNum, pDSA->g) == 0)
- // {
- // WrtLogI("DSA Certificate found");
- // /* TODO load this certificate to m_cmBuff value */
- // WrtLogE("Not implemented!");
- //
- // EVP_PKEY_free(pKey);
- // X509_free(pCertificate);
- //
- // BN_free(pDSApBigNum);
- // BN_free(pDSAqBigNum);
- // BN_free(pDSAgBigNum);
- //
- // certmgr_release_certificate_data(&descriptor);
- // return NO_ERROR;
- // }
- //
- // if (pDSApBigNum)
- // {
- // BN_free(pDSApBigNum);
- // }
- // if (pDSAqBigNum)
- // {
- // BN_free(pDSAqBigNum);
- // }
- // if (pDSAgBigNum)
- // {
- // BN_free(pDSAgBigNum);
- // }
- //
- // }
- // EVP_PKEY_free(pKey);
- // }
- // X509_free(pCertificate);
- // }
- // else
- // WrtLogE("Unable to load certificate");
- //
- // certmgr_release_certificate_data(&descriptor);
- // }
- //
- // WrtLogE("No DSA certificate with given parameters");
- //
- // return CERTIFICATE_NOT_FOUND;
}
bool CertificateLoader::convertBase64NodeToBigNum(const std::string& strNode,
{
(void) strNode;
(void) ppBigNum;
- WrtLogE("Not implemented.");
+ LogError("Not implemented.");
return false;
- // if (!ppBigNum || *ppBigNum != NULL)
- // {
- // WrtLogE("Ptr variable not initialized properly!");
- // return false;
- // }
- //
- // // decode base64 to binary
- // long int binBuffLength = 0;
- // unsigned char* binBuff = NULL;
- //
- // binBuff = certmgr_util_base64_decode(const_cast<char*> (strNode.c_str()), strNode.length(), &binBuffLength);
- //
- // if (!binBuff)
- // {
- // WrtLogE("base64 decode failed");
- // return false;
- // }
- //
- // // convert binary to bignum
- // *ppBigNum = BN_bin2bn(binBuff, binBuffLength, *ppBigNum);
- //
- // free(binBuff);
- //
- // if (!(*ppBigNum))
- // {
- // WrtLogE("Conversion from node to bignum failed");
- // return false;
- // }
- //
- // return true;
}
-// KW bool CertificateLoader::convertBigNumToBase64Node(const BIGNUM* pBigNum, std::string& strNode)
-// KW {
-// KW if (!pBigNum)
-// KW {
-// KW WrtLogE("null ptr");
-// KW return false;
-// KW }
-// KW
-// KW int nNumLength = BN_num_bytes(pBigNum);
-// KW unsigned char* buffer = new unsigned char[nNumLength + 1];
-// KW
-// KW // convert bignum to binary format
-// KW if (BN_bn2bin(pBigNum, buffer) < 0)
-// KW {
-// KW WrtLogE("Conversion from bignum to binary failed");
-// KW delete []buffer;
-// KW return false;
-// KW }
-// KW
-// KW char* pBase64Node = NULL;
-// KW unsigned long int buffLen = 0;
-// KW certmgr_util_base64_encode(buffer, (unsigned long int) nNumLength, &pBase64Node, &buffLen);
-// KW
-// KW strNode.assign(pBase64Node, buffLen);
-// KW
-// KW delete []buffer;
-// KW return true;
-// KW }
} // namespace ValidationCore
#include <dpl/assert.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
namespace ValidationCore {
VerificationStatus CertificateVerifier::check(
CertificateCollection &certCollection) const
{
- WrtLogD("== Certificate collection validation start ==");
+ LogDebug("== Certificate collection validation start ==");
Assert(certCollection.isChain() && "Collection must form chain.");
VerificationStatus statusOcsp;
} else {
statusCrl = VERIFICATION_STATUS_GOOD;
}
- WrtLogD("== Certificate collection validation end ==");
+ LogDebug("== Certificate collection validation end ==");
return getStatus(statusOcsp, statusCrl);
}
VerificationStatus CertificateVerifier::obtainOcspStatus(
const CertificateCollection &chain) const
{
- WrtLogD("== Obtain ocsp status ==");
+ LogDebug("== Obtain ocsp status ==");
CachedOCSP ocsp;
return ocsp.check(chain);
}
VerificationStatus CertificateVerifier::obtainCrlStatus(
const CertificateCollection &chain) const
{
- WrtLogD("== Obtain crl status ==");
+ LogDebug("== Obtain crl status ==");
CachedCRL crl;
return crl.check(chain);
}
if (ocsp == VERIFICATION_STATUS_REVOKED ||
crl == VERIFICATION_STATUS_REVOKED)
{
- WrtLogD("Return status: REVOKED");
+ LogDebug("Return status: REVOKED");
return VERIFICATION_STATUS_REVOKED;
}
if (ocsp == VERIFICATION_STATUS_GOOD) {
- WrtLogD("Return status: GOOD");
+ LogDebug("Return status: GOOD");
return VERIFICATION_STATUS_GOOD;
}
if (ocsp == VERIFICATION_STATUS_UNKNOWN) {
- WrtLogD("Return status: UNKNOWN");
+ LogDebug("Return status: UNKNOWN");
return VERIFICATION_STATUS_UNKNOWN;
}
if (ocsp == VERIFICATION_STATUS_NOT_SUPPORT) {
- WrtLogD("Return status: NOT_SUPPORT");
+ LogDebug("Return status: NOT_SUPPORT");
return VERIFICATION_STATUS_GOOD;
}
- WrtLogD("Return status: ERROR");
+ LogDebug("Return status: ERROR");
return VERIFICATION_STATUS_ERROR;
}
} else {
statusCrl.add(VERIFICATION_STATUS_GOOD);
}
- WrtLogD("== Certificate collection validateion end ==");
+ LogDebug("== Certificate collection validateion end ==");
return getStatus(statusOcsp.convertToStatus(), statusCrl.convertToStatus());
}
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <dpl/assert.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/scoped_resource.h>
#include <string.h>
#include <iostream>
X509 **xcert)
{
if (!xcert || *xcert || !subject) {
- WrtLogE("Invalid input!");
+ LogError("Invalid input!");
return;
}
ScopedContext ctx(cert_svc_cert_context_init());
if (ctx.Get() == NULL) {
- WrtLogW("Error in cert_svc_cert_context_init.");
+ LogWarning("Error in cert_svc_cert_context_init.");
return;
}
- WrtLogD("Search certificate with subject: %s", buffer);
+ LogDebug("Search certificate with subject: " << buffer);
result = cert_svc_search_certificate(ctx.Get(), SUBJECT_STR, buffer);
- WrtLogD("Search finished!");
+ LogDebug("Search finished!");
if (CERT_SVC_ERR_NO_ERROR != result) {
- WrtLogW("Error during certificate search");
+ LogWarning("Error during certificate search");
return;
}
fileList = ctx.Get()->fileNames;
if (fileList == NULL) {
- WrtLogD("No certificate found");
+ LogDebug("No certificate found");
return;
}
if (fileList->filename == NULL) {
- WrtLogW("Empty filename");
+ LogWarning("Empty filename");
return;
}
- WrtLogD("Found cert file: %s", fileList->filename);
+ LogDebug("Found cert file: " << fileList->filename);
ScopedContext ctx2(cert_svc_cert_context_init());
if (ctx2.Get() == NULL) {
- WrtLogW("Error in cert_svc_cert_context_init.");
+ LogWarning("Error in cert_svc_cert_context_init.");
return;
}
// TODO add read_certifcate_from_file function to Certificate.h
if (CERT_SVC_ERR_NO_ERROR !=
cert_svc_load_file_to_context(ctx2.Get(), fileList->filename)) {
- WrtLogW("Error in cert_svc_load_file_to_context");
+ LogWarning("Error in cert_svc_load_file_to_context");
return;
}
pCertificate = d2i_X509(NULL, &ptr, ctx2.Get()->certBuf->size);
if (pCertificate == NULL) {
- WrtLogW("Error during certificate conversion in d2i_X509");
+ LogWarning("Error during certificate conversion in d2i_X509");
return;
}
*xcert = pCertificate;
if (fileList->next != NULL) {
- WrtLogE("There is more then one certificate with same subject :/");
+ LogError("There is more then one certificate with same subject :/");
// TODO Implement me.
for (fileList = fileList->next;
fileList != NULL;
fileList = fileList->next) {
- WrtLogE("Additional certificate with same subject: %s", fileList->filename);
+ LogError("Additional certificate with same subject: " << fileList->filename);
}
}
}
#include <openssl/x509v3.h>
#include <boost/optional.hpp>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/assert.h>
#include <dpl/foreach.h>
#include <dpl/scoped_free.h>
&cpath,
&use_ssl))
{
- WrtLogW("Error in OCSP_parse_url");
+ LogWarning("Error in OCSP_parse_url");
return SoupMessageSendBase::REQUEST_STATUS_CONNECTION_ERROR;
}
if (certs.size() < 2) {
// no certificates to verify, just return a error
- WrtLogW("No validation will be proceed. OCSP require at"
- " least 2 certificates in chain. Found only %d", certs.size());
+ LogWarning("No validation will be proceed. OCSP require at"
+ " least 2 certificates in chain. Found only " << certs.size());
statusSet.add(VERIFICATION_STATUS_ERROR);
return statusSet;
}
time_t minValidity = 0;
for (++parent; parent != certs.end(); ++iter, ++parent) {
- WrtLogD("Certificate validation (CN:%s)", (*iter)->getOneLine().c_str());
- WrtLogD("Parent certificate (CN:%s)", (*parent)->getOneLine().c_str());
+ LogDebug("Certificate validation (CN:" << (*iter)->getOneLine() << ")");
+ LogDebug("Parent certificate (CN:" << (*parent)->getOneLine() << ")");
statusSet.add(validateCertificate(*iter, *parent));
if ((0 == minValidity || minValidity > m_responseValidity) &&
m_responseValidity > 0)
VcoreThrowMsg(OCSPImpl::Exception::VerificationError,
"Default responder is not set");
}
- WrtLogW("Default responder will be used");
+ LogWarning("Default responder will be used");
uri = m_strResponderURI;
}
responseCont,
newRequest.ocspCertId);
} VcoreCatch(OCSPImpl::Exception::ConnectionError) {
- WrtLogW("OCSP: ConnectionError");
+ LogWarning("OCSP: ConnectionError");
return VERIFICATION_STATUS_CONNECTION_FAILED;
} VcoreCatch(OCSPImpl::Exception::CertificateRevoked) {
- WrtLogW("OCSP: Revoked");
+ LogWarning("OCSP: Revoked");
return VERIFICATION_STATUS_REVOKED;
} VcoreCatch(OCSPImpl::Exception::CertificateUnknown) {
- WrtLogW("OCSP: Unknown");
+ LogWarning("OCSP: Unknown");
return VERIFICATION_STATUS_UNKNOWN;
} VcoreCatch(OCSPImpl::Exception::VerificationError) {
- WrtLogW("OCSP: Verification error");
+ LogWarning("OCSP: Verification error");
return VERIFICATION_STATUS_VERIFICATION_ERROR;
} VcoreCatch(OCSPImpl::Exception::Base) {
- WrtLogW("OCSP: Error");
+ LogWarning("OCSP: Error");
return VERIFICATION_STATUS_ERROR;
}
- WrtLogW("OCSP: Good");
+ LogWarning("OCSP: Good");
return VERIFICATION_STATUS_GOOD;
}
OCSP_REQUEST* newRequest = OCSP_REQUEST_new();
if (!newRequest) {
- WrtLogW("OCSP: Failed to create a request");
+ LogWarning("OCSP: Failed to create a request");
return CreateRequestResult();
}
OCSP_CERTID* certId = addSerial(argCert, argIssuer);
if (!certId) {
- WrtLogW("OCSP: Unable to create a serial id");
+ LogWarning("OCSP: Unable to create a serial id");
return CreateRequestResult();
}
SSLSmartContainer <OCSP_CERTID> certIdCont(certId);
// Inserting certificate ID to request
if (!OCSP_request_add0_id(requestCont, certIdCont)) {
- WrtLogW("OCSP: Unable to create a certificate id");
+ LogWarning("OCSP: Unable to create a certificate id");
return CreateRequestResult();
}
if (m_bSignRequest) {
if (!m_pSignCert || !m_pSignKey) {
- WrtLogW("OCSP: Unable to sign request if "
+ LogWarning("OCSP: Unable to sign request if "
"SignCert or SignKey was not set");
return CreateRequestResult();
}
0,
0))
{
- WrtLogW("OCSP: Unable to sign request");
+ LogWarning("OCSP: Unable to sign request");
return CreateRequestResult();
}
}
if (NULL != foundAlg) {
m_pCertIdDigestAlg = foundAlg;
} else {
- WrtLogD("Request for unsupported CertId digest algorithm"
- "ignored!");
+ LogDebug("Request for unsupported CertId digest algorithm ignored!");
}
}
if (NULL != foundAlg) {
m_pRequestDigestAlg = foundAlg;
} else {
- WrtLogD("Request for unsupported OCSP request digest algorithm"
- "ignored!");
+ LogDebug("Request for unsupported OCSP request digest algorithm ignored!");
}
}
// verify ocsp response
int response = OCSP_basic_verify(basic, NULL, m_pTrustedStore, 0);
if (response <= 0) {
- WrtLogW("OCSP verification failed");
+ LogWarning("OCSP verification failed");
}
return response > 0;
asn1GeneralizedTimeToTimeT(nextUpdate,&m_responseValidity);
time_t now;
time(&now);
- WrtLogD("Time of next OCSP update got from server: %d", m_responseValidity);
- WrtLogD("Expires in: %d", (m_responseValidity - now));
- WrtLogD("Original: %d", nextUpdate->data);
+ LogDebug("Time of next OCSP update got from server: " << m_responseValidity);
+ LogDebug("Expires in: " << (m_responseValidity - now));
+ LogDebug("Original: " << nextUpdate->data);
}
switch (status) {
BIO_free_all(res_mem_bio);
if (!response) {
- WrtLogW("OCSP: Failed to convert OCSP Response to DER format");
+ LogWarning("OCSP: Failed to convert OCSP Response to DER format");
return std::make_pair(false, static_cast<OCSP_RESPONSE*>(NULL));
}
{
switch (result) {
case OCSP_RESPONSE_STATUS_MALFORMEDREQUEST:
- WrtLogW("OCSP: Server returns "
+ LogWarning("OCSP: Server returns "
"OCSP_RESPONSE_STATUS_MALFORMEDREQUEST status");
break;
case OCSP_RESPONSE_STATUS_INTERNALERROR:
- WrtLogW("OCSP: Server returns "
+ LogWarning("OCSP: Server returns "
"OCSP_RESPONSE_STATUS_INTERNALERROR status");
break;
case OCSP_RESPONSE_STATUS_TRYLATER:
- WrtLogW("OCSP: Server returns "
+ LogWarning("OCSP: Server returns "
"OCSP_RESPONSE_STATUS_TRYLATER status");
break;
case OCSP_RESPONSE_STATUS_SIGREQUIRED:
- WrtLogW("OCSP: Server returns "
+ LogWarning("OCSP: Server returns "
"OCSP_RESPONSE_STATUS_SIGREQUIRED status");
break;
case OCSP_RESPONSE_STATUS_UNAUTHORIZED:
- WrtLogW("OCSP: Server returns "
+ LogWarning("OCSP: Server returns "
"OCSP_RESPONSE_STATUS_UNAUTHORIZED status");
break;
default:
#include <pcrecpp.h>
#include <dpl/errno_string.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
namespace {
if (a >= '0' && a <= '9') return a-'0';
if (a >= 'A' && a <= 'F') return a-'A' + 10;
if (a >= 'a' && a <= 'f') return a-'a' + 10;
- WrtLogE("Symbol '%c' is out of scope.", a);
+ LogError("Symbol '" << a << "' is out of scope.");
throw ERROR_DECODING_URL;
}
}
}
} catch (Result &) {
- WrtLogE("Error while decoding url path: %s", path.c_str());
+ LogError("Error while decoding url path : " << path);
throw ERROR_DECODING_URL;
}
return std::string(output.begin(), output.end());
std::string currentDir = m_dirpath + directory;
if ((dp = opendir(currentDir.c_str())) == NULL) {
- WrtLogE("Error opening directory: %s", currentDir.c_str());
+ LogError("Error opening directory : " << currentDir);
m_errorDescription = currentDir;
return ERROR_OPENING_DIR;
}
}
if (dirp->d_type == DT_DIR) {
- WrtLogD("Open directory: %s", (directory + dirp->d_name).c_str());
+ LogDebug("Open directory : " << (directory + dirp->d_name));
std::string tmp_directory = directory + dirp->d_name + "/";
Result result = dfsCheckDirectories(referenceSet,
tmp_directory,
if (referenceSet.end() ==
referenceSet.find(directory + dirp->d_name))
{
- WrtLogD("Found file: %s", (directory + dirp->d_name).c_str());
- WrtLogE("Unknown ERROR_REFERENCE_NOT_FOUND.");
+ LogDebug("Found file : " << (directory + dirp->d_name));
+ LogError("Unknown ERROR_REFERENCE_NOT_FOUND.");
closedir(dp);
m_errorDescription = directory + dirp->d_name;
return ERROR_REFERENCE_NOT_FOUND;
}
} else {
- WrtLogE("Unknown file type.");
+ LogError("Unknown file type.");
closedir(dp);
m_errorDescription = directory + dirp->d_name;
return ERROR_UNSUPPORTED_FILE_TYPE;
if (errno != 0) {
m_errorDescription = VcoreDPL::GetErrnoString();
- WrtLogE("readdir failed. Errno code: %d, Description: ", errno, m_errorDescription.c_str());
+ LogError("readdir failed. Errno code : " << errno << ", Description : " << m_errorDescription);
closedir(dp);
return ERROR_READING_DIR;
}
* @brief Simple c++ interface for libxml2.
*/
#include <dpl/assert.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <vcore/SaxReader.h>
{
Assert(m_reader == 0 && "Double initialization of SaxReader");
- WrtLogD("SaxReader opening file: %s", filename.c_str());
+ LogDebug("SaxReader opening file: " << filename);
m_reader = xmlNewTextReaderFilename(filename.c_str());
* @brief Search for author-signature.xml and signatureN.xml files.
*/
#include <vcore/SignatureFinder.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dirent.h>
#include <errno.h>
* find a dir
*/
if ((dp = opendir(m_dir.c_str())) == NULL) {
- WrtLogE("Error opening directory: %s", m_dir.c_str());
+ LogError("Error opening directory: " << m_dir);
return ERROR_OPENING_DIR;
}
}
if (errno != 0) {
- WrtLogE("Error in readdir");
+ LogError("Error in readdir");
closedir(dp);
return ERROR_READING_DIR;
}
#include <vcore/CertificateVerifier.h>
#endif
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
namespace {
const time_t TIMET_DAY = 60 * 60 * 24;
std::string roleURI = data.getRoleURI();
if (roleURI.empty()) {
- WrtLogW("URI attribute in Role tag couldn't be empty.");
+ LogWarning("URI attribute in Role tag couldn't be empty.");
return false;
}
if (roleURI != TOKEN_ROLE_AUTHOR_URI && data.isAuthorSignature()) {
- WrtLogW("URI attribute in Role tag does not "
+ LogWarning("URI attribute in Role tag does not "
"match with signature filename.");
return false;
}
if (roleURI != TOKEN_ROLE_DISTRIBUTOR_URI && !data.isAuthorSignature()) {
- WrtLogW("URI attribute in Role tag does not "
+ LogWarning("URI attribute in Role tag does not "
"match with signature filename.");
return false;
}
bool checkProfileURI(const SignatureData &data) {
if (TOKEN_PROFILE_URI != data.getProfileURI()) {
- WrtLogW(
- "Profile tag contains unsupported value in URI attribute( %s ).", (data.getProfileURI()).c_str());
+ LogWarning(
+ "Profile tag contains unsupported value in URI attribute " << data.getProfileURI());
return false;
}
return true;
ObjectList::const_iterator iter;
for (iter = objectList.begin(); iter != objectList.end(); ++iter) {
if (!data.containObjectReference(*iter)) {
- WrtLogW("Signature does not contain reference for object %s", (*iter).c_str());
+ LogWarning("Signature does not contain reference for object " << *iter);
return false;
}
}
// First step - sort certificate
if (!collection.sort()) {
- WrtLogW("Certificates do not form valid chain.");
+ LogWarning("Certificates do not form valid chain.");
return SignatureValidator::SIGNATURE_INVALID_CERT_CHAIN;//SIGNATURE_INVALID;
}
// Check for error
if (collection.empty()) {
- WrtLogW("Certificate list in signature is empty.");
+ LogWarning("Certificate list in signature is empty.");
return SignatureValidator::SIGNATURE_INVALID_CERT_CHAIN;//SIGNATURE_INVALID;
}
// Is Root CA certificate trusted?
CertStoreId::Set storeIdSet = createCertificateIdentifier().find(root);
- WrtLogD("Is root certificate from TIZEN_DEVELOPER domain: %d", storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
- WrtLogD("Is root certificate from TIZEN_TEST domain: %d", storeIdSet.contains(CertStoreId::TIZEN_TEST));
- WrtLogD("Is root certificate from TIZEN_VERIFY domain: %d", storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
- WrtLogD("Is root certificate from TIZEN_STORE domain: %d", storeIdSet.contains(CertStoreId::TIZEN_STORE));
- WrtLogD("Is root certificate from TIZEN_PUBLIC domain: %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Is root certificate from TIZEN_PARTNER domain: %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Is root certificate from TIZEN_PLATFORM domain: %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Is root certificate from TIZEN_DEVELOPER domain : " << storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
+ LogDebug("Is root certificate from TIZEN_TEST domain : " << storeIdSet.contains(CertStoreId::TIZEN_TEST));
+ LogDebug("Is root certificate from TIZEN_VERIFY domain : " << storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
+ LogDebug("Is root certificate from TIZEN_STORE domain : " << storeIdSet.contains(CertStoreId::TIZEN_STORE));
+ LogDebug("Is root certificate from TIZEN_PUBLIC domain : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Is root certificate from TIZEN_PARTNER domain : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Is root certificate from TIZEN_PLATFORM domain : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
- WrtLogD("Visibility level is public : %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Visibility level is partner : %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Visibility level is platform : %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Visibility level is public : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Visibility level is partner : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Visibility level is platform : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
if (data.isAuthorSignature())
{
if (!storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("author-signature.xml has got unrecognized Root CA "
+ LogWarning("author-signature.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
}
else
{
- WrtLogD("signaturefile name = %s", data.getSignatureFileName().c_str());
+ LogDebug("signaturefile name = " << data.getSignatureFileName());
if (storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogE("distributor has author level siganture! Signature will be disregarded.");
+ LogError("distributor has author level siganture! Signature will be disregarded.");
return SignatureValidator::SIGNATURE_IN_DISTRIBUTOR_CASE_AUTHOR_CERT;//SIGNATURE_INVALID;
}
{
if (storeIdSet.contains(CertStoreId::VIS_PUBLIC) || storeIdSet.contains(CertStoreId::VIS_PARTNER) || storeIdSet.contains(CertStoreId::VIS_PLATFORM))
{
- WrtLogD("Root CA for signature1.xml is correct.");
+ LogDebug("Root CA for signature1.xml is correct.");
}
else
{
- WrtLogW("signature1.xml has got unrecognized Root CA "
+ LogWarning("signature1.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
// If the end certificate is not ROOT CA we should disregard signature
// but still signature must be valid... Aaaaaa it's so stupid...
if (!(root->isSignedBy(root))) {
- WrtLogW("Root CA certificate not found. Chain is incomplete.");
+ LogWarning("Root CA certificate not found. Chain is incomplete.");
// context.allowBrokenChain = true;
}
memset(&tc, 0, sizeof(tc));
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", t->tm_year + 1900, t->tm_mon + 1,t->tm_mday );
- WrtLogD("## System's currentTime : %s", msg);
+ LogDebug("## System's currentTime : " << msg);
fprintf(stderr, "## System's currentTime : %s\n", msg);
tb = _ASN1_GetTimeT(notBeforeTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tb.tm_year + 1900, tb.tm_mon + 1,tb.tm_mday );
- WrtLogD("## certificate's notBeforeTime : %s", msg);
+ LogDebug("## certificate's notBeforeTime : " << msg);
fprintf(stderr, "## certificate's notBeforeTime : %s\n", msg);
ta = _ASN1_GetTimeT(notAfterTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", ta.tm_year + 1900, ta.tm_mon + 1,ta.tm_mday );
- WrtLogD("## certificate's notAfterTime : %s", msg);
+ LogDebug("## certificate's notAfterTime : " << msg);
fprintf(stderr, "## certificate's notAfterTime : %s\n", msg);
if (storeIdSet.contains(CertStoreId::TIZEN_TEST) || storeIdSet.contains(CertStoreId::TIZEN_VERIFY))
{
- WrtLogD("## TIZEN_VERIFY : check certificate Time : FALSE");
+ LogDebug("## TIZEN_VERIFY : check certificate Time : FALSE");
fprintf(stderr, "## TIZEN_VERIFY : check certificate Time : FALSE\n");
return SignatureValidator::SIGNATURE_INVALID_CERT_TIME;//SIGNATURE_INVALID;
}
}
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tc.tm_year + 1900, tc.tm_mon + 1,tc.tm_mday );
- WrtLogD("## cmp cert with validation time : %s", msg);
+ LogDebug("## cmp cert with validation time : " << msg);
fprintf(stderr, "## cmp cert with validation time : %s\n", msg);
time_t outCurrent = mktime(&tc);
if (notAfter < nowTime)
{
context.validationTime = notAfter - TIMET_DAY;
- WrtLogW("Author certificate is expired. notAfter...");
+ LogWarning("Author certificate is expired. notAfter...");
}
*/
if (notBefore > nowTime)
{
- WrtLogW("Author certificate is expired. notBefore time is greater than system-time.");
+ LogWarning("Author certificate is expired. notBefore time is greater than system-time.");
t = localtime(&nowTime);
- WrtLogD("System's current Year : %d", (t->tm_year + 1900));
- WrtLogD("System's current month : %d", (t->tm_mon + 1));
- WrtLogD("System's current day : %d", (t->tm_mday));
t = localtime(¬Before);
- WrtLogD("Author certificate's notBefore Year : %d", (t->tm_year + 1900));
- WrtLogD("Author certificate's notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Author certificate's notBefore day : %d", (t->tm_mday));
context.validationTime = notBefore + TIMET_DAY;
t = localtime(&context.validationTime);
- WrtLogD("Modified current Year : %d", (t->tm_year + 1900));
- WrtLogD("Modified current notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Modified current notBefore day : %d", (t->tm_mday));
}
}
#endif
if (!data.isAuthorSignature())
{
if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validate(&context)) {
- WrtLogW("Installation break - invalid package!");
+ LogWarning("Installation break - invalid package!");
return SignatureValidator::SIGNATURE_INVALID_HASH_SIGNATURE;//SIGNATURE_INVALID;
}
data.setReference(context.referenceSet);
if (!checkObjectReferences(data)) {
- WrtLogW("Failed to check Object References");
+ LogWarning("Failed to check Object References");
return SignatureValidator::SIGNATURE_INVALID_HASH_SIGNATURE;//SIGNATURE_INVALID;
}
/*
ReferenceValidator fileValidator(widgetContentPath);
if (ReferenceValidator::NO_ERROR != fileValidator.checkReferences(data)) {
- WrtLogW("Invalid package - file references broken");
+ LogWarning("Invalid package - file references broken");
return SignatureValidator::SIGNATURE_INVALID_NO_HASH_FILE;//SIGNATURE_INVALID;
}
*/
coll.load(sortedCertificateList);
if (!coll.sort()) {
- WrtLogD("Collection does not contain chain!");
+ LogDebug("Collection does not contain chain!");
return SignatureValidator::SIGNATURE_INVALID_CERT_CHAIN;//SIGNATURE_INVALID;
}
#endif
if (disregard) {
- WrtLogW("Signature is disregard. RootCA is not a member of Tizen");
+ LogWarning("Signature is disregard. RootCA is not a member of Tizen");
return SignatureValidator::SIGNATURE_INVALID_DISTRIBUTOR_CERT;//SIGNATURE_DISREGARD;
}
return SignatureValidator::SIGNATURE_VERIFIED;
const std::list<std::string>& uriList)
{
if(uriList.size() == 0 )
- WrtLogW("checkList >> no hash");
+ LogWarning("checkList >> no hash");
bool disregard = false;
// First step - sort certificate
if (!collection.sort()) {
- WrtLogW("Certificates do not form valid chain.");
+ LogWarning("Certificates do not form valid chain.");
return SignatureValidator::SIGNATURE_INVALID;
}
// Check for error
if (collection.empty()) {
- WrtLogW("Certificate list in signature is empty.");
+ LogWarning("Certificate list in signature is empty.");
return SignatureValidator::SIGNATURE_INVALID;
}
// Is Root CA certificate trusted?
CertStoreId::Set storeIdSet = createCertificateIdentifier().find(root);
- WrtLogD("Is root certificate from TIZEN_DEVELOPER domain: %d", storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
- WrtLogD("Is root certificate from TIZEN_TEST domain: %d", storeIdSet.contains(CertStoreId::TIZEN_TEST));
- WrtLogD("Is root certificate from TIZEN_VERIFY domain: %d", storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
- WrtLogD("Is root certificate from TIZEN_PUBLIC domain: %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Is root certificate from TIZEN_PARTNER domain: %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Is root certificate from TIZEN_PLATFORM domain: %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Is root certificate from TIZEN_DEVELOPER domain : " << storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
+ LogDebug("Is root certificate from TIZEN_TEST domain : " << storeIdSet.contains(CertStoreId::TIZEN_TEST));
+ LogDebug("Is root certificate from TIZEN_VERIFY domain : " << storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
+ LogDebug("Is root certificate from TIZEN_PUBLIC domain : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Is root certificate from TIZEN_PARTNER domain : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Is root certificate from TIZEN_PLATFORM domain : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
- WrtLogD("Visibility level is public : %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Visibility level is partner : %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Visibility level is platform : %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Visibility level is public : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Visibility level is partner : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Visibility level is platform : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
if (data.isAuthorSignature())
{
if (!storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("author-signature.xml has got unrecognized Root CA "
+ LogWarning("author-signature.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
- WrtLogD("Root CA for author signature is correct.");
+ LogDebug("Root CA for author signature is correct.");
}
else
{
- WrtLogD("signaturefile name = %s", data.getSignatureFileName().c_str());
+ LogDebug("signaturefile name = " << data.getSignatureFileName());
if (data.getSignatureNumber() == 1)
{
if (storeIdSet.contains(CertStoreId::VIS_PUBLIC) || storeIdSet.contains(CertStoreId::VIS_PARTNER) || storeIdSet.contains(CertStoreId::VIS_PLATFORM))
{
- WrtLogD("Root CA for signature1.xml is correct.");
+ LogDebug("Root CA for signature1.xml is correct.");
}
else
{
- WrtLogW("signature1.xml has got unrecognized Root CA "
+ LogWarning("signature1.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
// If the end certificate is not ROOT CA we should disregard signature
// but still signature must be valid... Aaaaaa it's so stupid...
if (!(root->isSignedBy(root))) {
- WrtLogW("Root CA certificate not found. Chain is incomplete.");
+ LogWarning("Root CA certificate not found. Chain is incomplete.");
// context.allowBrokenChain = true;
}
memset(&tc, 0, sizeof(tc));
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", t->tm_year + 1900, t->tm_mon + 1,t->tm_mday );
- WrtLogD("## System's currentTime : %s", msg);
+ LogDebug("## System's currentTime : " << msg);
fprintf(stderr, "## System's currentTime : %s\n", msg);
tb = _ASN1_GetTimeT(notBeforeTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tb.tm_year + 1900, tb.tm_mon + 1,tb.tm_mday );
- WrtLogD("## certificate's notBeforeTime : %s", msg);
+ LogDebug("## certificate's notBeforeTime : " << msg);
fprintf(stderr, "## certificate's notBeforeTime : %s\n", msg);
ta = _ASN1_GetTimeT(notAfterTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", ta.tm_year + 1900, ta.tm_mon + 1,ta.tm_mday );
- WrtLogD("## certificate's notAfterTime : %s", msg);
+ LogDebug("## certificate's notAfterTime : " << msg);
fprintf(stderr, "## certificate's notAfterTime : %s\n", msg);
if (storeIdSet.contains(CertStoreId::TIZEN_VERIFY))
{
- WrtLogD("## TIZEN_VERIFY : check certificate Time : FALSE");
+ LogDebug("## TIZEN_VERIFY : check certificate Time : FALSE");
fprintf(stderr, "## TIZEN_VERIFY : check certificate Time : FALSE\n");
return SignatureValidator::SIGNATURE_INVALID;
}
tc.tm_mday = (tb.tm_mday + ta.tm_mday)/2;
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tc.tm_year + 1900, tc.tm_mon + 1,tc.tm_mday );
- WrtLogD("## cmp cert with validation time : %s", msg);
+ LogDebug("## cmp cert with validation time : " << msg);
fprintf(stderr, "## cmp cert with validation time : %s\n", msg);
time_t outCurrent = mktime(&tc);
if (notAfter < nowTime)
{
context.validationTime = notAfter - TIMET_DAY;
- WrtLogW("Author certificate is expired. notAfter...");
+ LogWarning("Author certificate is expired. notAfter...");
}
*/
if (notBefore > nowTime)
{
- WrtLogW("Author certificate is expired. notBefore time is greater than system-time.");
+ LogWarning("Author certificate is expired. notBefore time is greater than system-time.");
t = localtime(&nowTime);
- WrtLogD("System's current Year : %d", (t->tm_year + 1900));
- WrtLogD("System's current month : %d", (t->tm_mon + 1));
- WrtLogD("System's current day : %d", (t->tm_mday));
t = localtime(¬Before);
- WrtLogD("Author certificate's notBefore Year : %d", (t->tm_year + 1900));
- WrtLogD("Author certificate's notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Author certificate's notBefore day : %d", (t->tm_mday));
context.validationTime = notBefore + TIMET_DAY;
t = localtime(&context.validationTime);
- WrtLogD("Modified current Year : %d", (t->tm_year + 1900));
- WrtLogD("Modified current notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Modified current notBefore day : %d", (t->tm_mday));
}
}
#endif
if(uriList.size() == 0)
{
if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validateNoHash(&context)) {
- WrtLogW("Installation break - invalid package! >> validateNoHash");
+ LogWarning("Installation break - invalid package! >> validateNoHash");
return SignatureValidator::SIGNATURE_INVALID;
}
}
{
XmlSecSingleton::Instance().setPartialHashList(uriList);
if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validatePartialHash(&context)) {
- WrtLogW("Installation break - invalid package! >> validatePartialHash");
+ LogWarning("Installation break - invalid package! >> validatePartialHash");
return SignatureValidator::SIGNATURE_INVALID;
}
}
/*
ReferenceValidator fileValidator(widgetContentPath);
if (ReferenceValidator::NO_ERROR != fileValidator.checkReferences(data)) {
- WrtLogW("Invalid package - file references broken");
+ LogWarning("Invalid package - file references broken");
return SignatureValidator::SIGNATURE_INVALID;
}
*/
coll.load(sortedCertificateList);
if (!coll.sort()) {
- WrtLogD("Collection does not contain chain!");
+ LogDebug("Collection does not contain chain!");
return SignatureValidator::SIGNATURE_INVALID;
}
#endif
if (disregard) {
- WrtLogW("Signature is disregard. RootCA is not a member of Tizen.");
+ LogWarning("Signature is disregard. RootCA is not a member of Tizen.");
return SignatureValidator::SIGNATURE_DISREGARD;
}
return SignatureValidator::SIGNATURE_VERIFIED;
// First step - sort certificate
if (!collection.sort()) {
- WrtLogW("Certificates do not form valid chain.");
+ LogWarning("Certificates do not form valid chain.");
return SignatureValidator::SIGNATURE_INVALID;
}
// Check for error
if (collection.empty()) {
- WrtLogW("Certificate list in signature is empty.");
+ LogWarning("Certificate list in signature is empty.");
return SignatureValidator::SIGNATURE_INVALID;
}
// Is Root CA certificate trusted?
CertStoreId::Set storeIdSet = createCertificateIdentifier().find(root);
- WrtLogD("Is root certificate from TIZEN_DEVELOPER domain: %d", storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
- WrtLogD("Is root certificate from TIZEN_TEST domain: %d", storeIdSet.contains(CertStoreId::TIZEN_TEST));
- WrtLogD("Is root certificate from TIZEN_VERIFY domain: %d", storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
- WrtLogD("Is root certificate from TIZEN_PUBLIC domain: %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Is root certificate from TIZEN_PARTNER domain: %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Is root certificate from TIZEN_PLATFORM domain: %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Is root certificate from TIZEN_DEVELOPER domain : " << storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
+ LogDebug("Is root certificate from TIZEN_TEST domain : " << storeIdSet.contains(CertStoreId::TIZEN_TEST));
+ LogDebug("Is root certificate from TIZEN_VERIFY domain : " << storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
+ LogDebug("Is root certificate from TIZEN_PUBLIC domain : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Is root certificate from TIZEN_PARTNER domain : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Is root certificate from TIZEN_PLATFORM domain : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
- WrtLogD("Visibility level is public : %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Visibility level is partner : %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Visibility level is platform : %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Visibility level is public : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Visibility level is partner : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Visibility level is platform : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
if (data.isAuthorSignature())
{
if (!storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("author-signature.xml has got unrecognized Root CA "
+ LogWarning("author-signature.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
} else {
- WrtLogD("signaturefile name = %s", data.getSignatureFileName().c_str());
+ LogDebug("signaturefile name = " << data.getSignatureFileName());
if (storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogE("distributor has author level siganture! Signature will be disregarded.");
+ LogError("distributor has author level siganture! Signature will be disregarded.");
return SignatureValidator::SIGNATURE_INVALID;
}
{
if (storeIdSet.contains(CertStoreId::VIS_PUBLIC) || storeIdSet.contains(CertStoreId::VIS_PARTNER) || storeIdSet.contains(CertStoreId::VIS_PLATFORM))
{
- WrtLogD("Root CA for signature1.xml is correct.");
+ LogDebug("Root CA for signature1.xml is correct.");
}
else
{
- WrtLogW("signature1.xml has got unrecognized Root CA "
+ LogWarning("signature1.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
// If the end certificate is not ROOT CA we should disregard signature
// but still signature must be valid... Aaaaaa it's so stupid...
if (!(root->isSignedBy(root))) {
- WrtLogW("Root CA certificate not found. Chain is incomplete.");
+ LogWarning("Root CA certificate not found. Chain is incomplete.");
// context.allowBrokenChain = true;
}
memset(&tc, 0, sizeof(tc));
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", t->tm_year + 1900, t->tm_mon + 1,t->tm_mday );
- WrtLogD("## System's currentTime : %s", msg);
+ LogDebug("## System's currentTime : " << msg);
fprintf(stderr, "## System's currentTime : %s\n", msg);
tb = _ASN1_GetTimeT(notBeforeTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tb.tm_year + 1900, tb.tm_mon + 1,tb.tm_mday );
- WrtLogD("## certificate's notBeforeTime : %s", msg);
+ LogDebug("## certificate's notBeforeTime : " << msg);
fprintf(stderr, "## certificate's notBeforeTime : %s\n", msg);
ta = _ASN1_GetTimeT(notAfterTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", ta.tm_year + 1900, ta.tm_mon + 1,ta.tm_mday );
- WrtLogD("## certificate's notAfterTime : %s", msg);
+ LogDebug("## certificate's notAfterTime : " << msg);
fprintf(stderr, "## certificate's notAfterTime : %s\n", msg);
if (storeIdSet.contains(CertStoreId::TIZEN_VERIFY))
{
- WrtLogD("## TIZEN_VERIFY : check certificate Time : FALSE");
+ LogDebug("## TIZEN_VERIFY : check certificate Time : FALSE");
fprintf(stderr, "## TIZEN_VERIFY : check certificate Time : FALSE\n");
return SignatureValidator::SIGNATURE_INVALID;
}
tc.tm_mday = (tb.tm_mday + ta.tm_mday)/2;
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tc.tm_year + 1900, tc.tm_mon + 1,tc.tm_mday );
- WrtLogD("## cmp cert with validation time : %s", msg);
+ LogDebug("## cmp cert with validation time : " << msg);
fprintf(stderr, "## cmp cert with validation time : %s\n", msg);
time_t outCurrent = mktime(&tc);
if (notAfter < nowTime)
{
context.validationTime = notAfter - TIMET_DAY;
- WrtLogW("Author certificate is expired. notAfter...");
+ LogWarning("Author certificate is expired. notAfter...");
}
*/
if (notBefore > nowTime)
{
- WrtLogW("Author certificate is expired. notBefore time is greater than system-time.");
+ LogWarning("Author certificate is expired. notBefore time is greater than system-time.");
t = localtime(&nowTime);
- WrtLogD("System's current Year : %d", (t->tm_year + 1900));
- WrtLogD("System's current month : %d", (t->tm_mon + 1));
- WrtLogD("System's current day : %d", (t->tm_mday));
t = localtime(¬Before);
- WrtLogD("Author certificate's notBefore Year : %d", (t->tm_year + 1900));
- WrtLogD("Author certificate's notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Author certificate's notBefore day : %d", (t->tm_mday));
context.validationTime = notBefore + TIMET_DAY;
t = localtime(&context.validationTime);
- WrtLogD("Modified current Year : %d", (t->tm_year + 1900));
- WrtLogD("Modified current notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Modified current notBefore day : %d", (t->tm_mday));
}
}
#endif
if (!data.isAuthorSignature())
{
if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validate(&context)) {
- WrtLogW("Installation break - invalid package!");
+ LogWarning("Installation break - invalid package!");
return SignatureValidator::SIGNATURE_INVALID;
}
ReferenceValidator fileValidator(widgetContentPath);
if (ReferenceValidator::NO_ERROR != fileValidator.checkReferences(data)) {
- WrtLogW("Invalid package - file references broken");
+ LogWarning("Invalid package - file references broken");
return SignatureValidator::SIGNATURE_INVALID;
}
}
coll.load(sortedCertificateList);
if (!coll.sort()) {
- WrtLogD("Collection does not contain chain!");
+ LogDebug("Collection does not contain chain!");
return SignatureValidator::SIGNATURE_INVALID;
}
#endif
if (disregard) {
- WrtLogW("Signature is disregard. RootCA is not a member of Tizen.");
+ LogWarning("Signature is disregard. RootCA is not a member of Tizen.");
return SignatureValidator::SIGNATURE_DISREGARD;
}
return SignatureValidator::SIGNATURE_VERIFIED;
bool complianceMode)
: m_impl(0)
{
- WrtLogD( "appType :%d", appType );
+ LogDebug( "appType : " << appType );
if(appType == TIZEN)
{
#include <dpl/assert.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
namespace SoupWrapper {
SoupMessage* SoupMessageSendBase::createRequest(){
SoupMessage *message;
- WrtLogI("Soup message will be send to: %s", m_host.c_str());
+ LogInfo("Soup message will be send to : " << m_host);
if (!m_requestBuffer.empty()) {
message = soup_message_new("POST", m_host.c_str());
}
if (!message) {
- WrtLogE("Error creating request!");
+ LogError("Error creating request!");
return 0;
}
#include <vconf.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
namespace SoupWrapper {
std::unique_ptr <SoupURI, std::function<void(SoupURI*)> >
proxyURI(soup_uri_new (proxy.get()), soup_uri_free);
- WrtLogD("Proxy ptr: %s Proxy addr: %s", (void*)proxy.get(), proxy.get());
-
for(int tryCount = 0; tryCount < m_tryCount; ++ tryCount){
- WrtLogD("Try(%d) to download %s", tryCount, m_host.c_str());
+ LogDebug("Try(" << tryCount << ") to download " << m_host);
ScopedSoupSession session(soup_session_async_new_with_options(
SOUP_SESSION_ASYNC_CONTEXT,
msg.Reset(createRequest());
if (!msg) {
- WrtLogE("Unable to send HTTP request.");
+ LogError("Unable to send HTTP request.");
m_status = STATUS_IDLE;
return REQUEST_STATUS_CONNECTION_ERROR;
}
m_status = STATUS_IDLE;
return REQUEST_STATUS_OK;
} else {
- WrtLogW("Soup failed with code [%d] message [%s]", msg->status_code, msg->response_body->data);
+ LogWarning("Soup failed with code [" << msg->status_code << "] message [" << msg->response_body->data << "]");
}
}
#include <string.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <dpl/assert.h>
namespace ValidationCore {
const int DATE_BUFFER_LENGTH = 15; // YYYYMMDDHHMMSSZ
if (NULL == res || NULL == tm) {
- WrtLogE("NULL pointer");
+ LogError("NULL pointer");
return -1;
}
if (DATE_BUFFER_LENGTH != tm->length || NULL == tm->data) {
- WrtLogE("Invalid ASN1_GENERALIZEDTIME");
+ LogError("Invalid ASN1_GENERALIZEDTIME");
return -1;
}
&time_s.tm_min,
&time_s.tm_sec) < 6)
{
- WrtLogE("Could not extract time data from ASN1_GENERALIZEDTIME");
+ LogError("Could not extract time data from ASN1_GENERALIZEDTIME");
return -1;
}
#include <glib-object.h>
#include <dpl/assert.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#ifdef TIZEN_FEATURE_CERT_SVC_OCSP_CRL
namespace {
{
#ifdef TIZEN_FEATURE_CERT_SVC_OCSP_CRL
if (threadInterface) {
- WrtLogD("Already Initialized");
+ LogDebug("Already Initialized");
return true;
}
#include <vcore/Certificate.h>
#include <vcore/CertificateConfigReader.h>
#include <vcore/Config.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <string>
CertificateConfigReader reader;
std::string file =
ConfigSingleton::Instance().getXMLConfigPath();
- WrtLogD("File with fingerprint list is: %s", file.c_str());
+ LogDebug("File with fingerprint list is : " << file);
std::string schema =
ConfigSingleton::Instance().getXMLSchemaPath();
- WrtLogD("File with fingerprint list schema is: %s", schema.c_str());
+ LogDebug("File with fingerprint list schema is : " << schema);
reader.initialize(file, schema);
reader.read(certificateIdentifier);
#include <ctype.h>
#include <idna.h>
-#include <<dpl/log/log.h>>
+#include <dpl/log/log.h>
#include <iri.h>
#include "ValidatorCommon.h"
char *output = NULL;
if (IDNA_SUCCESS !=
idna_to_ascii_lz(m_host.c_str(), &output, IDNA_USE_STD3_ASCII_RULES)) {
- WrtLogE("libidn error");
+ LogError("libidn error");
m_parseFailed = true;
free(output);
return;
m_port = PORT_HTTPS;
return;
} else {
- WrtLogD("Scheme %s is not support by WAC2.0 ", m_scheme.c_str());
+ LogDebug("Scheme %s is not support by WAC2.0 " << m_scheme);
m_parseFailed = true;
}
}
#include <vcore/ValidatorFactories.h>
#include <vcore/XmlsecAdapter.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
namespace {
const time_t TIMET_DAY = 60 * 60 * 24;
std::string roleURI = data.getRoleURI();
if (roleURI.empty()) {
- WrtLogW("URI attribute in Role tag couldn't be empty.");
+ LogWarning("URI attribute in Role tag couldn't be empty.");
return false;
}
if (roleURI != TOKEN_ROLE_AUTHOR_URI && data.isAuthorSignature()) {
- WrtLogW("URI attribute in Role tag does not "
+ LogWarning("URI attribute in Role tag does not "
"match with signature filename.");
return false;
}
if (roleURI != TOKEN_ROLE_DISTRIBUTOR_URI && !data.isAuthorSignature()) {
- WrtLogW("URI attribute in Role tag does not "
+ LogWarning("URI attribute in Role tag does not "
"match with signature filename.");
return false;
}
bool checkProfileURI(const SignatureData &data) {
if (TOKEN_PROFILE_URI != data.getProfileURI()) {
- WrtLogW("Profile tag contains unsupported value in URI attribute (%s).", (data.getProfileURI()).c_str());
+ LogWarning("Profile tag contains unsupported value in URI attribute " << data.getProfileURI());
return false;
}
return true;
ObjectList::const_iterator iter;
for (iter = objectList.begin(); iter != objectList.end(); ++iter) {
if (!data.containObjectReference(*iter)) {
- WrtLogW("Signature does not contain reference for object %s", (*iter).c_str());
+ LogWarning("Signature does not contain reference for object " << *iter);
return false;
}
}
// First step - sort certificate
if (!collection.sort()) {
- WrtLogW("Certificates do not form valid chain.");
+ LogWarning("Certificates do not form valid chain.");
return WrtSignatureValidator::SIGNATURE_INVALID_CERT_CHAIN;//SIGNATURE_INVALID;
}
// Check for error
if (collection.empty()) {
- WrtLogW("Certificate list in signature is empty.");
+ LogWarning("Certificate list in signature is empty.");
return WrtSignatureValidator::SIGNATURE_INVALID_CERT_CHAIN;//SIGNATURE_INVALID;
}
// Is Root CA certificate trusted?
CertStoreId::Set storeIdSet = createCertificateIdentifier().find(root);
- WrtLogD("Is root certificate from TIZEN_DEVELOPER domain: %d", storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
- WrtLogD("Is root certificate from TIZEN_TEST domain: %d", storeIdSet.contains(CertStoreId::TIZEN_TEST));
- WrtLogD("Is root certificate from TIZEN_VERIFY domain: %d", storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
- WrtLogD("Is root certificate from TIZEN_PUBLIC domain: %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Is root certificate from TIZEN_PARTNER domain: %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Is root certificate from TIZEN_PLATFORM domain: %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
- WrtLogD("Visibility level is public : %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Visibility level is partner : %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Visibility level is platform : %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Is root certificate from TIZEN_DEVELOPER domain : " << storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
+ LogDebug("Is root certificate from TIZEN_TEST domain : " << storeIdSet.contains(CertStoreId::TIZEN_TEST));
+ LogDebug("Is root certificate from TIZEN_VERIFY domain : " << storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
+ LogDebug("Is root certificate from TIZEN_PUBLIC domain : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Is root certificate from TIZEN_PARTNER domain : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Is root certificate from TIZEN_PLATFORM domain : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Visibility level is public : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Visibility level is partner : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Visibility level is platform : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
if (data.isAuthorSignature())
{
if (!storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("author-signature.xml has got unrecognized Root CA "
+ LogWarning("author-signature.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
{
if (storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("distributor has author level siganture! Signature will be disregarded.");
+ LogWarning("distributor has author level siganture! Signature will be disregarded.");
return WrtSignatureValidator::SIGNATURE_IN_DISTRIBUTOR_CASE_AUTHOR_CERT;//SIGNATURE_INVALID;
}
- WrtLogD("signaturefile name = %s", data.getSignatureFileName().c_str());
+ LogDebug("signaturefile name = " << data.getSignatureFileName());
if (data.getSignatureNumber() == 1)
{
if (storeIdSet.contains(CertStoreId::VIS_PUBLIC) || storeIdSet.contains(CertStoreId::VIS_PARTNER) || storeIdSet.contains(CertStoreId::VIS_PLATFORM))
{
- WrtLogD("Root CA for signature1.xml is correct.");
+ LogDebug("Root CA for signature1.xml is correct.");
}
else
{
- WrtLogW("signature1.xml has got unrecognized Root CA "
+ LogWarning("signature1.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
// If the end certificate is not ROOT CA we should disregard signature
// but still signature must be valid... Aaaaaa it's so stupid...
if (!(root->isSignedBy(root))) {
- WrtLogW("Root CA certificate not found. Chain is incomplete.");
+ LogWarning("Root CA certificate not found. Chain is incomplete.");
//context.allowBrokenChain = true;
}
memset(&tc, 0, sizeof(tc));
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", t->tm_year + 1900, t->tm_mon + 1,t->tm_mday );
- WrtLogD("## System's currentTime : %s", msg);
+ LogDebug("## System's currentTime : " << msg);
fprintf(stderr, "## System's currentTime : %s\n", msg);
tb = _ASN1_GetTimeT(notBeforeTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tb.tm_year + 1900, tb.tm_mon + 1,tb.tm_mday );
- WrtLogD("## certificate's notBeforeTime : %s", msg);
+ LogDebug("## certificate's notBeforeTime : " << msg);
fprintf(stderr, "## certificate's notBeforeTime : %s\n", msg);
ta = _ASN1_GetTimeT(notAfterTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", ta.tm_year + 1900, ta.tm_mon + 1,ta.tm_mday );
- WrtLogD("## certificate's notAfterTime : %s", msg);
+ LogDebug("## certificate's notAfterTime : " << msg);
fprintf(stderr, "## certificate's notAfterTime : %s\n", msg);
if (storeIdSet.contains(CertStoreId::TIZEN_TEST) || storeIdSet.contains(CertStoreId::TIZEN_VERIFY))
{
- WrtLogD("## TIZEN_VERIFY : check certificate Time : FALSE");
+ LogDebug("## TIZEN_VERIFY : check certificate Time : FALSE");
fprintf(stderr, "## TIZEN_VERIFY : check certificate Time : FALSE\n");
return WrtSignatureValidator::SIGNATURE_INVALID_CERT_TIME;//SIGNATURE_INVALID;
}
}
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tc.tm_year + 1900, tc.tm_mon + 1,tc.tm_mday );
- WrtLogD("## cmp cert with validation time : %s", msg);
+ LogDebug("## cmp cert with validation time : " << msg);
fprintf(stderr, "## cmp cert with validation time : %s\n", msg);
time_t outCurrent = mktime(&tc);
if (notAfter < nowTime)
{
context.validationTime = notAfter - TIMET_DAY;
- WrtLogW("Author certificate is expired. notAfter...");
+ LogWarning("Author certificate is expired. notAfter...");
}
*/
if (notBefore > nowTime)
{
- WrtLogW("Author certificate is expired. notBefore time is greater than system-time.");
+ LogWarning("Author certificate is expired. notBefore time is greater than system-time.");
t = localtime(&nowTime);
- WrtLogD("System's current Year : %d", (t->tm_year + 1900));
- WrtLogD("System's current month : %d", (t->tm_mon + 1));
- WrtLogD("System's current day : %d", (t->tm_mday));
+ LogDebug("System's current Year : " << (t->tm_year + 1900));
+ LogDebug("System's current month : " << (t->tm_mon + 1));
+ LogDebug("System's current day : " << (t->tm_mday));
t = localtime(¬Before);
- WrtLogD("Author certificate's notBefore Year : %d", (t->tm_year + 1900));
- WrtLogD("Author certificate's notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Author certificate's notBefore day : %d", (t->tm_mday));
+ LogDebug("Author certificate's notBefore Year : " << (t->tm_year + 1900));
+ LogDebug("Author certificate's notBefore month : " << (t->tm_mon + 1));
+ LogDebug("Author certificate's notBefore day : " << (t->tm_mday));
context.validationTime = notBefore + TIMET_DAY;
t = localtime(&context.validationTime);
- WrtLogD("Modified current Year : %d", (t->tm_year + 1900));
- WrtLogD("Modified current notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Modified current notBefore day : %d", (t->tm_mday));
+ LogDebug("Modified current Year : " << (t->tm_year + 1900));
+ LogDebug("Modified current notBefore month : " << (t->tm_mon + 1));
+ LogDebug("Modified current notBefore day : " << (t->tm_mday));
}
}
#endif
if (!data.isAuthorSignature())
{
if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validate(&context)) {
- WrtLogW("Installation break - invalid package!");
+ LogWarning("Installation break - invalid package!");
return WrtSignatureValidator::SIGNATURE_INVALID_HASH_SIGNATURE;//SIGNATURE_INVALID;
}
data.setReference(context.referenceSet);
if (!checkObjectReferences(data)) {
- WrtLogW("Failed to check Object References");
+ LogWarning("Failed to check Object References");
return WrtSignatureValidator::SIGNATURE_INVALID_HASH_SIGNATURE;//SIGNATURE_INVALID;
}
ReferenceValidator fileValidator(widgetContentPath);
if (ReferenceValidator::NO_ERROR != fileValidator.checkReferences(data)) {
- WrtLogW("Invalid package - file references broken");
+ LogWarning("Invalid package - file references broken");
return WrtSignatureValidator::SIGNATURE_INVALID_NO_HASH_FILE;//SIGNATURE_INVALID;
}
}
coll.load(sortedCertificateList);
if (!coll.sort()) {
- WrtLogD("Collection does not contain chain!");
+ LogDebug("Collection does not contain chain!");
return WrtSignatureValidator::SIGNATURE_INVALID_CERT_CHAIN;//SIGNATURE_INVALID;
}
#endif
if (disregard) {
- WrtLogW("Signature is disregard. RootCA is not a member of Tizen");
+ LogWarning("Signature is disregard. RootCA is not a member of Tizen");
return WrtSignatureValidator::SIGNATURE_INVALID_DISTRIBUTOR_CERT;//SIGNATURE_DISREGARD;
}
return WrtSignatureValidator::SIGNATURE_VERIFIED;
// First step - sort certificate
if (!collection.sort()) {
- WrtLogW("Certificates do not form valid chain.");
+ LogWarning("Certificates do not form valid chain.");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
// Check for error
if (collection.empty()) {
- WrtLogW("Certificate list in signature is empty.");
+ LogWarning("Certificate list in signature is empty.");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
// Is Root CA certificate trusted?
CertStoreId::Set storeIdSet = createCertificateIdentifier().find(root);
- WrtLogD("Is root certificate from TIZEN_DEVELOPER domain: %d", storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
- WrtLogD("Is root certificate from TIZEN_TEST domain: %d", storeIdSet.contains(CertStoreId::TIZEN_TEST));
- WrtLogD("Is root certificate from TIZEN_VERIFY domain: %d", storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
- WrtLogD("Is root certificate from TIZEN_PUBLIC domain: %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Is root certificate from TIZEN_PARTNER domain: %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Is root certificate from TIZEN_PLATFORM domain: %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
-
- WrtLogD("Visibility level is public : %d", storeIdSet.contains(CertStoreId::VIS_PUBLIC));
- WrtLogD("Visibility level is partner : %d", storeIdSet.contains(CertStoreId::VIS_PARTNER));
- WrtLogD("Visibility level is platform : %d", storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Is root certificate from TIZEN_DEVELOPER domain : " << storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER));
+ LogDebug("Is root certificate from TIZEN_TEST domain : " << storeIdSet.contains(CertStoreId::TIZEN_TEST));
+ LogDebug("Is root certificate from TIZEN_VERIFY domain : " << storeIdSet.contains(CertStoreId::TIZEN_VERIFY));
+ LogDebug("Is root certificate from TIZEN_PUBLIC domain : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Is root certificate from TIZEN_PARTNER domain : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Is root certificate from TIZEN_PLATFORM domain : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
+ LogDebug("Visibility level is public : " << storeIdSet.contains(CertStoreId::VIS_PUBLIC));
+ LogDebug("Visibility level is partner : " << storeIdSet.contains(CertStoreId::VIS_PARTNER));
+ LogDebug("Visibility level is platform : " << storeIdSet.contains(CertStoreId::VIS_PLATFORM));
if (data.isAuthorSignature())
{
if (!storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("author-signature.xml has got unrecognized Root CA "
+ LogWarning("author-signature.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
{
if (storeIdSet.contains(CertStoreId::TIZEN_DEVELOPER))
{
- WrtLogW("distributor has author level siganture! Signature will be disregarded.");
+ LogWarning("distributor has author level siganture! Signature will be disregarded.");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
- WrtLogD("signaturefile name = %s", data.getSignatureFileName().c_str());
+ LogDebug("signaturefile name = " << data.getSignatureFileName());
if (data.getSignatureNumber() == 1)
{
if (storeIdSet.contains(CertStoreId::VIS_PUBLIC) || storeIdSet.contains(CertStoreId::VIS_PARTNER) || storeIdSet.contains(CertStoreId::VIS_PLATFORM))
{
- WrtLogD("Root CA for signature1.xml is correct.");
+ LogDebug("Root CA for signature1.xml is correct.");
}
else
{
- WrtLogW("signature1.xml has got unrecognized Root CA "
+ LogWarning("signature1.xml has got unrecognized Root CA "
"certificate. Signature will be disregarded.");
disregard = true;
}
// If the end certificate is not ROOT CA we should disregard signature
// but still signature must be valid... Aaaaaa it's so stupid...
if (!(root->isSignedBy(root))) {
- WrtLogW("Root CA certificate not found. Chain is incomplete.");
+ LogWarning("Root CA certificate not found. Chain is incomplete.");
// context.allowBrokenChain = true;
}
memset(&tc, 0, sizeof(tc));
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", t->tm_year + 1900, t->tm_mon + 1,t->tm_mday );
- WrtLogD("## System's currentTime : %s", msg);
+ LogDebug("## System's currentTime : " << msg);
fprintf(stderr, "## System's currentTime : %s\n", msg);
tb = _ASN1_GetTimeT(notBeforeTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tb.tm_year + 1900, tb.tm_mon + 1,tb.tm_mday );
- WrtLogD("## certificate's notBeforeTime : %s", msg);
+ LogDebug("## certificate's notBeforeTime : " << msg);
fprintf(stderr, "## certificate's notBeforeTime : %s\n", msg);
ta = _ASN1_GetTimeT(notAfterTime);
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", ta.tm_year + 1900, ta.tm_mon + 1,ta.tm_mday );
- WrtLogD("## certificate's notAfterTime : %s", msg);
+ LogDebug("## certificate's notAfterTime : " << msg);
fprintf(stderr, "## certificate's notAfterTime : %s\n", msg);
if (storeIdSet.contains(CertStoreId::TIZEN_VERIFY))
{
- WrtLogD("## TIZEN_VERIFY : check certificate Time : FALSE");
+ LogDebug("## TIZEN_VERIFY : check certificate Time : FALSE");
fprintf(stderr, "## TIZEN_VERIFY : check certificate Time : FALSE\n");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
}
snprintf(msg, sizeof(msg), "Year: %d, month: %d, day : %d", tc.tm_year + 1900, tc.tm_mon + 1,tc.tm_mday );
- WrtLogD("## cmp cert with validation time : %s", msg);
+ LogDebug("## cmp cert with validation time : " << msg);
fprintf(stderr, "## cmp cert with validation time : %s\n", msg);
time_t outCurrent = mktime(&tc);
if (notAfter < nowTime)
{
context.validationTime = notAfter - TIMET_DAY;
- WrtLogW("Author certificate is expired. notAfter...");
+ LogWarning("Author certificate is expired. notAfter...");
}
*/
if (notBefore > nowTime)
{
- WrtLogW("Author certificate is expired. notBefore time is greater than system-time.");
+ LogWarning("Author certificate is expired. notBefore time is greater than system-time.");
t = localtime(&nowTime);
- WrtLogD("System's current Year : %d", (t->tm_year + 1900));
- WrtLogD("System's current month : %d", (t->tm_mon + 1));
- WrtLogD("System's current day : %d", (t->tm_mday));
+ LogDebug("System's current Year : " << (t->tm_year + 1900));
+ LogDebug("System's current month : " << (t->tm_mon + 1));
+ LogDebug("System's current day : " << (t->tm_mday));
t = localtime(¬Before);
- WrtLogD("Author certificate's notBefore Year : %d", (t->tm_year + 1900));
- WrtLogD("Author certificate's notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Author certificate's notBefore day : %d", (t->tm_mday));
+ LogDebug("Author certificate's notBefore Year : " << (t->tm_year + 1900));
+ LogDebug("Author certificate's notBefore month : " << (t->tm_mon + 1));
+ LogDebug("Author certificate's notBefore day : " << (t->tm_mday));
context.validationTime = notBefore + TIMET_DAY;
t = localtime(&context.validationTime);
- WrtLogD("Modified current Year : %d", (t->tm_year + 1900));
- WrtLogD("Modified current notBefore month : %d", (t->tm_mon + 1));
- WrtLogD("Modified current notBefore day : %d", (t->tm_mday));
+ LogDebug("Modified current Year : " << (t->tm_year + 1900));
+ LogDebug("Modified current notBefore month : " << (t->tm_mon + 1));
+ LogDebug("Modified current notBefore day : " << (t->tm_mday));
}
}
#endif
if (!data.isAuthorSignature())
{
if (XmlSec::NO_ERROR != XmlSecSingleton::Instance().validate(&context)) {
- WrtLogW("Installation break - invalid package!");
+ LogWarning("Installation break - invalid package!");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
ReferenceValidator fileValidator(widgetContentPath);
if (ReferenceValidator::NO_ERROR != fileValidator.checkReferences(data)) {
- WrtLogW("Invalid package - file references broken");
+ LogWarning("Invalid package - file references broken");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
}
coll.load(sortedCertificateList);
if (!coll.sort()) {
- WrtLogD("Collection does not contain chain!");
+ LogDebug("Collection does not contain chain!");
return WrtSignatureValidator::SIGNATURE_INVALID;
}
#endif
if (disregard) {
- WrtLogW("Signature is disregard. RootCA is not a member of Tizen.");
+ LogWarning("Signature is disregard. RootCA is not a member of Tizen.");
return WrtSignatureValidator::SIGNATURE_DISREGARD;
}
return WrtSignatureValidator::SIGNATURE_VERIFIED;
#include <xmlsec/errors.h>
#include <dpl/assert.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <vcore/XmlsecAdapter.h>
{
std::string path = s_prefixPath + filename;
- // WrtLogD("Xmlsec opening: %s", path);
+ // LogDebug("Xmlsec opening : " << path);
return new FileWrapper(xmlFileOpen(path.c_str()),false);
}
int XmlSec::fileCloseCallback(void *context)
{
- //WrtLogD("Xmlsec closing: ");
FileWrapper *fw = static_cast<FileWrapper*>(context);
int output = 0;
if (!(fw->released)) {
if(reason != 256)
{
fprintf(stderr, "## [validate error]: %s\n", total);
- WrtLogE(" %s", total);
+ LogError(" " << total);
}
else
{
- WrtLogD(" %s", total);
+ LogDebug(" " << total);
}
}
#endif
if (xmlSecInit() < 0) {
- WrtLogE("Xmlsec initialization failed.");
+ LogError("Xmlsec initialization failed.");
ThrowMsg(Exception::InternalError, "Xmlsec initialization failed.");
}
if (xmlSecCheckVersion() != 1) {
xmlSecShutdown();
- WrtLogE("Loaded xmlsec library version is not compatible.");
+ LogError("Loaded xmlsec library version is not compatible.");
ThrowMsg(Exception::InternalError,
"Loaded xmlsec library version is not compatible.");
}
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
if (xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
xmlSecShutdown();
- WrtLogE(
+ LogError(
"Error: unable to load default xmlsec-crypto library. Make sure "
"that you have it installed and check shared libraries path "
"(LD_LIBRARY_PATH) envornment variable.");
if (xmlSecCryptoAppInit(NULL) < 0) {
xmlSecShutdown();
- WrtLogE("Crypto initialization failed.");
+ LogError("Crypto initialization failed.");
ThrowMsg(Exception::InternalError, "Crypto initialization failed.");
}
if (xmlSecCryptoInit() < 0) {
xmlSecCryptoAppShutdown();
xmlSecShutdown();
- WrtLogE("Xmlsec-crypto initialization failed.");
+ LogError("Xmlsec-crypto initialization failed.");
ThrowMsg(Exception::InternalError,
"Xmlsec-crypto initialization failed.");
}
int size, res = -1;
fileExtractPrefix(context);
- WrtLogD("Prefix path: %s", s_prefixPath.c_str());
+ LogDebug("Prefix path : " << s_prefixPath);
xmlSecIOCleanupCallbacks();
/* load file */
doc = xmlParseFile(context->signatureFile.c_str());
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)) {
- WrtLogW("Unable to parse file %s", (context->signatureFile).c_str());
+ LogWarning("Unable to parse file " << context->signatureFile);
goto done;
}
node = xmlSecFindNode(xmlDocGetRootElement(
doc), xmlSecNodeSignature, xmlSecDSigNs);
if (node == NULL) {
- WrtLogW("Start node not found in %s", (context->signatureFile).c_str());
+ LogWarning("Start node not found in " << context->signatureFile);
goto done;
}
/* create signature context */
dsigCtx = xmlSecDSigCtxCreate(mngr);
if (dsigCtx == NULL) {
- WrtLogE("Failed to create signature context.");
+ LogError("Failed to create signature context.");
goto done;
}
}
if (context->validationTime) {
- WrtLogD("Setting validation time.");
+ LogDebug("Setting validation time.");
dsigCtx->keyInfoReadCtx.certsVerificationTime = context->validationTime;
}
if( m_noHash == true || m_partialHash == true ) {
- WrtLogD("SignatureEx start >> ");
+ LogDebug("SignatureEx start >> ");
if( m_pList == NULL ) {
- WrtLogW("## [validate]: uriList does not exist" );
+ LogWarning("## [validate]: uriList does not exist" );
fprintf(stderr, "## [validate]: uriList does not exist\n");
res = xmlSecDSigCtxVerifyEx(dsigCtx, node, 1, NULL);
} else {
if(m_pList == NULL)
{
- WrtLogW("## [validate]: uriList does not exist" );
+ LogWarning("## [validate]: uriList does not exist" );
fprintf(stderr, "## [validate]: uriList does not exist\n");
res = -1;
goto done;
}
if(res < 0) {
- WrtLogE("SignatureEx verify error.");
+ LogError("SignatureEx verify error.");
fprintf(stderr, "## [validate error]: SignatureEx verify error\n");
res = -1;
goto done;
}
} else {
- WrtLogD("Signature start >> ");
+ LogDebug("Signature start >> ");
/* Verify signature */
if (xmlSecDSigCtxVerify(dsigCtx, node) < 0) {
- WrtLogE("Signature verify error.");
+ LogError("Signature verify error.");
fprintf(stderr, "## [validate error]: Signature verify error\n");
res = -1;
goto done;
if (dsigCtx->keyInfoReadCtx.flags2 &
XMLSEC_KEYINFO_ERROR_FLAGS_BROKEN_CHAIN) {
- WrtLogW("XMLSEC_KEYINFO_FLAGS_ALLOW_BROKEN_CHAIN was set to true!");
- WrtLogW("Signature contains broken chain!");
+ LogWarning("XMLSEC_KEYINFO_FLAGS_ALLOW_BROKEN_CHAIN was set to true!");
+ LogWarning("Signature contains broken chain!");
context->errorBrokenChain = true;
}
/* print verification result to stdout */
if (dsigCtx->status == xmlSecDSigStatusSucceeded) {
- WrtLogD("Signature is OK");
+ LogDebug("Signature is OK");
res = 0;
} else {
- WrtLogD("Signature is INVALID");
+ LogDebug("Signature is INVALID");
res = -1;
goto done;
}
if (dsigCtx->c14nMethod && dsigCtx->c14nMethod->id &&
dsigCtx->c14nMethod->id->name) {
- // WrtLogI("Canonicalization method: %s", (reinterpret_cast<const char *>(dsigCtx->c14nMethod->id->name)).c_str());
+ // LogInfo("Canonicalization method: " << (reinterpret_cast<const char *>(dsigCtx->c14nMethod->id->name)).c_str());
}
size = xmlSecPtrListGetSize(&(dsigCtx->signedInfoReferences));
reinterpret_cast<const char *>(dsigRefCtx->digestMethod->id
->name);
std::string strDigest(pDigest);
- /*WrtLogI("reference digest method: %s" (reinterpret_cast<const char *>(dsigRefCtx->digestMethod->id->name)).c_str());*/
+ /*LogInfo("reference digest method: " << (reinterpret_cast<const char *>(dsigRefCtx->digestMethod->id->name)).c_str());*/
if (strDigest == DIGEST_MD5) {
- WrtLogW("MD5 digest method used! Please use sha");
+ LogWarning("MD5 digest method used! Please use sha");
res = -1;
break;
}
int size = i2d_X509(context->certificatePtr->getX509(), &derCertificate);
if (!derCertificate) {
- WrtLogE("Failed during x509 conversion to der format.");
+ LogError("Failed during x509 conversion to der format.");
ThrowMsg(Exception::InternalError,
"Failed during x509 conversion to der format.");
}
xmlSecKeyDataFormatDer,
xmlSecKeyDataTypeTrusted) < 0) {
OPENSSL_free(derCertificate);
- WrtLogE("Failed to load der certificate from memory.");
+ LogError("Failed to load der certificate from memory.");
ThrowMsg(Exception::InternalError,
"Failed to load der certificate from memory.");
}
context->certificatePath.c_str(),
xmlSecKeyDataFormatPem,
xmlSecKeyDataTypeTrusted) < 0) {
- WrtLogE("Failed to load PEM certificate from file.");
+ LogError("Failed to load PEM certificate from file.");
ThrowMsg(Exception::InternalError,
"Failed to load PEM certificate from file.");
}
xmlSecErrorsSetCallback(LogDebugPrint);
if (!m_initialized) {
- WrtLogE("XmlSec is not initialized.");
+ LogError("XmlSec is not initialized.");
ThrowMsg(Exception::InternalError, "XmlSec is not initialized");
}
AutoPtr<xmlSecKeysMngr> mngr(xmlSecKeysMngrCreate());
if (!mngr.get()) {
- WrtLogE("Failed to create keys manager.");
+ LogError("Failed to create keys manager.");
ThrowMsg(Exception::InternalError, "Failed to create keys manager.");
}
if (xmlSecCryptoAppDefaultKeysMngrInit(mngr.get()) < 0) {
- WrtLogE("Failed to initialize keys manager.");
+ LogError("Failed to initialize keys manager.");
ThrowMsg(Exception::InternalError, "Failed to initialize keys manager.");
}
context->referenceSet.clear();
#include <openssl/bio.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <cert-svc/cinstance.h>
#include <cert-svc/ccert.h>
#define START_TRUSTED "-----BEGIN TRUSTED CERTIFICATE-----"
#define END_TRUSTED "-----END TRUSTED CERTIFICATE-----"
-#ifndef LOG_TAG
-#define LOG_TAG "CERT_SVC"
-#endif
-
using namespace ValidationCore;
namespace {
fieldId = SUBJECT_COMMONNAME;
break;
default:
- WrtLogE("Not implemented!");
+ LogError("Not implemented!");
return CERTSVC_WRONG_ARGUMENT;
}
cert_svc_cert_context_final);
if (ctx.get() == NULL) {
- WrtLogW("Error in cert_svc_cert_context_init.");
+ LogWarning("Error in cert_svc_cert_context_init.");
return CERTSVC_FAIL;
}
- WrtLogD("Match string: %s", value);
+ LogDebug("Match string : " << value);
result = cert_svc_search_certificate(ctx.get(), fieldId, const_cast<char*>(value));
- WrtLogD("Search finished!");
+ LogDebug("Search finished!");
if (CERT_SVC_ERR_NO_ERROR != result) {
- WrtLogW("Error during certificate search");
+ LogWarning("Error during certificate search");
return CERTSVC_FAIL;
}
ScopedCertCtx ctx2(cert_svc_cert_context_init(),
cert_svc_cert_context_final);
if (ctx2.get() == NULL) {
- WrtLogW("Error in cert_svc_cert_context_init.");
+ LogWarning("Error in cert_svc_cert_context_init.");
return CERTSVC_FAIL;
}
if (CERT_SVC_ERR_NO_ERROR !=
cert_svc_load_file_to_context(ctx2.get(), fileList->filename))
{
- WrtLogW("Error in cert_svc_load_file_to_context");
+ LogWarning("Error in cert_svc_load_file_to_context");
return CERTSVC_FAIL;
}
int certId = addCert(CertificatePtr(new Certificate(*(ctx2.get()->certBuf))));
xmlDocPtr doc = xmlParseFile(FINGERPRINT_LIST_PATH);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL))
{
- WrtLogE("Failed to prase fingerprint_list.xml");
+ LogError("Failed to prase fingerprint_list.xml");
return CERTSVC_IO_ERROR;
}
xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(doc));
if(curPtr == NULL)
{
- WrtLogE("Can not find root");
+ LogError("Can not find root");
ret = CERTSVC_IO_ERROR;
goto out;
}
xmlAttr* attr = curPtr->properties;
if(!attr->children || !attr->children->content)
{
- WrtLogE("Failed to get fingerprints from list");
+ LogError("Failed to get fingerprints from list");
ret = CERTSVC_FAIL;
goto out;
}
xmlNodePtr FpPtr = xmlFirstElementChild(curPtr);
if(FpPtr == NULL)
{
- WrtLogE("Could not find fingerprint");
+ LogError("Could not find fingerprint");
ret = CERTSVC_FAIL;
goto out;
}
- WrtLogD("Retrieve level : %s", strLevel);
+ LogDebug("Retrieve level : " << strLevel);
while(FpPtr)
{
xmlChar *content = xmlNodeGetContent(FpPtr);
if(xmlStrcmp(content, (xmlChar*)fingerprint.c_str()) == 0)
{
- WrtLogD("fingerprint : %s are %s", content, strLevel);
+ LogDebug("fingerprint : " << content << " are " << strLevel);
if(!xmlStrcmp(strLevel, xmlPathDomainPlatform))
{
*visibility = CERTSVC_VISIBILITY_PLATFORM;
result = c_certsvc_pkcs12_load_certificates_from_store(storeType, pfxIdString.privateHandler, &certs, &ncerts);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Unable to load certificates from store.");
+ LogError("Unable to load certificates from store.");
return result;
}
Alias.privateLength = strlen(certs[i]);
result = certsvc_pkcs12_get_certificate_info_from_store(instance, storeType, Alias, &certBuffer, &certLength);
if (result != CERTSVC_SUCCESS || !certBuffer) {
- WrtLogE("Failed to get certificate buffer.");
+ LogError("Failed to get certificate buffer.");
return CERTSVC_FAIL;
}
}
if (!trailer) {
- WrtLogE("Failed the get the certificate.");
+ LogError("Failed the get the certificate.");
return CERTSVC_FAIL;
}
&size);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Error in certsvc_pkcs12_private_key_dup");
+ LogError("Error in certsvc_pkcs12_private_key_dup");
return result;
}
BIO *b = BIO_new(BIO_s_mem());
if ((int)size != BIO_write(b, buffer, size)) {
- WrtLogE("Error in BIO_write");
+ LogError("Error in BIO_write");
BIO_free_all(b);
certsvc_pkcs12_private_key_free(buffer);
return CERTSVC_FAIL;
return CERTSVC_SUCCESS;
}
- WrtLogE("Result is null. Openssl REASON code is: %d", ERR_GET_REASON(ERR_peek_last_error()));
+ LogError("Result is null. Openssl REASON code is : " << ERR_GET_REASON(ERR_peek_last_error()));
return CERTSVC_FAIL;
}
return impl(certificate.privateInstance)->getVisibility(certificate, visibility);
} catch (...)
{
- WrtLogE("exception occur");
+ LogError("exception occur");
}
return CERTSVC_FAIL;
}
try {
result = c_certsvc_pkcs12_get_certificate_buffer_from_store(storeType, gname, &certBuffer, &length);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Failed to get certificate buffer from store.");
+ LogError("Failed to get certificate buffer from store.");
return result;
}
pBio = BIO_new(BIO_s_mem());
if (pBio == NULL) {
- WrtLogE("Failed to allocate memory.");
+ LogError("Failed to allocate memory.");
result = CERTSVC_BAD_ALLOC;
}
length = BIO_write(pBio, (const void*) certBuffer, length);
if (length < 1) {
- WrtLogE("Failed to load cert into bio.");
+ LogError("Failed to load cert into bio.");
result = CERTSVC_BAD_ALLOC;
}
fileName.append(CERTSVC_PKCS12_STORAGE_DIR);
fileName.append(gname);
if (!(fp_write = fopen(fileName.c_str(), "w"))) {
- WrtLogE("Failed to open the file for writing, [%s].", fileName.c_str());
+ LogError("Failed to open the file for writing, [" << fileName << "].");
result = CERTSVC_FAIL;
goto error;
}
if (fwrite(certBuffer, sizeof(char), (size_t)length, fp_write) != (size_t)length) {
- WrtLogE("Fail to write certificate.");
+ LogError("Fail to write certificate.");
result = CERTSVC_FAIL;
goto error;
}
fclose(fp_write);
result = certsvc_certificate_new_from_file(instance, fileName.c_str(), certificate);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Failed to construct certificate from buffer.");
+ LogError("Failed to construct certificate from buffer.");
goto error;
}
unlink(fileName.c_str());
int *is_unique)
{
if (pfxIdString.privateHandler == NULL || pfxIdString.privateLength<=0) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
CertSvcStoreCertList** certList)
{
if (*certList == NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
int* length)
{
if (*certList != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
int* length)
{
if (*certList != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
int* length)
{
if (*certList != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
size_t* certSize)
{
if (*certBuffer != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsDeleteCertFromStore(storeType, gname);
try {
if (path.privateHandler != NULL) {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsImportToStore(storeType, path, password, pfxIdString);
char **alias)
{
if (gname.privateHandler == NULL || gname.privateLength<=0) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsGetAliasNameForCertInStore(storeType, gname, alias);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsSetCertStatusToStore(storeType, is_root_app, gname, status);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsGetCertStatusFromStore(storeType, gname, status);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->getCertFromStore(instance, storeType, gname, certificate);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->getPkcsCertificateListFromStore(instance, storeType, pfxIdString, certificateList);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->getPkcsPrivateKeyFromStore(storeType, gname, certBuffer, certSize);
int result = certsvc_pkcs12_private_key_dup_from_store(instance, storeType, gname, &buffer, &size);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Error in certsvc_pkcs12_private_key_dup");
+ LogError("Error in certsvc_pkcs12_private_key_dup");
return result;
}
BIO *b = BIO_new(BIO_s_mem());
if ((int)size != BIO_write(b, buffer, size)) {
- WrtLogE("Error in BIO_write");
+ LogError("Error in BIO_write");
BIO_free_all(b);
certsvc_pkcs12_private_key_free(buffer);
return CERTSVC_FAIL;
if (*pkey)
return CERTSVC_SUCCESS;
- WrtLogE("Result is null. Openssl REASON code is: %d", ERR_GET_REASON(ERR_peek_last_error()));
+ LogError("Result is null. Openssl REASON code is : " << ERR_GET_REASON(ERR_peek_last_error()));
return CERTSVC_FAIL;
}
*/
#include <vcore/exception.h>
-#include <dpl/log/vcore_log.h>
+#include <dpl/log/log.h>
#include <stddef.h>
#include <cstdio>
void LogUnhandledException(const std::string &str)
{
- // Logging to dlog
- VcoreLogD("%s", str.c_str());
+ LogDebug("" << str);
}
void LogUnhandledException(const std::string &str,
int line,
const char *function)
{
- // Logging to dlog
- VcoreLogE("[%s:%d][%s]%s", filename, line, function, str.c_str());
+ LogError("[" << filename << ":" << line << "][" << function << "]" << str);
}
} // namespace ValidationCore