public interface PINPadDevice extends Device
The PINPad device object is obtained from the POSTerminal
, its' as follows:
PINPadDevice pinPadDevice = (PINPadDevice) POSTerminal.getInstance().getDevice("cloudpos.device.pinpad");Among them, the "cloudpos.device.pinpad" string is to identify the PINPad device, defined by the specific implementation.
Uses the PINPad device object to control the operation of the PINPad device.
An app can request permission to access the device, as shown below:
listenForPinBlock(KeyInfo, String, boolean, OperationListener, int)
and waitForPinBlock(KeyInfo, String, boolean, int)
.
calculateMac(KeyInfo, int, byte[])
.
encryptData(KeyInfo, byte[])
.
updateUserKey(int, int, byte[],int, byte[])
and updateUserKey(int, int, byte[])
.
Device
Modifier and Type | Field and Description |
---|---|
static int |
CHECK_TYPE_CUP
check type of check value.
|
static int |
CHECK_TYPE_NONE
check type of check value.
|
static int |
KEY_TYPE_FIX
key type: Fix key
|
static int |
KEY_TYPE_MK_SK
key type: Master/Session key
|
static int |
KEY_TYPE_TDUKPT
key type: TDUKPT
|
static int |
KEY_TYPE_TDUKPT_2009
key type: TDUKPT 2009
|
static int |
USER_KEY_ID_DATA
Data key
|
static int |
USER_KEY_ID_MAC
MAC key
|
static int |
USER_KEY_ID_PIN
PIN key
|
Modifier and Type | Method and Description |
---|---|
byte[] |
calculateMac(KeyInfo keyInfo,
int macFlag,
byte[] plain)
Calculates the MAC using current user key defined in
KeyInfo . |
void |
clearText()
Clears the message in the LCD.
|
byte[] |
encryptData(KeyInfo keyInfo,
byte[] plain)
Encrypts the data using user key defined in
KeyInfo |
byte[] |
encryptData(KeyInfo keyInfo,
byte[] plain,
int mode,
byte[] IV,
int IVLen)
Encrypts the data using user key defined in
KeyInfo |
byte[] |
getRandom(int length)
Gets random data.
|
byte[] |
getSessionKeyCheckValue(int masterKeyID,
int userKeyID,
int algoCheckValue)
Get check value for session key.
|
java.lang.String |
getSN()
Gets PINPad serial number.
|
void |
listenForOfflinePin(boolean voicePrompt,
OperationListener listener,
int timeout)
Let the user to wait the offline pin.
|
void |
listenForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
OperationListener listener,
int timeout)
Let the user input the PIN and calculate the encrypted pin block.
|
void |
open(int logicalID)
Opens the control of the PINPad.
|
void |
setPINLength(int minLen,
int maxLen)
Set the length of input PIN.
|
void |
showText(int lineIndex,
java.lang.String message)
Displays message in the LCD.
|
void |
showText(int lineIndex,
java.lang.String message,
boolean voicePrompt)
Displays message in the LCD.
|
void |
updateMasterKey(int masterKeyID,
byte[] oldMasterKey,
byte[] newMasterKey)
Updates master key.
|
void |
updateMasterKeyWithCheck(int masterKeyID,
byte[] cipherNewMasterKey,
byte[] checkValue,
int algoCheckValue)
Updates master key, the master key must be ciphered by transport key.
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey)
Updates the user key(session key).
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue)
Updates the user key(session key).
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue,
KeyInfo keyInfo)
Update user key when using Master/Session key type.
|
void |
updateUserKeyWithCheck(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int userKeyType,
byte[] checkValue,
int algoCheckValue)
Updates the user key(session key).
|
PINPadOperationResult |
waitForOfflinePin(boolean voicePrompt,
int timeout)
The synchronous method of
listenForOfflinePin(boolean,OperationListener,int) . |
PINPadOperationResult |
waitForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
int timeout)
The synchronous method of
listenForPinBlock(KeyInfo,String,boolean,OperationListener,int) . |
cancelRequest, close, getFailCount, getUsageCount, open
static final int KEY_TYPE_TDUKPT
static final int KEY_TYPE_MK_SK
static final int KEY_TYPE_FIX
static final int KEY_TYPE_TDUKPT_2009
static final int USER_KEY_ID_PIN
Uses when calculate pin block.
static final int USER_KEY_ID_MAC
Uses when calculate MAC.
static final int USER_KEY_ID_DATA
Uses when encrypt data.
static final int CHECK_TYPE_NONE
Uses when update user key with check value.
static final int CHECK_TYPE_CUP
Uses when update user key with check value.
void open(int logicalID) throws DeviceException
logicalID
- logical ID of the device to open.DeviceException
- for the standard reasons that are documented in
DeviceException
.void showText(int lineIndex, java.lang.String message) throws DeviceException
lineIndex
- message
- DeviceException
- for the standard reasons that are documented in
DeviceException
.void showText(int lineIndex, java.lang.String message, boolean voicePrompt) throws DeviceException
lineIndex
- message
- voicePrompt
- DeviceException
- for the standard reasons that are documented in
DeviceException
.void clearText() throws DeviceException
DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateMasterKey(int masterKeyID, byte[] oldMasterKey, byte[] newMasterKey) throws DeviceException
masterKeyID
- the master key index.oldMasterKey
- the original master key.newMasterKey
- the new master key.DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKey(int masterKeyID, int userKeyID, byte[] cipherNewUserKey, int checkType, byte[] checkValue) throws DeviceException
masterKeyID
- Master key index.userKeyID
- User key type.cipherNewUserKey
- Cipher new user key.checkType
- check value type:CHECK_TYPE_NONE
, CHECK_TYPE_CUP
.checkValue
- check value.DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKey(int masterKeyID, int userKeyID, byte[] cipherNewUserKey) throws DeviceException
masterKeyID
- Master key index.userKeyID
- User key index.cipherNewUserKey
- Cipher new user key.DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] encryptData(KeyInfo keyInfo, byte[] plain) throws DeviceException
KeyInfo
keyInfo
- plain
- Plain data buffer.DeviceException
- for the standard reasons that are documented in
DeviceException
.void listenForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, OperationListener listener, int timeout) throws DeviceException
PINPadOperationResult
sent to the handleResult
method of the OperationListener
.
Because this method uses a timeout parameter, the device receiving this request MUST be able to
successfully respond to cancelRequest()
and abort the operation.
In case of a timeout occurring, the operation result will contain code=
ERR_TIMEOUT
, and no information about
pin block will be available.
keyInfo
- The key configuration that used by the PINPad calculate.pan
- the ASCII string of the card number.voicePrompt
- play the audio to notice user.listener
- The operation listener.timeout
- the maximum pending time of the method, in milliseconds.
Note that the timeout will begin when the request begins to be
processed. The timeout
parameter is then only
indicative. There are two special cases for
timeout
, as follows:
timeout == FOREVER
, the method will wait
until something is available on the associated service's
input.
timeout == IMMEDIATE
, the method will
immediately read the input
DeviceException
- for the standard reasons that are documented in
DeviceException
.PINPadOperationResult waitForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, int timeout) throws DeviceException
listenForPinBlock(KeyInfo,String,boolean,OperationListener,int)
.
keyInfo
- The key configuration that used by the PINPad calculate.pan
- the ASCII string of the card number.voicePrompt
- play the audio to notice user.timeout
- the maximum pending time of the method, in milliseconds.
Note that the timeout will begin when the request begins to be
processed. The timeout
parameter is then only
indicative. There are two special cases for
timeout
, as follows:
timeout == FOREVER
, the method will wait
until something is available on the associated service's
input.
timeout == IMMEDIATE
, the method will
immediately read the input
DeviceException
- for the standard reasons that are documented in
DeviceException
.void listenForOfflinePin(boolean voicePrompt, OperationListener listener, int timeout) throws DeviceException
voicePrompt
- play the audio to notice user.listener
- The operation listener.timeout
- the maximum pending time of the method, in milliseconds.
Note that the timeout will begin when the request begins to be
processed. The timeout
parameter is then only
indicative. There are two special cases for
timeout
, as follows:
timeout == FOREVER
, the method will wait
until something is available on the associated service's
input.
timeout == IMMEDIATE
, the method will
immediately read the input
DeviceException
PINPadOperationResult waitForOfflinePin(boolean voicePrompt, int timeout) throws DeviceException
listenForOfflinePin(boolean,OperationListener,int)
.voicePrompt
- timeout
- DeviceException
byte[] calculateMac(KeyInfo keyInfo, int macFlag, byte[] plain) throws DeviceException
KeyInfo
.keyInfo
- The key configuration that used by the PINPad calculate.macFlag
- the constants as follows:
plain
- plain data buffer.DeviceException
- for the standard reasons that are documented in
DeviceException
.void setPINLength(int minLen, int maxLen) throws DeviceException
minLen
- The minimum length.maxLen
- The maximum length.DeviceException
- for the standard reasons that are documented in
DeviceException
.java.lang.String getSN() throws DeviceException
DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] getRandom(int length) throws DeviceException
length
- The length of the random data.DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKeyWithCheck(int masterKeyID, int userKeyID, byte[] cipherNewUserKey, int userKeyType, byte[] checkValue, int algoCheckValue) throws DeviceException
masterKeyID
- index of master keyuserKeyID
- index of user keycipherNewUserKey
- ciphered user keyuserKeyType
- user key type. 0--PIN key;1--MAC key;2--Data keycheckValue
- check value of user keyalgoCheckValue
- ALGO_CHECK_VALUE 0--ALGO_CHECK_VALUE_DEFAULT;1--ALGO_CHECK_VALUE_SE919DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateMasterKeyWithCheck(int masterKeyID, byte[] cipherNewMasterKey, byte[] checkValue, int algoCheckValue) throws DeviceException
masterKeyID
- index of master keycipherNewMasterKey
- ciphed master keycheckValue
- check valuealgoCheckValue
- ALGO_CHECK_VALUE 0--ALGO_CHECK_VALUE_DEFAULT;1--ALGO_CHECK_VALUE_SE919DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] encryptData(KeyInfo keyInfo, byte[] plain, int mode, byte[] IV, int IVLen) throws DeviceException
KeyInfo
keyInfo
- plain
- plain data buffermode
- 0--PINPAD_ENCRYPT_STRING_MODE_EBC;1--PINPAD_ENCRYPT_STRING_MODE_CBC;2--PINPAD_ENCRYPT_STRING_MODE_CFB;3--PINPAD_ENCRYPT_STRING_MODE_OFB.NoPadding.IV
- initial vectorIVLen
- length of initial vectorDeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKey(int masterKeyID, int userKeyID, byte[] cipherNewUserKey, int checkType, byte[] checkValue, KeyInfo keyInfo) throws DeviceException
masterKeyID
- master key index.userKeyID
- user key index:USER_KEY_ID_PIN
, USER_KEY_ID_MAC
, USER_KEY_ID_DATA
.cipherNewUserKey
- ciphered by master keycheckType
- check typeCHECK_TYPE_NONE
, CHECK_TYPE_CUP
.checkValue
- check valuekeyInfo
- DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] getSessionKeyCheckValue(int masterKeyID, int userKeyID, int algoCheckValue) throws DeviceException
masterKeyID
- master key index.userKeyID
- user key index:USER_KEY_ID_PIN
, USER_KEY_ID_MAC
, USER_KEY_ID_DATA
.algoCheckValue
- ALGO_CHECK_VALUE 0--ALGO_CHECK_VALUE_DEFAULT;1--ALGO_CHECK_VALUE_SE919DeviceException
- for the standard reasons that are documented in
DeviceException
.