dca_interface  6.3.4
Setting up a Database Connection

Initialization

When using URL Classification or other packages that require a signature database, you will need to set up a dca::DbConnection object to access the database.

This object defines where the requests will be sent to and, for example, whether or not to use a proxy server etc.

To create a DbConnection object, you must first create and initialize a dca::DbConnectionData structure, then use dca::DcaInstance::createDbConnection() to create the connection object.

Database types

URL Database Connections supporting either local or remote connections.

Local Database connections are using a database that is stored locally on hard drive.

The database is stored in folder:

dca/init/dca_urlclassification/db/

Updates on regular time bases are provided by using the functions dca::UpdateModule::performUpdate() and dca:DcaInstance::schedule().

Remote database connections are using a HTTP connection to one of our remote URL Database Servers

IP Reputation Database Connections are supporting only local connections.

Malware Database Connections are supporting only local connections.

The database is stored in folder:

dca/init/dca_ipr/db/

Updates on regular time bases are provided by using the functions dca::UpdateModule::performUpdate() and dca:DcaInstance::schedule().

Web Application Classification Database Connections are supporting only local connections.

The database is stored in folder:

dca/init/dca_wac/db/

Updates on regular time bases are provided by using the functions dca::UpdateModule::performUpdate() and dca:DcaInstance::schedule().

ZLA Database Connections are supporting only local connections.

The database is stored in folder:

dca/init/dca_mail/db/

Updates on regular time bases are provided by using the functions dca::UpdateModule::performUpdate() and dca:DcaInstance::schedule().

Custom Database connections using only local databases.

The database can be created by the Client application and also the updates must be added by the application itself.

Custom databases can be created and maintained using the Custom Database Module Toolbox.

We do not provide updates for custom databases.

The database type, and whether or not a connection should be local or remote, can be specified when filling out the required dca::DbConnectionData structure.

Local connections

When setting up a local database connection (for a URL or Mail database), the localData field of DbConnectionData can be optionally filled in. This specifies when and how often the local database is merged with database update files (a potentially time consuming operation).

When setting up a custom database connection, the customData field of DbConnectionData can be optionally filled in. This specifies when and how often the custom database is merged with database update files (the files are generated by the Custom Database Toolbox maintenance functions), settings for the database cache, and where the custom database is located on disk.

For more information on Custom databases, please refer to the section Custom Database Module.

Note:

Local Mail and URL signature databases are initially empty when using a default distribution of the SCA. A connection to a database can be established, but no signature queries will match until a complete database has been downloaded. The download of a complete local database occurs as part of the update and schedule processes.

See also
Using the default local database as part of your distribution

Remote connections

Only a URL database can be accessed via a remote connection. Mail and Custom databases are always local. When creating a remote connection, the remoteServerData field of DbConnectionData must be filled in. This specifies the encryption settings to use when communicating with the remote server. These settings will have been provided for you as part of your license.

In addition, a proxy server can be configured when communicating with a remote server. To do this, setup a dca::ProxySettings structure and pass this additionally to the dca::DcaInstance::createDbConnection() function. It is also possible to setup global (default) proxy settings for the SCA (see dca::DcaInstance::setDefaultProxySettings()).

Using the database connection

A database connection can only be used in conjunction with a dca::UrlDbClassifier or dca::ZlaClassifier . Please refer to the section on URL Classification or Zero Level Analysis (ZLA) for more information on this.

Example code

The following code demonstrates how to set up a database connection to a URL database.

// assume we have a valid DcaInstance (myDca) and License (myLicense)
dca::DbConnectionData myDbConnectionData;
myDbConnectionData.dbType = DBT_Url; // we want to use a URL signature database
if( using_local_dbconnection ) {
// set up a database connection using a local signature database - if there is no
// local database present, you will get an error and should switch to remote database mode
myDbConnectionData.useLocalDatabase = true;
}
else {
// set up a database connection using remote signature database
myDbConnectionData.useLocalDatabase = false;
myDbConnectionData.remoteServerData.encryptionData = "lksi2342... your license encryption data ...";
myDbConnectionData.remoteServerData.encryptionKey = 13; // your license encryption key
}
// create the database connection by using the set up DbConnectionData
dca::DbConnection myDbConnection = myDca.createDbConnection( myLicense, myDbConnectionData );
// myDbConnection is valid and can be used now
unsigned int encryptionKey
The encryption key to be used (provided with your license)
Definition: base_classes.h:779
Stores the connection data for a database.
Definition: base_classes.h:815
Database connection class for a local or remote database.
Definition: base_classes.h:859
bool useLocalDatabase
Set to true to connect to a local or custom database, set to false to use a remote database.
Definition: base_classes.h:821
const DbType DBT_Url
Used for DbConnection classes for URL classification.
DbType dbType
The type of the database.
Definition: base_classes.h:820
DbConnectionRemoteServerData remoteServerData
If you are creating a remote database connection, this structure must be filled out with the encrypti...
Definition: base_classes.h:824
DbConnection createDbConnection(const License &aLicense, const DbConnectionData &dbcData, const ProxySettings &proxySettings=ProxySettings(), LogLevel aLogLevel=LOG_Initial) const
Creates a DbConnection object using the given DbConnectionData.
std::string encryptionData
The encryption data to be used (provided with your license)
Definition: base_classes.h:778