Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
Make static method
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanyaharinarayan committed Apr 14, 2022
1 parent a31ec91 commit 4664a4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -42,7 +42,7 @@ public String computeRowHmac(String table, List<Object> fields) {
*
* Uses MessageDigest to prevent timing attacks.
* */
public boolean compareHmacs(String left, String right) {
public static boolean compareHmacs(String left, String right) {
return MessageDigest.isEqual(
left.getBytes(UTF_8),
right.getBytes(UTF_8)
Expand Down
8 changes: 4 additions & 4 deletions server/src/main/java/keywhiz/service/daos/AclDAO.java
Expand Up @@ -370,7 +370,7 @@ private SanitizedSecret processSanitizedSecretRow(Record row, Client client) {
String secretHmac = rowHmacGenerator.computeRowHmac(
SECRETS.getName(), List.of(row.getValue(SECRETS.NAME), row.getValue(SECRETS.ID))
);
if (!rowHmacGenerator.compareHmacs(secretHmac, row.getValue(SECRETS.ROW_HMAC))) {
if (!RowHmacGenerator.compareHmacs(secretHmac, row.getValue(SECRETS.ROW_HMAC))) {
String errorMessage = String.format(
"Secret HMAC verification failed for secret: %s", row.getValue(SECRETS.NAME));
if (rowHmacLog) {
Expand All @@ -384,7 +384,7 @@ private SanitizedSecret processSanitizedSecretRow(Record row, Client client) {
String clientHmac = rowHmacGenerator.computeRowHmac(
CLIENTS.getName(), List.of(client.getName(), client.getId())
);
if (!rowHmacGenerator.compareHmacs(clientHmac, row.getValue(CLIENTS.ROW_HMAC))) {
if (!RowHmacGenerator.compareHmacs(clientHmac, row.getValue(CLIENTS.ROW_HMAC))) {
String errorMessage = String.format(
"Client HMAC verification failed for client: %s", client.getName());
if (rowHmacLog) {
Expand All @@ -397,7 +397,7 @@ private SanitizedSecret processSanitizedSecretRow(Record row, Client client) {

String membershipsHmac = rowHmacGenerator.computeRowHmac(
MEMBERSHIPS.getName(), List.of(client.getId(), row.getValue(MEMBERSHIPS.GROUPID)));
if (!rowHmacGenerator.compareHmacs(membershipsHmac, row.getValue(MEMBERSHIPS.ROW_HMAC))) {
if (!RowHmacGenerator.compareHmacs(membershipsHmac, row.getValue(MEMBERSHIPS.ROW_HMAC))) {
String errorMessage = String.format(
"Memberships HMAC verification failed for clientId: %d in groupId: %d",
client.getId(), row.getValue(MEMBERSHIPS.GROUPID));
Expand All @@ -412,7 +412,7 @@ private SanitizedSecret processSanitizedSecretRow(Record row, Client client) {
String accessgrantsHmac = rowHmacGenerator.computeRowHmac(
ACCESSGRANTS.getName(),
List.of(row.getValue(MEMBERSHIPS.GROUPID), row.getValue(SECRETS.ID)));
if (!rowHmacGenerator.compareHmacs(accessgrantsHmac, row.getValue(ACCESSGRANTS.ROW_HMAC))) {
if (!RowHmacGenerator.compareHmacs(accessgrantsHmac, row.getValue(ACCESSGRANTS.ROW_HMAC))) {
String errorMessage = String.format(
"Access Grants HMAC verification failed for groupId: %d in secretId: %d",
row.getValue(MEMBERSHIPS.GROUPID), row.getValue(SECRETS.ID));
Expand Down

0 comments on commit 4664a4e

Please sign in to comment.