forked from auth0/java-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJWTAudienceException.java
More file actions
36 lines (29 loc) · 1.02 KB
/
JWTAudienceException.java
File metadata and controls
36 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.auth0.jwt;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.Validate;
import java.util.ArrayList;
import java.util.List;
/**
* Represents Exception related to Audience - for example illegal audience on JWT Verification
*/
public class JWTAudienceException extends JWTVerifyException {
private JsonNode audienceNode;
public JWTAudienceException(final JsonNode audienceNode) {
this.audienceNode = audienceNode;
}
public JWTAudienceException(final String message, final JsonNode audienceNode) {
super(message);
this.audienceNode = audienceNode;
}
public List<String> getAudience() {
final ArrayList<String> audience = new ArrayList<>();
if (audienceNode.isArray()) {
for (final JsonNode jsonNode : audienceNode) {
audience.add(jsonNode.textValue());
}
} else if (audienceNode.isTextual()) {
audience.add(audienceNode.textValue());
}
return audience;
}
}