quantranhong1999 commented on code in PR #2021:
URL: https://github.com/apache/james-project/pull/2021#discussion_r1500433073
##########
server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java:
##########
@@ -23,28 +23,47 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
import java.security.GeneralSecurityException;
import java.util.Collection;
+import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStoreDAO;
import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.api.ObjectNotFoundException;
import org.apache.james.blob.api.ObjectStoreIOException;
+import org.apache.james.util.Size;
import org.reactivestreams.Publisher;
+import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.google.common.base.Preconditions;
import com.google.common.io.ByteSource;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.CountingOutputStream;
import com.google.common.io.FileBackedOutputStream;
import com.google.crypto.tink.subtle.AesGcmHkdfStreaming;
+import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
public class AESBlobStoreDAO implements BlobStoreDAO {
- // For now, aligned with with MimeMessageInputStreamSource file threshold,
detailed benchmarking might be conducted to challenge this choice
- public static final int FILE_THRESHOLD_100_KB = 100 * 1024;
+ public static final int FILE_THRESHOLD_ENCRYPT =
Optional.ofNullable(System.getenv("james.blob.aes.file.threshold.encrypt"))
+ .map(s -> Size.parse(s, Size.Unit.NoUnit))
+ .map(s -> (int) s.asBytes())
+ .orElse(100 * 1024);
+ public static final int MAXIMUM_BLOB_SIZE =
Optional.ofNullable(System.getenv("james.blob.aes.blob.max.size"))
+ .map(s -> Size.parse(s, Size.Unit.NoUnit))
+ .map(s -> (int) s.asBytes())
+ .orElse(100 * 1024 * 1024);
+ public static final int FILE_THRESHOLD_DECRYPT =
Optional.ofNullable(System.getenv("james.blob.aes.file.threshold.decrypt"))
Review Comment:
```suggestion
public static final int FILE_THRESHOLD_DECRYPT =
Optional.ofNullable(System.getProperty("james.blob.aes.file.threshold.decrypt"))
```
Should get JVM property instead of env IMO.
##########
server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java:
##########
@@ -23,28 +23,47 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
import java.security.GeneralSecurityException;
import java.util.Collection;
+import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStoreDAO;
import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.api.ObjectNotFoundException;
import org.apache.james.blob.api.ObjectStoreIOException;
+import org.apache.james.util.Size;
import org.reactivestreams.Publisher;
+import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.google.common.base.Preconditions;
import com.google.common.io.ByteSource;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.CountingOutputStream;
import com.google.common.io.FileBackedOutputStream;
import com.google.crypto.tink.subtle.AesGcmHkdfStreaming;
+import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
public class AESBlobStoreDAO implements BlobStoreDAO {
- // For now, aligned with with MimeMessageInputStreamSource file threshold,
detailed benchmarking might be conducted to challenge this choice
- public static final int FILE_THRESHOLD_100_KB = 100 * 1024;
+ public static final int FILE_THRESHOLD_ENCRYPT =
Optional.ofNullable(System.getenv("james.blob.aes.file.threshold.encrypt"))
+ .map(s -> Size.parse(s, Size.Unit.NoUnit))
+ .map(s -> (int) s.asBytes())
+ .orElse(100 * 1024);
+ public static final int MAXIMUM_BLOB_SIZE =
Optional.ofNullable(System.getenv("james.blob.aes.blob.max.size"))
Review Comment:
```suggestion
public static final int MAXIMUM_BLOB_SIZE =
Optional.ofNullable(System.getProperty("james.blob.aes.blob.max.size"))
```
##########
server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java:
##########
@@ -23,28 +23,47 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
import java.security.GeneralSecurityException;
import java.util.Collection;
+import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStoreDAO;
import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.api.ObjectNotFoundException;
import org.apache.james.blob.api.ObjectStoreIOException;
+import org.apache.james.util.Size;
import org.reactivestreams.Publisher;
+import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.google.common.base.Preconditions;
import com.google.common.io.ByteSource;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.CountingOutputStream;
import com.google.common.io.FileBackedOutputStream;
import com.google.crypto.tink.subtle.AesGcmHkdfStreaming;
+import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
public class AESBlobStoreDAO implements BlobStoreDAO {
- // For now, aligned with with MimeMessageInputStreamSource file threshold,
detailed benchmarking might be conducted to challenge this choice
- public static final int FILE_THRESHOLD_100_KB = 100 * 1024;
+ public static final int FILE_THRESHOLD_ENCRYPT =
Optional.ofNullable(System.getenv("james.blob.aes.file.threshold.encrypt"))
Review Comment:
```suggestion
public static final int FILE_THRESHOLD_ENCRYPT =
Optional.ofNullable(System.getProperty("james.blob.aes.file.threshold.encrypt"))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]