Android Sample Applications

Follwing is an Android sample applications demonstrating both client-direct and backend-proxied FIDO2 authentication patterns. These examples are useful for developers building Android applications that integrate with the Arculus FIDO2 Server.

Minimal Examples

These minimal examples show the essential code to register and authenticate a user without any UI scaffolding or error handling.

Minimal Client-Direct Example

import co.arculus.fido.android.ArculusFidoAsync;
import co.arculus.fido.ArculusFidoServer;
import co.arculus.android.ArculusFidoResultCallback;

ArculusFidoAsync arculusFido = ArculusFidoAsync.createInstance(context, callback);

// Registration
ArculusFidoServer fidoServer = new ArculusFidoServer("fido.example.com");
fidoServer.setBeginRegistrationPath("fidoapi/certify/attestation/options", null);
fidoServer.setCompleteRegistrationPath("fidoapi/certify/attestation/result", null);

arculusFido.register(
    fidoServer,
    "123456",                    // pin
    "[email protected]",          // username
    "My Device",                 // displayname
    "example.com",               // relyingParty
    false,                       // resetDevice
    null                         // registrationInfo
);

// Authentication
fidoServer.setBeginAuthorizationPath("fidoapi/certify/assertion/options", null);
fidoServer.setCompleteAuthorizationPath("fidoapi/certify/assertion/result", null);

arculusFido.authenticate(
    fidoServer,
    "123456",                    // pin
    "[email protected]",          // username
    "My Device",                 // displayname
    "example.com"                // relyingParty
);

// Callback implementation
@Override
public void registerResult(String response) {
    Log.d("FIDO", "Registration: " + response);
}

@Override
public void authenticateResult(String response) {
    Log.d("FIDO", "Authentication: " + response);
}

Minimal Backend-Proxied Example

Complete Sample Applications

The following sections provide complete, production-ready sample applications with full error handling, UI components, and backend integration.

Client-Direct Pattern

A simple WebView-based sample app demonstrating direct FIDO2 server communication:

A complete sample app demonstrating the backend-proxied pattern with 3-phase authentication and registration flows. This pattern is recommended for production deployments.

Backend API Client

Complete Backend-Proxied Sample App

Backend Implementation (Java Servlet)

The backend service receives requests from the Android app and proxies them to the FIDO2 Server. The implementation is identical to the iOS backend (see 5.2 iOS Sample Applications - Backend Implementation) since both iOS and Android apps use the same backend API contract.

Key Points:

  • Same operation-based routing (operation: "register" or operation: "authenticate")

  • Same phase detection (presence of cardResponseData determines begin vs. complete)

  • Same session cookie handling

  • Same FIDO2 Server REST API endpoints

The backend implementation shown in the iOS sample applications page applies to Android as well.

Last updated