Check that URLs are safe using BlackBerry Protect (C++). More...
#include <GDSafeUrl.h>
BlackBerry Protect uses a combination of cloud and on-device based AI and machine learning to identify malware and unsafe URLs. It is integrated into the Dynamics HTTP secure communication APIs and when licensed provides protection without further integration being required.
If an application wants to check a URL outside of utilizing GDURLLoadingSystem this class can be used to first confirm if BlackBerry Protect is enabled for the user (SafeUrl::isSafeBrowsingEnabled) and then to check that specific URLs are safe (SafeUrl::checkUrl)
Caller class needs to implement the callback class and wrap it into shared pointer and pass it as a weak pointer. The reference number is optional. These APIs can be called only after SDK has been initialised (i.e. after the authorized event).
The caller can use this API in two modes:
1. One-to-one mode: in this case, you need to have separate callback object (wrapped in a shared pointer) for each URL request. However, this will not scale well. 2. Dispatch mode: you can keep a single callback object and use a reference number for matching your URLs and results. This will scale well.
Please note that SafeUrl class follows the "Monostate" design pattern, that is - you can create as many instances of this class as you wish and all will behave as if they are the same object.
Classes | |
class | SafeUrlCallback |
Callback object returned from SafeURL. More... | |
class | SafeUrlResultItem |
Item within the SafeURL callback. More... | |
Public Types | |
enum | UrlCheckResult { UNKNOWN = 0, SAFE = 1, UNSAFE = 20 } |
Result codes from testing if a URL is safe. More... | |
enum | UrlCheckError { NONE = 0, NETWORK = 1, GENERAL = 2 } |
Error codes from testing if a URL is safe. More... | |
Public Member Functions | |
void | checkUrl (const std::string &url, const std::weak_ptr< SafeUrlCallback > callback, const long long reference=0, const bool suppressUserPrompt=false) const |
This function checks whether or not the url is safe to make an http request. More... | |
bool | isSafeBrowsingEnabled () |
Determine if Safe Browsing is enabled. More... | |
|
strong |
|
strong |
These constants can be used for handling errors returned by BlackBerry Protect safe browsing detection.
void checkUrl | ( | const std::string & | url, |
const std::weak_ptr< SafeUrlCallback > | callback, | ||
const long long | reference = 0 , |
||
const bool | suppressUserPrompt = false |
||
) | const |
The result is returned to the callback object SafeUrlCallback that is passed by the caller.
url | string A string containing the URL. |
callback | std::weak_ptr<SafeUrlCallback> A callback object that is called when the result is obtained . |
reference | long long An optional parameter that is set by the caller, which is returned to the callback object. |
suppressUserPrompt | boolean An optional boolean parameter to suppress the user interface prompt shown by the Dynamics Runtime if the URL is unsafe. |
bool isSafeBrowsingEnabled | ( | ) |
This function returns whether or not the safe browsing feature within BlackBerry Protect is enabled for the user.
bool
true if enabled, false if disabled.