Skip to content

Commit aa56fa7

Browse files
Avoid schema keyId uuid representation errors.
To avoid driver configuration specific UUID representation format errors (binary subtype 3 vs. subtype 4) we now directly convert the given key into its subtype 4 format. Resolves: #3929
1 parent ca95513 commit aa56fa7

File tree

1 file changed

+3
-7
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/encryption

1 file changed

+3
-7
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/encryption/EncryptionUtils.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public final class EncryptionUtils {
3535
/**
3636
* Resolve a given plain {@link String} value into the store native {@literal keyId} format, considering potential
3737
* {@link Expression expressions}. <br />
38-
* The potential keyId is probed against an {@link UUID#fromString(String) UUID value} and the {@literal base64}
39-
* encoded {@code $binary} representation.
38+
* The potential keyId is converted to the {@literal base64} encoded {@code $binary} representation.
4039
*
4140
* @param value the source value to resolve the keyId for. Must not be {@literal null}.
4241
* @param evaluationContext a {@link Supplier} used to provide the {@link EvaluationContext} in case an
@@ -57,11 +56,8 @@ public static Object resolveKeyId(String value, Supplier<EvaluationContext> eval
5756
return potentialKeyId;
5857
}
5958
}
60-
try {
61-
return UUID.fromString(potentialKeyId.toString());
62-
} catch (IllegalArgumentException e) {
63-
return org.bson.Document.parse("{ val : { $binary : { base64 : '" + potentialKeyId + "', subType : '04'} } }")
59+
60+
return org.bson.Document.parse("{ val : { $binary : { base64 : '" + potentialKeyId + "', subType : '04'} } }")
6461
.get("val");
65-
}
6662
}
6763
}

0 commit comments

Comments
 (0)