mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Merge pull request #2880 from FOCONIS/feature/improve-enc-support
ADD encryption support for Between and InRange
This commit is contained in:
3 files changed
+59
-3
No files matched your search
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.expression;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -34,13 +35,24 @@ final class BetweenExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isDbEncrypted()) {
|
||||
// bind the key as well as the value
|
||||
String encryptKey = prop.beanProperty().encryptKey().getStringValue();
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
}
|
||||
request.addBindValue(low());
|
||||
request.addBindValue(high());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
request.append(propName).append(_BETWEEN);
|
||||
String pname = propName;
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isDbEncrypted()) {
|
||||
pname = prop.beanProperty().decryptProperty(propName);
|
||||
}
|
||||
request.append(pname).append(_BETWEEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.expression;
|
||||
import io.ebeaninternal.api.BindValuesKey;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.api.SpiExpressionRequest;
|
||||
import io.ebeaninternal.server.el.ElPropertyValue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -32,13 +33,29 @@ final class InRangeExpression extends AbstractExpression {
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isDbEncrypted()) {
|
||||
// bind the key twice, for both values
|
||||
String encryptKey = prop.beanProperty().encryptKey().getStringValue();
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
request.addBindValue(low());
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
request.addBindValue(high());
|
||||
return;
|
||||
}
|
||||
request.addBindValue(low());
|
||||
request.addBindValue(high());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
request.append("(").append(propName).append(" >= ? and ").append(propName).append(" < ?)");
|
||||
String pname = propName;
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && prop.isDbEncrypted()) {
|
||||
pname = prop.beanProperty().decryptProperty(propName);
|
||||
}
|
||||
request.append("(").append(pname).append(" >= ? and ").append(pname).append(" < ?)");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user