Class WebAuthnEncoder
java.lang.Object
net.shibboleth.idp.plugin.authn.webauthn.impl.WebAuthnEncoder
Encoder for
credentials that converts raw values into a format suitable for views.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringchooseLatestAndTransform(Instant first, Instant second) Choose the latest (on the time-line) instant, format it into a display friendly string, and return it.static StringformatDiscoverable(Optional<Boolean> discoverable) Format the isDiscoverable flag for display.static StringformatInstant(Instant time) Format the given instant into a display friendly string.static StringformatInstant(Instant time, String pattern) Format the given instant into a display friendly string using the given pattern.static StringformatInstant(Instant time, DateTimeFormatter formatter) Format the given instant into a display friendly string using the given formatter.static StringformatTransports(Set<com.yubico.webauthn.data.AuthenticatorTransport> transports) Convert a set oftransportsinto a CSV string.static booleanDoes the credential have attached metadata.static StringserializePublicKeyCredentialOptionsAsJSON(com.yubico.webauthn.data.PublicKeyCredentialCreationOptions options) Serialize the PublicKeyCredentialOptions request into a JSON string.static StringserializePublicKeyCredentialRequestOptionsAsJSON(com.yubico.webauthn.data.PublicKeyCredentialRequestOptions options) Serialize the PublicKeyCredentialRequestOptions request into a JSON string.
-
Field Details
-
LOG
@Nonnull private static final org.slf4j.Logger LOGClass logger.
-
-
Constructor Details
-
WebAuthnEncoder
private WebAuthnEncoder()Private constructor.
-
-
Method Details
-
serializePublicKeyCredentialOptionsAsJSON
public static String serializePublicKeyCredentialOptionsAsJSON(@Nullable com.yubico.webauthn.data.PublicKeyCredentialCreationOptions options) Serialize the PublicKeyCredentialOptions request into a JSON string.- Parameters:
options- the options to serialize- Returns:
- the JSON serialized PublicKeyCredentialOptions, or an empty string if there is an error converting the string.
-
serializePublicKeyCredentialRequestOptionsAsJSON
public static String serializePublicKeyCredentialRequestOptionsAsJSON(@Nullable com.yubico.webauthn.data.PublicKeyCredentialRequestOptions options) Serialize the PublicKeyCredentialRequestOptions request into a JSON string.- Parameters:
options- the options to serialize- Returns:
- the JSON serialized PublicKeyCredentialRequestOptions, or an empty string if there is an error converting the string.
-
formatInstant
Format the given instant into a display friendly string.- Parameters:
time- the instant to encode- Returns:
- a formatted time string
-
formatInstant
@Nonnull @NotEmpty public static String formatInstant(@Nullable Instant time, @Nullable String pattern) Format the given instant into a display friendly string using the given pattern.- Parameters:
time- the instant to encodepattern- the date time pattern to use- Returns:
- a formatted time string
- Since:
- 1.1.0
-
formatInstant
@Nonnull @NotEmpty public static String formatInstant(@Nullable Instant time, @Nullable DateTimeFormatter formatter) Format the given instant into a display friendly string using the given formatter.- Parameters:
time- the instant to encodeformatter- the formatter to use- Returns:
- a formatted time string
- Since:
- 1.1.0
-
chooseLatestAndTransform
@Nonnull @NotEmpty public static String chooseLatestAndTransform(@Nullable Instant first, @Nullable Instant second) Choose the latest (on the time-line) instant, format it into a display friendly string, and return it.- Parameters:
first- the first instantsecond- the second instant- Returns:
- the latest of the two, formatted.
- Since:
- 1.1.0
-
formatDiscoverable
Format the isDiscoverable flag for display. Can be used to determine if the credential is a 'passkey'. That is, either true, false, or unknown if empty.- Parameters:
discoverable- the isDiscoverable flag- Returns:
- is the credential discoverable (a 'passkey' or resident key) true, false, or unknown
-
isAuthenticatorMetadataAttached
Does the credential have attached metadata.- Parameters:
cred- the credential to check- Returns:
- true if the credential has metadata, false otherwise.
-
formatTransports
@Nonnull public static String formatTransports(@Nullable Set<com.yubico.webauthn.data.AuthenticatorTransport> transports) Convert a set oftransportsinto a CSV string.- Parameters:
transports- the transports to convert- Returns:
- the CSV string
-