# Class PublicKeyCredential

java.lang.Object
com.codename1.io.webauthn.PublicKeyCredential

public final class PublicKeyCredential extends Object

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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `TYPE_PUBLIC_KEY`
  Credential type -- always `"public-key"` for WebAuthn.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map<String,Object>`
  `asMap()`
  Read-only view of the parsed JSON.
  `static PublicKeyCredential`
  `fromJson(String json)`
  Parses a RegistrationResponseJSON / AuthenticationResponseJSON document returned by the native authenticator.
  `String`
  `getAttestationObject()`
  `response.attestationObject` for a registration response, base64url-encoded.
  `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.
  `String`
  `getClientDataJSON()`
  `response.clientDataJSON`, base64url-encoded.
  `String`
  `getId()`
  `id` -- the credential identifier, base64url-encoded.
  `String`
  `getRawId()`
  `rawId` -- the same identifier as a base64url-encoded byte array.
  `String`
  `getSignature()`
  `response.signature` for an assertion response, base64url-encoded.
  `String`
  `getUserHandle()`
  `response.userHandle` for an assertion response, base64url-encoded.
  `boolean`
  `isRegistration()`
  `true` if this is a registration (create) response.
  `String`
  `toJson()`
  Returns the original JSON.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### TYPE_PUBLIC_KEY

    public static final String TYPE_PUBLIC_KEY
    Credential type -- always `"public-key"` for WebAuthn.
    See Also:
      - Constant Field Values

- ## 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.