Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle SSE in statObject() properly and have one source code. #775

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions api/src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,20 @@ private String getText(XmlPullParser xpp) throws XmlPullParserException {
return null;
}

private void checkReadRequestSse(ServerSideEncryption sse) throws InvalidArgumentException {
if (sse == null) {
return;
}

if (sse.getType() != ServerSideEncryption.Type.SSE_C) {
throw new InvalidArgumentException("only SSE_C is supported for all read requests.");
}

if (sse.getType().requiresTls() && !this.baseUrl.isHttps()) {
throw new InvalidArgumentException(sse.getType().name()
+ "operations must be performed over a secure connection.");
}
}

/**
* Executes GET method for given request parameters.
Expand Down Expand Up @@ -1481,13 +1495,8 @@ public void setAppInfo(String name, String version) {
public ObjectStat statObject(String bucketName, String objectName)
throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException,
InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
InternalException,InvalidResponseException {
HttpResponse response = executeHead(bucketName, objectName);
ResponseHeader header = response.header();
Map<String,List<String>> httpHeaders = response.httpHeaders();
ObjectStat objectStat = new ObjectStat(bucketName, objectName, header, httpHeaders);

return objectStat;
InternalException, InvalidResponseException, InvalidArgumentException {
return statObject(bucketName, objectName, null);
}

/**
Expand Down Expand Up @@ -1523,14 +1532,14 @@ public ObjectStat statObject(String bucketName, String objectName, ServerSideEnc
throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException,
InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
InternalException, InvalidArgumentException, InvalidResponseException {
if ((sse.getType() == ServerSideEncryption.Type.SSE_S3)
|| (sse.getType() == ServerSideEncryption.Type.SSE_KMS)) {
throw new InvalidArgumentException("Invalid encryption option specified for encryption type " + sse.getType());
} else if ((sse.getType() == ServerSideEncryption.Type.SSE_C) && (!this.baseUrl.isHttps())) {
throw new InvalidArgumentException("SSE_C operations must be performed over a secure connection.");
checkReadRequestSse(sse);

Map<String, String> headers = null;
if (sse != null) {
headers = new HashMap<>();
sse.marshal(headers);
}
Map<String, String> headers = new HashMap<>();
sse.marshal(headers);

HttpResponse response = executeHead(bucketName, objectName, headers);
ResponseHeader header = response.header();
Map<String,List<String>> httpHeaders = response.httpHeaders();
Expand Down