Class DeviceBindingApi

java.lang.Object
com.unblu.sdk.module.integrity.devicebinding.DeviceBindingApi

public final class DeviceBindingApi extends Object
Public API for the mobile device binding feature.

The native host app owns the proof-of-possession flow end-to-end: it scans the QR code, generates and uses the RSA key pair in the Android Keystore via DeviceKeyManager, and signs the server-issued challenges locally.

Obtain an instance via AppIntegrityModuleApi.getDeviceBindingApi(com.unblu.sdk.core.configuration.UnbluClientConfiguration, java.lang.String, java.lang.String, java.lang.String).

  • Constructor Details

    • DeviceBindingApi

      public DeviceBindingApi(@NonNull com.unblu.sdk.module.integrity.internal.devicebinding.DeviceBindingBridge bridge, @NonNull com.unblu.sdk.module.integrity.internal.devicebinding.DeviceKeyManager deviceKeyManager)
  • Method Details

    • registerWithQrPayload

      public void registerWithQrPayload(@NonNull String qrPayload, @NonNull DeviceBindingCallback<String> callback)
      Registers the current device against the binding represented by the given QR code payload (the unblu-bind://… URI shown in the Agent Desk).

      Steps performed locally: parse the token from the QR code; ensure a Keystore key pair exists (recording the base64 X.509 SPKI public key); ask the server for an enrollment challenge; sign the (base64-decoded) challenge; send the base64 signature back to complete enrollment. On success the bindingId is persisted locally and delivered to callback.onSuccess.

    • registerWithToken

      public void registerWithToken(@NonNull String token, @NonNull DeviceBindingCallback<String> callback)
      Registers the current device using a raw enrollment token — the token value of the QR payload — for when the user types or pastes the code manually instead of scanning. Same flow as registerWithQrPayload(String, DeviceBindingCallback) without the unblu-bind://… URI parsing.
    • verify

      public void verify(@NonNull String bindingId, @NonNull DeviceBindingCallback<Void> callback)
      Round-trips a fresh challenge to confirm the binding is still active server-side. Succeeds with onSuccess(null) when the server confirms the signature; fails with a DeviceBindingException otherwise (including BINDING_REVOKED / BINDING_NOT_FOUND).
    • revoke

      public void revoke(@NonNull String bindingId, @NonNull DeviceBindingCallback<Void> callback)
      Revokes the binding with the given ID on the server, then deletes the local Keystore key pair on success. Idempotent on the native side: if the server already revoked the binding, the local key is still cleared.
    • getLocalBindingId

      @Nullable public String getLocalBindingId()
      The bindingId persisted on this device, or null if there's no binding for this app (never enrolled, or revoked, or local data cleared). There is no network round trip: the method reads from the encrypted Keystore-backed preferences. Pair this with verify(java.lang.String, com.unblu.sdk.module.integrity.devicebinding.DeviceBindingCallback<java.lang.Void>) to silently reconfirm a binding on session start.
    • getSessionCookies

      @Nullable public Map<String,String> getSessionCookies()
      The session cookies (name -> value) obtained for the device binding REST calls, or null if no server call has completed yet (or the bridge isn't REST-backed).
    • getDeviceId

      @Nullable public String getDeviceId()
      The device identifier the server assigned during login (the value of the …-device cookie), or null if no server call has completed yet. The server creates a DeviceInfo for this id, and the device binding is anchored to it.
    • getSessionUnbluCookies

      @Nullable public Set<UnbluCookie> getSessionUnbluCookies()
      The session obtained during the device-binding login as UnbluCookies. Returns the same set the binding calls used, including the …-device cookie carrying getDeviceId(). Returns null if no server call has completed yet. Assign to UnbluClientConfiguration.Builder.setCustomCookies(...) so the WebView reuses the session (and the device id) without logging in again.