Class VivoAuthenticator

  • All Implemented Interfaces:
    Runnable

    public class VivoAuthenticator
    extends Thread
    Main class. Handles all the NFC and API stuff to interact with the VivoKey API. To use this class, create an instance of it with the API key (in hex string format) as an arg to the constructor. Then attach a VivoTag to it using setTag. It should be ready to start() after this. See example app for details.
    • Constructor Detail

      • VivoAuthenticator

        public VivoAuthenticator​(String apikey)
        Constructor. Requires a tag to be loaded before the thread is started.
        Parameters:
        apikey - the API key for the Chipscan API.
    • Method Detail

      • setTag

        public void setTag​(VivoTag tag)
        Set the VivoTag received and processed from an intent. This will set the Authenticator in a state.
        Parameters:
        tag - the VivoTag processed from an intent.
      • isRunning

        public boolean isRunning()
        Returns the state of the thread.
        Returns:
        boolean, true if run()/start() started but not finished.
      • isError

        public boolean isError()
        Returns if the thread exited on an error.
        Returns:
        boolean, true if run()/start() threw an exception.
      • getErrorCode

        public int getErrorCode()
        Returns the error code, as defined above.
        Returns:
        int error code, 0 if no error
      • getErrorString

        public String getErrorString()
        Get the human-readable error string.
        Returns:
        Error string, "" if empty
      • isFinished

        public boolean isFinished()
        Returns if the thread has finished it's work.
        Returns:
        boolean, true if run() finished.
      • getChallenge

        public void getChallenge()
        Starts a synchronous attempt to grab a challenge. Ensure this is run in a thread.
      • run

        public void run()
        Processes an implant and authenticates with the API. Will process all RF with a tag after discovery, and HTTP requests will be sent. Do not run in the UI thread. Android refuses to allow network access in a UI thread.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • getResult

        public VivoAuthResult getResult()
        Retrieves the VivoAuthResult from the API.
        Returns:
        a VivoAuthResult representing the API response.