Esempio n. 1
0
 public function testIsSimpleMapFormat()
 {
     $this->assertTrue(Str::isSimpleMapFormat('realm="panlatent.com",access_token=""'));
     $this->assertTrue(Str::isSimpleMapFormat("realm=\"panlatent.com\" \n  ,  \n  access_token=\"\""));
     $this->assertTrue(Str::isSimpleMapFormat("realm=\"panlatent.com\" \n  access_token=\"\""));
     $this->assertFalse(Str::isSimpleMapFormat("realm=\"panlatent.com\" \n  ,,  \n  access_token=\"\""));
     $this->assertFalse(Str::isSimpleMapFormat('realm="pan'));
     $this->assertFalse(Str::isSimpleMapFormat('realm="panlatent.com",access'));
     $this->assertFalse(Str::isSimpleMapFormat('realm="panlatent.com"ABC,access_token=""'));
 }
Esempio n. 2
0
 /**
  * Returns a array from the authorization header.
  *
  * @return array|bool
  */
 public function getAuthorization()
 {
     $authorization = ['type' => '', 'value' => '', 'parameters' => []];
     if ($content = $this->headers->get('AUTHORIZATION')) {
         $content = explode(' ', trim($content, ' '), 3);
         if (is_array($content) && count($content) > 0) {
             $authorization['type'] = ucfirst(strtolower($content[0]));
             if (isset($content[1]) && Str::isSimpleMapFormat($content[1])) {
                 $authorization['parameters'] = Str::convertSimpleMapArray($content[1]);
             } else {
                 isset($content[1]) and $authorization['value'] = $content[1];
                 isset($content[2]) and $authorization['parameters'] = Str::convertSimpleMapArray($content[2]);
             }
             return $authorization;
         }
     }
     return false;
 }