Skip to content

Commit

Permalink
Merge pull request #326 from holashchand/issue-1013
Browse files Browse the repository at this point in the history
[BUG]: fixed decryption in list entity api
  • Loading branch information
challabeehyv authored May 27, 2024
2 parents 976bb45 + bb8ca94 commit b3ded1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public JsonNode getDecryptedJson(JsonNode rootNode) throws EncryptionException {
return objectNode;
}

public JsonNode getDecryptedJson(String entityType, JsonNode data) throws EncryptionException {
return process(data, entityType, null);
}

protected Map<String, Object> performOperation(Map<String, Object> plainMap) throws EncryptionException {
return encryptionService.decrypt(plainMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ public class NativeSearchService implements ISearchService {
@Value("${search.removeNonPublicFieldsForNativeSearch:true}")
private boolean removeNonPublicFieldsForNativeSearch;

@Autowired(required = false)
private DecryptionHelper decryptionHelper;

@Value("${encryption.enabled}")
private boolean encryptionEnabled;

@Override
public JsonNode search(JsonNode inputQueryNode, String userId) throws IOException {
return search(inputQueryNode, userId, false);
Expand Down Expand Up @@ -167,6 +173,10 @@ private ObjectNode removeNonPublicFields(SearchQuery searchQuery, ObjectNode sha
for(JsonNode node : arrayNode) {
data.add(JSONUtil.removeNodesByPath(node, definitionsManager.getExcludingFieldsForEntity(entityType)));
}
} else if (encryptionEnabled) {
for(JsonNode node : arrayNode) {
data.add(decryptionHelper.getDecryptedJson(entityType, node));
}
} else {
data = arrayNode;
}
Expand Down

0 comments on commit b3ded1d

Please sign in to comment.