|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.ibm.etill.ldbcardcassette.LdbCardCassette.LuhnStringValidationItem
This class converts a parameter's value from a byte array into a string and then validates that the result passes the Luhn check.
Credit Card numbers are (most times) 13 to 16 digit numbers which are protected by a special numerical check, called Luhn check. From right to left, each digit is multiplied by the alternating factors 1 and 2 (the rightmost digit is always multiplied by 1). For each result, the digits are summed together. Then, these sums are totaled. Finally, to be a valid Credit Card number, the total must be evenly divisible by 10.
Example (Credit Card number: 1234 5678 7654 3210):
First, start from the right and multiply each digit by an alternating factor of 1 and 2. 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0 * * * * * * * * * * * * * * * * 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 = = = = = = = = = = = = = = = = 2 2 6 4 10 12 14 16 14 12 10 4 6 2 2 0
Sum the digits in the results. 2 2 6 4 (1+0) (1+2) (1+4) (1+6) (1+4) (1+2) (1+0) 4 6 2 2 0
Total the sums from above. 2 + 2 + 6 + 5 + 1 + 3 + 5 + 7 + 5 + 3 + 1 + 4 + 6 + 2 + 2 + 0 = 60
Divide the sum by 10 and if the remainder is 0 the value is valid. 60 % 10 = 0 so this number is valid.
Field Summary | |
private static int[] |
clsLuhnValue
The Luhn value of a given digit depends on the alternating factor that is applied to the digit. |
Constructor Summary | |
LdbCardCassette.LuhnStringValidationItem(java.lang.String argParameter,
short argSecondaryReturnCode,
boolean argNullValuesAllowed,
int argMinLength,
int argMaxLength)
This constructor is used to create a Luhn String Validation item. |
Method Summary | |
java.lang.Object |
validateAndInsertValue(byte[] argValue,
com.ibm.etill.framework.payapi.ParameterTable argResultTable)
This method uses the parent's method to convert the byte array into a string and validate that the result is not too long or too short. |
Field Detail |
private static final int[] clsLuhnValue
Constructor Detail |
public LdbCardCassette.LuhnStringValidationItem(java.lang.String argParameter, short argSecondaryReturnCode, boolean argNullValuesAllowed, int argMinLength, int argMaxLength)
argParameter
- - the parameter keyword whose value is to
be validatedargSecondaryReturnCode
- - the secondary return code used
to identify the parameter when it is invalidargNullValuesAllowed
- - a flag that specifies whether or
not the parameter value can be nullargMinLength
- - the minimum length of a valid stringargMaxLength
- - the maximum length of a valid stringMethod Detail |
public java.lang.Object validateAndInsertValue(byte[] argValue, com.ibm.etill.framework.payapi.ParameterTable argResultTable) throws com.ibm.etill.framework.payapi.ETillAbortOperation
argValue
- - the value passed by the merchantargResultTable
- - the parameter table to be passed to the
cassette
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |