Class VivoAPI


  • public class VivoAPI
    extends Object
    Handles connections to the VivoKey API.
    • Field Detail

      • httpClient

        protected cz.msebera.android.httpclient.client.HttpClient httpClient
      • clientBuilder

        protected final cz.msebera.android.httpclient.impl.client.HttpClientBuilder clientBuilder
      • postGetChall

        protected final cz.msebera.android.httpclient.client.methods.HttpPost postGetChall
      • postPcdChallenge

        protected final cz.msebera.android.httpclient.client.methods.HttpPost postPcdChallenge
      • postCheckResponse

        protected final cz.msebera.android.httpclient.client.methods.HttpPost postCheckResponse
      • apikey

        protected String apikey
    • Constructor Detail

      • VivoAPI

        public VivoAPI​(String apikey)
        Constructor. Creates the required parts to send commands. Requires an API key.
        Parameters:
        apikey - API key for the VivoKey API.
    • Method Detail

      • getChallenge

        public String getChallenge()
        Gets a challenge from the API using the specified key.
        Returns:
        a hex string of the challenge provided
      • pcdChallenge

        public String pcdChallenge​(String uid,
                                   String chall,
                                   String chipResp)
        Get a Spark 2/Apex PCD challenge.
        Parameters:
        uid - chip uid in hex string format
        chall - a challenge from the API in hex string format
        chipResp - the chip response to AuthenticatePart1
        Returns:
        the PCD response
      • checkResponse

        public VivoAuthResult checkResponse​(String uid,
                                            String chall,
                                            String chipResp)
        Checks a chip response against the response provided.
        Parameters:
        chipResp - the hex string from the chip.
        uid - chip UID in hex string format.
        chall - challenge from earlier API call in hex string format.
        Returns:
        the VivoAuthResult representing this chip authentication. Returns null on failure.