General
The UAF Client App API is a wrapper for all calls to the SurePasID FIDO Server and to the FIDO UAF Client.
SurePassID Server Initialization
Before using theĀ UAF Client App API, the SurePassID Server information must be set. The initialization should be done in the Application's onCreate method.
The SurePassID server name must be set. The tenant account name and key are optional.
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
title | SurePassID Server Initialization |
---|
|
import com.surepassid.server.task.SurePassServerTask;
public class UafDemoApp extends Application {
@Override
public void onCreate() {
super.onCreate();
SurePassServerTask.setSurePassServer("sandbox.surepassid.com");
SurePassServerTask.setSurePassAccountName("TENANT_ACCOUNT_NAME");
SurePassServerTask.setSurePassAccountKey("TENANT_ACCOUNT_KEY");
}
} |
code
}
} |
UAF Registration
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
title | UAF Registration |
---|
linenumbers | true |
---|
|
import com.surepassid.fido.uaf.application.SurePassIdUaf;
import com.surepassid.fido.uaf.client.UafClientErrorCode;
import com.surepassid.fido.uaf.client.UafClientIntent;
public class UafRegistrationFragment extends Fragment {
private SurePassIdUaf mUaf;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.uaf_register_fragment, container, false);
final Button button = view.findViewById(R.id.uaf_register_button);
button.setOnClickListener(v -> {
/**
* Register a new UAF authenticator for the current user.
*/
mUaf.processRegistration(
new SurePassIdUaf.ErrorCallback() {
/**
* This operation always triggers the error callback and return NO_ERROR if the
* registration was successful. Otherwise, the appropriate ErrorCode is returned.
*
* If the registration was successful and the user signed in with their uanename
* and password, the sessionToken obtained from validate user is invalidated.
* user is invalidated. The user must re-authenticate via UAF.processAuthentication.
*
* @param errorCode ErrorCode as defined in the FIDO UAF Application API and
* Transport Binding Specification
*/
@Override
public void onErrorResult(UafClientErrorCode errorCode) {
}
}
);
});
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// Forward the result to SurePassIdUaf.onActivityResult
mUaf.onActivityResult(requestCode, resultCode, intent);
break;
}
}
} |
UAF Authentication
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
title | UAF Authentication |
---|
linenumbers | true |
---|
|
import com.surepassid.fido.uaf.application.SurePassIdUaf;
import com.surepassid.fido.uaf.client.UafClientErrorCode;
import com.surepassid.fido.uaf.client.UafClientIntent;
public class UafAuthenticationFragment extends Fragment {
private SurePassIdUaf mUaf;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.uaf_authenticate_fragment, container, false);
final Button button = view.findViewById(R.id.uaf_authenticate_button);
button.setOnClickListener(v -> {
/**
* Perform a UAF Authentication operation.
*/
mUaf.processAuthentication(
new SurePassIdUaf.AuthenticationCallback() {
/**
* If the authentication operation was successful, the session token is returned.
*
* @param sessionToken
*/
@Override
public void onAuthenticationResult(String sessionToken) {
}
},
new SurePassIdUaf.ErrorCallback() {
/**
* If this operation failed, the appropriate ErrorCode is returned.
*
* @param errorCode ErrorCode as defined in the FIDO UAF Application API and
* Transport Binding Specification
*/
@Override
public void onErrorResult(UafClientErrorCode errorCode) {
}
}
);
});
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// Forward the result to SurePassIdUaf.onActivityResult
mUaf.onActivityResult(requestCode, resultCode, intent);
break;
}
}
} |
UAF Transaction Confirmation
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
title | UAF Transaction Confirmation |
---|
linenumbers | true |
---|
|
import com.surepassid.fido.uaf.application.SurePassIdUaf;
import com.surepassid.fido.uaf.client.UafClientErrorCode;
import com.surepassid.fido.uaf.client.UafClientIntent;
public class UafTransactionConfirmationFragment extends Fragment {
private SurePassIdUaf mUaf;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.uaf_transaction_fragment, container, false);
final Button button = view.findViewById(R.id.uaf_transaction_button);
button.setOnClickListener(v -> {
/**
* Perform a UAF Transaction Confirmation operation.
*
* TODO: This may require a parameter to specify the desired transaction.
*/
mUaf.processTransactionConfirmation(
new SurePassIdUaf.ErrorCallback() {
/**
* This operation always triggers the error callback and return NO_ERROR if the
* transaction confirmation was successful. Otherwise, the appropriate
* ErrorCode is returned.
*
* @param errorCode ErrorCode as defined in the FIDO UAF Application API and
* Transport Binding Specification
*/
@Override
public void onErrorResult(UafClientErrorCode errorCode) {
}
}
);
});
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// Forward the result to SurePassIdUaf.onActivityResult
mUaf.onActivityResult(requestCode, resultCode, intent);
break;
}
}
} |
UAF Deregistration
Code Block |
---|
language | java |
---|
theme | Eclipse |
---|
title | UAF Deregistration |
---|
linenumbers | true |
---|
|
import com.surepassid.fido.uaf.application.SurePassIdUaf;
import com.surepassid.fido.uaf.client.UafClientErrorCode;
import com.surepassid.fido.uaf.client.UafClientIntent;
public class UafDeregistrationFragment extends Fragment {
private SurePassIdUaf mUaf;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.uaf_deregister_fragment, container, false);
final Button button = view.findViewById(R.id.uaf_deregister_button);
button.setOnClickListener(v -> {
/**
* Used to deregister UAF Authenticators.
*/
mUaf.processDeregistration(
new SurePassIdUaf.ErrorCallback() {
/**
* This operation always triggers the error callback and return NO_ERROR if the
* transaction confirmation was successful. Otherwise, the appropriate
* ErrorCode is returned.
*
* @param errorCode ErrorCode as defined in the FIDO UAF Application API and
* Transport Binding Specification
*/
@Override
public void onErrorResult(UafClientErrorCode errorCode) {
}
}
);
});
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// Forward the result to SurePassIdUaf.onActivityResult
mUaf.onActivityResult(requestCode, resultCode, intent);
break;
}
}
} |
...