Name

global.ARCSecurityUtils

Description

No description available

Script

var ARCSecurityUtils = Class.create();
ARCSecurityUtils.prototype = {
  initialize: function() {
  },
  
  
  verifyCaptcha: function(captchaText) {
  	if (gs.getProperty('sn_anon_rc.arc.captcha.google.enabled', 'false') == 'false' && captchaText)
  		return new SNC.PwdImageCaptcha().validateCaptchaValue(captchaText);
  	},
  
  verifyGoogleCaptcha: function(captchaResponse) {
  	try {
  		// Create REST message to check the passed token with Google recaptcha service:
  		/* eslint-disable no-undef */
  		var r = new sn_ws.RESTMessageV2();
  		/* eslint-disable no-undef */
  		
  		r.setHttpMethod('post');
  		r.setEndpoint('https://www.google.com/recaptcha/api/siteverify');
  		
  		var secret = gs.getProperty('google.captcha.secret');
  		var Encrypter = new GlideEncrypter();
  		
  		r.setQueryParameter('secret', Encrypter.decrypt(secret));
  		r.setQueryParameter('response', captchaResponse);
  		
  		var response = r.execute();
  		
  		var responseBody = response.getBody();
  		
  		var parser = new JSONParser();
  		var parsed = parser.parse(responseBody);
  		
  		return parsed;
  		
  	}
  	catch(ex) {
  		return "false";
  	}
  },

  type: 'ARCSecurityUtils'
};

Sys ID

c38ac25bc3e270102920b8889d40dde5

Offical Documentation

Official Docs: