The Site Reputation SDK enables you to warn or guard your users from accessing low reputation websites. The getSiteReputation function of the SDK returns a SiteReputation structure with attributes you can use to form a decision on whether to block access to a site or display a warning to your users.
var client: SudoSiteReputationClient!let uri ="http://www.wikipedia.com"let result =tryawait instance.getSiteReputation(url: uri)switch result.status {case .notMalicious:breakcase .malicious:breakcase .unkown:break}
// val client: SudoSiteReputationClientlaunch {try {val siteReputation =withContext(Dispatchers.IO) { client.getSiteReputation( url ="http://somedodgyhost.com/somewhere" ) }if (badSite.status == SudoSiteReputation.MaliciousState.MALICIOUS) { System.out.println("This page is bad mkay") } } catch (e: SudoSiteReputationException) {// Handle/notify user of exception }}
SiteReputation Interface
/** * The state of knowledge of a site's reputation. */exporttypeReputationStatus='NOTMALICIOUS'|'MALICIOUS'|'UNKNOWN'/** * The response of a given url's site reputation. */exportinterfaceSiteReputation {/** Returns `MALICIOUS` if malicious, `NOTMALICIOUS` if not, and `UNKNOWN` if unable to be determined. */ reputationStatus:ReputationStatus}
publicstructSiteReputation {/// Search statuspublicenumReputationStatus {// URI not in dataset as not maliciouscase notMalicious// URI found in dataset as maliciouscase malicious// URI not found in the datasetcase unkown }/// The returned result of the lookup for the site. If .success you can expect the other properties to be non nil.publiclet status: ReputationStatus}
publicdataclassSiteReputation(/** status of the search */val status: ReputationStatus,) : Parcelable {enumclassReputationStatus {/** site is to be malicious */ MALICIOUS,/** site is not known to be malicious */ NOTMALICIOUS,/** no site data available to make a determination */ UNKNOWN }}