Package com.vivokey.chipscanlib
Class VivoTag
- java.lang.Object
-
- com.vivokey.chipscanlib.VivoTag
-
public class VivoTag extends Object
Represents a VivoKey tag found in the NFC field. Create by using the constructor with a Tag found from a NFC Intent.
-
-
Field Summary
Fields Modifier and Type Field Description static int
APEX
This is a sub-instance of an Apex implant.protected static byte[]
NDEF_SEL
The NDEF select APDUstatic int
NTAG4XX
This is a sub-instance of a Spark 2 implant.static int
NTAG5
This is a sub-instance of a NTAG 5 type implant.protected Spark2
sp2Tag
static int
SPARK_1
This is an instance of a ISO15693-type implant.static int
SPARK_2
This is an instance of a ISO14443A-type implant.protected android.nfc.tech.TagTechnology
tagtech
protected int
tagtype
protected byte[]
taguid
protected static byte[]
VKID_AID
The Vk-Identity APDU.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
authenticatePart1()
Processes the first part of a Spark 2 or Apex-style implant.String
authenticatePart2(String pcdChallenge)
Performs the second step of authentication against a Spark 2 or Apex-style implant.void
close()
Disable I/O operations to the tag from thisTagTechnology
object, and release resources.void
connect()
Enable I/O operations to the tag from the underlying TagTechnology object.android.nfc.Tag
getTag()
int
getType()
Returns the tag type.protected String
getUid()
Returns the uid as a hex string.boolean
isConnected()
Helper to indicate if I/O operations should be possible.int
probe14443()
Probes an ISO14443 implant to determine it's subtype.void
reconnect()
Re-connect to theTag
associated with this connection.String
singleSign(String challenge)
Processes a single-part challenge-response (Spark 1 type) for an implant.
-
-
-
Field Detail
-
SPARK_1
public static final int SPARK_1
This is an instance of a ISO15693-type implant.- See Also:
- Constant Field Values
-
SPARK_2
public static final int SPARK_2
This is an instance of a ISO14443A-type implant.- See Also:
- Constant Field Values
-
NTAG4XX
public static final int NTAG4XX
This is a sub-instance of a Spark 2 implant.- See Also:
- Constant Field Values
-
APEX
public static final int APEX
This is a sub-instance of an Apex implant.- See Also:
- Constant Field Values
-
NTAG5
public static final int NTAG5
This is a sub-instance of a NTAG 5 type implant.- See Also:
- Constant Field Values
-
VKID_AID
protected static final byte[] VKID_AID
The Vk-Identity APDU.
-
NDEF_SEL
protected static final byte[] NDEF_SEL
The NDEF select APDU
-
taguid
protected byte[] taguid
-
tagtech
protected android.nfc.tech.TagTechnology tagtech
-
tagtype
protected int tagtype
-
sp2Tag
protected Spark2 sp2Tag
-
-
Constructor Detail
-
VivoTag
public VivoTag(byte[] uid, int tagtype, android.nfc.tech.TagTechnology tech)
Constructor for emulated tags. Allows you to set the parameters. Note: you must override the- Parameters:
uid
- the UID for the tagtagtype
- integer tagtype to set
-
VivoTag
public VivoTag(android.nfc.Tag tag) throws IOException
Constructor. Takes a tag as an input and represents this internally.- Parameters:
tag
- the tag to represent.- Throws:
IOException
-
-
Method Detail
-
getType
public int getType()
Returns the tag type.- Returns:
- tag type.
-
getUid
protected String getUid()
Returns the uid as a hex string.- Returns:
- uid as hex string.
-
connect
public void connect() throws IOException
Enable I/O operations to the tag from the underlying TagTechnology object. May cause RF activity and may block. Must not be called from the main application thread. A blocked call will be canceled with IOException by calling close from another thread. Only one TagTechnology object (and, by extension, one VivoTag object) can be connected to a Tag at a time. Applications must call close when I/O operations are complete. Requires the android.Manifest.permission.NFC permission.- Throws:
IOException
-
getTag
public android.nfc.Tag getTag()
-
reconnect
public void reconnect() throws IOException
Re-connect to theTag
associated with this connection. Reconnecting to a tag can be used to reset the state of the tag itself.May cause RF activity and may block. Must not be called from the main application thread. A blocked call will be canceled with
IOException
by callingclose()
from another thread.Requires the
Manifest.permission.NFC
permission.- Throws:
TagLostException
- if the tag leaves the fieldIOException
- if there is an I/O failure, or connect is canceled- See Also:
connect()
,close()
-
close
public void close() throws IOException
Disable I/O operations to the tag from thisTagTechnology
object, and release resources.Also causes all blocked I/O operations on other thread to be canceled and return with
IOException
.Requires the
Manifest.permission.NFC
permission.- Throws:
IOException
- See Also:
connect()
-
isConnected
public boolean isConnected()
Helper to indicate if I/O operations should be possible.Returns true if
connect()
has completed, andclose()
has not been called, and theTag
is not known to be out of range.Does not cause RF activity, and does not block.
- Returns:
- true if I/O operations should be possible
-
probe14443
public int probe14443() throws IOException
Probes an ISO14443 implant to determine it's subtype. Attempts to select the Apex Identity applet.- Returns:
- the integer subtype of this implant.
- Throws:
IOException
-
singleSign
public String singleSign(String challenge) throws org.apache.commons.codec.DecoderException, IOException
Processes a single-part challenge-response (Spark 1 type) for an implant.- Parameters:
challenge
- the challenge, in hex string format, from the API.- Returns:
- the chip response, in hex string format.
- Throws:
org.apache.commons.codec.DecoderException
IOException
-
authenticatePart1
public String authenticatePart1() throws IOException
Processes the first part of a Spark 2 or Apex-style implant.- Returns:
- a hex string with the chip challenge, or an empty string if failed.
- Throws:
IOException
-
authenticatePart2
public String authenticatePart2(String pcdChallenge) throws org.apache.commons.codec.DecoderException, IOException
Performs the second step of authentication against a Spark 2 or Apex-style implant.- Parameters:
pcdChallenge
- the API challenge for this chip in hex string format.- Returns:
- the chip response in hex string.
- Throws:
org.apache.commons.codec.DecoderException
IOException
-
-