Package com.vivokey.chipscanlib
Class VivoAuthenticator
- java.lang.Object
-
- java.lang.Thread
-
- com.vivokey.chipscanlib.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description static int
ERROR_APIERR
static int
ERROR_TAGERR
static int
ERROR_TAGINVALID
static int
ERROR_TAGLOST
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description VivoAuthenticator(String apikey)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
getChallenge()
Starts a synchronous attempt to grab a challenge.int
getErrorCode()
Returns the error code, as defined above.String
getErrorString()
Get the human-readable error string.VivoAuthResult
getResult()
Retrieves the VivoAuthResult from the API.boolean
isError()
Returns if the thread exited on an error.boolean
isFinished()
Returns if the thread has finished it's work.boolean
isRunning()
Returns the state of the thread.void
run()
Processes an implant and authenticates with the API.void
setTag(VivoTag tag)
Set theVivoTag
received and processed from an intent.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
ERROR_TAGLOST
public static final int ERROR_TAGLOST
- See Also:
- Constant Field Values
-
ERROR_APIERR
public static final int ERROR_APIERR
- See Also:
- Constant Field Values
-
ERROR_TAGINVALID
public static final int ERROR_TAGINVALID
- See Also:
- Constant Field Values
-
ERROR_TAGERR
public static final int ERROR_TAGERR
- See Also:
- Constant Field Values
-
-
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 theVivoTag
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.
-
getResult
public VivoAuthResult getResult()
Retrieves the VivoAuthResult from the API.- Returns:
- a VivoAuthResult representing the API response.
-
-