Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dushaniw committed Feb 20, 2024
1 parent 4a477c4 commit 51aee18
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,30 @@ private void handleRevokedTokenMessage(String revokedToken, long expiryTime, Str
revokedTokenMap.get(APIConstants.NotificationEvent.CONSUMER_KEY) != null &&
revokedTokenMap.containsKey(APIConstants.NotificationEvent.REVOCATION_TIME) &&
revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME) != null) {
RevokedJWTDataHolder.getInstance().addRevokedConsumerKeyToMap(
(String) revokedTokenMap.get(APIConstants.NotificationEvent.CONSUMER_KEY),
(long) revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
try {
RevokedJWTDataHolder.getInstance().addRevokedConsumerKeyToMap(
(String) revokedTokenMap.get(APIConstants.NotificationEvent.CONSUMER_KEY),
convertRevokedTime(revokedTokenMap));
} catch (NumberFormatException e) {
log.warn("Event dropped due to unsupported value type for "
+ APIConstants.NotificationEvent.REVOCATION_TIME + " : "
+ revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
}
}
} else if (APIConstants.NotificationEvent.SUBJECT_ENTITY_REVOCATION_EVENT.equals(tokenType)) {
HashMap<String, Object> revokedTokenMap = base64Decode(revokedToken);
if (revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_TYPE) != null &&
revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME) != null &&
revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_ID) != null) {
String entityType = (String) revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_TYPE);
long revocationTime = (long) revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME);
long revocationTime = 0;
try {
revocationTime = convertRevokedTime(revokedTokenMap);
} catch (NumberFormatException e) {
log.warn("Event dropped due to unsupported value type for "
+ APIConstants.NotificationEvent.REVOCATION_TIME + " : "
+ revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
}
String entityId = (String) revokedTokenMap.get(APIConstants.NotificationEvent.ENTITY_ID);
if (APIConstants.NotificationEvent.ENTITY_TYPE_USER_ID.equals(entityType)) {
RevokedJWTDataHolder.getInstance().addRevokedSubjectEntityUserToMap(entityId, revocationTime);
Expand Down Expand Up @@ -138,4 +151,9 @@ private HashMap<String, Object> base64Decode(String encodedRevokedToken) {
}
return new HashMap<>();
}

private long convertRevokedTime(HashMap<String, Object> revokedTokenMap) throws NumberFormatException {

return Long.parseLong((String) revokedTokenMap.get(APIConstants.NotificationEvent.REVOCATION_TIME));
}
}

0 comments on commit 51aee18

Please sign in to comment.