Get JWS signature index from context.
329340
protected function getSignatureIndex(array $context): int
    {
        $signatureIndex = 0;

        if (isset($context['signature_index']) && \is_int($context['signature_index'])) {
            $signatureIndex = $context['signature_index'];
        }

        return $signatureIndex;
    }
1207860
def get_jsapi_signature(self, noncestr, ticket, timestamp, url):
        
        data = [
            'noncestr={noncestr}'.format(noncestr=noncestr),
            'jsapi_ticket={ticket}'.format(ticket=ticket),
            'timestamp={timestamp}'.format(timestamp=timestamp),
            'url={url}'.format(url=url),
        ]
        signer = WeChatSigner(delimiter=b'&')
        signer.add_data(*data)
        return signer.signature
537804
def signatureJWT(self, message):
        
        return hmac.new(
            key=self.secretkey,
            msg=message,
            digestmod=hashlib.sha256
        ).hexdigest()
1013130
def _context_json(name):
    """"""
    from renku.models import provenance

    cls = getattr(provenance, name)
    return {
        '@context': cls._jsonld_context,
        '@type': cls._jsonld_type,
    }
26751
def get_signing_key(self, algorithm, service_context):
        
        return service_context.keyjar.get_signing_key(
            alg2keytype(algorithm), alg=algorithm)
1091873
def get_signature_names(self):
        
        signature_expr = re.compile("^(META-INF/)(.*)(\.RSA|\.EC|\.DSA)$")
        signatures = []

        for i in self.get_files():
            if signature_expr.search(i):
                signatures.append(i)

        if len(signatures) > 0:
            return signatures

        return None
858030
static String getClassSignature(String[] interfaces, String className, String apiName) {
        StringBuilder signature;

        signature = new StringBuilder("<Z::" + XsdSupportingStructure.elementTypeDesc + ">" + JAVA_OBJECT_DESC);

        if (interfaces != null){
            for (String anInterface : interfaces) {
                signature.append("L")
                        .append(getFullClassTypeName(anInterface, apiName))
                        .append("<L")
                        .append(getFullClassTypeName(className, apiName))
                        .append("<TZ;>;TZ;>;");
            }
        }

        return signature.toString();
    }
976878
def _get_proc_like_prefix(self, sig):
        
        sig_match = chpl_sig_pattern.match(sig)
        if sig_match is None:
            return ChapelObject.get_signature_prefix(self, sig)

        prefixes, _, _, _, _ = sig_match.groups()
        if prefixes:
            return prefixes.strip() + ' '
        elif self.objtype.startswith('iter'):
            return 'iter' + ' '
        elif self.objtype in ('method', 'function'):
            return 'proc' + ' '
        else:
            return ChapelObject.get_signature_prefix(self, sig)
430604
private synchronized JMSContext getInternalJMSContext() {
        TransactionSynchronizationRegistry tranSyncRegistry = null;
        try {

            boolean tranIsActive = false;

            tranSyncRegistry = (TransactionSynchronizationRegistry) new InitialContext().lookup(TSR_LOOKUP_NAME);

            if (tranSyncRegistry != null)
            {
                tranIsActive = (tranSyncRegistry.getTransactionStatus() == Status.STATUS_ACTIVE);
            }

            if (tranIsActive)
            {

                Object resource = tranSyncRegistry.getResource(jmsContextInfo);

                if (resource != null) {

                    return (JMSContext) resource;

                } else {

                    final JMSContext transactedContext = createJMSContext(jmsContextInfo, tranIsActive);

                    //Once the new JMSContext is created,  add it to the transaction registry to 
                    //retrieve it later if the new JMSContext is requested for the same configuration
                    //but in same transactional context
                    tranSyncRegistry.putResource(jmsContextInfo, transactedContext);

                    //Register a Synchronization object in transaction registry for a call back
                    //when the transaction is complete,  we will close the JMSContext once the 
                    //Transaction is complete
                    tranSyncRegistry.registerInterposedSynchronization(new Synchronization() {
                        @Override
                        public void beforeCompletion() {}

                        @Override
                        public synchronized void afterCompletion(int status) {
                            transactedContext.close();
                            inTransaction = false;
                        }
                    });

                    return transactedContext;
                }
            } else {

                //Non transacted,  create a new JMSContext and return it
                if (internalJMSContext == null) {
                    internalJMSContext = createJMSContext(jmsContextInfo, tranIsActive);
                }
                return internalJMSContext;
            }
        } catch (Exception e)
        {
            throw new RuntimeException(e.getLocalizedMessage(), e);
        }
    }
1035346
def verify(jwsjs):
    """"""
    get_ed25519ll()
    # XXX forbid duplicate keys in JSON input using object_pairs_hook (2.7+)
    recipients = jwsjs["recipients"]
    encoded_payload = binary(jwsjs["payload"])
    headers = []
    for recipient in recipients:
        assertTrue(len(recipient) == 2, "Unknown recipient key {0}".format(recipient))
        h = binary(recipient["header"])
        s = binary(recipient["signature"])
        header = json.loads(native(urlsafe_b64decode(h)))
        assertTrue(header["alg"] == ALG,
                   "Unexpected algorithm {0}".format(header["alg"]))
        if "alg" in header["jwk"] and "kty" not in header["jwk"]:
            header["jwk"]["kty"] = header["jwk"]["alg"]  # b/w for JWK < -08
        assertTrue(header["jwk"]["kty"] == ALG,  # true for Ed25519
                   "Unexpected key type {0}".format(header["jwk"]["kty"]))
        vk = urlsafe_b64decode(binary(header["jwk"]["vk"]))
        secured_input = b".".join((h, encoded_payload))
        sig = urlsafe_b64decode(s)
        sig_msg = sig+secured_input
        verified_input = native(ed25519ll.crypto_sign_open(sig_msg, vk))
        verified_header, verified_payload = verified_input.split('.')
        verified_header = binary(verified_header)
        decoded_header = native(urlsafe_b64decode(verified_header))
        headers.append(json.loads(decoded_header))

    verified_payload = binary(verified_payload)

    # only return header, payload that have passed through the crypto library.
    payload = json.loads(native(urlsafe_b64decode(verified_payload)))

    return headers, payload
422686
def retrieve_matching_jwk(self, token):
        """"""
        response_jwks = requests.get(
            self.OIDC_OP_JWKS_ENDPOINT,
            verify=self.get_settings('OIDC_VERIFY_SSL', True)
        )
        response_jwks.raise_for_status()
        jwks = response_jwks.json()

        # Compute the current header from the given token to find a match
        jws = JWS.from_compact(token)
        json_header = jws.signature.protected
        header = Header.json_loads(json_header)

        key = None
        for jwk in jwks['keys']:
            if jwk['kid'] != smart_text(header.kid):
                continue
            if 'alg' in jwk and jwk['alg'] != smart_text(header.alg):
                raise SuspiciousOperation('alg values do not match.')
            key = jwk
        if key is None:
            raise SuspiciousOperation('Could not find a valid JWKS.')
        return key
1211882
private function getInputToVerify(Object\JWSInterface $jws, Object\SignatureInterface $signature, $detached_payload)
    {
        $encoded_protected_headers = $signature->getEncodedProtectedHeaders();
        if (!$signature->hasProtectedHeader('b64') || true === $signature->getProtectedHeader('b64')) {
            if (null !== $jws->getEncodedPayload($signature)) {
                return sprintf('%s.%s', $encoded_protected_headers, $jws->getEncodedPayload($signature));
            }

            $payload = empty($jws->getPayload()) ? $detached_payload : $jws->getPayload();
            $payload = is_string($payload) ? $payload : json_encode($payload);

            return sprintf('%s.%s', $encoded_protected_headers, Base64Url::encode($payload));
        }

        $payload = empty($jws->getPayload()) ? $detached_payload : $jws->getPayload();
        $payload = is_string($payload) ? $payload : json_encode($payload);

        return sprintf('%s.%s', $encoded_protected_headers, $payload);
    }
398391
def getextensibleindex(bunchdt, data, commdct, key, objname):
    """"""
    theobject = getobject(bunchdt, key, objname)
    if theobject == None:
        return None
    theidd = iddofobject(data, commdct, key)
    extensible_i = [
        i for i in range(len(theidd)) if 'begin-extensible' in theidd[i]]
    try:
        extensible_i = extensible_i[0]
    except IndexError:
        return theobject
381941
def signature(self):
        ''' 
        '''
        return self.name, [str(x.type) for x in self.elems]
983601
def signature(self):
        """"""
        #We can't really do anything sensible without the name of the function
        #whose signature we are completing.
        iexec, execmod = self.context.parser.tree_find(self.context.el_name, 
                                              self.context.module, "executables")
        if iexec is None:
            #Look in the interfaces next using a tree find as well
            iexec, execmod = self.context.parser.tree_find(self.context.el_name, self.context.module,
                                                  "interfaces")
        if iexec is None:
            return []

        return self._signature_index(iexec)
362417
def signature(self):
        """"""
        if self.usage is not None:
            return self.usage


        params = self.clean_params
        if not params:
            return ''

        result = []
        for name, param in params.items():
            greedy = isinstance(param.annotation, converters._Greedy)

            if param.default is not param.empty:
                # We don't want None or '' to trigger the [name=value] case and instead it should
                # do [name] since [name=None] or [name=] are not exactly useful for the user.
                should_print = param.default if isinstance(param.default, str) else param.default is not None
                if should_print:
                    result.append('[%s=%s]' % (name, param.default) if not greedy else
                                  '[%s=%s]...' % (name, param.default))
                    continue
                else:
                    result.append('[%s]' % name)

            elif param.kind == param.VAR_POSITIONAL:
                result.append('[%s...]' % name)
            elif greedy:
                result.append('[%s]...' % name)
            elif self._is_typing_optional(param.annotation):
                result.append('[%s]' % name)
            else:
                result.append('<%s>' % name)

        return ' '.join(result)
563279
def get_signature(self, req):
        
        oss_url = url.URL(req.url)

        oss_headers = [
            "{0}:{1}\n".format(key, val)
            for key, val in req.headers.lower_items()
            if key.startswith(self.X_OSS_PREFIX)
        ]
        canonicalized_headers = "".join(sorted(oss_headers))
        logger.debug(
            "canonicalized header : [{0}]".format(canonicalized_headers)
        )

        oss_url.params = {
            key: val
            for key, val in oss_url.params.items()
            if key in self.SUB_RESOURCES or key in self.OVERRIDE_QUERIES
        }

        oss_url.forge(key=lambda x: x[0])
        canonicalized_str = "{0}/{1}{2}".format(
            canonicalized_headers,
            self.get_bucket(oss_url.host),
            oss_url.uri
        )

        str_to_sign = "\n".join([
            req.method,
            req.headers["content-md5"],
            req.headers["content-type"],
            req.headers["date"],
            canonicalized_str
        ])
        logger.debug(
            "signature str is \n{0}\n{1}\n{0}\n".format("#" * 20, str_to_sign)
        )
        if isinstance(str_to_sign, requests.compat.str):
            str_to_sign = str_to_sign.encode("utf8")

        signature_bin = hmac.new(self._secret_key, str_to_sign, hashlib.sha1)
        signature = base64.b64encode(signature_bin.digest()).decode("utf8")
        logger.debug("signature is [{0}]".format(signature))
        return signature