Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.datecs.api.universalreader
Class UniversalReader.SmartCardReader

    java.lang.Object
      com.datecs.api.universalreader.UniversalReader.SmartCardReader

Enclosing class:
  UniversalReader

    public final class UniversalReader.SmartCardReader

extends java.lang.Object

This class provides functionality for the Smart Card reader.

Method Summary
`boolean` | `isCardPresent()` Returns if smart card is present into reader.
`ResponseAPDU` | `read(byte[] data)` Sends APDU read request.
`ResponseAPDU` | `read(int cla, int ins, int p1, int p2, int lc)` Sends APDU read request.
`AnswerToReset` | `reset()` Resets the smart card and returns the ATR.
`void` | `select(int slot)` Selects the smart card reader slot.
`void` | `setPower(boolean on)` Powers on/off smart card.
`ResponseAPDU` | `transmit(byte[] data)` Sends combined APDU write/read request.
`ResponseAPDU` | `transmit(int cla, int ins, int p1, int p2, byte[] data)` Sends combined APDU write/read request.
`ResponseAPDU` | `write(byte[] data)` Sends APDU write request.
`ResponseAPDU` | `write(int cla, int ins, int p1, int p2, byte[] data)` Sends APDU write request.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### setPower

    public void setPower(boolean on)
                  throws java.io.IOException,
                         UniversalReaderException

  Powers on/off smart card.

  Call this method to powered on the smart card before any APDU request, and to powered off the smart card when finish to use it.

  Parameters:
    `on` - the flag indicates where to power on/off the reader.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### reset

    public AnswerToReset reset()
                        throws java.io.IOException,
                               UniversalReaderException

  Resets the smart card and returns the ATR.

  Call this method before sending first APDU command.

  Returns:
    an instance of ResponseATR.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### write

    public ResponseAPDU write(int cla,
                              int ins,
                              int p1,
                              int p2,
                              byte[] data)
                       throws java.io.IOException,
                              UniversalReaderException

  Sends APDU write request.

  Parameters:
    `cla` - the CLA parameter. Consults with smart card documentation.
    `ins` - the INS parameter. Consults with smart card documentation.
    `p1` - the P1 parameter. Consults with smart card documentation.
    `p2` - the P2 parameter. Consults with smart card documentation.
    `data` - the byte array to write to the smart card or `null` if you don't want to send any data with the command.
  Returns:
    an instance of ResponseAPDU.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### write

    public ResponseAPDU write(byte[] data)
                       throws java.io.IOException,
                              UniversalReaderException

  Sends APDU write request. If `data` is `null`, a `NullPointerException` is thrown.

  Parameters:
    `data` - the byte array contains write command that send to the smart card.
  Returns:
    an instance of ResponseAPDU.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### read

    public ResponseAPDU read(int cla,
                             int ins,
                             int p1,
                             int p2,
                             int lc)
                      throws java.io.IOException,
                             UniversalReaderException

  Sends APDU read request.

  Parameters:
    `cla` - the CLA parameter. Consults with smart card documentation.
    `ins` - the INS parameter. Consults with smart card documentation.
    `p1` - the P1 parameter. Consults with smart card documentation.
    `p2` - the P2 parameter. Consults with smart card documentation.
    `lc` - the number of bytes requested to read from smart card.
  Returns:
    an instance of ResponseAPDU.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### read

    public ResponseAPDU read(byte[] data)
                      throws java.io.IOException,
                             UniversalReaderException

  Sends APDU read request. If `data` is `null`, a `NullPointerException` is thrown.

  Parameters:
    `data` - the byte array contains read command that send to the smart card.
  Returns:
    an instance of ResponseAPDU.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### transmit

    public ResponseAPDU transmit(int cla,
                                 int ins,
                                 int p1,
                                 int p2,
                                 byte[] data)
                          throws java.io.IOException,
                                 UniversalReaderException

  Sends combined APDU write/read request.

  Parameters:
    `cla` - the CLA parameter. Consult smart card documentation.
    `ins` - the INS parameter. Consult smart card documentation.
    `p1` - the P1 parameter. Consult smart card documentation.
    `p2` - the P2 parameter. Consult smart card documentation.
    `data` - the byte array to write to the smart card or `null` if you don't want to send any data with the command.
  Returns:
    an instance of ResponseAPDU.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### transmit

    public ResponseAPDU transmit(byte[] data)
                          throws java.io.IOException,
                                 UniversalReaderException

  Sends combined APDU write/read request. If `data` is `null`, a `NullPointerException` is thrown.

  Parameters:
    `data` - the byte array contains write command that send the smart card.
  Returns:
    an instance of ResponseAPDU.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### isCardPresent

    public boolean isCardPresent()
                          throws java.io.IOException,
                                 UniversalReaderException

  Returns if smart card is present into reader.

  Returns:
    the `true` if smart card available into module; otherwise returns `false`.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

### select

    public void select(int slot)
                throws java.io.IOException,
                       UniversalReaderException

  Selects the smart card reader slot.

  Parameters:
    `slot` - the smart card reader slot number, starting from 0.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
    `UniversalReaderException` - if an error occurs during execution.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD