kopia lustrzana https://github.com/gaul/s3proxy
rodzic
0e3a7ef843
commit
f202207c63
|
@ -547,7 +547,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
case "PUT":
|
case "PUT":
|
||||||
if (path.length <= 2 || path[2].isEmpty()) {
|
if (path.length <= 2 || path[2].isEmpty()) {
|
||||||
if ("".equals(request.getParameter("acl"))) {
|
if ("".equals(request.getParameter("acl"))) {
|
||||||
handleSetContainerAcl(request, response, blobStore,
|
handleSetContainerAcl(request, response, is, blobStore,
|
||||||
path[1]);
|
path[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -746,7 +746,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSetContainerAcl(HttpServletRequest request,
|
private void handleSetContainerAcl(HttpServletRequest request,
|
||||||
HttpServletResponse response, BlobStore blobStore,
|
HttpServletResponse response, InputStream is, BlobStore blobStore,
|
||||||
String containerName) throws IOException, S3Exception {
|
String containerName) throws IOException, S3Exception {
|
||||||
ContainerAccess access;
|
ContainerAccess access;
|
||||||
|
|
||||||
|
@ -762,6 +762,22 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PushbackInputStream pis = new PushbackInputStream(is);
|
||||||
|
int ch = pis.read();
|
||||||
|
if (ch != -1) {
|
||||||
|
pis.unread(ch);
|
||||||
|
AccessControlPolicy policy = new XmlMapper().readValue(
|
||||||
|
pis, AccessControlPolicy.class);
|
||||||
|
String accessString = mapXmlAclsToCannedPolicy(policy);
|
||||||
|
if (accessString.equals("private")) {
|
||||||
|
access = ContainerAccess.PRIVATE;
|
||||||
|
} else if (accessString.equals("public-read")) {
|
||||||
|
access = ContainerAccess.PUBLIC_READ;
|
||||||
|
} else {
|
||||||
|
throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
blobStore.setContainerAccess(containerName, access);
|
blobStore.setContainerAccess(containerName, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,14 +865,21 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
pis.unread(ch);
|
pis.unread(ch);
|
||||||
AccessControlPolicy policy = new XmlMapper().readValue(
|
AccessControlPolicy policy = new XmlMapper().readValue(
|
||||||
pis, AccessControlPolicy.class);
|
pis, AccessControlPolicy.class);
|
||||||
access = mapXmlAclsToCannedPolicy(policy);
|
String accessString = mapXmlAclsToCannedPolicy(policy);
|
||||||
|
if (accessString.equals("private")) {
|
||||||
|
access = BlobAccess.PRIVATE;
|
||||||
|
} else if (accessString.equals("public-read")) {
|
||||||
|
access = BlobAccess.PUBLIC_READ;
|
||||||
|
} else {
|
||||||
|
throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blobStore.setBlobAccess(containerName, blobName, access);
|
blobStore.setBlobAccess(containerName, blobName, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Map XML ACLs to a canned policy if an exact tranformation exists. */
|
/** Map XML ACLs to a canned policy if an exact tranformation exists. */
|
||||||
private static BlobAccess mapXmlAclsToCannedPolicy(
|
private static String mapXmlAclsToCannedPolicy(
|
||||||
AccessControlPolicy policy) throws S3Exception {
|
AccessControlPolicy policy) throws S3Exception {
|
||||||
if (!policy.owner.id.equals(FAKE_OWNER_ID)) {
|
if (!policy.owner.id.equals(FAKE_OWNER_ID)) {
|
||||||
throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
|
throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
|
||||||
|
@ -882,9 +905,9 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
|
|
||||||
if (ownerFullControl) {
|
if (ownerFullControl) {
|
||||||
if (allUsersRead) {
|
if (allUsersRead) {
|
||||||
return BlobAccess.PUBLIC_READ;
|
return "public-read";
|
||||||
}
|
}
|
||||||
return BlobAccess.PRIVATE;
|
return "private";
|
||||||
} else {
|
} else {
|
||||||
throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
|
throw new S3Exception(S3ErrorCode.NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue