Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



Infocode
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 Block
import com.surepassid.fido.uaf.application.SurePassIdUaf;
import com.surepassid.fido.uaf.client.UafClientErrorCode;
import com.surepassid.fido.uaf.client.UafClientIntent;

public SurePassIdUafclass UafRegistrationFragment mUafextends =Fragment new SurePassIdUaf(this.getActivity());{
    private SurePassIdUaf mUaf;

  /**  @Nullable
    @Override
  * Used topublic discoverView theonCreateView(@NonNull availableLayoutInflater authenticatorsinflater, and@Nullable capabilities.ViewGroup container,
        */         mUaf.discover(            @Nullable Bundle savedInstanceState) {
 new SurePassIdUaf.DiscoveryCallback() {     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 -> {
     * If the discovery operation was successful, the/**
discoveryData is returned.           * Register a new UAF authenticator for the current user.
 *            */
         * @param discoveryData AsmUaf.processRegistration(
defined in the FIDO UAF Application API and             new SurePassIdUaf.ErrorCallback() {
      *                  /**
  Transport Binding Specification                      */ This operation always triggers the error callback and return NO_ERROR if the
        @Override                 * registration was successful. publicOtherwise, voidthe onDiscoveryResult(DiscoveryData discoveryData) {
appropriate ErrorCode is returned.
                    }     *
           },              * If the new SurePassIdUaf.ErrorCallback() {
    registration was successful, the sessionToken obtained from validate
               /**          * user is invalidated. The user must re-authenticate via UAF.processAuthentication.
  * 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) {

                    }    }
            }        }
);          /**  );
       * Register});
a
new UAF authenticator for the current user.  return view;
    }

*/    @Override
    mUaf.processRegistration(public void onActivityCreated(@Nullable Bundle savedInstanceState) {
           new SurePassIdUaf.ErrorCallback() {super.onActivityCreated(savedInstanceState);
        mUaf = new SurePassIdUaf(this.getActivity());
    }

   /** @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        switch *(requestCode) This{
operation always triggers the error callback and return NO_ERROR if the  case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
                // Forward *the registrationresult wasto successfulSurePassIdUaf.onActivityResult
Otherwise, the appropriate ErrorCode is returned.           mUaf.onActivityResult(requestCode, resultCode, intent);
        *        break;
        }
    * If the registration was successful, the sessionToken obtained from validate
   }
}


Code Block
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
user is invalidated. The userpublic must re-authenticate via UAF.processAuthentication.
  View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                  *           @Nullable Bundle savedInstanceState) {
       * @paramfinal errorCodeView ErrorCodeview as defined in the FIDO UAF Application API and= inflater.inflate(R.layout.uaf_authenticate_fragment, container, false);

        final Button button = view.findViewById(R.id.uaf_authenticate_button);

        button.setOnClickListener(v -> *{

            /**
       Transport Binding Specification    * Perform a UAF Authentication operation.
             */
            mUaf.processAuthentication(
       @Override             new SurePassIdUaf.AuthenticationCallback() {
     public void onErrorResult(UafClientErrorCode errorCode) {               /**
      }                 }  * If the authentication operation was successful, );the session token is returned.
     /**          * Perform a UAF Authentication operation.     *
    */         mUaf.processAuthentication(            * @param sessionToken
  new SurePassIdUaf.AuthenticationCallback() {                     */**
                     * If the authentication@Override
operation was successful, the session token is returned.                 public void onAuthenticationResult(String sessionToken) {
*
                     * @param sessionToken }
                    */},
                    @Override
  new SurePassIdUaf.ErrorCallback() {
                 public void onAuthenticationResult(String sessionToken) {   /**
                  }       * If this operation failed, the appropriate ErrorCode is returned.
},                 new SurePassIdUaf.ErrorCallback() {      *
              /**           * @param errorCode ErrorCode as defined in the FIDO UAF Application *API Ifand
this operation failed, the appropriate ErrorCode is returned.                  *    *              Transport Binding Specification
     * @param errorCode ErrorCode as defined in the FIDO UAF Application API and        */
             *           @Override
      Transport Binding Specification                public void onErrorResult(UafClientErrorCode errorCode) {

*/                     @Override   }
                 public void onErrorResult(UafClientErrorCode errorCode) { }
            );
        });

        return view;
     }

    @Override
  );  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
   /**     super.onActivityCreated(savedInstanceState);
     * Perform a UAFmUaf Transaction= Confirmationnew operation.SurePassIdUaf(this.getActivity());
    }

   * @Override
    public void onActivityResult(int requestCode, *int TODO:resultCode, ThisIntent may require a parameter to specify the desired transaction.
 intent) {
        switch (requestCode) {
       */     case UafClientIntent.REQUEST_CODE_UAF_OPERATION:
  mUaf.processTransactionConfirmation(              // Forward the result newto SurePassIdUaf.ErrorCallback()onActivityResult
{                mUaf.onActivityResult(requestCode, resultCode, intent);
  /**              break;
       * This operation always triggers the error callback and return NO_ERROR if the
  }
    }
}


Code Block
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;
        }
    }
}


Code Block
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 -> {
       * 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;
   }     }
   ); }
}