Requires that the request contain a valid signature to gain access
    to a specified resource.
431992
def signature_required(secret_key_func):
    
    def actual_decorator(obj):

        def test_func(request, *args, **kwargs):
            secret_key = secret_key_func(request, *args, **kwargs)
            return validate_signature(request, secret_key)

        decorator = request_passes_test(test_func)
        return wrap_object(obj, decorator)

    return actual_decorator
108217
def sign(self):
        """"""
        self.verify_integrity()
        
        if session.get('u2f_sign_required', False):
            if request.method == 'GET':
                response = self.get_signature_challenge()

                if response['status'] == 'ok':
                    return jsonify(response), 200
                else:
                    return jsonify(response), 404

            elif request.method == 'POST':
                response = self.verify_signature(request.json)

                if response['status'] == 'ok':
                    return jsonify(response), 201
                else:
                    return jsonify(response), 400

        return jsonify({'status': 'failed', 'error': 'Unauthorized!'}), 401
45745
def get(method, hmc, uri, uri_parms, logon_required):
        """"""
        try:
            resource = hmc.lookup_by_uri(uri)
        except KeyError:
            raise InvalidResourceError(method, uri)
        return resource.properties
730704
function signAWSRequest({ credentials, request }) {
  const signer = new AWS.Signers.V4(request, 'es')
  signer.addAuthorization(credentials, new Date())
  return request
}
1191365
private String buildAuthorizationHeader(SignableRequest<?> request,
            byte[] signature, AWSCredentials credentials,
            AWS4SignerRequestParams signerParams) {
        final String signingCredentials = credentials.getAWSAccessKeyId() + "/"
                + signerParams.getScope();

        final String credential = "Credential="
                + signingCredentials;
        final String signerHeaders = "SignedHeaders="
                + getSignedHeadersString(request);
        final String signatureHeader = "Signature="
                + BinaryUtils.toHex(signature);

        final StringBuilder authHeaderBuilder = new StringBuilder();

        authHeaderBuilder.append(AWS4_SIGNING_ALGORITHM)
                         .append(" ")
                         .append(credential)
                         .append(", ")
                         .append(signerHeaders)
                         .append(", ")
                         .append(signatureHeader);

        return authHeaderBuilder.toString();
    }
467636
def _validate_signature(minion_id, signature, impersonated_by_master):
    '''
    
    '''
    pki_dir = __opts__['pki_dir']
    if impersonated_by_master:
        public_key = '{0}/master.pub'.format(pki_dir)
    else:
        public_key = '{0}/minions/{1}'.format(pki_dir, minion_id)

    log.trace('Validating signature for %s', minion_id)
    signature = base64.b64decode(signature)
    if not salt.crypt.verify_signature(public_key, minion_id, signature):
        raise salt.exceptions.AuthenticationError(
            'Could not validate token request from {0}'.format(minion_id)
            )
    log.trace('Signature ok')
469150
function signature ( $request, $base_string, $consumer_secret, $token_secret )
	{
		return $request->urlencode($request->urlencode($consumer_secret).'&'.$request->urlencode($token_secret));
	}
107271
def sign_request(self, signature_method, consumer, token):
        """"""

        if not self.is_form_encoded:
            # according to
            # http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
            # section 4.1.1 "OAuth Consumers MUST NOT include an
            # oauth_body_hash parameter on requests with form-encoded
            # request bodies."
            if not self.body:
               self.body = ''
            self['oauth_body_hash'] = base64.b64encode(sha1(to_utf8(self.body)).digest())

        if 'oauth_consumer_key' not in self:
            self['oauth_consumer_key'] = consumer.key

        if token and 'oauth_token' not in self:
            self['oauth_token'] = token.key

        self['oauth_signature_method'] = signature_method.name
        self['oauth_signature'] = signature_method.sign(self, consumer, token)
394337
public function verify ( $request, $base_string, $consumer_secret, $token_secret, $signature )
	{
		$decoded_sig = base64_decode($request->urldecode($signature));
		  
		// Fetch the public key cert based on the request
		$cert = $this->fetch_public_cert($request);
		
		// Pull the public key ID from the certificate
		$publickeyid = openssl_get_publickey($cert);
		
		// Check the computed signature against the one passed in the query
		$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);   
		
		// Release the key resource
		openssl_free_key($publickeyid);
		return $ok == 1;
	}
865273
protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) {
    //copied from org.springframework.security.ui.AbstractProcessingFilter.requiresAuthentication
    String uri = request.getRequestURI();
    int pathParamIndex = uri.indexOf(';');

    if (pathParamIndex > 0) {
      // strip everything after the first semi-colon
      uri = uri.substring(0, pathParamIndex);
    }

    if ("".equals(request.getContextPath())) {
      return uri.endsWith(filterProcessesUrl);
    }

    boolean match = uri.endsWith(request.getContextPath() + filterProcessesUrl);
    if (log.isDebugEnabled()) {
      log.debug(uri + (match ? " matches " : " does not match ") + filterProcessesUrl);
    }
    return match;
  }
282279
public static boolean verify(
      Signature signatureAlgorithm, PublicKey publicKey, byte[] signatureBytes, byte[] contentBytes)
      throws InvalidKeyException, SignatureException {
    signatureAlgorithm.initVerify(publicKey);
    signatureAlgorithm.update(contentBytes);
    // SignatureException may be thrown if we are tring the wrong key.
    try {
      return signatureAlgorithm.verify(signatureBytes);
    } catch (SignatureException e) {
      return false;
    }
  }
1209817
def verify(content, signature)
      hmac = OpenSSL::HMAC.hexdigest('sha1', @secret, content)
      signature.downcase == "sha1=#{hmac}"
    end
1210001
protected boolean requestRequiresAuthentication(final HttpServletRequest request, final HttpServletResponse response) {
        val accessTokenRequest = isAccessTokenRequest(request, response);
        if (!accessTokenRequest) {
            val extractor = extractAccessTokenGrantRequest(request);
            if (extractor.isPresent()) {
                val ext = extractor.get();
                return ext.requestMustBeAuthenticated();
            }
        } else {
            val extractor = extractAccessTokenGrantRequest(request);
            if (extractor.isPresent()) {
                val ext = extractor.get();
                return ext.getResponseType() != OAuth20ResponseTypes.DEVICE_CODE;
            }
        }
        return false;
    }
446845
public void verify(HttpServletRequest servletRequest, byte[] serializedRequestEnvelope, RequestEnvelope deserializedRequestEnvelope) {
        String baseEncoded64Signature = servletRequest.getHeader(ServletConstants.SIGNATURE_REQUEST_HEADER);
        String signingCertificateChainUrl = servletRequest.getHeader(ServletConstants.SIGNATURE_CERTIFICATE_CHAIN_URL_REQUEST_HEADER);
        if ((baseEncoded64Signature == null) || (signingCertificateChainUrl == null)) {
            throw new SecurityException(
                    "Missing signature/certificate for the provided skill request");
        }

        try {
            X509Certificate signingCertificate;
            if (CERTIFICATE_CACHE.containsKey(signingCertificateChainUrl)) {
                signingCertificate = CERTIFICATE_CACHE.get(signingCertificateChainUrl);
                /*
                 * check the before/after dates on the certificate are still valid for the present
                 * time
                 */
                signingCertificate.checkValidity();
            } else {
                signingCertificate = retrieveAndVerifyCertificateChain(signingCertificateChainUrl);

                // if certificate is valid, then add it to the cache
                CERTIFICATE_CACHE.put(signingCertificateChainUrl, signingCertificate);
            }

            // verify that the request was signed by the provided certificate
            Signature signature = Signature.getInstance(ServletConstants.SIGNATURE_ALGORITHM);
            signature.initVerify(signingCertificate.getPublicKey());
            signature.update(serializedRequestEnvelope);
            if (!signature.verify(Base64.decodeBase64(baseEncoded64Signature
                    .getBytes(ServletConstants.CHARACTER_ENCODING)))) {
                throw new SecurityException(
                        "Failed to verify the signature/certificate for the provided skill request");
            }
        } catch (GeneralSecurityException | IOException ex) {
            throw new SecurityException(
                    "Failed to verify the signature/certificate for the provided skill request",
                    ex);
        }
    }
680758
function authorizedHandler(value) {
    if (! value) return value;

    delete value.public_id;
    delete value.version;
    delete value.signature;
    delete value.resource_type;

    return value;
}
895809
public byte[] verifyVrfSignature(byte[] publicKey, byte[] message, byte[] signature)
      throws VrfSignatureVerificationFailedException
  {
    if (publicKey == null || publicKey.length != 32) {
      throw new IllegalArgumentException("Invalid public key!");
    }

    if (message == null || signature == null || signature.length != 96) {
      throw new VrfSignatureVerificationFailedException("Invalid message or signature format");
    }

    return provider.verifyVrfSignature(publicKey, message, signature);
  }
173432
def validate_signature(self, filename):
        """"""

        if not GPG_PRESENT:
            return False

        sigfilename = filename + '.sig'

        try:
            with open(sigfilename):
                pass

        except IOError:
            # Signature file does not exist
            return False

        # Check if the sig is valid for the sigfile
        # TODO: Check for whitespace in filepaths
        return verify(sigfilename, filename)