Sample callback method:  CAUTION: does not check CRL/ARL.
338556
def sample_verify_callback(is_ok, ctx)
    unless is_ok
      depth = ctx.error_depth
      code = ctx.error
      msg = ctx.error_string
      STDERR.puts "at depth #{depth} - #{code}: #{msg}" if $DEBUG
      return false
    end

    cert = ctx.current_cert
    self_signed = false
    ca = false
    pathlen = nil
    server_auth = true
    self_signed = (cert.subject.cmp(cert.issuer) == 0)

    # Check extensions whatever its criticality is. (sample)
    cert.extensions.each do |ex|
      case ex.oid
      when 'basicConstraints'
        /CA:(TRUE|FALSE), pathlen:(\d+)/ =~ ex.value
        ca = ($1 == 'TRUE')
        pathlen = $2.to_i
      when 'keyUsage'
        usage = ex.value.split(/\s*,\s*/)
        ca = usage.include?('Certificate Sign')
        server_auth = usage.include?('Key Encipherment')
      when 'extendedKeyUsage'
        usage = ex.value.split(/\s*,\s*/)
        server_auth = usage.include?('Netscape Server Gated Crypto')
      when 'nsCertType'
        usage = ex.value.split(/\s*,\s*/)
        ca = usage.include?('SSL CA')
        server_auth = usage.include?('SSL Server')
      end
    end

    if self_signed
      STDERR.puts 'self signing CA' if $DEBUG
      return true
    elsif ca
      STDERR.puts 'middle level CA' if $DEBUG
      return true
    elsif server_auth
      STDERR.puts 'for server authentication' if $DEBUG
      return true
    end

    return false
  end
773599
function (baseUrl, method, handler, example, callback) {
    baseUrl = baseUrl || 'http://localhost';

    var client = null;
    var results = {
      failed: [],
      passed: []
    };
    var self = this;
    var testUrl = url.parse(String(baseUrl));
    testUrl.pathname = normalizePath(self.path, testUrl.pathname);
    testUrl = url.parse(url.format(testUrl));
    switch (testUrl.protocol) {
      case 'https:':
        client = https;
        break;
      case 'http:':
        client = http;
        break;
      default:
        var error = new Error('Invalid base site: ' + baseUrl +
          ' (should start with "http://" or "https://")');
        callback(error, results);
        return;
    }

    var beforeEachTest = self.beforeEachTest || function (next) { next(); };
    if (typeof beforeEachTest !== 'function') {
      callback(new Error('"beforeEachTest" should be a function'), results);
      return;
    }

    var afterEachTest = self.afterEachTest || function (next) { next(); };
    if (typeof afterEachTest !== 'function') {
      callback(new Error('"afterEachTest" should be a function'), results);
      return;
    }

    var requestOptions = {
      hostname: testUrl.hostname,
      port: testUrl.port,
      path: testUrl.pathname,
      method: method
    };

    var exampleRequest = example.request || {};
    var exampleResponse = example.response || {};

    if (exampleRequest.urlParameters) {
      requestOptions.path = replaceUrlParameters(requestOptions.path,
        exampleRequest.urlParameters);
    }

    if (exampleRequest.queryParameters) {
      var queryPairs = [];
      for (var queryParameter in exampleRequest.queryParameters) {
        var queryValue = exampleRequest.queryParameters[queryParameter];
        queryPairs.push(encodeURIComponent(queryParameter) +
          (queryValue ? '=' + encodeURIComponent(queryValue) : ''));
      }
      requestOptions.path += '?' + queryPairs.join('&');
    }

    if (exampleRequest.headers) {
      requestOptions.headers = exampleRequest.headers;
    }

    var summary = {
      handler: handler.title || '(no title)',
      method: requestOptions.method,
      uri: requestOptions.path,
      request: exampleRequest
    };

    beforeEachTest(function (error) {
      if (error) {
        callback(error, results);
        return;
      }

      var request = client.request(requestOptions, function (response) {
        var success = true;

        var expectedStatusCode = (typeof exampleResponse.status === 'function'
          ? exampleResponse.status
          : function (statusCode) {
            return statusCode === (exampleResponse.status || 200);
          });
        if (!expectedStatusCode(response.statusCode)) {
          success = false;
        }

        var expectedHeaders = null;
        if (exampleResponse.headers) {
          expectedHeaders = exampleResponse.headers;
          for (var header in expectedHeaders) {
            var headerValue = expectedHeaders[header];
            var expectedHeaderValue = (typeof headerValue === 'function'
              ? headerValue
              : function (value) {
                return value === headerValue;
              });
            if (!expectedHeaderValue(response.headers[header.toLowerCase()])) {
              success = false;
              break;
            }
          }
        }

        var expectedBody = null;
        if ('body' in exampleResponse) {
          var exampleBody = exampleResponse.body;
          expectedBody = (typeof exampleBody === 'function'
            ? exampleBody
            : function (body) {
              return body === jsonStringifyIfObject(exampleBody).trim();
            });
        }

        var body = '';
        response.on('data', function (chunk) {
          body += String(chunk);
        });

        response.on('end', function () {
          clearTimeout(timeout);
          body = body.trim();
          if (expectedBody !== null && !expectedBody(body)) {
            success = false;
          }
          if (success) {
            summary.response = exampleResponse;
            results.passed.push(summary);
            afterEachTest(function (error) {
              callback(error, results);
            });
            return;
          }
          summary.expectedResponse = exampleResponse;
          summary.actualResponse = {
            status: response.statusCode
          };
          if (expectedHeaders !== null) {
            summary.actualResponse.headers = response.headers;
          }
          if (expectedBody !== null) {
            summary.actualResponse.body = body;
          }
          results.failed.push(summary);
          afterEachTest(function (error) {
            callback(error, results);
          });
        });
      });

      request.on('error', function (error) {
        clearTimeout(timeout);
        summary.expectedResponse = exampleResponse;
        summary.actualResponse = {
          error: error.message || String(error)
        };
        results.failed.push(summary);
        afterEachTest(function (error) {
          callback(error, results);
        });
      });

      // Abort requests that take longer than 10 seconds.
      var timeout = setTimeout(function () {
        request.emit('error', new Error('timed out'));
      }, 10000);

      if ('body' in exampleRequest) {
        request.write(jsonStringifyIfObject(exampleRequest.body));
      }
      request.end();
    });
  }
2223
def validate_callback(self, service, pgturl, pgtid, pgtiou):
        """"""
        if not proxy_allowed(service):
            raise UnauthorizedServiceProxy("%s is not authorized to use proxy authentication" % service)

        if not is_scheme_https(pgturl):
            raise InvalidProxyCallback("Proxy callback %s is not HTTPS" % pgturl)

        if not proxy_callback_allowed(service, pgturl):
            raise InvalidProxyCallback("%s is not an authorized proxy callback URL" % pgturl)

        # Verify that the SSL certificate is valid
        verify = os.environ.get('REQUESTS_CA_BUNDLE', True)
        try:
            requests.get(pgturl, verify=verify, timeout=5)
        except requests.exceptions.SSLError:
            raise InvalidProxyCallback("SSL certificate validation failed for proxy callback %s" % pgturl)
        except requests.exceptions.RequestException as e:
            raise InvalidProxyCallback(e)

        # Callback certificate appears valid, so send the ticket strings
        pgturl = add_query_params(pgturl, {'pgtId': pgtid, 'pgtIou': pgtiou})
        try:
            response = requests.get(pgturl, verify=verify, timeout=5)
        except requests.exceptions.RequestException as e:
            raise InvalidProxyCallback(e)

        try:
            response.raise_for_status()
        except requests.exceptions.HTTPError as e:
            raise InvalidProxyCallback("Proxy callback %s returned %s" % (pgturl, e))
260016
public void checkReloadState(final AsyncCallback<Boolean> callback) {

        // :read-attribute(name=process-type)
        final ModelNode operation = new ModelNode();
        operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
        operation.get(NAME).set("server-state");
        operation.get(ADDRESS).setEmptyList();

        dispatcher.execute(new DMRAction(operation), new SimpleCallback<DMRResponse>() {

            @Override
            public void onSuccess(DMRResponse result) {

                ModelNode response = result.get();
                System.out.println(response);

                if(response.isFailure()) {
                    callback.onFailure(new RuntimeException("Failed to poll server state"));
                }
                else
                {
                    // TODO: only works when this response changes the reload state
                    String outcome = response.get(RESULT).asString();
                    boolean keepRunning = !outcome.equalsIgnoreCase("running");//reloadState.isStaleModel();

                    if(!keepRunning)
                    {

                        // clear state
                        reloadState.reset();

                        Console.info(Console.MESSAGES.successful("Reload Server"));
                        getView().setReloadRequired(reloadState);
                        getEventBus().fireEvent(new ReloadEvent());
                    }

                    callback.onSuccess(keepRunning);
                }
            }
        });
    }
1246991
def check_connection (self):
        
        if (self.parent_url is not None and
           not self.parent_url.startswith(u"file:")):
            msg = _("local files are only checked without parent URL or when the parent URL is also a file")
            raise LinkCheckerError(msg)
        if self.is_directory():
            self.set_result(_("directory"))
        else:
            url = fileutil.pathencode(self.url)
            self.url_connection = urlopen(url)
            self.check_case_sensitivity()
604000
def execute_callback(callback, *args)
      (callback.arity == 2 ? callback.call(*args[0, 2]) : callback.call(*args)) if callback
    end
1294746
def validate_callback_data(method):
    
    @wraps(method)
    def method_wrapper(*args, **kwargs):
        """

        Parameters
        ----------
        *args
        **kwargs

        Returns
        -------
        method's output
        """
        expected = method.__code__.co_varnames

        # rename curret gam object
        if 'self' in kwargs:
            gam = kwargs['self']
            del(kwargs['self'])
            kwargs['gam'] = gam

        # loop once to check any missing
        missing = []
        for e in expected:
            if e == 'self':
                continue
            if e not in kwargs:
                missing.append(e)
        assert len(missing) == 0, 'CallBack cannot reference: {}'.\
                                  format(', '.join(missing))

        # loop again to extract desired
        kwargs_subset = {}
        for e in expected:
            if e == 'self':
                continue
            kwargs_subset[e] = kwargs[e]

        return method(*args, **kwargs_subset)

    return method_wrapper
87077
function callbackMiddleware (req, res, next) {
  if (req.url.indexOf('callback') === -1) {
    next()
  } else if (req.url.indexOf('error') === -1) {
    res.status(200).jsonp({ created: true })
  } else {
    res.status(400).jsonp({ error: true })
  }
}
1151833
function handleCallback(err, url, callback) {
	if (callback.__called) {
		return;
	}
	callback.__called = true;
	callback(err, {
		url: url,
		title: callback.__title,
		count: callback.__redirectCounter,
		tracks: callback.__tracks
	});
}
505553
function tryCallback(callback, args) {
  try {
    return callback.apply(this, args);
  } catch (e) {
    if (typeof e === 'string') {
      return new binding.types.Error(e);
    } else if (e instanceof Error) {
      return new binding.types.Error(e.message);
    } else {
      return new binding.types.Error('An unexpected error occurred');
    }
  }
}
435541
function callback(err,other) {
			// check if the 'err' is boolean, if so then this is a 'exists' callback special case
			if (err && (typeof err !== 'boolean')) return reject(err);
			// convert arguments to proper array, ignoring error argument
			let args = Array.prototype.slice.call(arguments, 1);
			// if arguments length is one or more resolve arguments as array,
			// otherwise resolve the argument as is.
			return resolve(args.length < 2 ? args[0] : args);
		}
773087
def should_not_sample_path(request):
    
    blacklisted_paths = request.registry.settings.get(
        'zipkin.blacklisted_paths', [])
    # Only compile strings, since even recompiling existing
    # compiled regexes takes time.
    regexes = [
        re.compile(r) if isinstance(r, six.string_types) else r
        for r in blacklisted_paths
    ]
    return any(r.match(request.path) for r in regexes)
1069503
def __postCallAction_codebp(self, event):
        

        # If the breakpoint was accidentally hit by another thread,
        # pass it to the debugger instead of calling the "post" callback.
        #
        # XXX FIXME:
        # I suppose this check will fail under some weird conditions...
        #
        tid = event.get_tid()
        if tid not in self.__paramStack:
            return True

        # Remove the code breakpoint at the return address.
        pid     = event.get_pid()
        address = event.breakpoint.get_address()
        event.debug.dont_break_at(pid, address)

        # Call the "post" callback.
        try:
            self.__postCallAction(event)

        # Forget the parameters.
        finally:
            self.__pop_params(tid)
474286
def _check_result(self):
        '''
        
        '''
        if not self.__call_result:
            raise CommandExecutionError('No output result from Zypper?')

        self.exit_code = self.__call_result['retcode']
        if self._is_lock():
            return False

        if self._is_error():
            _error_msg = list()
            if not self._is_xml_mode():
                msg = self.__call_result['stderr'] and self.__call_result['stderr'].strip() or ""
                if msg:
                    _error_msg.append(msg)
            else:
                try:
                    doc = dom.parseString(self.__call_result['stdout'])
                except ExpatError as err:
                    log.error(err)
                    doc = None
                if doc:
                    msg_nodes = doc.getElementsByTagName('message')
                    for node in msg_nodes:
                        if node.getAttribute('type') == 'error':
                            _error_msg.append(node.childNodes[0].nodeValue)
                elif self.__call_result['stderr'].strip():
                    _error_msg.append(self.__call_result['stderr'].strip())
            self.error_msg = _error_msg
        return True
579003
def _handleCallInitiated(self, regexMatch, callId=None, callType=1):
        
        if self._dialEvent:
            if regexMatch:
                groups = regexMatch.groups()
                # Set self._dialReponse to (callId, callType)
                if len(groups) >= 2:
                    self._dialResponse = (int(groups[0]) , int(groups[1]))
                else:
                    self._dialResponse = (int(groups[0]), 1) # assume call type: VOICE
            else:
                self._dialResponse = callId, callType
            self._dialEvent.set()
1199579
def main(args=None):
    """"""
    retcode = 0
    try:
        ci = CliInterface()
        args = ci.parser.parse_args()
        result = args.func(args)
        if result is not None:
            print(result)
        retcode = 0
    except Exception:
        retcode = 1
        traceback.print_exc()
    sys.exit(retcode)
1119498
function (callbackId) {
    const sender = this.sender
    if (!supportLocalStorage) {
      return callNotSupportFail(sender, callbackId)
    }
    try {
      const len = localStorage.length
      sender.performCallback(callbackId, {
        result: SUCCESS,
        data: len
      })
    }
    catch (e) {
      // accept any exception thrown during a storage attempt as a quota error
      callFail(sender, callbackId)
    }
  }