Package org.springframework.security.web.webauthn.management

# Class Webauthn4JRelyingPartyOperations

java.lang.Object
org.springframework.security.web.webauthn.management.Webauthn4JRelyingPartyOperations

All Implemented Interfaces:
  `WebAuthnRelyingPartyOperations`

public class Webauthn4JRelyingPartyOperations extends Object implements WebAuthnRelyingPartyOperations
A WebAuthn4j implementation of `WebAuthnRelyingPartyOperations`.

Since:
  6.4

## Constructor Summary

Constructors
Constructor
Description
`Webauthn4JRelyingPartyOperations(PublicKeyCredentialUserEntityRepository userEntities, UserCredentialRepository userCredentials, PublicKeyCredentialRpEntity rpEntity, Set<String> allowedOrigins)`
Creates a new instance.

## Method Summary

Modifier and Type
Method
Description
`PublicKeyCredentialUserEntity`
`authenticate(RelyingPartyAuthenticationRequest request)`
Authenticates the `RelyingPartyAuthenticationRequest` passed in
`PublicKeyCredentialRequestOptions`
`createCredentialRequestOptions(PublicKeyCredentialRequestOptionsRequest request)`
Creates the `PublicKeyCredentialRequestOptions` used to authenticate a user.
`PublicKeyCredentialCreationOptions`
`createPublicKeyCredentialCreationOptions(PublicKeyCredentialCreationOptionsRequest request)`
Creates the `PublicKeyCredentialCreationOptions` used to register new credentials.
`CredentialRecord`
`registerCredential(RelyingPartyRegistrationRequest rpRegistrationRequest)`
If `RelyingPartyRegistrationRequest` is valid, will register and return a new `CredentialRecord`.
`void`
`setCustomizeCreationOptions(Consumer<PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder> customizeCreationOptions)`
Sets a `Consumer` used to customize the `PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder` for `createPublicKeyCredentialCreationOptions(PublicKeyCredentialCreationOptionsRequest)`.
`void`
`setCustomizeRequestOptions(Consumer<PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder> customizeRequestOptions)`
Sets a `Consumer` used to customize the `PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder` for `createCredentialRequestOptions(PublicKeyCredentialRequestOptionsRequest)`.The default values are always populated, but can be overridden with this property.
`void`
`setWebAuthnManager(com.webauthn4j.WebAuthnManager webAuthnManager)`
Sets the `WebAuthnManager` to use.

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

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

## Constructor Details

### Webauthn4JRelyingPartyOperations

public Webauthn4JRelyingPartyOperations(PublicKeyCredentialUserEntityRepository userEntities, UserCredentialRepository userCredentials, PublicKeyCredentialRpEntity rpEntity, Set<String> allowedOrigins)
Creates a new instance.

Parameters:
  `userEntities` - the `PublicKeyCredentialUserEntityRepository` to use.
  `userCredentials` - the `UserCredentialRepository` to use.
  `rpEntity` - the `PublicKeyCredentialRpEntity` to use.
  `allowedOrigins` - the allowed origins.

## Method Details

### setWebAuthnManager

public void setWebAuthnManager(com.webauthn4j.WebAuthnManager webAuthnManager)
Sets the `WebAuthnManager` to use. The default is `WebAuthnManager.createNonStrictWebAuthnManager()`

Parameters:
  `webAuthnManager` - the `WebAuthnManager`.

### setCustomizeCreationOptions

public void setCustomizeCreationOptions(Consumer<PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder> customizeCreationOptions)
Sets a `Consumer` used to customize the `PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder` for `createPublicKeyCredentialCreationOptions(PublicKeyCredentialCreationOptionsRequest)`. The default values are always populated, but can be overridden with this property.

Parameters:
  `customizeCreationOptions` - the `Consumer` to customize the `PublicKeyCredentialCreationOptions.PublicKeyCredentialCreationOptionsBuilder`

### setCustomizeRequestOptions

public void setCustomizeRequestOptions(Consumer<PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder> customizeRequestOptions)
Sets a `Consumer` used to customize the `PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder` for `createCredentialRequestOptions(PublicKeyCredentialRequestOptionsRequest)`.The default values are always populated, but can be overridden with this property.

Parameters:
  `customizeRequestOptions` - the `Consumer` to customize the `PublicKeyCredentialRequestOptions.PublicKeyCredentialRequestOptionsBuilder`

### createPublicKeyCredentialCreationOptions

public PublicKeyCredentialCreationOptions createPublicKeyCredentialCreationOptions(PublicKeyCredentialCreationOptionsRequest request)
Description copied from interface: `WebAuthnRelyingPartyOperations`
Creates the `PublicKeyCredentialCreationOptions` used to register new credentials.

Specified by:
  `createPublicKeyCredentialCreationOptions` in interface `WebAuthnRelyingPartyOperations`
Parameters:
  `request` - the `PublicKeyCredentialCreationOptionsRequest` to create the `PublicKeyCredentialCreationOptions`
Returns:
  the `PublicKeyCredentialCreationOptions` for the `Authentication` passed in. Cannot be null.

### registerCredential

public CredentialRecord registerCredential(RelyingPartyRegistrationRequest rpRegistrationRequest)
Description copied from interface: `WebAuthnRelyingPartyOperations`
If `RelyingPartyRegistrationRequest` is valid, will register and return a new `CredentialRecord`.

Specified by:
  `registerCredential` in interface `WebAuthnRelyingPartyOperations`
Parameters:
  `rpRegistrationRequest` - the `RelyingPartyRegistrationRequest` to process.
Returns:
  a new `CredentialRecord`

### createCredentialRequestOptions

public PublicKeyCredentialRequestOptions createCredentialRequestOptions(PublicKeyCredentialRequestOptionsRequest request)
Description copied from interface: `WebAuthnRelyingPartyOperations`
Creates the `PublicKeyCredentialRequestOptions` used to authenticate a user.

Specified by:
  `createCredentialRequestOptions` in interface `WebAuthnRelyingPartyOperations`
Parameters:
  `request` - the `PublicKeyCredentialRequestOptionsRequest`.
Returns:
  the `PublicKeyCredentialRequestOptions` used to authenticate a user.

### authenticate

public PublicKeyCredentialUserEntity authenticate(RelyingPartyAuthenticationRequest request)
Description copied from interface: `WebAuthnRelyingPartyOperations`
Authenticates the `RelyingPartyAuthenticationRequest` passed in

Specified by:
  `authenticate` in interface `WebAuthnRelyingPartyOperations`
Parameters:
  `request` - the `RelyingPartyAuthenticationRequest`
Returns:
  the principal name (e.g. username) if authentication was successful