get()
get() API gets the plaintext value associated with a token or an array of tokens. This method is overloaded to handle customData, token arrays, customData, and saveExceptions.
Note
The plaintext value for token generated using insertIrreversibleToken() method will not be returned, instead it will return the string value “Irreversible Token”.
saveExceptions is the toggle for “Smart Check” option, see Smart Check.
Syntax
public String get (String token, String table, int format) throws TokenException
public String get (String token, String customData, String table, int format) throws TokenException
public String[] get (String[] token, String table, int format) throws TokenException
public String[] get (String[] token, String[] customData, String table, int format) throws TokenException
public TmResult get (String[] token, String[] customData, String table, int format, boolean saveExceptions) throws TokenException
Request Parameters
Parameters | Data Types | Descriptions |
---|---|---|
token | string | A token corresponds to an encrypted value, or an array of such tokens. |
customData | string | Customer-specific data. |
table | string | This is the Token Vault name and it must be in CAPITAL LETTERS. |
format | integer | The format of the returned value. Use one of the following options to set the masking format of the returned value: • MaskingFormat.SHOW_ALL or 0: shows all characters of a plaintext value. For example, 1234879345619370• MaskingFormat.SHOW_FIRST_SIX or 1: shows only the first six characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as 123456XXXXXXXXXX.• MaskingFormat.SHOW_FIRST_TWO_LAST_FOUR or 2: shows only the first two and last four characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as 12XXXXXXXXXX3456.• MaskingFormat.SHOW_FIRST_SIX_LAST_FOUR or 3: shows only the first six and last four characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as 123456XXXXXX1234.• MaskingFormat.SHOW_LAST_FOUR or TokenService.MASK_TOKEN or 6: shows only the last four characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as XXXXXXXXXXXX1234.• Masking format ID can be generated using the createMaskingFormat API. |
saveExceptions | boolean | boolean indicating if the Smart Check feature should be applied. (See Smart Check) When set to true, the feature is applied. |
Note
For My SQL, if the customData parameter is null or empty, then the get() API returns results for all customData values in token vault.
Returned values
Returned either one of the following.
A decrypted value.
An array of decrypted value(s).
TmResult (an object) which provides array of decrypted values, error indexes and messages.
Exception
Throws TokenException
if:
The table is missing.
The token is null or invalid.
The CT-V cannot decrypt the value.
The token and customData arrays do not have the same number of elements.
A customData element is too long or too short.
Example
get("5541997351273456", "CREDIT_CARD_NUMBERS", TokenService.MASK_TOKEN).
The method does the following:
Looks up the encryption key for the Credit_Card_Numbers row in the key table.
Requests the key from the Key Manager.
Uses the token to find the ciphertext in the token vault.
Decrypts the ciphertext.
Returns the plaintext in the masked format (XXXXXXXXXXXX3456).
The last parameter controls the plaintext format. To mask the original value in X’s and reveal only the last four digits, use TokenService.MASK_TOKEN as shown above. To return the full plaintext, call get("5541997351273456", "CREDIT_CARD_NUMBERS", 0).