Skip to content

Commit 7f54ca8

Browse files
committed
[backend] move hash to redact class. (#5526)
1 parent 4cccccd commit 7f54ca8

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

openaev-api/src/main/java/io/openaev/service/LogService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import org.springframework.web.context.request.RequestContextHolder;
3434
import org.springframework.web.context.request.ServletRequestAttributes;
3535

36-
import static io.openaev.helper.CryptoHelper.hashWithSHA256;
37-
3836
/**
3937
* Log service — builds structured {@link LogEvent} events for CRUD and authentication
4038
* operations.
@@ -397,8 +395,8 @@ private void populateUserMetadata(LogEvent doc) {
397395
User user = userService.user(userId);
398396

399397
if (user != null && user.getEmail() != null) {
400-
String hash = hashWithSHA256(user.getEmail());
401-
meta.setUserEmail(hash);
398+
String email = ObjectRedactionUtils.hash(user.getEmail());
399+
meta.setUserEmail(email);
402400
hasData = true;
403401
}
404402
}

openaev-api/src/main/java/io/openaev/utils/object/ObjectRedactionUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import java.util.Set;
77

8+
import static io.openaev.helper.CryptoHelper.hashWithSHA256;
9+
810
public class ObjectRedactionUtils {
911

1012
private static final String REDACTED = "*** Redacted ***";
@@ -38,4 +40,8 @@ public static JsonNode redact(JsonNode node, String entityTypeName) {
3840
});
3941
return copy;
4042
}
43+
44+
public static String hash(String value) {
45+
return hashWithSHA256(value);
46+
}
4147
}

0 commit comments

Comments
 (0)