kopia lustrzana https://github.com/gaul/s3proxy
get rid of default blob store
rodzic
d76717e733
commit
16bb2082f4
|
@ -151,7 +151,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
"log-delivery-write"
|
"log-delivery-write"
|
||||||
);
|
);
|
||||||
|
|
||||||
private final BlobStore defaultBlobStore;
|
private final boolean anonymousIdentity;
|
||||||
private final Optional<String> virtualHost;
|
private final Optional<String> virtualHost;
|
||||||
private final XMLInputFactory xmlInputFactory =
|
private final XMLInputFactory xmlInputFactory =
|
||||||
XMLInputFactory.newInstance();
|
XMLInputFactory.newInstance();
|
||||||
|
@ -162,6 +162,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
S3ProxyHandler(final BlobStore blobStore, final String identity,
|
S3ProxyHandler(final BlobStore blobStore, final String identity,
|
||||||
final String credential, Optional<String> virtualHost) {
|
final String credential, Optional<String> virtualHost) {
|
||||||
if (identity != null) {
|
if (identity != null) {
|
||||||
|
anonymousIdentity = false;
|
||||||
blobStoreLocator = new BlobStoreLocator() {
|
blobStoreLocator = new BlobStoreLocator() {
|
||||||
@Override
|
@Override
|
||||||
public Map.Entry<String, BlobStore> locateBlobStore(
|
public Map.Entry<String, BlobStore> locateBlobStore(
|
||||||
|
@ -172,17 +173,17 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
return Maps.immutableEntry(credential, blobStore);
|
return Maps.immutableEntry(credential, blobStore);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultBlobStore = null;
|
|
||||||
} else {
|
} else {
|
||||||
|
anonymousIdentity = true;
|
||||||
|
final Map.Entry<String, BlobStore> anonymousBlobStore =
|
||||||
|
Maps.immutableEntry(null, blobStore);
|
||||||
blobStoreLocator = new BlobStoreLocator() {
|
blobStoreLocator = new BlobStoreLocator() {
|
||||||
@Override
|
@Override
|
||||||
public Map.Entry<String, BlobStore> locateBlobStore(
|
public Map.Entry<String, BlobStore> locateBlobStore(
|
||||||
String identityArg, String container, String blob) {
|
String identityArg, String container, String blob) {
|
||||||
return null;
|
return anonymousBlobStore;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
defaultBlobStore = blobStore;
|
|
||||||
}
|
}
|
||||||
this.virtualHost = requireNonNull(virtualHost);
|
this.virtualHost = requireNonNull(virtualHost);
|
||||||
xmlOutputFactory.setProperty("javax.xml.stream.isRepairingNamespaces",
|
xmlOutputFactory.setProperty("javax.xml.stream.isRepairingNamespaces",
|
||||||
|
@ -250,7 +251,7 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultBlobStore == null && !hasDateHeader && !hasXAmzDateHeader &&
|
if (!anonymousIdentity && !hasDateHeader && !hasXAmzDateHeader &&
|
||||||
request.getParameter("Expires") == null) {
|
request.getParameter("Expires") == null) {
|
||||||
throw new S3Exception(S3ErrorCode.ACCESS_DENIED,
|
throw new S3Exception(S3ErrorCode.ACCESS_DENIED,
|
||||||
"AWS authentication requires a valid Date or" +
|
"AWS authentication requires a valid Date or" +
|
||||||
|
@ -304,11 +305,11 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
path[i] = URLDecoder.decode(path[i], "UTF-8");
|
path[i] = URLDecoder.decode(path[i], "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map.Entry<String, BlobStore> provider =
|
||||||
|
blobStoreLocator.locateBlobStore(
|
||||||
|
requestIdentity, path.length > 1 ? path[1] : null,
|
||||||
|
path.length > 2 ? path[2] : null);
|
||||||
if (requestIdentity != null) {
|
if (requestIdentity != null) {
|
||||||
Map.Entry<String, BlobStore> provider =
|
|
||||||
blobStoreLocator.locateBlobStore(
|
|
||||||
requestIdentity, path.length > 1 ? path[1] : null,
|
|
||||||
path.length > 2 ? path[2] : null);
|
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
throw new S3Exception(S3ErrorCode.INVALID_ACCESS_KEY_ID);
|
throw new S3Exception(S3ErrorCode.INVALID_ACCESS_KEY_ID);
|
||||||
}
|
}
|
||||||
|
@ -330,10 +331,10 @@ final class S3ProxyHandler extends AbstractHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (defaultBlobStore == null) {
|
if (!anonymousIdentity) {
|
||||||
throw new S3Exception(S3ErrorCode.ACCESS_DENIED);
|
throw new S3Exception(S3ErrorCode.ACCESS_DENIED);
|
||||||
} else {
|
} else {
|
||||||
blobStore = defaultBlobStore;
|
blobStore = provider.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue