diff --git a/spring-content-encryption/src/main/java/internal/org/springframework/content/fragments/EncryptingContentStoreImpl.java b/spring-content-encryption/src/main/java/internal/org/springframework/content/fragments/EncryptingContentStoreImpl.java index b9793b1a9..faeff0f78 100644 --- a/spring-content-encryption/src/main/java/internal/org/springframework/content/fragments/EncryptingContentStoreImpl.java +++ b/spring-content-encryption/src/main/java/internal/org/springframework/content/fragments/EncryptingContentStoreImpl.java @@ -329,7 +329,7 @@ public Resource getResource(S entity, PropertyPath propertyPath, GetResourcePara return r; } - private int getOffset(Resource r, GetResourceParams params) { + private long getOffset(Resource r, GetResourceParams params) { int offset = 0; if (r instanceof RangeableResource == false) @@ -337,18 +337,18 @@ private int getOffset(Resource r, GetResourceParams params) { if (params.getRange() == null) return offset; - return Integer.parseInt(StringUtils.substringBetween(params.getRange(), "bytes=", "-")); + return Long.parseUnsignedLong(StringUtils.substringBetween(params.getRange(), "bytes=", "-")); } - private int getOffset(Resource r, org.springframework.content.commons.store.GetResourceParams params) { - int offset = 0; + private long getOffset(Resource r, org.springframework.content.commons.store.GetResourceParams params) { + long offset = 0; if (r instanceof RangeableResource == false) return offset; if (params.getRange() == null) return offset; - return Integer.parseInt(StringUtils.substringBetween(params.getRange(), "bytes=", "-")); + return Long.parseUnsignedLong(StringUtils.substringBetween(params.getRange(), "bytes=", "-")); } @Override diff --git a/spring-content-encryption/src/main/java/org/springframework/content/encryption/EnvelopeEncryptionService.java b/spring-content-encryption/src/main/java/org/springframework/content/encryption/EnvelopeEncryptionService.java index 09480763e..08f6dc495 100644 --- a/spring-content-encryption/src/main/java/org/springframework/content/encryption/EnvelopeEncryptionService.java +++ b/spring-content-encryption/src/main/java/org/springframework/content/encryption/EnvelopeEncryptionService.java @@ -84,7 +84,7 @@ private SecretKey generateDataKey() { return KEY_GENERATOR.generateKey(); } - private InputStream decryptInputStream(final SecretKeySpec secretKeySpec, byte[] nonce, int offset, InputStream is) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, IOException, InvalidAlgorithmParameterException { + private InputStream decryptInputStream(final SecretKeySpec secretKeySpec, byte[] nonce, long offset, InputStream is) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, IOException, InvalidAlgorithmParameterException { Cipher cipher = Cipher.getInstance(transformation); byte[] iv = new byte[128 / 8]; @@ -124,7 +124,7 @@ private SecretKeySpec decryptKey(byte[] encryptedKey, String keyName) { return key; } - public InputStream decrypt(byte[] ecryptedContext, InputStream is, int offset, String keyName) { + public InputStream decrypt(byte[] ecryptedContext, InputStream is, long offset, String keyName) { byte[] key = new byte[105]; System.arraycopy(ecryptedContext, 0, key, 0, 105);