public final class PublicKeyCredential

  1. Object
  2. PublicKeyCredential

The authenticator’s response to a passkey ceremony – either a registration (type=public-key, response.attestationObject present) or an assertion (response.signature + response.authenticatorData present).

Immutable. The most common usage is to call toJson() and POST the result to your relying-party server, which then runs full signature / origin / counter verification using a server-side library. Do not try to verify the attestation or assertion on the device – that is the relying party’s responsibility.

Fields

public static final String TYPE_PUBLIC_KEY = "public-key"Credential type – always "public-key" for WebAuthn.

Methods

public static PublicKeyCredential fromJson(String json)Parses a RegistrationResponseJSON / AuthenticationResponseJSON document returned by the native authenticator.
public String toJson()Returns the original JSON.
public Map<String, Object> asMap()Read-only view of the parsed JSON.
public String getId()id – the credential identifier, base64url-encoded.
public String getRawId()rawId – the same identifier as a base64url-encoded byte array.
public String getAuthenticatorAttachment()authenticatorAttachment"platform" if a built-in authenticator (Face ID / Touch ID, Android biometrics) handled the request, "cross-platform" for a hardware key, or null if the OS did not report it.
public boolean isRegistration()true if this is a registration (create) response.
public String getClientDataJSON()response.clientDataJSON, base64url-encoded.
public String getAttestationObject()response.attestationObject for a registration response, base64url-encoded.
public String getSignature()response.signature for an assertion response, base64url-encoded.
public String getUserHandle()response.userHandle for an assertion response, base64url-encoded.

Inherited methods

Field details

TYPE_PUBLIC_KEY

public static final String TYPE_PUBLIC_KEY = "public-key"
Credential type – always "public-key" for WebAuthn.

Method details

fromJson

public static PublicKeyCredential fromJson(String json)
Parses a RegistrationResponseJSON / AuthenticationResponseJSON document returned by the native authenticator.

toJson

public String toJson()
Returns the original JSON. POST this back to your relying-party server verbatim.

asMap

public Map<String, Object> asMap()
Read-only view of the parsed JSON.

getId

public String getId()
id – the credential identifier, base64url-encoded. Stable across ceremonies for the same authenticator + relying party pair, so this is what you store on the server.

getRawId

public String getRawId()
rawId – the same identifier as a base64url-encoded byte array.

getAuthenticatorAttachment

public String getAuthenticatorAttachment()
authenticatorAttachment"platform" if a built-in authenticator (Face ID / Touch ID, Android biometrics) handled the request, "cross-platform" for a hardware key, or null if the OS did not report it.

isRegistration

public boolean isRegistration()
true if this is a registration (create) response. false for an assertion (get) response.

getClientDataJSON

public String getClientDataJSON()
response.clientDataJSON, base64url-encoded. Decoded server-side and checked against the original challenge / origin.

getAttestationObject

public String getAttestationObject()
response.attestationObject for a registration response, base64url-encoded. null on an assertion response.

getSignature

public String getSignature()
response.signature for an assertion response, base64url-encoded. null on a registration response.

getUserHandle

public String getUserHandle()
response.userHandle for an assertion response, base64url-encoded. Matches the user.id from the registration ceremony.