createNewFormat()
createNewFormat() API creates a new token format which can be used with the insert() method.
Syntax
public int createNewFormat (int leadPositions, int trailPositions, String leadMask, int luhnCheck) throws TokenException
public int createNewFormat (int leadPositions, int trailPositions, String leadMask, int luhnCheck, int tokenLength) throws TokenException
public int createNewFormat (int formatForToken, int minLength, int maxLength, String leadMask)
public int createNewFormat (String description, String splitter, String splicer) throws TokenException
This API is overloaded to account these parameters:
tokenLength
(Optional)String
tokenFormat
, Stringsplitter
, and Stringsplicer
(All required)
Tip
The API listed above immediately simplifies the process of creating new formats, by using Java regular expression syntax. As indicated, this API requires the format name and two pieces of data. For more information, refer to Create Custom Token Formats with Java Regular Expressions.
Request Paramters
Parameters | Data Types | Descriptions |
---|---|---|
leadPositions | integer | Number of positions to preserve (if any) on the left side of the value. |
trailPositions | integer | Number of positions to preserve (if any) on the right side of the value. |
leadMask | string | A fixed number of digits to mask the leading positions. For example, if leadMask is set to 7777, the first four digits of the token will be 7’s. When leadMask is set, the leadPositions value is ignored. For example, for input value 1234 5678 9012 3456, setting leadMask to 7777 and leadPosition to 6 results in 7777 8031 4902 1531 and not 7777 5631 4902 1531. |
luhnCheck | integer | Indicates if the token should fail the check (-1), pass the check (1), or does not matter (0). |
tokenLength | integer | This parameter is optional. it indicates the length of the token if it is different from the input data. tokenLength cannot be larger than the Token Vault’s token column. |
splitter | string | Splits the input value(s) into groups. |
splicer | string | Combines groups into resulting token. |
minLength | integer | Minimum length of the token. |
maxLength | integer | Maximum length of the token. |
ITokenGenerator | Allows users to create custom tokenization functions that define the way data is tokenized. | |
ITokenValidator | Allows users to create custom token validation functions, even though CT-V still creates the token. |
Note
leadPositions + trailPositions or leadMask + trailPositions cannot be larger than the token length. Either the value set in the tokenLength parameter or in the Token Vault’s token column. If this rule is ignored, an exception is thrown.
Returned Value
Returns integer as the new token format. The value will be greater than 100.
Exception
Throws TokenException
if the below parameters are invalid or the tokenLength is negative or longer than 256 characters.
leadPositions
trailPositions
leadMask
luhnCheck
Example
int tokenFormat = createNewFormat(7, 0, null, 1);
A token is created which retains the first 7 characters of the input value and passes the luhn check. You can then use this new token format in the insert() method, like this:
String token = TokenService.insert(creditCard, tokenVault1, tokenFormat, true);