public class EMSR
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
EMSR.EMSRInformation
The class that contains various information about encrypted magnetic stripe reader (EMSR).
|
static class |
EMSR.EMSRKeyInformation
The class that contains various information about encrypted magnetic stripe reader (EMSR).
|
Modifier and Type | Field and Description |
---|---|
static int |
ENCRYPTION_TYPE_AES256
Encrypted Magnetic Head AES 256 encryption algorithm After decryption, the result data will
be as follows:
Random data (4 bytes).
|
static int |
ENCRYPTION_TYPE_IDTECH
Encrypted Magnetic Head IDTECH encryption algorithm, please refer to IDTECH documentation for
detailed format and examples.
|
static int |
ENCRYPTION_TYPE_OLD_RSA
Card data will be sent encrypted in the format:
Encryption type (1 byte): 01 - RSA2048 encrypted.
|
static int |
ENCRYPTION_TYPE_RSA
Card data will be sent encrypted in the format:
Encryption type (1 byte): 01 - RSA2048 encrypted.
|
static int |
KEY_AES_AUTHENTICATION |
static int |
KEY_AES_DATA_ENCRYPTION
Encryption key, if set magnetic card data will be encrypted.
|
static int |
KEY_AES_KEK
Encrypted head key loading key.
|
static int |
KEY_DUKPT_MASTER
Encrypted head DUKPT master key.
|
static int |
KEY_NO_KEY
No key.
|
static int |
KEY_TMK_AES
Encrypted head TMK key.
|
static int |
MODE_READ_JIS
Read JIS card.
|
static int |
MODE_READ_PREFIX
Read data with prefix before tracks - 0xF0, 0xF1, 0xF2.
|
static int |
MODE_READ_RAW
Read raw data.
|
static int |
MODE_READ_TRACK1
Read track 1.
|
static int |
MODE_READ_TRACK2
Read track 2.
|
static int |
MODE_READ_TRACK3
Read track 3.
|
static int |
STATUS_EMSR_BAD_ARRAY |
static int |
STATUS_EMSR_BARCODE_MISHMASH |
static int |
STATUS_EMSR_BARCODE_NO_READER |
static int |
STATUS_EMSR_CARD_ERROR |
static int |
STATUS_EMSR_HARD |
static int |
STATUS_EMSR_INVALID_COMMAND |
static int |
STATUS_EMSR_INVALID_LENGTH |
static int |
STATUS_EMSR_INVALID_SIGNATURE |
static int |
STATUS_EMSR_NO_BARCODE_READ |
static int |
STATUS_EMSR_NO_DATA |
static int |
STATUS_EMSR_NO_PERMISSION |
static int |
STATUS_EMSR_NO_RESPONSE |
static int |
STATUS_EMSR_SYNTAX_ERROR |
static int |
STATUS_EMSR_TAMPERED |
Constructor and Description |
---|
EMSR(java.io.InputStream in,
java.io.OutputStream out)
Constructs a new instance of this class from a given
InputStream and OutputStream . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the streams and release all associated resources.
|
void |
disable()
Disable encrypted magnetic stripe reader (EMSR).
|
void |
enable()
Enable encrypted magnetic stripe reader (EMSR).
|
EMSR.EMSRInformation |
getInformation()
Returns information about encrypted magnetic stripe reader (EMSR).
|
EMSR.EMSRKeyInformation |
getKeyInformation(int keyId)
Returns information about keys into encrypted magnetic stripe reader (EMSR).
|
void |
loadKey(byte[] keyData)
Loads new key, in plain or encrypted with already loaded AES256 Key Encryption Key (KEK).
|
byte[] |
readCardData(int mode)
Read card data.
|
static void |
setDebug(boolean on)
Specify whether the object can output debug information
|
void |
setEncryptionType(int type)
Set encryption type.
|
int |
test(int ms)
Test encrypted magnetic head.
|
byte[] |
transmitEMSR(byte[] input)
Transmit data to encrypted magnetic stripe reader (EMSR).
|
public static final int STATUS_EMSR_INVALID_COMMAND
public static final int STATUS_EMSR_NO_PERMISSION
public static final int STATUS_EMSR_CARD_ERROR
public static final int STATUS_EMSR_SYNTAX_ERROR
public static final int STATUS_EMSR_NO_RESPONSE
public static final int STATUS_EMSR_NO_DATA
public static final int STATUS_EMSR_BAD_ARRAY
public static final int STATUS_EMSR_NO_BARCODE_READ
public static final int STATUS_EMSR_BARCODE_MISHMASH
public static final int STATUS_EMSR_BARCODE_NO_READER
public static final int STATUS_EMSR_INVALID_LENGTH
public static final int STATUS_EMSR_TAMPERED
public static final int STATUS_EMSR_INVALID_SIGNATURE
public static final int STATUS_EMSR_HARD
public static final int KEY_AES_AUTHENTICATION
public static final int KEY_AES_DATA_ENCRYPTION
public static final int KEY_AES_KEK
public static final int KEY_TMK_AES
public static final int KEY_DUKPT_MASTER
public static final int KEY_NO_KEY
public static final int ENCRYPTION_TYPE_OLD_RSA
Random data, track 2 data, cardholder name, sha256 and the padding are encrypted with AES128.
public static final int ENCRYPTION_TYPE_RSA
Random data, track 2 data, cardholder name, sha256 and the padding are encrypted with AES128.
public static final int ENCRYPTION_TYPE_AES256
public static final int ENCRYPTION_TYPE_IDTECH
public static final int MODE_READ_TRACK1
public static final int MODE_READ_TRACK2
public static final int MODE_READ_TRACK3
public static final int MODE_READ_JIS
public static final int MODE_READ_RAW
public static final int MODE_READ_PREFIX
public EMSR(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
InputStream
and OutputStream
.in
- the input stream.out
- the output stream.java.io.IOException
- if an I/O error occurs.public void close()
public static void setDebug(boolean on)
on
- True to enable debbuging; otherwise false.public byte[] transmitEMSR(byte[] input) throws java.io.IOException
input
- the input data to process.java.io.IOException
- if an I/O error occurs.public void enable() throws EMSRException, java.io.IOException
EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public void disable() throws EMSRException, java.io.IOException
EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public EMSR.EMSRInformation getInformation() throws EMSRException, java.io.IOException
EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public EMSR.EMSRKeyInformation getKeyInformation(int keyId) throws EMSRException, java.io.IOException
keyId
- the ID of the key to get the version, one of the KEY_* constants definition.EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public void loadKey(byte[] keyData) throws EMSRException, java.io.IOException
keyData
- a byte array, that consists of: EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public void setEncryptionType(int type) throws EMSRException, java.io.IOException
type
- the encryption type, one of the ENCRYPTION_TYPE_* constants definition.EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public int test(int ms) throws EMSRException, java.io.IOException
ms
- the timeout of operation.EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.public byte[] readCardData(int mode) throws EMSRException, java.io.IOException
mode
- the mode. If can be combination of MODE_* constant values.EMSRException
- if a reader error occurs.java.io.IOException
- if an I/O error occurs.