public interface PINPadDevice extends Device
PINPadDevice interface defines the API for interacting with PIN Pad devices.
This interface allows applications to control the operations of a PIN Pad device for tasks like PIN entry, encryption, and key management.
An instance of PINPadDevice is obtained as follows:
PINPadDevice pinPadDevice = (PINPadDevice) POSTerminal.getInstance().getDevice("com.cloudpos.device.pinpad");
"com.cloudpos.device.pinpad" is the identifier for the PINPad device, as defined by the specific implementation.
Different operations and permissions are associated with this device:
listenForPinBlock(com.cloudpos.pinpad.KeyInfo, java.lang.String, boolean, com.cloudpos.OperationListener, int) and waitForPinBlock(com.cloudpos.pinpad.KeyInfo, java.lang.String, boolean, int).
calculateMac(com.cloudpos.pinpad.KeyInfo, int, byte[]).
encryptData(com.cloudpos.pinpad.KeyInfo, byte[]).
updateUserKey(int, int, byte[], int, byte[]).
Device| Modifier and Type | Field and Description |
|---|---|
static int |
ALGO_CHECK_VALUE_DEFAULT |
static int |
ALGO_CHECK_VALUE_SE919 |
static int |
CHECK_TYPE_CUP |
static int |
CHECK_TYPE_NONE |
static int |
KEY_TYPE_FIX |
static int |
KEY_TYPE_MK_SK |
static int |
KEY_TYPE_PUBLIC |
static int |
KEY_TYPE_TDUKPT |
static int |
KEY_TYPE_TDUKPT_2009 |
static int |
KEY_TYPE_TDUKPT_2009_RESPONSE |
static int |
USER_KEY_ID_DATA |
static int |
USER_KEY_ID_MAC |
static int |
USER_KEY_ID_PIN |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
calculateMac(KeyInfo keyInfo,
int macFlag,
byte[] plain)
Calculates the MAC using the current user key as defined in KeyInfo.
|
byte[] |
calculateResponseMac(KeyInfo keyInfo,
byte[] plainData,
int macFlag)
Calculates the MAC (Message Authentication Code) using the TDUKPT method and a response MAC key.
|
int |
changePin(KeyInfo keyInfo,
byte[] cardNum,
byte[] pinOld,
byte[] pinNew,
int[] lengthResult,
int timeout)
Changes the user's PIN.
|
void |
clearText()
Clears any displayed text from the PINPad's LCD screen.
|
int |
createPin(KeyInfo keyInfo,
byte[] cardNum,
byte[] pinNew,
int timeout,
int nFlagSound)
Creates a new PIN.
|
byte[] |
encryptData(KeyInfo keyInfo,
byte[] plain)
Encrypts data using the specified key.
|
byte[] |
encryptData(KeyInfo keyInfo,
byte[] plain,
int mode,
byte[] IV,
int IVLen)
Encrypts data using the user-specified key with additional encryption options.
|
int |
getDukptStatus(int dukptID,
byte[] KSNBuf)
Gets the status of a DUKPT Key.
|
int |
getLastPINLength()
Retrieves the length of the last input PIN.
|
int |
getMkStatus(int mkId)
Checks the status of a Master Key.
|
byte[] |
getRandom(int length)
Generates random data of a specified length.
|
byte[] |
getSessionKeyCheckValue(int masterKeyID,
int userKeyID,
int algoCheckValue)
Retrieves the check value for a session key.
|
int |
getSkStatus(int mkId,
int skID)
Checks the status of a Session Key.
|
java.lang.String |
getSN()
Retrieves the serial number of the PINPad device.
|
void |
listenForOfflinePin(boolean voicePrompt,
OperationListener listener,
int timeout)
Waits for the user to enter their offline PIN.
|
void |
listenForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
OperationListener listener,
int timeout)
Listens for user PIN input and calculates the encrypted PIN block asynchronously.
|
void |
listenForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
OperationListener listener,
int timeout,
int mode,
byte[] IV)
Asynchronously listens for user PIN input and calculates an encrypted PIN block with a specific mode.
|
void |
open(int logicalID)
Opens the PINPad device for operation.
|
int |
selectPinblockFormat(int nPinblockFormat)
Selects the pinblock format to use.
|
boolean |
setAllowByPass(boolean allow)
Allows or disallows bypassing the PIN for online EMV transactions.
|
boolean |
setGUIConfiguration(int flag,
byte[] data)
Configures the PINPAD GUI.
|
boolean |
setGUIConfiguration(java.lang.String key,
java.lang.String value)
Configures the PINPAD GUI, including style, sound, and colors.
|
void |
setPINLength(int minLen,
int maxLen)
Sets the minimum and maximum length of the PIN to be entered by the user.
|
boolean |
setupCallbackHandler(com.cloudpos.jniinterface.PinPadCallbackHandler handler)
Sets up a callback for customizing the PINPAD UI.
|
void |
showText(int lineIndex,
java.lang.String message)
Displays a text message on the PINPad's LCD screen.
|
void |
showText(int lineIndex,
java.lang.String message,
boolean voicePrompt)
Displays a text message on the PINPad's LCD screen.
|
void |
updateMasterKey(int masterKeyID,
byte[] oldMasterKey,
byte[] newMasterKey)
Updates the master key used by the PINPad device.
|
void |
updateMasterKeyWithCheck(int masterKeyID,
byte[] cipherNewMasterKey,
byte[] checkValue,
int algoCheckValue)
Updates the master key, which must be encrypted by a transport key.
|
void |
updateMasterKeyWithCheckByMK(int masterKeyID,
byte[] cipherNewMasterKey,
byte[] checkValue,
int algoCheckValue)
Updates the master key, which must be encrypted by the old master key.
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey)
Updates the user key (session key) encrypted by the master key using 3DES algorithm.
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int userKeyType)
Updates the user key (session key) encrypted by the master key using 3DES algorithm.
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue)
Updates the user key (session key) encrypted by the master key using 3DES algorithm.
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue,
KeyInfo keyInfo)
Updates the user key(session key) with additional check value options.
|
void |
updateUserKeyWithCheck(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int userKeyType,
byte[] checkValue,
int algoCheckValue)
Updates the user key(session key).
|
int |
updateUserKeyWithTR31Format(int masterKeyID,
int userKeyID,
byte[] tr31Msg)
Updates the user key with TR31 formatted message.
|
boolean |
verifyResponseMac(KeyInfo keyInfo,
byte[] plainData,
int macFlag,
byte[] macData,
int nDirection)
Verifies the response MAC.
|
PINPadOperationResult |
waitForOfflinePin(boolean voicePrompt,
int timeout)
A synchronous version of 'listenForOfflinePin'.
|
PINPadOperationResult |
waitForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
int timeout)
Synchronously waits for user PIN input and calculates the encrypted PIN block.
|
PINPadOperationResult |
waitForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
int timeout,
int mode,
byte[] IV)
Synchronously calculates an encrypted PIN block with a specific mode.
|
cancelRequest, close, getFailCount, getUsageCount, openstatic final int KEY_TYPE_TDUKPT
static final int KEY_TYPE_MK_SK
static final int KEY_TYPE_PUBLIC
static final int KEY_TYPE_FIX
static final int KEY_TYPE_TDUKPT_2009
static final int KEY_TYPE_TDUKPT_2009_RESPONSE
static final int USER_KEY_ID_PIN
static final int USER_KEY_ID_MAC
static final int USER_KEY_ID_DATA
static final int CHECK_TYPE_NONE
static final int CHECK_TYPE_CUP
static final int ALGO_CHECK_VALUE_DEFAULT
static final int ALGO_CHECK_VALUE_SE919
void open(int logicalID) throws DeviceException
logicalID - The logical ID to identify the specific PINPad device to open.DeviceException - for standard reasons as documented in DeviceException.void showText(int lineIndex,
java.lang.String message)
throws DeviceException
lineIndex - The line number (e.g., 0 or 1) where the message should be displayed.message - The text message to be displayed.DeviceException - for standard reasons as documented in DeviceException.void showText(int lineIndex,
java.lang.String message,
boolean voicePrompt)
throws DeviceException
lineIndex - The line number (e.g., 0 or 1) where the message should be displayed.message - The text message to be displayed.voicePrompt - voicePrompt Indicates whether a voice prompt should be played (true/false). Currently not supported.DeviceException - for standard reasons as documented in DeviceException.void clearText()
throws DeviceException
DeviceException - for standard reasons as documented in DeviceException.void updateMasterKey(int masterKeyID,
byte[] oldMasterKey,
byte[] newMasterKey)
throws DeviceException
masterKeyID - The index of the master key to be updated.oldMasterKey - The current master key.newMasterKey - The new master key to replace the old one.DeviceException - for standard reasons as documented in DeviceException.void updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue)
throws DeviceException
masterKeyID - Index of the master key.userKeyID - Index of the user key.cipherNewUserKey - New user key encrypted with the master key.checkType - Type of check value used: CHECK_TYPE_NONE or CHECK_TYPE_CUP.checkValue - Check value for the key.DeviceException - for standard reasons as documented in DeviceException.void updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int userKeyType)
throws DeviceException
masterKeyID - Index of the master key.userKeyID - Index of the user key.cipherNewUserKey - New user key encrypted with the master key.userKeyType - Type of user key used: USER_KEY_ID_PIN, USER_KEY_ID_MAC or USER_KEY_ID_DATA.DeviceException - for standard reasons as documented in DeviceException.void updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey)
throws DeviceException
masterKeyID - Index of the master key.userKeyID - Index of the user key.cipherNewUserKey - New user key encrypted with the master key.DeviceException - for standard reasons as documented in DeviceException.byte[] encryptData(KeyInfo keyInfo, byte[] plain) throws DeviceException
keyInfo - Details of the key used for encryption.plain - The plain data to be encrypted.DeviceException - for standard reasons as documented in DeviceException.void listenForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, OperationListener listener, int timeout) throws DeviceException
cancelRequest() in case of a timeout.keyInfo - Key configuration for PIN calculation.pan - ASCII string of the card number.voicePrompt - If true, plays audio for user notification.listener - Receives operation results.timeout - Maximum time to wait for input in milliseconds. Note:
* - If 'timeout' equals 'FOREVER', waits indefinitely for input.
* - If 'timeout' equals 'IMMEDIATE', immediately processes the input.DeviceException - for standard reasons as documented in DeviceException.PINPadOperationResult waitForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, int timeout) throws DeviceException
keyInfo - Key configuration for PIN calculation.pan - ASCII string of the card number.voicePrompt - If true, plays audio for user notification.timeout - Maximum time to wait for input in milliseconds. Note:
- If 'timeout' equals 'FOREVER', waits indefinitely for input.
- If 'timeout' equals 'IMMEDIATE', immediately processes the input.DeviceException - for standard reasons as documented in DeviceException.PINPadOperationResult waitForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, int timeout, int mode, byte[] IV) throws DeviceException
keyInfo - Key configuration for PIN calculation.pan - ASCII string of the card number.voicePrompt - If true, plays audio for user notification.timeout - Maximum time to wait for input in milliseconds. Note:
- If 'timeout' equals 'FOREVER', waits indefinitely for input.
- If 'timeout' equals 'IMMEDIATE', immediately processes the input.mode - Encryption mode (default 0(mode none), MODE_ESP: 10).IV - Initialization Vector, required for MODE_ESP, 8 bytes.DeviceException - for standard reasons as documented in DeviceException.void listenForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, OperationListener listener, int timeout, int mode, byte[] IV) throws DeviceException
keyInfo - Key configuration for PIN calculation.pan - ASCII string of the card number.voicePrompt - If true, plays audio for user notification.listener - Receives operation results.timeout - Maximum time to wait for input in milliseconds.Note:
- If 'timeout' equals 'FOREVER', waits indefinitely for input.
- If 'timeout' equals 'IMMEDIATE', immediately processes the input.mode - Encryption mode (default 0(mode none), MODE_ESP: 10).IV - Initialization Vector, required for MODE_ESP, 8 bytes.DeviceException - for standard reasons as documented in DeviceException.void listenForOfflinePin(boolean voicePrompt,
OperationListener listener,
int timeout)
throws DeviceException
voicePrompt - If true, plays audio to notify the user.listener - The operation listener that will receive the result.timeout - Maximum time to wait for input, in milliseconds. Note:
- If 'timeout' equals 'FOREVER', waits indefinitely for input.
- If 'timeout' equals 'IMMEDIATE', immediately processes the input.DeviceException - for standard reasons as documented in DeviceException.PINPadOperationResult waitForOfflinePin(boolean voicePrompt, int timeout) throws DeviceException
voicePrompt - If true, plays audio to notify the user.timeout - Maximum time to wait for input, in milliseconds.DeviceException - for standard reasons as documented in DeviceException.byte[] calculateMac(KeyInfo keyInfo, int macFlag, byte[] plain) throws DeviceException
keyInfo - Key configuration used for MAC calculation.macFlag - Algorithm flag for MAC calculation:
plain - Data for which the MAC is to be calculated.DeviceException - for standard reasons as documented in DeviceException.void setPINLength(int minLen,
int maxLen)
throws DeviceException
minLen - The minimum length of the PIN.maxLen - The maximum length of the PIN.DeviceException - for standard reasons as documented in DeviceException.java.lang.String getSN()
throws DeviceException
DeviceException - for standard reasons as documented in DeviceException.byte[] getRandom(int length)
throws DeviceException
length - The length of the random data to be generated.DeviceException - for standard reasons as documented in DeviceException.void updateUserKeyWithCheck(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int userKeyType,
byte[] checkValue,
int algoCheckValue)
throws DeviceException
masterKeyID - Master key indexuserKeyID - User key indexcipherNewUserKey - ciphered user keyuserKeyType - user key type. 0--PIN key;1--MAC key;2--Data keycheckValue - check value of user keyalgoCheckValue - algorithm of calculate the checkvalue used: ALGO_CHECK_VALUE_DEFAULT or ALGO_CHECK_VALUE_SE919.DeviceException - for the standard reasons that are documented in
DeviceException.void updateMasterKeyWithCheck(int masterKeyID,
byte[] cipherNewMasterKey,
byte[] checkValue,
int algoCheckValue)
throws DeviceException
masterKeyID - Master key index.cipherNewMasterKey - Ciphered new master key.checkValue - Check value for the key.algoCheckValue - Algorithm used for check value calculation: ALGO_CHECK_VALUE_DEFAULT or ALGO_CHECK_VALUE_SE919.DeviceException - for standard reasons as documented in DeviceException.void updateMasterKeyWithCheckByMK(int masterKeyID,
byte[] cipherNewMasterKey,
byte[] checkValue,
int algoCheckValue)
throws DeviceException
masterKeyID - Master key index.cipherNewMasterKey - Ciphered new master key, encrypted by the old master key.checkValue - Check value for the key.algoCheckValue - Algorithm used for check value calculation: ALGO_CHECK_VALUE_DEFAULT or ALGO_CHECK_VALUE_SE919.DeviceException - for standard reasons as documented in DeviceException.byte[] encryptData(KeyInfo keyInfo, byte[] plain, int mode, byte[] IV, int IVLen) throws DeviceException
keyInfo - Information about the key used for encryption.plain - The plain data to be encrypted.mode - Encryption mode: MODE_EBC(0), MODE_CBC(1), MODE_CFB(2) or MODE_OFB.NoPadding(3).IV - Initial vector for the encryption (used in certain modes: CBC, CFB, OFB mode).IVLen - Length of the initial vector, must be equal to block length according to the algorithm.DeviceException - for standard reasons as 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.cipherNewUserKey - Ciphered new user key.checkType - Type of check value used: CHECK_TYPE_NONE or CHECK_TYPE_CUP.checkValue - Check value for the key.keyInfo - Key configuration used for PIN calculation(used in JNI:selectKey).DeviceException - for standard reasons as documented in DeviceException.int updateUserKeyWithTR31Format(int masterKeyID,
int userKeyID,
byte[] tr31Msg)
throws DeviceException
masterKeyID - Index of the master key.userKeyID - Index of the user key to be updated.tr31Msg - TR31 formatted key update message.DeviceException - for standard reasons as documented in DeviceException.byte[] getSessionKeyCheckValue(int masterKeyID,
int userKeyID,
int algoCheckValue)
throws DeviceException
masterKeyID - Index of the master key.userKeyID - Index of the user key.algoCheckValue - Algorithm used for the check value calculation: ALGO_CHECK_VALUE_DEFAULT or ALGO_CHECK_VALUE_SE919.DeviceException - for standard reasons as documented in DeviceException.boolean verifyResponseMac(KeyInfo keyInfo, byte[] plainData, int macFlag, byte[] macData, int nDirection) throws DeviceException
keyInfo - Key configuration used for MAC verification.plainData - Data used for MAC calculation.macFlag - MAC calculation algorithm flag:
macData - MAC data to verify.nDirection - Reserved for future use, currently should be set to 0.DeviceException - for standard reasons as documented in DeviceException.byte[] calculateResponseMac(KeyInfo keyInfo, byte[] plainData, int macFlag) throws DeviceException
keyInfo - Configuration settings for the PINPad to calculate the MAC.plainData - The data for which the MAC is to be calculated.macFlag - Specifies the algorithm to be used for MAC calculation, with the following options:
DeviceException - for standard reasons as documented in DeviceException.boolean setGUIConfiguration(int flag,
byte[] data)
throws DeviceException
flag - Determines the setting to be adjusted (1, 2, or 3).data - Specifies the configuration based on the flag.
| flag | data |
|---|---|
| 1 | 0x00(Left)/0x01(Center)/0x02(Right) |
| 2 | content of title |
| 3 | data[0] = 0 default normal virtual data[0] = 1 big virtual data[0] = 2 Q3K data[0] = 3 horizontal virtual, landscape orientation data[0] = 4 Function button in bottom |
DeviceException - for standard reasons as documented in DeviceException.boolean setGUIConfiguration(java.lang.String key,
java.lang.String value)
throws DeviceException
key - The setting to configure (e.g., style, sound).value - The desired value for the setting.
| key | value | default |
|---|---|---|
| style | system | system |
| sound | true/false | false |
| displaybackcolor | RGB color | #6C8C4F |
| inputtextcolor | RGB color | #FFFFFF |
| disablebackgrounddarkening | true/false | false |
DeviceException - for standard reasons as documented in DeviceException.int getMkStatus(int mkId)
throws DeviceException
mkId - The index of the master key.DeviceException - for standard reasons as documented in DeviceException.int getSkStatus(int mkId,
int skID)
throws DeviceException
mkId - The master key index.skID - The session key index.DeviceException - for standard reasons as documented in DeviceException.int getDukptStatus(int dukptID,
byte[] KSNBuf)
throws DeviceException
dukptID - The DUKPT key index.KSNBuf - Buffer to store the Key Serial Number.DeviceException - for standard reasons as documented in DeviceException.boolean setAllowByPass(boolean allow)
throws DeviceException
allow - Set to true to allow bypassing, false to disallow.DeviceException - for standard reasons as documented in DeviceException.boolean setupCallbackHandler(com.cloudpos.jniinterface.PinPadCallbackHandler handler)
throws DeviceException
handler - The callback handler for UI customization.DeviceException - for standard reasons as documented in DeviceException.int changePin(KeyInfo keyInfo, byte[] cardNum, byte[] pinOld, byte[] pinNew, int[] lengthResult, int timeout) throws DeviceException
keyInfo - Key configuration for calculation.cardNum - Card number.pinOld - Old PIN.pinNew - New PIN.lengthResult - Result of the length.timeout - Time to wait for input in milliseconds.DeviceException - for standard reasons as documented in DeviceException.int createPin(KeyInfo keyInfo, byte[] cardNum, byte[] pinNew, int timeout, int nFlagSound) throws DeviceException
keyInfo - Key configuration for calculation.cardNum - Card number in ASCII.pinNew - Buffer to store the new PIN block.timeout - Timeout for user input in milliseconds, negative for indefinite wait.nFlagSound - Flag for voice prompt (0 for none, 1 for prompt).DeviceException - for standard reasons as documented in DeviceException.int selectPinblockFormat(int nPinblockFormat)
throws DeviceException
nPinblockFormat - Format index (0~5, ISO0/ISO1/ISO2/ISO3/ISO4/SM4).DeviceException - for standard reasons as documented in DeviceException.int getLastPINLength()
throws DeviceException
DeviceException - for standard reasons as documented in DeviceException.