[java-idp-plugin-webauthn] branch main updated: JWEBAUTHN-52 - Add a WebAuthnEncoder time format method that accepts a TimeZoneId

Phil Smart philip.smart at jisc.ac.uk
Fri Apr 11 16:57:29 UTC 2025


This is an automated email from the git hooks/post-receive script.

philsmart pushed a commit to branch main
in repository java-idp-plugin-webauthn.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-webauthn.git;a=commit;h=f36b691002a4923df2eaaea3bc9205e98204c19e

The following commit(s) were added to refs/heads/main by this push:
     new f36b691  JWEBAUTHN-52 - Add a WebAuthnEncoder time format method that accepts a TimeZoneId
f36b691 is described below

commit f36b691002a4923df2eaaea3bc9205e98204c19e
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Apr 11 17:57:25 2025 +0100

    JWEBAUTHN-52 - Add a WebAuthnEncoder time format method that accepts a
    TimeZoneId
    
     - timeZoneId can be specified as a string.
    
    https://shibboleth.atlassian.net/browse/JWEBAUTHN-52
---
 .../authn/webauthn/impl/WebAuthnEncoder.java       | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
index 97c77a5..2865d94 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
@@ -14,6 +14,7 @@
 
 package net.shibboleth.idp.plugin.authn.webauthn.impl;
 
+import java.time.DateTimeException;
 import java.time.Instant;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
@@ -120,6 +121,29 @@ public final class WebAuthnEncoder {
         return formatInstant(time, DateTimeFormatter.ofPattern(pattern).withZone(ZoneId.of("UTC")));           
     }
     
+    /**
+     * Format the given instant into a display friendly string using the given pattern and time zone.
+     * 
+     * @param time the instant to encode
+     * @param pattern the date time pattern to use
+     * @param zoneId the timezone to use
+     * 
+     * @return a formatted time string
+     * 
+     * @since 1.2.0
+     */
+    @Nonnull @NotEmpty public static String formatInstant(@Nullable final Instant time, 
+            @Nullable final String pattern, @Nullable final String zoneId) {
+        if (time == null || pattern == null || zoneId == null) { 
+            return "";
+        }
+        try {
+            return formatInstant(time, DateTimeFormatter.ofPattern(pattern).withZone(ZoneId.of(zoneId)));  
+        } catch (final DateTimeException e) {
+            return "";
+        }           
+    }
+    
     /**
      * Format the given instant into a display friendly string using the given formatter.
      * 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list