@@ -41,7 +41,7 @@ |
||
| 41 | 41 | /** |
| 42 | 42 | * Set it up |
| 43 | 43 | * @param \JaegerApp\Platforms\AbstractPlatform $platform |
| 44 | - * @param \JaegerApp\BackupPro\Rest $rest |
|
| 44 | + * @param $rest |
|
| 45 | 45 | */ |
| 46 | 46 | public function __construct(\JaegerApp\Platforms\AbstractPlatform $platform, \JaegerApp\Rest $rest) |
| 47 | 47 | { |
@@ -65,13 +65,13 @@ |
||
| 65 | 65 | */ |
| 66 | 66 | public function getVersion($version_key) |
| 67 | 67 | { |
| 68 | - if(is_null($this->version)) |
|
| 68 | + if (is_null($this->version)) |
|
| 69 | 69 | { |
| 70 | 70 | //determine the version |
| 71 | 71 | $headers = \getallheaders(); |
| 72 | - if(isset($headers[$version_key]) && is_numeric($headers[$version_key]) && in_array($headers[$version_key], $this->api_versions)) |
|
| 72 | + if (isset($headers[$version_key]) && is_numeric($headers[$version_key]) && in_array($headers[$version_key], $this->api_versions)) |
|
| 73 | 73 | { |
| 74 | - $version = 'V'.str_replace('.','_',$headers[$version_key]); |
|
| 74 | + $version = 'V'.str_replace('.', '_', $headers[$version_key]); |
|
| 75 | 75 | } |
| 76 | 76 | else |
| 77 | 77 | { |
@@ -72,8 +72,7 @@ |
||
| 72 | 72 | if(isset($headers[$version_key]) && is_numeric($headers[$version_key]) && in_array($headers[$version_key], $this->api_versions)) |
| 73 | 73 | { |
| 74 | 74 | $version = 'V'.str_replace('.','_',$headers[$version_key]); |
| 75 | - } |
|
| 76 | - else |
|
| 75 | + } else |
|
| 77 | 76 | { |
| 78 | 77 | $version = 'V1'; |
| 79 | 78 | } |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | public function renderOutput(\Nocarrier\Hal $hal) |
| 80 | 80 | { |
| 81 | 81 | $this->sendHeaders(); |
| 82 | - if($this->getSystemErrors()) |
|
| 82 | + if ($this->getSystemErrors()) |
|
| 83 | 83 | { |
| 84 | 84 | $system_errors = array(); |
| 85 | - foreach($this->getSystemErrors() As $key => $value) { |
|
| 85 | + foreach ($this->getSystemErrors() As $key => $value) { |
|
| 86 | 86 | $system_errors[$key] = $this->m62Lang($key); |
| 87 | 87 | } |
| 88 | 88 | $hal->setData($hal->getData() + array('_system_errors' => $system_errors)); |
| 89 | 89 | |
| 90 | 90 | } |
| 91 | - if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'xml') !== false) |
|
| 91 | + if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'xml') !== false) |
|
| 92 | 92 | { |
| 93 | 93 | header('Content-Type: application/hal+xml'); |
| 94 | 94 | return $hal->asXml(true); |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | $problem = $this->getApiProblem($title, $type); |
| 119 | 119 | $problem->setStatus($code); |
| 120 | 120 | $problem->setDetail($detail); |
| 121 | - if($errors) |
|
| 121 | + if ($errors) |
|
| 122 | 122 | { |
| 123 | 123 | $problem['errors'] = $errors; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $this->sendHeaders(); |
| 127 | - if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'xml') !== false) |
|
| 127 | + if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'xml') !== false) |
|
| 128 | 128 | { |
| 129 | 129 | header('Content-Type: application/problem+xml'); |
| 130 | 130 | return $problem->asXml(true); |
@@ -92,8 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | header('Content-Type: application/hal+xml'); |
| 94 | 94 | return $hal->asXml(true); |
| 95 | - } |
|
| 96 | - else |
|
| 95 | + } else |
|
| 97 | 96 | { |
| 98 | 97 | header('Content-Type: application/hal+json'); |
| 99 | 98 | return $hal->asJson(true); |
@@ -128,8 +127,7 @@ discard block |
||
| 128 | 127 | { |
| 129 | 128 | header('Content-Type: application/problem+xml'); |
| 130 | 129 | return $problem->asXml(true); |
| 131 | - } |
|
| 132 | - else |
|
| 130 | + } else |
|
| 133 | 131 | { |
| 134 | 132 | header('Content-Type: application/problem+json'); |
| 135 | 133 | return $problem->asJson(true); |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace JaegerApp\Platforms\View; |
| 11 | 11 | |
| 12 | -use Nocarrier\Hal; |
|
| 13 | 12 | use Crell\ApiProblem\ApiProblem; |
| 13 | +use Nocarrier\Hal; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Jaeger - Rest View Object |
@@ -88,9 +88,9 @@ |
||
| 88 | 88 | $hmac = $this->getRest()->getServer()->getHmac(); |
| 89 | 89 | $data = array_merge($this->getRequestHeaders(true), $this->getBodyData()); |
| 90 | 90 | $auth = $hmac->setData($data) |
| 91 | - ->setRoute($this->getPlatform()->getPost('bp_method')) |
|
| 92 | - ->setMethod($_SERVER['REQUEST_METHOD']) |
|
| 93 | - ->auth($this->settings['api_key'], $this->settings['api_secret']); |
|
| 91 | + ->setRoute($this->getPlatform()->getPost('bp_method')) |
|
| 92 | + ->setMethod($_SERVER['REQUEST_METHOD']) |
|
| 93 | + ->auth($this->settings['api_key'], $this->settings['api_secret']); |
|
| 94 | 94 | |
| 95 | 95 | if(!$auth) { |
| 96 | 96 | return false; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | ->setMethod($_SERVER['REQUEST_METHOD']) |
| 93 | 93 | ->auth($this->settings['api_key'], $this->settings['api_secret']); |
| 94 | 94 | |
| 95 | - if(!$auth) { |
|
| 95 | + if (!$auth) { |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function getBodyData() |
| 107 | 107 | { |
| 108 | - if(is_null($this->body_data)) |
|
| 108 | + if (is_null($this->body_data)) |
|
| 109 | 109 | { |
| 110 | 110 | $data = json_decode(file_get_contents("php://input"), true); |
| 111 | - if(!$data) |
|
| 111 | + if (!$data) |
|
| 112 | 112 | { |
| 113 | 113 | $data = array(); |
| 114 | 114 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | public function getRequestHeaders($auth = true) |
| 127 | 127 | { |
| 128 | 128 | $headers = \getallheaders(); |
| 129 | - if($auth) { |
|
| 129 | + if ($auth) { |
|
| 130 | 130 | $hmac = $this->getRest()->getServer()->getHmac(); |
| 131 | 131 | $return = array( |
| 132 | 132 | $hmac->getPrefix().'timestamp' => (isset($headers[$hmac->getPrefix().'timestamp']) ? $headers[$hmac->getPrefix().'timestamp'] : ''), |
@@ -62,14 +62,14 @@ |
||
| 62 | 62 | //make sure we have the require attributes |
| 63 | 63 | $required = array('timestamp'); |
| 64 | 64 | $data = $this->getData(); |
| 65 | - foreach($required AS $require) { |
|
| 66 | - if(!isset($data[$this->prefix.$require])) { |
|
| 65 | + foreach ($required AS $require) { |
|
| 66 | + if (!isset($data[$this->prefix.$require])) { |
|
| 67 | 67 | return false; |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | //looks good, now let's process it |
| 72 | - $auth = new Auth($this->getMethod(), $this->getRoute(), $this->getData(), [ |
|
| 72 | + $auth = new Auth($this->getMethod(), $this->getRoute(), $this->getData(), [ |
|
| 73 | 73 | new CheckKey, |
| 74 | 74 | new CheckVersion, |
| 75 | 75 | new CheckTimestamp, |
@@ -79,9 +79,7 @@ |
||
| 79 | 79 | |
| 80 | 80 | try { |
| 81 | 81 | return $auth->attempt($token, $this->prefix); |
| 82 | - } |
|
| 83 | - |
|
| 84 | - catch (SignatureException $e) { |
|
| 82 | + } catch (SignatureException $e) { |
|
| 85 | 83 | return false; |
| 86 | 84 | } |
| 87 | 85 | } |
@@ -11,12 +11,12 @@ |
||
| 11 | 11 | namespace JaegerApp\Rest; |
| 12 | 12 | |
| 13 | 13 | use PhilipBrown\Signature\Auth; |
| 14 | -use PhilipBrown\Signature\Token; |
|
| 14 | +use PhilipBrown\Signature\Exceptions\SignatureException; |
|
| 15 | 15 | use PhilipBrown\Signature\Guards\CheckKey; |
| 16 | -use PhilipBrown\Signature\Guards\CheckVersion; |
|
| 17 | -use PhilipBrown\Signature\Guards\CheckTimestamp; |
|
| 18 | 16 | use PhilipBrown\Signature\Guards\CheckSignature; |
| 19 | -use PhilipBrown\Signature\Exceptions\SignatureException; |
|
| 17 | +use PhilipBrown\Signature\Guards\CheckTimestamp; |
|
| 18 | +use PhilipBrown\Signature\Guards\CheckVersion; |
|
| 19 | +use PhilipBrown\Signature\Token; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Jaeger - REST Hmac Object |