48 const std::string S_ToolName =
"wacenumsample";
49 const std::string S_ToolVersion =
"1.2";
56 "<redist-folder> <ticket> <product> [<locale>]\n"
57 " redist-folder - the folder where the DCA is installed to\n"
58 " ticket - a valid ticket\n"
59 " product - the product associated with your ticket\n"
60 " locale - optional locale for the WAC category info names and descriptions, default = en_US\n\n"
68 # define DCA_BINDIR "bin/Win32"
70 # define DCA_BINDIR "bin/linux"
77 #define DCA_INITDIR "init"
82 #define DCA_LOGDIR "./logs"
106 static void SetupLicense(
const std::string& ticket,
const std::string& product,
109 licenseData.
ticket = ticket;
121 struct tm *expirationTime = localtime( &expirationDate );
123 std::cout <<
"License Info:" << std::endl;
124 std::cout <<
" DCA is " << ( aLicense.
isLicensed() ?
"licensed." :
125 "not licensed." ) << std::endl;
126 std::cout <<
" MaxUsers:" << aLicense.
getMaxUsers() <<
130 std::cout <<
" Ticket:" << aLicense.
getTicket() <<
132 std::cout <<
" Session:" << aLicense.
getSession() <<
136 std::cout <<
" Expiration Date:" << asctime( expirationTime ) <<
146 std::cout <<
"IBM DCA Sample: " << S_ToolName <<
" (" << S_ToolVersion <<
")" << std::endl;
156 std::cout << name <<
" usage:" << std::endl;
170 const std::string& localeString )
172 if( aApplications.
size() == 0 ) {
173 std::cout <<
"Given WacApplications are empty." << std::endl;
177 std::cout <<
"Enumerating Applications:" << std::endl;
182 std::string myCategoryName =
"Not available";
184 myCategoryName = myCategory.
name( localeString );
186 std::cout <<
"Application #" << (i+1) <<
")\t" <<
187 "name=" << myApplication.
name( localeString ) <<
188 ", description=" << myApplication.
description( localeString ) <<
190 <<
" [" << myCategoryName <<
"]" <<
191 ", id=" << myApplication.
id() <<
195 if( numOfActions == 0 ) {
196 std::cout <<
"\tNo Actions available." << std::endl;
199 std::cout <<
"\tAvailable Actions:" << std::endl;
202 std::cout <<
"\tAction #" << (u+1) <<
")\t" <<
203 "name=" << myAction.
name( localeString ) <<
204 ", id=" << myAction.
id() << std::endl;
209 if( numOfTags == 0 ) {
210 std::cout <<
"\tNo Tags available." << std::endl;
213 std::cout <<
"\tAvailable Tags:" << std::endl;
216 std::cout <<
"\tTag #" << (j+1) <<
")\t" <<
217 "name=" << myTag.
name( localeString ) <<
218 ", id=" << myTag.
id() << std::endl;
221 std::cout << std::endl;
223 std::cout << std::endl;
233 void EnumActions(
const dca_wac::WacActions& aWacActions,
const std::string& localeString )
235 if( aWacActions.
size() == 0 ) {
236 std::cout <<
"Given WacActions are empty." << std::endl;
240 std::cout <<
"Enumerating Actions:" << std::endl;
243 std::cout <<
"Action #" << (i+1) <<
")\t" <<
244 "name=" << myAction.
name( localeString ) <<
245 ", description=" << myAction.
description( localeString ) <<
246 ", id=" << myAction.
id() <<
249 std::cout << std::endl;
259 void EnumTags(
const dca_wac::WacTags& aWacTags,
const std::string& localeString )
261 if( aWacTags.
size() == 0 ) {
262 std::cout <<
"Given WacTags are empty." << std::endl;
266 std::cout <<
"Enumerating Tags:" << std::endl;
269 std::cout <<
"Tag #" << (i+1) <<
")\t" <<
270 "name=" << myTag.
name( localeString ) <<
271 ", description=" << myTag.
description( localeString ) <<
272 ", id=" << myTag.
id() <<
275 std::cout << std::endl;
287 const std::string& localeString )
289 std::cout <<
"Entered WAC Enumeration routine." << std::endl;
290 std::cout << std::endl;
293 EnumActions( myActions, localeString );
296 EnumTags( myTags, localeString );
299 EnumApplications( aDcaCategoriesInfo, myApplications, localeString );
301 std::cout <<
"Leaving WAC Enumeration routine." << std::endl;
302 std::cout << std::endl;
312 if( aLocales.
size() == 0 ) {
313 std::cout <<
"Given Locales are empty." << std::endl;
317 std::cout <<
"Enumerating Locales:" << std::endl;
320 std::cout <<
"Locale #" << (i+1) <<
")\t" <<
325 std::cout << std::endl;
334 void EnumCategories(
const dca::Categories& aCategories,
const std::string& localeString )
336 if( aCategories.
size() == 0 ) {
337 std::cout <<
"Given Categories are empty." << std::endl;
341 std::cout <<
"Enumerating Categories:" << std::endl;
344 std::cout <<
"Category #" << (i+1) <<
")\t" <<
345 "name=" << myCategory.
name( localeString ) <<
346 ", id=" << myCategory.
id() <<
349 std::cout << std::endl;
358 void EnumDcaCategoriesInfo(
const dca::CategoriesInfo& aCategoriesInfo,
const std::string& localeString )
360 std::cout <<
"Entered DCA Enumeration routine." << std::endl;
361 std::cout << std::endl;
364 EnumLocales( myLocales );
367 EnumCategories( myCategories, localeString );
369 std::cout <<
"Leaving DCA Enumeration routine." << std::endl;
370 std::cout << std::endl;
380 int main(
int argc,
char *argv[] )
392 std::string myRedistFolder = argv[ 1 ];
393 const std::string myTicket = argv[ 2 ];
394 const std::string myProduct = argv[ 3 ];
395 std::string myLocale =
"en_US";
402 if( myRedistFolder.empty() || myTicket.empty() ||
403 myProduct.empty() ) {
409 const char c = myRedistFolder[ myRedistFolder.length() - 1 ];
410 if( c !=
'/' && c !=
'\\' )
411 myRedistFolder +=
"/";
438 EnumDcaCategoriesInfo( myDcaCategoriesInfo, myLocale );
447 EnumWacCategoriesInfo( myDcaCategoriesInfo, myCategoriesInfo, myLocale );
454 std::cerr <<
"DCA Exception occured. Details: " << ex.
getDescription() <<
458 catch(
const std::exception& s ) {
459 std::cerr <<
"std::exception occured. Details: " << s.what() <<
"." << std::endl;
463 std::cerr <<
"Unknown exception caught." << std::endl;
Is used to create a License object. A license first must be created with DcaInstance::createLicense t...
std::string description(const std::string &localeString=std::string()) const
Returns the localized (brief) description of the application.
DCA_ACTION_ID_TYPE id() const
Returns the internal id of a WacAction class.
Exception class used in the DCA.
const DCA_CATEGORIES_INFO_TYPE DCA_CAT_INFO_TYPE_URL
Refers to the internal categories info for URL classification.
std::string name(const std::string &localeString=std::string()) const
Returns the localized (display) name of the tag.
void InitCUrl()
Initializes libcurl. Do not use any DCA function before initializing libcurl.
std::string initDir
the directory in which the DCA init files are stored
DCA_SIZE_TYPE size() const
Returns the number of categories in the container.
std::string name(const std::string &localeString=std::string()) const
Returns the localized (display) name of the application.
int getMaxSessions() const
Returns the maximum allowed sessions associated with your ticket/license.
time_t getExpirationDate() const
Returns the expiration date of the license in UTC.
std::string getDescription() const
Returns a description of the error.
Definition of a container class for Category objects.
CategoriesInfo getCategoriesInfo(DCA_CATEGORIES_INFO_TYPE categoryType) const
Returns the DCA internal categories, groups and locales.
Encapsulation of a locale class, which allows access to the language id and the display name of local...
static void SetupInitData(const std::string &redist_folder, InitData &initData)
Sets up the given initData by substituting the given redist_folder with DCA subdirectories.
DCA_CATEGORY_ID_TYPE categoryId() const
Returns the id of the associated dca::Category. Each application is a member of only one category.
std::string binDir
the directory in which the DCA binary (*.dca) files are stored
This header includes initialization/deinitialization support functions for the 3rd party libraries us...
A container class that allows access to the contained Categories, Groups and Locales.
void SetOpenSslCallbacks()
Initializes the required callbacks for OpenSSL when using HTTPS or SSL connections in a multi-threade...
The WacAction class represents a given action of an application e.g. UPLOAD FILE, ADD ATTACHMENT,...
void UnsetOpenSslCallbacks()
Unsets the openssl callbacks. Do not call any DCA function after you have called this function.
DCA_CATEGORY_ID_TYPE id() const
The category id.
WacActions getActions() const
Returns all actions available for the application. If an application does not support actions,...
int getMaxUsers() const
Returns the maximum allowed users associated with your ticket/license.
void DeinitCUrl()
Deinitializes libcurl. Do not call any DCA function after you have called this function.
std::string description(const std::string &localeString=std::string()) const
Returns the localized (brief) description of the action.
DCA_SIZE_TYPE size() const
Returns the number of categories in the container.
WacCategoriesInfo getCategoriesInfo() const
Retrieve the WacCategoriesInfo class.
#define DCA_LOGDIR
Relative directory for logfile(s).
std::string description(const std::string &localeString=std::string()) const
Returns the localized (brief) description of the tag.
Package header file for the WAC (Web Application Classification) Package.
#define DCA_INITDIR
DCA subdirectory of the DCA initialization data.
Definition of a container class for WacAction objects.
DCA_RESULT_TYPE getReturnCode() const
Gets the code of the error.
WacTags getTags() const
Returns the contained WacTags.
std::string name(const std::string &localeString=std::string()) const
Returns the localized (display) name of the action.
The WacApplication class represents a given application e.g. HOTMAIL, GMAIL etc.
Locales getLocales() const
Returns the contained Locales.
static void PrintToolHeader()
Prints out the name and the version of this sample.
Defintion of the WacClassification class.
Use a License to initialize a classification package or a toolbox package.
Category byId(DCA_CATEGORY_ID_TYPE id) const
Returns the category with the given category id.
WacActions getActions() const
Returns the contained WacActions.
Container class for all WAC enumeration objects.
bool isLicensed(DCA_MODULE_ID_TYPE id=0, bool force=false) const
Checks whether the given License is valid for the given module id.
static void PrintLicenseInfo(const License &aLicense)
Prints out the information about the provided License.
std::string ticket
The ticket as provided in the license.
This header includes all header files of the DCA Base Package.
DCA_APPLICATION_ID_TYPE id() const
Returns the internal id of a WacApplication class.
Encapsulates the init and deinit of the DCA API.
Category NullCategory
Defines a constant unassigned Category you can use for checks. if( myCat == NullCategory ) --> myCat ...
std::string product
The product code used with the license.
Definition of a container class for WacApplication objects.
WacAction at(DCA_INDEX_TYPE index) const
Returns the WacAction with the given index.
DCA_TAG_ID_TYPE id() const
Returns the internal id of a WacTag class.
static WacClassification create(const dca::DcaInstance &aDca, const dca::License &aLicense)
Initializes the WacClassification module.
static DCA_MODULE_ID_TYPE ID
The unique ID of the WAC classification module.
std::string logDir
the directory in which the DCA log file should be created
WacApplications getApplications() const
Returns the contained WacApplications.
static void PrintUsage(const char *name)
Prints out the syntax of the sample.
std::string getLastMessage() const
Returns the last message received from our license server or if none available the last available mes...
size_t DCA_INDEX_TYPE
Type for index access (used for arrays and collections).
Categories getCategories() const
Returns the contained Categories.
WacTags getTags() const
Returns all tags that are defined for a given application e.g. "RISKLEVEL_1", "HIGH BANDWIDTH" etc.
size_t DCA_SIZE_TYPE
Type for size (used for size of array and collections).
std::string name(const std::string &localeString=std::string()) const
Returns the localized (display) name of the category.
std::string displayName() const
Returns the display name of the locale.
std::string getTicket() const
Returns the ticket of the license as string.
#define DCA_BINDIR
DCA subdirectory of the DCA binaries.
std::string getSession() const
Returns the session of the license as string.
Definition of a container class for Locale objects.
std::string languageId() const
Returns the language id as defined in the related categories.xml.
DCA_SIZE_TYPE size() const
Returns the number of applications in the container.
DCA_SIZE_TYPE size() const
Returns the number of actions in the container.
const std::string S_UsageString
Usage string, displayed if a parameter is missing.
The WacTag class represents a given tag that is associated with an application e.g....
This structure is used to initialize the DcaInstance.
Encapsulates a category as defined in the categories XML schema (see Categories XML: Categories).
static DcaInstance create(const InitData &initData)
Creates a DcaInstance, starts up the DCA API and initializes the required main module.
static void SetupLicense(const std::string &ticket, const std::string &product, LicenseData &licenseData)
Sets up the given licenseData by copying the given ticket and product strings.
License createLicense(const LicenseData &licData, const ProxySettings &proxySettings=ProxySettings(), LogLevel aLogLevel=LOG_Initial) const
Creates a License object using the given LicenseData.
int main(int argc, char *argv[])
The main routine.