5.3 Hub Verifies Intent of the Subscriber
170083
def intent_verified(hub, callback_url, mode, topic_url, lease_seconds):
    

    challenge = uuid4()
    params = {
        'hub.mode': mode,
        'hub.topic': topic_url,
        'hub.challenge': challenge,
        'hub.lease_seconds': lease_seconds,
    }
    try:
        response = request_url(hub.config, 'GET', callback_url, params=params)
        assert response.status_code == 200 and response.text == challenge
    except requests.exceptions.RequestException as e:
        warn("Cannot verify subscriber intent", e)
    except AssertionError as e:
        warn(INTENT_UNVERIFIED % (response.status_code, response.content), e)
    else:
        return True
    return False
947930
def verify(self, **kwargs):
        
        super(RegistrationResponse, self).verify(**kwargs)

        has_reg_uri = "registration_client_uri" in self
        has_reg_at = "registration_access_token" in self
        if has_reg_uri != has_reg_at:
            raise VerificationError((
                "Only one of registration_client_uri"
                " and registration_access_token present"), self)

        return True
1279211
def is_subscribed(self):
		""""""

		subscribed = next(
			(
				config_item['value'] == 'true'
				for config_item in self.config()
				if config_item['key'] == 'isNautilusUser'
			),
			None
		)

		if subscribed:
			self.tier = 'aa'
		else:
			self.tier = 'fr'

		return subscribed
599837
def subscribed(self, user):
        
        for who, record in self.logs:
            if (record["field_name"] == "cc" and
                    user.email in record["added"]):
                return True
        return False
1044312
function(s, args, ef) {

        this.log(this.type + "->" + "sub: " +  s.id);

        var ret;

        ret = s.notify(args, this);

        if (false === ret || this.stopped > 1) {
            this.log(this.type + " cancelled by subscriber");
            return false;
        }

        return true;
    }
692309
def requestAccountUpdates(self, subscribe=True):
        
        if self.subscribeAccount != subscribe:
            self.subscribeAccount = subscribe
            self.ibConn.reqAccountUpdates(subscribe, 0)
1029248
public boolean verifySender(InetAddress remoteAddr) {
        boolean returnValue = true;

        if (alists != null) {
            returnValue = !alists.accessDenied(remoteAddr);
        }
        return returnValue;
    }
1096937
def verify_notification(data):
    
    pemfile = grab_keyfile(data['SigningCertURL'])
    cert = crypto.load_certificate(crypto.FILETYPE_PEM, pemfile)
    signature = base64.decodestring(six.b(data['Signature']))

    if data['Type'] == "Notification":
        hash_format = NOTIFICATION_HASH_FORMAT
    else:
        hash_format = SUBSCRIPTION_HASH_FORMAT

    try:
        crypto.verify(
            cert, signature, six.b(hash_format.format(**data)), 'sha1')
    except crypto.Error:
        return False
    return True
395228
def authenticate_subscribe(message)
      subscription = CisRailsChat.subscription(:channel => message["subscription"], :timestamp => message["ext"]["cis_rails_chat_timestamp"])
      if message["ext"]["cis_rails_chat_signature"] != subscription[:signature]
        message["error"] = "Incorrect signature."
      elsif CisRailsChat.signature_expired? message["ext"]["cis_rails_chat_timestamp"].to_i
        message["error"] = "Signature has expired."
      end
    end
377406
def is_subscribed(self, login, repo):
        
        json = False
        if login and repo:
            url = self._build_url('user', 'subscriptions', login, repo)
            json = self._boolean(self._get(url), 204, 404)
        return json
468703
def can_approve(self, user, **data):
        
        service_id = data.get('service_id', self.service_id)

        try:
            service = yield Service.get(service_id)

            is_repo_admin = user.is_org_admin(service.organisation_id)

            is_reseller_preverifying = user.is_reseller() and data.get('pre_verified', False)

            raise Return(is_repo_admin or is_reseller_preverifying)
        except couch.NotFound:
            pass

        raise Return(False)
1117732
static ConfirmSubscriptionResult confirmSubscription(HttpClient httpClient, String subscribeUrl) {
        try {
            HttpGet request = new HttpGet(subscribeUrl);
            HttpResponse response = httpClient.execute(request);
            if (ApacheUtils.isRequestSuccessful(response)) {
                return new StaxResponseHandler<ConfirmSubscriptionResult>(ConfirmSubscriptionResultStaxUnmarshaller.getInstance())
                    .handle(ApacheUtils.createResponse(null, request, response, null)).getResult();
            } else {
                throw new HttpException("Could not confirm subscription", response);
            }
        } catch (Exception e) {
            throw new SdkClientException(e);
        }
    }
176894
def verify(self, user, device=None):
        
        payload = {"user": user, "token": self.token}
        if device:
            payload["device"] = device
        try:
            request = Request("post", USER_URL, payload)
        except RequestError:
            return None
        else:
            return request.answer["devices"]
260959
def _subscribe(self):
        
        cmd = MAGIC + SUBSCRIBE + self._mac \
            + PADDING_1 + self._mac_reversed + PADDING_1
        status = self._udp_transact(cmd, self._subscribe_resp)
        if status is not None:
            self.last_subscribed = time.time()
            return status == ON
        else:
            raise S20Exception(
                "No status could be found for {}".format(self.host))
1328012
function isAnchorTagApplied({ result, plugins = [] }, { regex }) {
  return (
    getAnchorRegex(regex).test(result) ||
    plugins.filter(plugin => plugin.id === "url").length
  )
}
1018229
function(params, callback) {
        if (!client) {
          fireEvent("error", {
            errorCode: 999,
            errorMessage: "ActiveMQ Client is not ready or has not been initialized!"
          });
        }

        var subscribeHeaders = {
          "destination": params.destination,
          "ack": params.ack
        };

        client.subscribe(subscribeHeaders, function(error, message) {
          if (error) {
            fireEvent("error", {
              errorCode: 999,
              errorMessage: "ActiveMQ Subscription Error!"
            });
            return;
          }

          message.readString("utf-8", function(error, body) {
            if (error) {
              fireEvent("error", {
                errorCode: 999,
                errorMessage: "ActiveMQ Read Message Error!"
              });
              return;
            }

            callback && callback(body);

            client.ack(message);
          });
        });
      }
1123116
def VerifyCoARequest(self):
        
        assert(self.raw_packet)
        hash = md5_constructor(self.raw_packet[0:4] + 16 * six.b('\x00') +
                self.raw_packet[20:] + self.secret).digest()
        return hash == self.authenticator