Callbacks

Summary

Due to the asynchronous nature of the PrivakeyCX library, it utilizes several interfaces to perform callbacks. These callbacks are used to return the results of a PrivakeyCX Library method. All callbacks are returned on the MainThread.


Global Callbacks

These callbacks can be called at any time, not just when the library is called into.

πŸ“˜

Initialization

To handle any of the global callbacks, they must be passed in during initialize().

FailedPasswordCallback

public interface FailedPasswordCallback {
  void onFailedPassword ( int attemptsRemaining );
}

onFailedPassword() is called when the user enters their PIN/password incorrectly. The number of attempts remaining until the device is revoked is passed as attemptsRemaining.


RequestStatusCallback

public interface RequestStatusCallback {
  void requestStatusUpdated ( Request request );
}

requestStatusUpdated() is called when a request's status changed. The request itself is passed as request.


AccountUpdatedCallback

public interface AccountUpdatedCallback {
  void accountUpdated ( Account account );
}

accountUpdated() is called when the account is updated. The account itself is passed as account.


DeviceUpdatedCallback

public interface DeviceUpdatedCallback {
  void deviceUpdated ( Device device );
}

deviceUpdated() is called when the device is updated. The device itself is passed as device.


NewRequestCallback

public interface NewRequestCallback {
  void newRequest ( Request request );
}

newRequest() is called when a new request is received. The request itself is passed as request.


GetRequestsCallback

public interface GetRequestsCallback {
  void onGetRequestsResult ( String appSpaceGuid, List<Request> requests, String error );
}

When any of the get-request calls are made (such as getRequests(), getRequestByGuid(), & getRequestsByStatus()), they immediately return the cached requests that match the criteria, if they exist. At the same time, the library also calls to the CX server to get the most up-to-date request data. When that network call finishes, onGetRequestsResult() is called with the following parameters:

  • appSpaceGuid: GUID of the appspace that these requests belong to.
  • requests: List of the requests that were returned from the server. If an error was returned, this will be null.
  • error: If something goes wrong, this string will tell you what.

Method Callbacks

In addition to the above global callbacks, many of the API methods have their own callbacks. This is necessary when a method makes a network call, so your app can receive the response asynchronously.

πŸ“˜

Constants

The method callbacks make extensive use of library constants. For more info on them, see the Constants page.

PrivakeyInitCallback

public interface PrivakeyInitCallback {
  void onInitializeResult ( String result );
}

Returns whether or not PrivakeyCX was initialized.

  • result: Will either be the PRIVAKEY_INITIALIZED constant if successful, or an error if not.

EnablePrivakeyCallback

public interface EnablePrivakeyCallback {
  void onEnablePrivakeyResult ( String result, PrivakeyAccount account );
}

Returns whether or not PrivakeyCX was enabled.

  • result: ACCOUNT_CREATED constant if successful, or an error if not.
  • account: The newly created PrivakeyAccount object.

AddAppSpaceCredentialCallback

public interface AddAppSpaceCredentialCallback {
  void onAddAppSpaceCredentialResult ( String result );
}

Returns whether or not the App Space credential was added.

  • result: CREDENTIALS_ADDED constant if successful, or an error if not.

BiometricAvailabilityCallback

public interface BiometricAvailabilityCallback {
  void onBiometricAvailabilityResult ( boolean isAvailable, String message );
}

Returns whether a sensor is available to verify biometrics.

  • isAvailable: True if a sensor is available and the user has registered biometrics.
  • message: Additional info about whether a sensor is available or not.

BiometricCallback

public interface BiometricCallback {
  void onBiometricResult ( String result );
}

Returns the result of enabling/disabling biometric support.

  • result: One of either BIOMETRIC_ENABLED, BIOMETRIC_DISABLED, or BIOMETRIC_KEY_READY if successful, or an error if not.

VerifyCurrentPasswordCallback

public interface VerifyCurrentPasswordCallback {
  void onVerifyCurrentPasswordResult ( String result );
}

Returns whether or not the current PIN verification was successful.

  • result: CURRENT_PIN_VERIFIED constant if successful, or an error if not.

ChangePasswordCallback

public interface ChangePasswordCallback {
  void onChangePasswordResult ( String result );
}

Returns whether or not the PIN change was successful.

  • result: PASSWORD_UPDATED constant if successful, or an error if not.

DisablePrivakeyCallback

public interface DisablePrivakeyCallback {
  void onDisablePrivakeyResult ( String result );
}

Returns whether or not PrivakeyCX was disabled.

  • result: PRIVAKEY_DISABLED constant if successful, or an error if not.

UpdateDeviceCallback

public interface UpdateDeviceCallback {
  void onUpdateDeviceResult ( String result );
}

Returns whether or not the device was updated.

  • result: DEVICE_UPDATED constant if successful, or an error if not.

IsBoundCallback

public interface IsBoundCallback{
  void onIsBoundResult ( boolean isBound, String error );
}

Returns whether the user is currently bound or not.

  • isBound: Whether the user is currently bound or not.
  • error: If something goes wrong, this string will tell you what.

ServicesCallback

public interface ServicesCallback {
  void onServicesReceivedResult ( List<AppSpace> services, String error );
}

Returns a list of services bound to this device.

  • services: List of bound services.
  • error: If something goes wrong, this string will tell you what.

DeviceQueryCallback

public interface DeviceQueryCallback {
  void onDeviceQueryResult ( List<Device> devices, String error );
}

Returns a list of devices.

  • devices: A list of devices that match the search criteria.
  • error: If something goes wrong, this string will tell you what.

RevokeAllCredentialsCallback

public interface RevokeAllCredentialsCallback {
  void onRevokeAllCredentialsResult ( String result );
}

Returns whether or not an entire device was revoked.

  • result: DEVICE_REVOKED constant if successful, or an error if not.

RevokeDeviceCallback

public interface RevokeDeviceCallback {
  void onRevokeDeviceResult ( Boolean result, String error );
}

Returns whether or not a single device was revoked.

  • result: True if the revoke was successful.
  • error: If something goes wrong, this string will tell you what.

RequestQueryCallback

public interface RequestQueryCallback {
  void onRequestQueryResult ( List<Request> requests, String error );
}

Returns a list of requests.

  • requests: List of requests that match the search criteria.
  • error: If something goes wrong, this string will tell you what.

RequestValidationCallback

public interface RequestValidationCallback {
  void onRequestValidationResult ( RequestValidation validationData, String error );
}

Returns the audit data of who processed a request.

  • validationData: Data containing the signature, JWT and additional audit info about the request. May be null if the privakeyId was not supplied or the request has not yet been processed, or if the request does not belong to the user requesting the audit.
  • error: If something goes wrong, this string will tell you what.

RequestActionCallback

public interface RequestActionCallback {
  void onRequestActionResult ( String result );
}

Returns whether or not the Request was acted on.

  • result: REQUEST_PROCESSED if successful, or an error if not.

RecordTelemetryCallback

public interface RecordTelemetryCallback {
  void onRecordTelemetryResult ( String result );
}

Returns whether or not the telemetry recording was successful.

  • result: TELEMETRY_POSTED if successful, or an error if not.