mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2774 Locally encrypted properties can be used in "in" queries
This commit is contained in:
1 parent
4cc012b974
commit
c5612d50fe
3 files changed
+57
-27
No files matched your search
@@ -117,29 +117,39 @@ public final class InExpression extends AbstractExpression implements IdInCommon
|
||||
}
|
||||
}
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && !prop.isAssocId()) {
|
||||
prop = null;
|
||||
}
|
||||
|
||||
if (prop == null) {
|
||||
if (bindValues.size() > 0) {
|
||||
// if we have no property, we wrap them in a multi value wrapper.
|
||||
// later the binder will decide, which bind strategy to use.
|
||||
request.addBindValue(new MultiValueWrapper(bindValues));
|
||||
}
|
||||
} else {
|
||||
List<Object> idList = new ArrayList<>();
|
||||
List<Object> values = bindValues;
|
||||
if (prop != null && prop.isAssocId()) {
|
||||
values = new ArrayList<>();
|
||||
for (Object bindValue : bindValues) {
|
||||
// extract the id values from the bean
|
||||
Object[] ids = prop.assocIdValues((EntityBean) bindValue);
|
||||
if (ids != null) {
|
||||
Collections.addAll(idList, ids);
|
||||
Collections.addAll(values, ids);
|
||||
}
|
||||
}
|
||||
if (!idList.isEmpty()) {
|
||||
request.addBindValue(new MultiValueWrapper(idList));
|
||||
}
|
||||
}
|
||||
if (values.isEmpty()) {
|
||||
// nothing in in-query
|
||||
return;
|
||||
} else if (prop.isDbEncrypted()) {
|
||||
// bind the key as well as the value
|
||||
String encryptKey = prop.beanProperty().encryptKey().getStringValue();
|
||||
request.addBindEncryptKey(encryptKey);
|
||||
} else if (prop.isLocalEncrypted()) {
|
||||
List<Object> encValues = new ArrayList<>(values.size());
|
||||
for (Object value : values) {
|
||||
encValues.add(prop.localEncrypt(value));
|
||||
}
|
||||
// this is most likely binary garbage, so don't add it to the bind log
|
||||
request.addBindEncryptKey(new MultiValueWrapper(encValues));
|
||||
return;
|
||||
}
|
||||
|
||||
// if we have no property, we wrap them in a multi value wrapper.
|
||||
// later the binder will decide, which bind strategy to use.
|
||||
request.addBindValue(new MultiValueWrapper(values));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,17 +164,22 @@ public final class InExpression extends AbstractExpression implements IdInCommon
|
||||
}
|
||||
|
||||
ElPropertyValue prop = getElProp(request);
|
||||
if (prop != null && !prop.isAssocId()) {
|
||||
prop = null;
|
||||
}
|
||||
|
||||
if (prop != null) {
|
||||
request.append(prop.assocIdInExpr(propName));
|
||||
request.append(prop.assocIdInValueExpr(not, bindValues.size()));
|
||||
} else {
|
||||
request.append(propName);
|
||||
request.appendInExpression(not, bindValues);
|
||||
if (prop.isAssocId()) {
|
||||
request.append(prop.assocIdInExpr(propName));
|
||||
request.append(prop.assocIdInValueExpr(not, bindValues.size()));
|
||||
}
|
||||
if (prop.isDbEncrypted()) {
|
||||
String dsql = prop.beanProperty().decryptProperty(propName);
|
||||
request.append(dsql);
|
||||
request.appendInExpression(not, bindValues);
|
||||
return;
|
||||
}
|
||||
}
|
||||
request.append(propName);
|
||||
request.appendInExpression(not, bindValues);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user