Skip to content

Commit

Permalink
"not provided" no longer UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
Vzor- committed Sep 9, 2024
1 parent 828b656 commit a0ce24c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/qz/auth/Certificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Certificate {

private static final Logger log = LogManager.getLogger(Certificate.class);
private static final String QUIETLY_FAIL = "quiet";
private static final String NOT_PROVIDED = "Not Provided";

public enum Algorithm {
SHA1("SHA1withRSA"),
Expand Down Expand Up @@ -445,9 +446,9 @@ public String get(Field field, Object optArg) {
case TRUSTED:
return String.valueOf(isTrusted());
case VALID_FROM:
return getValidFrom((TimeZone)optArg) + " " + ((TimeZone)optArg).getDisplayName(false, TimeZone.SHORT);
return getValidFrom((TimeZone)optArg);
case VALID_TO:
return getValidTo((TimeZone)optArg) + " " + ((TimeZone)optArg).getDisplayName(false, TimeZone.SHORT);
return getValidTo((TimeZone)optArg);
case FINGERPRINT:
return getFingerprint();
case VALID:
Expand Down Expand Up @@ -477,7 +478,7 @@ public String getValidFrom(TimeZone timeZone) {
if (validFrom.isAfter(UNKNOWN_MIN)) {
return formatDate(validFrom, timeZone);
} else {
return "Not Provided";
return NOT_PROVIDED;
}
}

Expand All @@ -489,19 +490,22 @@ public String getValidTo(TimeZone timeZone) {
if (validTo.isBefore(UNKNOWN_MAX)) {
return formatDate(validTo, timeZone);
} else {
return "Not Provided";
return NOT_PROVIDED;
}
}

private String formatDate(Instant date, TimeZone timeZone) {
ZoneId zoneId;
String timeZoneString;
if (timeZone == null) {
zoneId = ZoneOffset.UTC;
timeZoneString = ""; // If no timezone was included, don't append a timezone ID.
} else {
zoneId = timeZone.toZoneId();
timeZoneString = " " + timeZone.getDisplayName(false, TimeZone.SHORT);
}
return dateFormat.format(date.atZone(zoneId));

return dateFormat.format(date.atZone(zoneId)) + timeZoneString;
}

public Instant getValidFromDate() {
Expand Down

0 comments on commit a0ce24c

Please sign in to comment.