Skip to content

Commit 65f83aa

Browse files
committed
UY-1225: improve error handling.
1 parent d3b39e1 commit 65f83aa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

types-api/src/main/java/pl/edu/icm/unity/types/authn/AuthenticationOptionsSelector.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ public AuthenticationOptionsSelector(JsonNode json)
4747
if (json.isTextual())
4848
{
4949
String[] specs = json.asText().split("\\.");
50+
if (specs.length != 2)
51+
throw new IllegalArgumentException("Invalid selector format: " + json.toString());
5052
this.authenticatorKey = specs[0];
5153
this.optionKey = specs[1];
5254
} else
5355
{
5456
if (!JsonUtil.notNull(json, "authenticatorKey"))
5557
throw new IllegalArgumentException("Expecting authenticatorKey in json object: " + json.toString());
5658
if (!JsonUtil.notNull(json, "optionKey"))
57-
throw new IllegalArgumentException("Expecting authenticatorKey in json object: " + json.toString());
59+
throw new IllegalArgumentException("Expecting optionKey in json object: " + json.toString());
60+
5861
this.authenticatorKey = JsonUtil.getWithDef(json, "authenticatorKey", null);
5962
this.optionKey = JsonUtil.getWithDef(json, "optionKey", null);
6063
}

0 commit comments

Comments
 (0)