Skip to content

Commit a17ecf1

Browse files
committed
Refactor messages by subclasses
merge SelectObjectContentRequest merge ListVersionsResult Remove unused CompleteMultipartUploadOutput.java merge ListMultipartUploadsResult merge NotificationRecords merge SseConfiguration merge DeleteRequest, DeleteResult merge RestoreRequest merge NotificationConfiguration merge LifecycleConfiguration merge ReplicationConfiguration merge Filter merge ObjectLockConfiguration merge ListAllMyBucketsResult merge Item merge ListObjectsResult Move common fields for ListPartsResult and GetObjectAttributesOutput Signed-off-by: Bala.FA <[email protected]>
1 parent c9e40cc commit a17ecf1

File tree

391 files changed

+19828
-22413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

391 files changed

+19828
-22413
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
echo "DEV_VERSION=$(./gradlew properties | awk '/^version:/ { print $2 }')" >> $GITHUB_ENV
3737
echo "RELEASE_VERSION=$(./gradlew properties -Prelease | awk '/^version:/ { print $2 }')" >> $GITHUB_ENV
38-
- name: Gradle build on Ununtu
38+
- name: Gradle build on Ubuntu
3939
if: matrix.os == 'ubuntu-latest'
4040
run: |
4141
./gradlew build

adminapi/src/main/java/io/minio/admin/AddServiceAccountResp.java renamed to adminapi/src/main/java/io/minio/admin/AddServiceAccountResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* "https://github.com/minio/madmin-go/blob/main/user-commands.go#L388">user-commands.go</a>
2929
*/
3030
@JsonIgnoreProperties(ignoreUnknown = true)
31-
public class AddServiceAccountResp {
31+
public class AddServiceAccountResponse {
3232
@JsonProperty("credentials")
3333
private Credentials credentials;
3434

adminapi/src/main/java/io/minio/admin/GroupAddUpdateRemoveInfo.java renamed to adminapi/src/main/java/io/minio/admin/AddUpdateRemoveGroupArgs.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2121
import com.fasterxml.jackson.annotation.JsonProperty;
2222
import java.util.Collections;
23-
import java.util.LinkedList;
2423
import java.util.List;
2524
import java.util.Objects;
2625
import javax.annotation.Nonnull;
2726
import javax.annotation.Nullable;
2827

2928
/** Represents groupAddUpdateRemove information. */
3029
@JsonIgnoreProperties(ignoreUnknown = true)
31-
public class GroupAddUpdateRemoveInfo {
30+
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "URF_UNREAD_FIELD")
31+
public class AddUpdateRemoveGroupArgs {
3232
@JsonProperty("group")
3333
private String group;
3434

@@ -41,7 +41,7 @@ public class GroupAddUpdateRemoveInfo {
4141
@JsonProperty("isRemove")
4242
private boolean isRemove;
4343

44-
public GroupAddUpdateRemoveInfo(
44+
public AddUpdateRemoveGroupArgs(
4545
@Nonnull @JsonProperty("group") String group,
4646
@Nullable @JsonProperty("groupStatus") Status groupStatus,
4747
@Nullable @JsonProperty("members") List<String> members,
@@ -51,20 +51,4 @@ public GroupAddUpdateRemoveInfo(
5151
this.members = (members != null) ? Collections.unmodifiableList(members) : null;
5252
this.isRemove = isRemove;
5353
}
54-
55-
public String group() {
56-
return group;
57-
}
58-
59-
public Status groupStatus() {
60-
return groupStatus;
61-
}
62-
63-
public List<String> members() {
64-
return Collections.unmodifiableList(members == null ? new LinkedList<>() : members);
65-
}
66-
67-
public boolean isRemove() {
68-
return isRemove;
69-
}
7054
}

adminapi/src/main/java/io/minio/admin/Crypto.java

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package io.minio.admin;
1919

20+
import io.minio.errors.MinioException;
2021
import java.io.ByteArrayOutputStream;
2122
import java.io.EOFException;
2223
import java.io.IOException;
@@ -156,22 +157,25 @@ private static byte[] generateKey(byte[] secret, byte[] salt) {
156157
}
157158

158159
private static byte[] generateEncryptDecryptAdditionalData(
159-
boolean encryptFlag, int aeadId, byte[] key, byte[] paddedNonce)
160-
throws InvalidCipherTextException {
161-
AEADCipher cipher = getEncryptCipher(aeadId, key, paddedNonce);
162-
int outputLength = cipher.getMac().length;
163-
byte[] additionalData = new byte[outputLength];
164-
cipher.doFinal(additionalData, 0);
165-
return appendBytes(new byte[] {0}, additionalData);
160+
boolean encryptFlag, int aeadId, byte[] key, byte[] paddedNonce) throws MinioException {
161+
try {
162+
AEADCipher cipher = getEncryptCipher(aeadId, key, paddedNonce);
163+
int outputLength = cipher.getMac().length;
164+
byte[] additionalData = new byte[outputLength];
165+
cipher.doFinal(additionalData, 0);
166+
return appendBytes(new byte[] {0}, additionalData);
167+
} catch (InvalidCipherTextException e) {
168+
throw new MinioException(e);
169+
}
166170
}
167171

168172
private static byte[] generateEncryptAdditionalData(int aeadId, byte[] key, byte[] paddedNonce)
169-
throws InvalidCipherTextException {
173+
throws MinioException {
170174
return generateEncryptDecryptAdditionalData(true, aeadId, key, paddedNonce);
171175
}
172176

173177
private static byte[] generateDecryptAdditionalData(int aeadId, byte[] key, byte[] paddedNonce)
174-
throws InvalidCipherTextException {
178+
throws MinioException {
175179
return generateEncryptDecryptAdditionalData(false, aeadId, key, paddedNonce);
176180
}
177181

@@ -190,7 +194,7 @@ private static byte[] updateNonceId(byte[] nonce, int idx) {
190194
}
191195

192196
/** Encrypt data payload. */
193-
public static byte[] encrypt(byte[] payload, String password) throws InvalidCipherTextException {
197+
public static byte[] encrypt(byte[] payload, String password) throws MinioException {
194198
byte[] nonce = random(NONCE_LENGTH);
195199
byte[] salt = random(SALT_LENGTH);
196200

@@ -219,7 +223,11 @@ public static byte[] encrypt(byte[] payload, String password) throws InvalidCiph
219223
int outputLength = cipher.getOutputSize(chunk.length);
220224
byte[] encryptedData = new byte[outputLength];
221225
int outputOffset = cipher.processBytes(chunk, 0, chunk.length, encryptedData, 0);
222-
cipher.doFinal(encryptedData, outputOffset);
226+
try {
227+
cipher.doFinal(encryptedData, outputOffset);
228+
} catch (InvalidCipherTextException e) {
229+
throw new MinioException(e);
230+
}
223231

224232
result = appendBytes(result, encryptedData);
225233

@@ -243,20 +251,24 @@ public static class DecryptReader {
243251
private byte[] oneByte = null;
244252
private boolean eof = false;
245253

246-
public DecryptReader(InputStream inputStream, byte[] secret)
247-
throws EOFException, IOException, InvalidCipherTextException {
254+
public DecryptReader(InputStream inputStream, byte[] secret) throws MinioException {
248255
this.inputStream = inputStream;
249256
this.secret = secret;
250-
readFully(this.inputStream, this.salt, true);
251-
readFully(this.inputStream, this.aeadId, true);
252-
readFully(this.inputStream, this.nonce, true);
257+
try {
258+
readFully(this.inputStream, this.salt, true);
259+
readFully(this.inputStream, this.aeadId, true);
260+
readFully(this.inputStream, this.nonce, true);
261+
} catch (EOFException e) {
262+
throw new MinioException(e);
263+
} catch (IOException e) {
264+
throw new MinioException(e);
265+
}
253266
this.key = generateKey(this.secret, this.salt);
254267
byte[] paddedNonce = appendBytes(this.nonce, new byte[] {0, 0, 0, 0});
255268
this.additionalData = generateDecryptAdditionalData(this.aeadId[0], this.key, paddedNonce);
256269
}
257270

258-
private byte[] decrypt(byte[] encryptedData, boolean lastChunk)
259-
throws InvalidCipherTextException {
271+
private byte[] decrypt(byte[] encryptedData, boolean lastChunk) throws MinioException {
260272
this.count++;
261273
if (lastChunk) {
262274
this.additionalData = markAsLast(this.additionalData);
@@ -268,12 +280,16 @@ private byte[] decrypt(byte[] encryptedData, boolean lastChunk)
268280
byte[] decryptedData = new byte[outputLength];
269281
int outputOffset =
270282
cipher.processBytes(encryptedData, 0, encryptedData.length, decryptedData, 0);
271-
cipher.doFinal(decryptedData, outputOffset);
283+
try {
284+
cipher.doFinal(decryptedData, outputOffset);
285+
} catch (InvalidCipherTextException e) {
286+
throw new MinioException(e);
287+
}
272288
return decryptedData;
273289
}
274290

275291
/** Read a chunk at least one byte more than chunk size. */
276-
private byte[] readChunk() throws IOException {
292+
private byte[] readChunk() throws EOFException, IOException {
277293
if (this.eof) {
278294
return new byte[] {};
279295
}
@@ -302,19 +318,24 @@ private byte[] readChunk() throws IOException {
302318
return baos.toByteArray();
303319
}
304320

305-
public byte[] readAllBytes() throws IOException, InvalidCipherTextException {
321+
public byte[] readAllBytes() throws MinioException {
306322
ByteArrayOutputStream baos = new ByteArrayOutputStream();
307323
while (!this.eof) {
308-
byte[] payload = this.readChunk();
309-
baos.write(this.decrypt(payload, this.eof));
324+
try {
325+
byte[] payload = this.readChunk();
326+
baos.write(this.decrypt(payload, this.eof));
327+
} catch (EOFException e) {
328+
throw new MinioException(e);
329+
} catch (IOException e) {
330+
throw new MinioException(e);
331+
}
310332
}
311333
return baos.toByteArray();
312334
}
313335
}
314336

315337
/** Decrypt data stream. */
316-
public static byte[] decrypt(InputStream inputStream, String password)
317-
throws EOFException, IOException, InvalidCipherTextException {
338+
public static byte[] decrypt(InputStream inputStream, String password) throws MinioException {
318339
DecryptReader reader =
319340
new DecryptReader(inputStream, password.getBytes(StandardCharsets.UTF_8));
320341
return reader.readAllBytes();

0 commit comments

Comments
 (0)