kopia lustrzana https://github.com/gaul/s3proxy
Remove explicit dependency on Apache commons-io
commons-fileupload2-javax exposes this as an implicit dependency but S3Proxy can replace its uses with Guava and modern Java.pull/763/head
rodzic
86aceaf45e
commit
b8bd258dcd
|
@ -26,8 +26,8 @@ import javax.annotation.concurrent.ThreadSafe;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import com.google.common.io.ByteStreams;
|
||||||
import org.apache.commons.io.input.BoundedInputStream;
|
|
||||||
import org.jclouds.blobstore.BlobStore;
|
import org.jclouds.blobstore.BlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
|
@ -211,10 +211,10 @@ public class Decryption {
|
||||||
if (this.skipFirstBlock) {
|
if (this.skipFirstBlock) {
|
||||||
offset = offset + Constants.AES_BLOCK_SIZE;
|
offset = offset + Constants.AES_BLOCK_SIZE;
|
||||||
}
|
}
|
||||||
IOUtils.skipFully(dis, offset);
|
ByteStreams.skipFully(dis, offset);
|
||||||
|
|
||||||
// trim the stream to a specific length if needed
|
// trim the stream to a specific length if needed
|
||||||
return new BoundedInputStream(dis, outputLength);
|
return outputLength >= 0 ? ByteStreams.limit(dis, outputLength) : dis;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateOffset(long offset) {
|
private void calculateOffset(long offset) {
|
||||||
|
|
|
@ -26,8 +26,6 @@ import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.ShortBufferException;
|
import javax.crypto.ShortBufferException;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public class DecryptionInputStream extends FilterInputStream {
|
public class DecryptionInputStream extends FilterInputStream {
|
||||||
|
|
||||||
|
@ -176,7 +174,8 @@ public class DecryptionInputStream extends FilterInputStream {
|
||||||
// update the remaining bytes of the next part
|
// update the remaining bytes of the next part
|
||||||
partBytesRemain = parts.get(nextPart).getSize();
|
partBytesRemain = parts.get(nextPart).getSize();
|
||||||
|
|
||||||
IOUtils.skip(in, Constants.PADDING_BLOCK_SIZE);
|
// Cannot call ByteStreams.skipFully since in may be shorter
|
||||||
|
in.readNBytes(Constants.PADDING_BLOCK_SIZE);
|
||||||
|
|
||||||
return ofinish;
|
return ofinish;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -43,7 +42,7 @@ public class PartPadding {
|
||||||
var partPadding = new PartPadding();
|
var partPadding = new PartPadding();
|
||||||
|
|
||||||
try (var is = blob.getPayload().openStream()) {
|
try (var is = blob.getPayload().openStream()) {
|
||||||
byte[] paddingBytes = IOUtils.toByteArray(is);
|
byte[] paddingBytes = is.readAllBytes();
|
||||||
ByteBuffer bb = ByteBuffer.wrap(paddingBytes);
|
ByteBuffer bb = ByteBuffer.wrap(paddingBytes);
|
||||||
|
|
||||||
byte[] delimiterBytes =
|
byte[] delimiterBytes =
|
||||||
|
|
|
@ -22,7 +22,8 @@ import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import com.google.common.io.MoreFiles;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||||
import org.gaul.s3proxy.AuthenticationType;
|
import org.gaul.s3proxy.AuthenticationType;
|
||||||
import org.gaul.s3proxy.S3Proxy;
|
import org.gaul.s3proxy.S3Proxy;
|
||||||
|
@ -164,7 +165,11 @@ public class S3ProxyJunitCore {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Unable to stop S3 proxy", e);
|
throw new RuntimeException("Unable to stop S3 proxy", e);
|
||||||
}
|
}
|
||||||
FileUtils.deleteQuietly(blobStoreLocation);
|
try {
|
||||||
|
MoreFiles.deleteRecursively(blobStoreLocation.toPath());
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
logger.debug("S3 proxy has stopped");
|
logger.debug("S3 proxy has stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue