GetSecurityKeyListTask

GetSecurityKeyListTask.runTask(TaskListener taskListener, String serverUrl, String sessionToken)

taskListener - Listener to processes the result of the request.

serverUrl - The URL of the SurePassID FIDO Server.

sessionToken - The value returned by ValidateUserTask after successfully authenticating with a username and password.

Example

ObtainU2fRequestTask.TYPE_ENROLL
ObtainU2fRequestTask.TYPE_SIGN

GetSecurityKeyListTask mSecurityKeyListTask;

mSecurityKeyListTask = GetSecurityKeyListTask.runTask(new TaskListener() {
    @Override
    public void onTaskSuccess() {
        // rebuild the security key list.
        SecurityKeyListAdapter adapter = (SecurityKeyListAdapter) mSecurityKeyListView.getAdapter(
        adapter.setSessionToken(mSessionToken);
        adapter.clear();
        int keyNumber = 0;
        if (mSecurityKeyListTask.getSecurityKeyList() != null) {
            for (SecurityKey securityKey : mSecurityKeyListTask.getSecurityKeyList()) {
                String securityKeyName = securityKey.getSecurityKeyName();
                // Just in case there was not a securityKeyName.
                if (securityKeyName == null || securityKeyName.isEmpty()) {
                    securityKeyName = "Security Key " + ++keyNumber;
                }
                adapter.add(new SecurityKeyItem(
                        securityKey.getTransports(),
                        securityKeyName,
                        securityKey.getKeyHandle()));
            }
        }
        adapter.notifyDataSetChanged();
        Snackbar.make(mCoordinatorLayout,
                String.format(getString(R.string.security_keys_for), mUsername),
                Snackbar.LENGTH_INDEFINITE).show();
        mSwipeLayout.setRefreshing(false);
    }
    @Override
    public void onTaskError(String errorMessage, int errorCode) {
        String message;
        if (errorCode == U2fServerCode.U2F_SERVER_ERROR_NO_ENROLLED_U2F_DEVICES) {
            SecurityKeyListAdapter adapter = (SecurityKeyListAdapter) mSecurityKeyListView.getAdap
            adapter.clear();
            adapter.notifyDataSetChanged();
            message = String.format(getString(R.string.no_security_keys_for), mUsername);
        } else {
            if (errorMessage != null) {
                message = getString(R.string.error_updating_security_key_list) + "\n" + errorMessa
            } else {
                message = getString(R.string.error_updating_security_key_list);
            }
        }
        Snackbar.make(mCoordinatorLayout, message, Snackbar.LENGTH_INDEFINITE).show();
        mSwipeLayout.setRefreshing(false);
    }
}, SignInActivity.SERVER_URL, mSessionToken);