...
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");
}
} |
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.
* 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 -> {
/**
* * Used to discover the available authenticators and capabilities.Perform a UAF Authentication operation.
*/
*/ mUaf.discoverprocessAuthentication(
new SurePassIdUaf.DiscoveryCallbackAuthenticationCallback() {
/**
* If the discoveryauthentication operation was successful, the discoveryData is returned.
*
session token is returned.
* @param discoveryData As defined in the FIDO*
UAF Application API and * @param sessionToken
Transport Binding Specification */
*/ @Override
@Override public void onAuthenticationResult(String sessionToken) {
public void onDiscoveryResult(DiscoveryData discoveryData) { }
} },
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 @Override
public void onErrorResult(UafClientErrorCode errorCode) { public void onErrorResult(UafClientErrorCode errorCode) {
} }
); /**
* Register a new UAF authenticator for the current}
user. */ );
mUaf.processRegistration( });
return view;
new SurePassIdUaf.ErrorCallback()}
{
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
/** super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
}
* This operation always triggers@Override
the error callback and returnpublic NO_ERROR if the
void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
* registration was successful. Otherwise, the appropriate ErrorCodecase is returned.
UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// *Forward the result to SurePassIdUaf.onActivityResult
* If the registration was successful, the sessionToken obtained from validatemUaf.onActivityResult(requestCode, resultCode, intent);
break;
}
* user is invalidated. The user must re-authenticate via UAF.processAuthentication.
}
} |
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,
* @param errorCode ErrorCode as defined in the FIDO UAF Application API and @Nullable Bundle savedInstanceState) {
*final View view = inflater.inflate(R.layout.uaf_transaction_fragment, container, false);
final Button Transport Bindingbutton Specification
= view.findViewById(R.id.uaf_transaction_button);
button.setOnClickListener(v -> {
*/ /**
* Perform a @OverrideUAF Transaction Confirmation operation.
*
public void onErrorResult(UafClientErrorCode errorCode) { * TODO: This may require a parameter to specify the desired transaction.
} */
} mUaf.processTransactionConfirmation(
); /** new SurePassIdUaf.ErrorCallback() {
* Perform a UAF Authentication operation. */ mUaf.processAuthentication(/**
new SurePassIdUaf.AuthenticationCallback() { * This operation always triggers the error callback and return NO_ERROR if the
/** * If the* authenticationtransaction operationconfirmation was successful. Otherwise, the appropriate
session token is returned. * ErrorCode is returned.
* @param sessionToken *
*/ * @param errorCode ErrorCode as defined in the FIDO UAF Application API @Overrideand
public void onAuthenticationResult(String sessionToken) { * Transport Binding Specification
} }, */
new SurePassIdUaf.ErrorCallback() { @Override
/** public void * If this operation failed, the appropriate ErrorCode is returned.onErrorResult(UafClientErrorCode errorCode) {
}
* }
* @param errorCode ErrorCode as defined in the FIDO UAF);
Application API and });
return view;
*}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
Transport Binding Specification super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
*/}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
@Override switch (requestCode) {
public void onErrorResult(UafClientErrorCode errorCode) {case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// Forward the result to SurePassIdUaf.onActivityResult
} mUaf.onActivityResult(requestCode, resultCode, }intent);
); break;
/** }
* Perform a}
UAF Transaction Confirmation operation.
*
* TODO: This may require a parameter to specify the desired transaction.
} |
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 mUaf.processTransactionConfirmationonCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
new SurePassIdUaf.ErrorCallback() { @Nullable Bundle savedInstanceState) {
/** final View view = inflater.inflate(R.layout.uaf_deregister_fragment, container, false);
* Thisfinal operationButton alwaysbutton triggers the error callback and return NO_ERROR if the= view.findViewById(R.id.uaf_deregister_button);
button.setOnClickListener(v -> {
* transaction confirmation was successful. Otherwise, the appropriate /**
* Used to deregister UAF Authenticators.
* ErrorCode is returned. */
mUaf.processDeregistration(
* new SurePassIdUaf.ErrorCallback() {
* @param errorCode ErrorCode as defined in the FIDO UAF Application API and /**
* * This operation Transportalways Bindingtriggers Specificationthe error callback and return NO_ERROR if the
*/ * transaction confirmation was successful. Otherwise, the appropriate
@Override public void onErrorResult(UafClientErrorCode errorCode) {
* ErrorCode is returned.
} *
} ); * @param errorCode ErrorCode as /**defined in the FIDO UAF Application API and
* Used to deregister UAF Authenticators. */ * mUaf.processDeregistration( new SurePassIdUaf.ErrorCallback() {Transport Binding Specification
/** */
* This operation always triggers the error callback and@Override
return NO_ERROR if the public *void transaction confirmation was successful. Otherwise, the appropriateonErrorResult(UafClientErrorCode errorCode) {
*}
ErrorCode is returned. }
* );
});
* @param errorCode ErrorCode as defined inreturn theview;
FIDO UAF Application API and}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
* super.onActivityCreated(savedInstanceState);
mUaf = new SurePassIdUaf(this.getActivity());
Transport Binding Specification}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
*/ switch (requestCode) {
@Override case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
// Forward publicthe voidresult onErrorResult(UafClientErrorCode errorCode) {to SurePassIdUaf.onActivityResult
mUaf.onActivityResult(requestCode, resultCode, intent);
} break;
} }
); }
} |