Skip to content

Commit 51aee18

Browse files
committed
1 parent 4a477c4 commit 51aee18

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/listeners/GatewayTokenRevocationMessageListener.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,30 @@ private void handleRevokedTokenMessage(String revokedToken, long expiryTime, Str
8989
revokedTokenMap.get(APIConstants.NotificationEvent.CONSUMER_KEY) != null &&
9090
revokedTokenMap.containsKey(APIConstants.NotificationEvent.REVOCATION_TIME) &&
9191
revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME) != null) {
92-
RevokedJWTDataHolder.getInstance().addRevokedConsumerKeyToMap(
93-
(String) revokedTokenMap.get(APIConstants.NotificationEvent.CONSUMER_KEY),
94-
(long) revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
92+
try {
93+
RevokedJWTDataHolder.getInstance().addRevokedConsumerKeyToMap(
94+
(String) revokedTokenMap.get(APIConstants.NotificationEvent.CONSUMER_KEY),
95+
convertRevokedTime(revokedTokenMap));
96+
} catch (NumberFormatException e) {
97+
log.warn("Event dropped due to unsupported value type for "
98+
+ APIConstants.NotificationEvent.REVOCATION_TIME + " : "
99+
+ revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
100+
}
95101
}
96102
} else if (APIConstants.NotificationEvent.SUBJECT_ENTITY_REVOCATION_EVENT.equals(tokenType)) {
97103
HashMap<String, Object> revokedTokenMap = base64Decode(revokedToken);
98104
if (revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_TYPE) != null &&
99105
revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME) != null &&
100106
revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_ID) != null) {
101107
String entityType = (String) revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_TYPE);
102-
long revocationTime = (long) revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME);
108+
long revocationTime = 0;
109+
try {
110+
revocationTime = convertRevokedTime(revokedTokenMap);
111+
} catch (NumberFormatException e) {
112+
log.warn("Event dropped due to unsupported value type for "
113+
+ APIConstants.NotificationEvent.REVOCATION_TIME + " : "
114+
+ revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
115+
}
103116
String entityId = (String) revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_ID);
104117
if (APIConstants.NotificationEvent.ENTITY_TYPE_USER_ID.equals(entityType)) {
105118
RevokedJWTDataHolder.getInstance().addRevokedSubjectEntityUserToMap(entityId, revocationTime);
@@ -138,4 +151,9 @@ private HashMap<String, Object> base64Decode(String encodedRevokedToken) {
138151
}
139152
return new HashMap<>();
140153
}
154+
155+
private long convertRevokedTime(HashMap<String, Object> revokedTokenMap) throws NumberFormatException {
156+
157+
return Long.parseLong((String) revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
158+
}
141159
}

0 commit comments

Comments
 (0)