Package net.shibboleth.idp.plugin.authn.webauthn.impl

# Class WebAuthnEncoder

java.lang.Object
net.shibboleth.idp.plugin.authn.webauthn.impl.WebAuthnEncoder

public final class WebAuthnEncoder extends Object
Encoder for `credentials` that converts raw values into a format suitable for views.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final org.slf4j.Logger`
`LOG`
Class logger.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`WebAuthnEncoder()`
Private constructor.

## Method Summary

Modifier and Type
Method
Description
`static String`
`chooseLatestAndTransform(Instant first, Instant second)`
Choose the latest (on the time-line) instant, format it into a display friendly string, and return it.
`static String`
`formatDiscoverable(Optional<Boolean> discoverable)`
Format the isDiscoverable flag for display.
`static String`
`formatInstant(Instant time)`
Format the given instant into a display friendly string.
`static String`
`formatInstant(Instant time, String pattern)`
Format the given instant into a display friendly string using the given pattern.
`static String`
`formatInstant(Instant time, String pattern, String zoneId)`
Format the given instant into a display friendly string using the given pattern and time zone.
`static String`
`formatInstant(Instant time, DateTimeFormatter formatter)`
Format the given instant into a display friendly string using the given formatter.
`static String`
`formatTransports(Set<com.yubico.webauthn.data.AuthenticatorTransport> transports)`
Convert a set of `transports` into a CSV string.
`static boolean`
`isAuthenticatorMetadataAttached(EnhancedCredentialRecord cred)`
Does the credential have attached metadata.
`static String`
`serializePublicKeyCredentialOptionsAsJSON(com.yubico.webauthn.data.PublicKeyCredentialCreationOptions options)`
Serialize the PublicKeyCredentialOptions request into a JSON string.
`static String`
`serializePublicKeyCredentialRequestOptionsAsJSON(com.yubico.webauthn.data.PublicKeyCredentialRequestOptions options)`
Serialize the PublicKeyCredentialRequestOptions request into a JSON string.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### LOG

@Nonnull private static final org.slf4j.Logger LOG
Class 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

@Nonnull @NotEmpty public static String formatInstant(@Nullable Instant time)
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 encode
  `pattern` - 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 String pattern, @Nullable String zoneId)
Format the given instant into a display friendly string using the given pattern and time zone.

Parameters:
  `time` - the instant to encode
  `pattern` - the date time pattern to use
  `zoneId` - the timezone to use
Returns:
  a formatted time string
Since:
  1.2.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 encode
  `formatter` - 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 instant
  `second` - the second instant
Returns:
  the latest of the two, formatted.
Since:
  1.1.0

### formatDiscoverable

@Nonnull public static String formatDiscoverable(@Nullable Optional<Boolean> discoverable)
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

public static boolean isAuthenticatorMetadataAttached(EnhancedCredentialRecord cred)
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 of `transports` into a CSV string.

Parameters:
  `transports` - the transports to convert
Returns:
  the CSV string