Thing Claiming - XEP-0347 § 3.9
504619
public IoTClaimed claimThing(Collection<Tag> metaTags) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
        return claimThing(metaTags, true);
    }
184126
function claimBackOldTextcoins(to_address, days){
	db.query(
		"SELECT mnemonic FROM sent_mnemonics LEFT JOIN unit_authors USING(address) \n\
		WHERE mnemonic!='' AND unit_authors.address IS NULL AND creation_date<"+db.addTime("-"+days+" DAYS"),
		function(rows){
			async.eachSeries(
				rows,
				function(row, cb){
					receiveTextCoin(row.mnemonic, to_address, function(err, unit, asset){
						if (err)
							console.log("failed claiming back old textcoin "+row.mnemonic+": "+err);
						else
							console.log("claimed back mnemonic "+row.mnemonic+", unit "+unit+", asset "+asset);
						cb();
					});
				}
			);
		}
	);
}
812208
function licensePacket(message) {
	var self = {
		bMsgtype : new type.UInt8(function() {
			return self.licensingMessage.obj.__TYPE__;
		}),
        flag : new type.UInt8(Preambule.PREAMBLE_VERSION_3_0),
        wMsgSize : new type.UInt16Le(function() {
        	return new type.Component(self).size();
        }),
        licensingMessage : message || new type.Factory(function(s) {
        	switch(self.bMsgtype.value) {
        	case MessageType.ERROR_ALERT:
        		self.licensingMessage = licensingErrorMessage({ readLength : new type.CallableValue(function() {
        			return self.wMsgSize.value - 4;
        		})}).read(s);
        		break;
        	case MessageType.LICENSE_REQUEST:
        		self.licensingMessage = serverLicenseRequest({ readLength : new type.CallableValue(function() {
        			return self.wMsgSize.value - 4;
        		})}).read(s);
        		break;
        	case MessageType.NEW_LICENSE_REQUEST:
        		self.licensingMessage = clientNewLicenseRequest({ readLength : new type.CallableValue(function() {
        			return self.wMsgSize.value - 4;
        		})}).read(s);
        		break;
        	case MessageType.PLATFORM_CHALLENGE:
        		self.licensingMessage = serverPlatformChallenge({ readLength : new type.CallableValue(function() {
        			return self.wMsgSize.value - 4;
        		})}).read(s);
        		break;
        	case MessageType.PLATFORM_CHALLENGE_RESPONSE:
        		self.licensingMessage = clientPLatformChallengeResponse({ readLength : new type.CallableValue(function() {
        			return self.wMsgSize.value - 4;
        		})}).read(s);
        		break;
        	default:
        		log.error('unknown license message type ' + self.bMsgtype.value);
        	}
        })
	};
	
	return new type.Component(self);
}
1214513
private function serverClaimsUtf8mb4Support()
	{
		$client_version = mysqli_get_client_info();
		$server_version = $this->getVersion();

		if (version_compare($server_version, '5.5.3', '<'))
		{
			return false;
		}

		if (strpos($client_version, 'mysqlnd') !== false)
		{
			$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);

			return version_compare($client_version, '5.0.9', '>=');
		}

		return version_compare($client_version, '5.5.3', '>=');
	}
317716
public Claim copy(Claim object) {
		return dataObjectFactory.getClaim(
				(EntityIdValue) visit(object.getSubject()),
				copy(object.getMainSnak()),
				copy(object.getQualifiers()));
	}
378470
private Claims getClaimsFromToken(String token) {
        Claims claims;
        try {
            claims = Jwts.parser()
                    .setSigningKey(jwtProperties.getSecret())
                    .parseClaimsJws(token)
                    .getBody();
        } catch (Exception e) {
            log.error("get claims from jwt token error : {}", e.getMessage());
            claims = null;
        }
        return claims;
    }
711312
function verifyHeaders(headers, packetlist) {
  const checkHashAlgos = function(hashAlgos) {
    const check = packet => algo => packet.hashAlgorithm === algo;

    for (let i = 0; i < packetlist.length; i++) {
      if (packetlist[i].tag === enums.packet.signature && !hashAlgos.some(check(packetlist[i]))) {
        return false;
      }
    }
    return true;
  };

  let oneHeader = null;
  let hashAlgos = [];
  headers.forEach(function(header) {
    oneHeader = header.match(/Hash: (.+)/); // get header value
    if (oneHeader) {
      oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
      oneHeader = oneHeader.split(',');
      oneHeader = oneHeader.map(function(hash) {
        hash = hash.toLowerCase();
        try {
          return enums.write(enums.hash, hash);
        } catch (e) {
          throw new Error('Unknown hash algorithm in armor header: ' + hash);
        }
      });
      hashAlgos = hashAlgos.concat(oneHeader);
    } else {
      throw new Error('Only "Hash" header allowed in cleartext signed message');
    }
  });

  if (!hashAlgos.length && !checkHashAlgos([enums.hash.md5])) {
    throw new Error('If no "Hash" header in cleartext signed message, then only MD5 signatures allowed');
  } else if (hashAlgos.length && !checkHashAlgos(hashAlgos)) {
    throw new Error('Hash algorithm mismatch in armor header and signature');
  }
}
148710
def _marshal_claims(self, query_claims):
        
        claims = reduce_claims(query_claims)
        # self.data['claimq'] = query_claims
        self.data['claims'] = claims

        entities = set()
        for eid in claims:
            if self.user_labels:
                if eid in self.user_labels or eid == 'P31':
                    entities.add(eid)  # P (property)
                else:
                    continue  # get only wanted entities
            else:
                entities.add(eid)  # P (property)

            for val in claims[eid]:
                if utils.is_text(val) and re.match(r'^Q\d+$', val):
                    entities.add(val)  # Q (item)

        self.data['entities'] = list(entities)
47635
async def add_claims(self, payload, user, *args, **kwargs):
        
        delta = timedelta(seconds=self.config.expiration_delta())
        exp = datetime.utcnow() + delta
        additional = {"exp": exp}

        for option in ["iss", "iat", "nbf", "aud"]:
            setting = "claim_{}".format(option.lower())
            if setting in self.config:  # noqa
                attr = self.config.get(setting)
                if attr:
                    self.claims.append(option)
                    method_name = "build_claim_{}".format(option)
                    method = getattr(utils, method_name)
                    additional.update({option: method(attr, self.config)})

        payload.update(additional)

        if self._custom_claims:
            custom_claims = {}
            for claim in self._custom_claims:
                custom_claims[claim.get_key()] = await utils.call(
                    claim.setup, payload, user
                )
            payload.update(custom_claims)

        return payload
668189
async function preclaim (name, options = {}) {
  const opt = R.merge(this.Ae.defaults, options)
  const _salt = salt()
  const height = await this.height()
  const hash = await commitmentHash(name, _salt)

  const preclaimTx = await this.namePreclaimTx(R.merge(opt, {
    accountId: await this.address(),
    commitmentId: hash
  }))

  const result = await this.send(preclaimTx, opt)

  return Object.freeze({
    ...result,
    height,
    claim: options => this.aensClaim(name, _salt, (height + 1), options),
    salt: _salt,
    commitmentId: hash
  })
}
1269525
void processClaimInjections(@Observes ProcessInjectionPoint pip) {
        log.debugf("pipRaw: %s", pip.getInjectionPoint());
        InjectionPoint ip = pip.getInjectionPoint();
        if (ip.getAnnotated().isAnnotationPresent(Claim.class)) {
            Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
            if (ip.getType() instanceof Class) {
                Class rawClass = (Class) ip.getType();
                // Primative types
                if (Modifier.isFinal(rawClass.getModifiers())) {
                    rawTypes.add(ip.getType());
                    rawTypeQualifiers.add(claim);
                    log.debugf("+++ Added Claim raw type: %s", ip.getType());
                    Class declaringClass = ip.getMember().getDeclaringClass();
                    Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
                    Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
                    if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
                        String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
                        pip.addDefinitionError(new DeploymentException(err));
                    }
                }
            // This handles collections of primative types
            } else if (isRawParameterizedType(ip.getType())) {
                log.debugf("+++ Added Claim ParameterizedType: %s", ip.getType());
                rawTypes.add(ip.getType());
                rawTypeQualifiers.add(claim);
            }
        } else {
            log.debugf("Skipping pip: %s, type: %s/%s", ip, ip.getType(), ip.getType().getClass());
        }
    }
859365
def GetScriptHashesForVerifying(self):
        
        hashes = super(ClaimTransaction, self).GetScriptHashesForVerifying()

        for hash, group in groupby(self.Claims, lambda x: x.PrevHash):
            tx, height = Blockchain.Default().GetTransaction(hash)

            if tx is None:
                raise Exception("Invalid Claim Operation")

            for claim in group:
                if len(tx.outputs) <= claim.PrevIndex:
                    raise Exception("Invalid Claim Operation")

                script_hash = tx.outputs[claim.PrevIndex].ScriptHash

                if script_hash not in hashes:
                    hashes.append(script_hash)

        hashes.sort()

        return hashes
1056066
function verifyIPN()
    {
        if (!count($_POST)) {
            throw new Exception("Missing POST Data");
        }

        $raw_post_data = file_get_contents('php://input');
        $raw_post_array = explode('&', $raw_post_data);
        $myPost = [];
        foreach ($raw_post_array as $keyval) {
            $keyval = explode('=', $keyval);
            if (count($keyval) == 2) {
                if ($keyval[0] === 'payment_date') {
                    if (substr_count($keyval[1], '+') === 1) {
                        $keyval[1] = str_replace('+', '%2B', $keyval[1]);
                    }
                }
                $myPost[$keyval[0]] = urldecode($keyval[1]);
            }
        }
        $req = 'cmd=_notify-validate';
        $get_magic_quotes_exists = false;
        if (function_exists('get_magic_quotes_gpc')) {
            $get_magic_quotes_exists = true;
        }
        foreach ($myPost as $key => $value) {
            if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
                $value = urlencode(stripslashes($value));
            } else {
                $value = urlencode($value);
            }
            $req .= "&$key=$value";
        }

        $ch = curl_init($this->getPaypalUri());
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
        curl_setopt($ch, CURLOPT_SSLVERSION, 6);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        if ($this->useLocalCerts) {
            curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . "/cert/cacert.pem");
        }
        curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_HTTPHEADER, ['Connection: Close']);
        $res = curl_exec($ch);
        $info = curl_getinfo($ch);
        $http_code = $info['http_code'];

        if ($http_code != 200) {
            throw new Exception("PayPal responded with http code $http_code");
        }

        if (!($res)) {
            $errno = curl_errno($ch);
            $errstr = curl_error($ch);
            curl_close($ch);
            throw new Exception("cURL error: [$errno] $errstr");
        }
        curl_close($ch);
        if ($res == self::VALID) {
            return true;
        } else {
            return false;
        }
    }
20793
private void verifyNameChaining(X509Certificate cert)
        throws CertPathValidatorException
    {
        if (prevSubject != null) {

            String msg = "subject/issuer name chaining";
            if (debug != null)
                debug.println("---checking " + msg + "...");

            X500Principal currIssuer = cert.getIssuerX500Principal();

            // reject null or empty issuer DNs
            if (X500Name.asX500Name(currIssuer).isEmpty()) {
                throw new CertPathValidatorException
                    (msg + " check failed: " +
                     "empty/null issuer DN in certificate is invalid", null,
                     null, -1, PKIXReason.NAME_CHAINING);
            }

            if (!(currIssuer.equals(prevSubject))) {
                throw new CertPathValidatorException
                    (msg + " check failed", null, null, -1,
                     PKIXReason.NAME_CHAINING);
            }

            if (debug != null)
                debug.println(msg + " verified.");
        }
    }
519304
def local_third_party_caveat(key, version):
    ''' 
    '''
    if version >= VERSION_2:
        loc = 'local {} {}'.format(version, key)
    else:
        loc = 'local {}'.format(key)
    return checkers.Caveat(location=loc, condition='')
1260428
boolean attemptToClaim(String workUnit, boolean claimForHandoff)
       throws InterruptedException
   {
       LOG.debug("Attempting to claim {}. For handoff? {}", workUnit, claimForHandoff);

       String path = claimForHandoff
               ? String.format("/%s/handoff-result/%s", cluster.name, workUnit)
               : cluster.workUnitClaimPath(workUnit);

       final boolean created = ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID);

       if (created) {
           if (claimForHandoff) {
               cluster.claimedForHandoff.add(workUnit);
           }
           cluster.startWork(workUnit);
           return true;
       }
       if (isPeggedToMe(workUnit)) {
           claimWorkPeggedToMe(workUnit);
           return true;
       }
       return false;
   }
93667
def _collect_values(handlers, names, user, client, values):
    

    results = {}

    def visitor(claim_name, func):
        data = {'user': user, 'client': client}
        data.update(values.get(claim_name) or {})
        claim_value = func(data)
        # If the claim_value is None, it means that the claim is not authorized.
        if claim_value is not None:
            # New values overwrite previous results
            results[claim_name] = claim_value

    _visit_handlers(handlers, visitor, 'claim', names)

    return results