| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
namespace AWS\CRT\Auth; |
| 7 |
|
| 8 |
use AWS\CRT\IO\InputStream; |
| 9 |
use AWS\CRT\NativeResource as NativeResource; |
| 10 |
|
| 11 |
class Signable extends NativeResource { |
| 12 |
|
| 13 |
public static function fromHttpRequest($http_message) { |
| 14 |
return new Signable(function() use ($http_message) { |
| 15 |
return self::$crt->signable_new_from_http_request($http_message->native); |
| 16 |
}); |
| 17 |
} |
| 18 |
|
| 19 |
public static function fromChunk($chunk_stream, $previous_signature="") { |
| 20 |
if (!($chunk_stream instanceof InputStream)) { |
| 21 |
$chunk_stream = new InputStream($chunk_stream); |
| 22 |
} |
| 23 |
return new Signable(function() use($chunk_stream, $previous_signature) { |
| 24 |
return self::$crt->signable_new_from_chunk($chunk_stream->native, $previous_signature); |
| 25 |
}); |
| 26 |
} |
| 27 |
|
| 28 |
public static function fromCanonicalRequest($canonical_request) { |
| 29 |
return new Signable(function() use($canonical_request) { |
| 30 |
return self::$crt->signable_new_from_canonical_request($canonical_request); |
| 31 |
}); |
| 32 |
} |
| 33 |
|
| 34 |
protected function __construct($ctor) { |
| 35 |
parent::__construct(); |
| 36 |
$this->acquire($ctor()); |
| 37 |
} |
| 38 |
|
| 39 |
function __destruct() { |
| 40 |
self::$crt->signable_release($this->release()); |
| 41 |
parent::__destruct(); |
| 42 |
} |
| 43 |
} |