| 1 | <?php |
| 2 | namespace Aws\S3\Crypto; |
| 3 | |
| 4 | use Aws\Crypto\MaterialsProviderInterfaceV3; |
| 5 | |
| 6 | trait CryptoParamsTraitV3 |
| 7 | { |
| 8 | use CryptoParamsTrait; |
| 9 | |
| 10 | protected function getMaterialsProvider(array $args): MaterialsProviderInterfaceV3 |
| 11 | { |
| 12 | if ($args['@MaterialsProvider'] instanceof MaterialsProviderInterfaceV3) { |
| 13 | return $args['@MaterialsProvider']; |
| 14 | } |
| 15 | |
| 16 | throw new \InvalidArgumentException('An instance of MaterialsProviderInterfaceV3' |
| 17 | . ' must be passed in the "MaterialsProvider" field.'); |
| 18 | } |
| 19 | |
| 20 | protected function getKeyCommitmentPolicy(array $args): string |
| 21 | { |
| 22 | if (empty($args['@CommitmentPolicy'])) { |
| 23 | throw new \InvalidArgumentException('A commitment policy must be' |
| 24 | . ' specified in the CommitmentPolicy field.'); |
| 25 | } |
| 26 | |
| 27 | if (!S3EncryptionClientV3::isSupportedKeyCommitmentPolicy($args['@CommitmentPolicy'])) { |
| 28 | throw new \InvalidArgumentException('The CommitmentPolicy requested is not' |
| 29 | . ' supported by the SDK.'); |
| 30 | } |
| 31 | |
| 32 | return $args['@CommitmentPolicy']; |
| 33 | } |
| 34 | } |