@@ -90,127 +90,8 @@ public function getBucket() {
9090 return $ this ->bucket ;
9191 }
9292
93- <<<<<<< HEAD
9493 public function getProxy () {
9594 return $ this ->proxy ;
96- =======
97- /**
98- * Add the SSE KMS parameterdepending on the
99- * KMS encryption strategy (bucket, individual or
100- * no encryption) for object creations.
101- *
102- * @return array with encryption parameters
103- */
104- public function getSseKmsPutParameters (): array {
105- if (!empty ($ this ->sseKmsBucketKeyId )) {
106- return [
107- 'ServerSideEncryption ' => 'aws:kms ' ,
108- ];
109- } elseif (!empty ($ this ->sseKmsKeyId )) {
110- return [
111- 'ServerSideEncryption ' => 'aws:kms ' ,
112- 'SSEKMSKeyId ' => $ this ->sseKmsKeyId ,
113- ];
114- } else {
115- return [];
116- }
117- }
118-
119- /**
120- * Add the SSE KMS parameter depending on the
121- * KMS encryption strategy (bucket, individual or
122- * no encryption) for object read.
123- *
124- * @return array with encryption parameters
125- */
126- public function getSseKmsGetParameters (): array {
127- if (!empty ($ this ->sseKmsBucketKeyId )) {
128- return [
129- 'ServerSideEncryption ' => 'aws:kms ' ,
130- 'SSEKMSKeyId ' => $ this ->sseKmsBucketKeyId ,
131- ];
132- } elseif (!empty ($ this ->sseKmsKeyId )) {
133- return [
134- 'ServerSideEncryption ' => 'aws:kms ' ,
135- 'SSEKMSKeyId ' => $ this ->sseKmsKeyId ,
136- ];
137- } else {
138- return [];
139- }
140- }
141-
142-
143- /**
144- * Create the required bucket
145- *
146- * @throws \Exception if bucket creation fails
147- */
148- protected function createNewBucket () {
149- $ logger = \OC ::$ server ->getLogger ();
150- try {
151- $ logger ->info ('Bucket " ' .$ this ->bucket .'" does not exist - creating it. ' , ['app ' => 'objectstore ' ]);
152- if (!$ this ->connection ::isBucketDnsCompatible ($ this ->bucket )) {
153- throw new \Exception ('The bucket will not be created because the name is not dns compatible, please correct it: ' .$ this ->bucket );
154- }
155- $ this ->connection ->createBucket (['Bucket ' => $ this ->bucket ]);
156- $ this ->testTimeout ();
157- } catch (S3Exception $ e ) {
158- $ logger ->logException ($ e , [
159- 'message ' => 'Invalid remote storage. ' ,
160- 'level ' => ILogger::DEBUG ,
161- 'app ' => 'objectstore ' ,
162- ]);
163- throw new \Exception ('Creation of bucket " ' .$ this ->bucket .'" failed. ' .$ e ->getMessage ());
164- }
165- }
166-
167- /**
168- * Check bucket key consistency or put bucket key if missing
169- * This operation only works for bucket owner or with
170- * s3:GetEncryptionConfiguration/s3:PutEncryptionConfiguration permission
171- *
172- * We recommend to use autocreate only on initial setup and
173- * use an S3:user only with object operation permission and no bucket operation permissions
174- * later with autocreate=false
175- *
176- * @throws \Exception if bucket key config is inconsistent or if putting the key fails
177- */
178- protected function checkOrPutBucketKey () {
179- $ logger = \OC ::$ server ->getLogger ();
180-
181- try {
182- $ encrypt_state = $ this ->connection ->getBucketEncryption ([
183- 'Bucket ' => $ this ->bucket ,
184- ]);
185- return ;
186- } catch (S3Exception $ e ) {
187- try {
188- $ logger ->info ('Bucket key for " ' .$ this ->bucket .'" is not set - adding it. ' , ['app ' => 'objectstore ' ]);
189- $ this ->connection ->putBucketEncryption ([
190- 'Bucket ' => $ this ->bucket ,
191- 'ServerSideEncryptionConfiguration ' => [
192- 'Rules ' => [
193- [
194- 'ApplyServerSideEncryptionByDefault ' => [
195- 'KMSMasterKeyID ' => $ this ->sseKmsBucketKeyId ,
196- 'SSEAlgorithm ' => 'aws:kms ' ,
197- ],
198- 'BucketKeyEnabled ' => true ,
199- ],
200- ],
201- ],
202- ]);
203- $ this ->testTimeout ();
204- } catch (S3Exception $ e ) {
205- $ logger ->logException ($ e , [
206- 'message ' => 'Bucket key problem. ' ,
207- 'level ' => ILogger::DEBUG ,
208- 'app ' => 'objectstore ' ,
209- ]);
210- throw new \Exception ('Putting configured bucket key to " ' .$ this ->bucket .'" failed. ' .$ e ->getMessage ());
211- }
212- }
213- >>>>>>> Fix small syntax problem
21495 }
21596
21697 /**
0 commit comments