• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 12.0.1.79
SafeUrl Class Reference

Check that URLs are safe using BlackBerry Protect (C++). More...

#include <GDSafeUrl.h>

Description

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...
 

Member Enumeration Documentation

◆ UrlCheckResult

enum UrlCheckResult
strong

These constants can determine the result returned by BlackBerry Protect safe browsing detection.

Enumerator
UNKNOWN 

The result could not be determined.

SAFE 

The URL is deemed to be safe.

UNSAFE 

The URL is flagged as being unsafe or malicious and should not be called.

◆ UrlCheckError

enum UrlCheckError
strong

These constants can be used for handling errors returned by BlackBerry Protect safe browsing detection.

Enumerator
NONE 

No error has been detected.

NETWORK 

There was a networking error whilst trying to check that the URL was safe.

GENERAL 

Another error was encountered whilst checking that the URL was safe.

Member Function Documentation

◆ checkUrl()

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.

Parameters
urlstring A string containing the URL.
callbackstd::weak_ptr<SafeUrlCallback> A callback object that is called when the result is obtained .
referencelong long An optional parameter that is set by the caller, which is returned to the callback object.
suppressUserPromptboolean An optional boolean parameter to suppress the user interface prompt shown by the Dynamics Runtime if the URL is unsafe.

◆ isSafeBrowsingEnabled()

bool isSafeBrowsingEnabled ( )

This function returns whether or not the safe browsing feature within BlackBerry Protect is enabled for the user.

Returns
bool true if enabled, false if disabled.

The documentation for this class was generated from the following file: