Skip to content

Commit

Permalink
feat(jans-auth-server): added flexible formatter handler for IdTokenF…
Browse files Browse the repository at this point in the history
…actory class (#3605)
  • Loading branch information
Milton-Ch committed Jan 12, 2023
1 parent b00c5d5 commit f4b0179
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.jans.as.server.model.common.*;
import io.jans.as.server.service.ScopeService;
import io.jans.as.server.service.SessionIdService;
import io.jans.as.server.service.date.DateFormatterService;
import io.jans.as.server.service.external.ExternalAuthenticationService;
import io.jans.as.server.service.external.ExternalDynamicScopeService;
import io.jans.as.server.service.external.ExternalUpdateTokenService;
Expand All @@ -42,6 +43,7 @@
import org.json.JSONObject;
import org.slf4j.Logger;

import java.io.Serializable;
import java.util.*;

import static io.jans.as.model.common.ScopeType.DYNAMIC;
Expand Down Expand Up @@ -92,6 +94,9 @@ public class IdTokenFactory {
@Inject
private SessionIdService sessionIdService;

@Inject
private DateFormatterService dateFormatterService;

private void setAmrClaim(JsonWebResponse jwt, String acrValues) {
List<String> amrList = Lists.newArrayList();

Expand Down Expand Up @@ -224,7 +229,8 @@ private void fillClaims(JsonWebResponse jwr,
} else if (value instanceof Boolean) {
jwr.getClaims().setClaim(key, (Boolean) value);
} else if (value instanceof Date) {
jwr.getClaims().setClaim(key, ((Date) value).getTime() / 1000);
Serializable formattedValue = dateFormatterService.formatClaim((Date) value, key);
jwr.getClaims().setClaimObject(key, formattedValue, true);
} else {
jwr.setClaim(key, (String) value);
}
Expand Down

0 comments on commit f4b0179

Please sign in to comment.