original_string: public function authentication(Request $request, array $credentials)
      {
          if (!isset($credentials['consumerKey'])) {
              return $request;
          }
          if (empty($credentials['method'])) {
              $credentials['method'] = 'hmac-sha1';
          }
          $credentials['method'] = strtoupper($credentials['method']);
  
          $value = null;
          switch ($credentials['method']) {
              case 'HMAC-SHA1':
                  $hasKeys = isset(
                      $credentials['consumerSecret'],
                      $credentials['token'],
                      $credentials['tokenSecret']
                  );
                  if (!$hasKeys) {
                      return $request;
                  }
                  $value = $this->_hmacSha1($request, $credentials);
                  break;
  
              case 'RSA-SHA1':
                  if (!isset($credentials['privateKey'])) {
                      return $request;
                  }
                  $value = $this->_rsaSha1($request, $credentials);
                  break;
  
              case 'PLAINTEXT':
                  $hasKeys = isset(
                      $credentials['consumerSecret'],
                      $credentials['token'],
                      $credentials['tokenSecret']
                  );
                  if (!$hasKeys) {
                      return $request;
                  }
                  $value = $this->_plaintext($request, $credentials);
                  break;
  
              default:
                  throw new Exception(sprintf('Unknown Oauth signature method %s', $credentials['method']));
          }
  
          return $request->withHeader('Authorization', $value);
      }
code: public function authentication(Request $request, array $credentials)
      {
          if (!isset($credentials['consumerKey'])) {
              return $request;
          }
          if (empty($credentials['method'])) {
              $credentials['method'] = 'hmac-sha1';
          }
          $credentials['method'] = strtoupper($credentials['method']);
  
          $value = null;
          switch ($credentials['method']) {
              case 'HMAC-SHA1':
                  $hasKeys = isset(
                      $credentials['consumerSecret'],
                      $credentials['token'],
                      $credentials['tokenSecret']
                  );
                  if (!$hasKeys) {
                      return $request;
                  }
                  $value = $this->_hmacSha1($request, $credentials);
                  break;
  
              case 'RSA-SHA1':
                  if (!isset($credentials['privateKey'])) {
                      return $request;
                  }
                  $value = $this->_rsaSha1($request, $credentials);
                  break;
  
              case 'PLAINTEXT':
                  $hasKeys = isset(
                      $credentials['consumerSecret'],
                      $credentials['token'],
                      $credentials['tokenSecret']
                  );
                  if (!$hasKeys) {
                      return $request;
                  }
                  $value = $this->_plaintext($request, $credentials);
                  break;
  
              default:
                  throw new Exception(sprintf('Unknown Oauth signature method %s', $credentials['method']));
          }
  
          return $request->withHeader('Authorization', $value);
      }
code_tokens: public function authentication ( Request $ request , array $ credentials ) { if ( ! isset ( $ credentials [ 'consumerKey' ] ) ) { return $ request ; } if ( empty ( $ credentials [ 'method' ] ) ) { $ credentials [ 'method' ] = 'hmac-sha1' ; } $ credentials [ 'method' ] = strtoupper ( $ credentials [ 'method' ] ) ; $ value = null ; switch ( $ credentials [ 'method' ] ) { case 'HMAC-SHA1' : $ hasKeys = isset ( $ credentials [ 'consumerSecret' ] , $ credentials [ 'token' ] , $ credentials [ 'tokenSecret' ] ) ; if ( ! $ hasKeys ) { return $ request ; } $ value = $ this -> _hmacSha1 ( $ request , $ credentials ) ; break ; case 'RSA-SHA1' : if ( ! isset ( $ credentials [ 'privateKey' ] ) ) { return $ request ; } $ value = $ this -> _rsaSha1 ( $ request , $ credentials ) ; break ; case 'PLAINTEXT' : $ hasKeys = isset ( $ credentials [ 'consumerSecret' ] , $ credentials [ 'token' ] , $ credentials [ 'tokenSecret' ] ) ; if ( ! $ hasKeys ) { return $ request ; } $ value = $ this -> _plaintext ( $ request , $ credentials ) ; break ; default : throw new Exception ( sprintf ( 'Unknown Oauth signature method %s' , $ credentials [ 'method' ] ) ) ; } return $ request -> withHeader ( 'Authorization' , $ value ) ; }
docstring: Add headers for Oauth authorization.
  
  @param \Cake\Http\Client\Request $request The request object.
  @param array $credentials Authentication credentials.
  @return \Cake\Http\Client\Request The updated request.
  @throws \Cake\Core\Exception\Exception On invalid signature types.
docstring_tokens: Add headers for Oauth authorization .