Skip to content

Commit

Permalink
Fix new method calculateCVV and verifyCVV names
Browse files Browse the repository at this point in the history
Correction names of methods calculateCVV and verifyCVV introduced in 74437d0
CVD (Card Verification Digit) is more general. It embrace CVV and CVC.
So the methods will be called: calculateCVD and verifyCVD
  • Loading branch information
demsey committed May 18, 2019
1 parent 86fc240 commit 0ce239d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions jpos/src/main/java/org/jpos/security/BaseSMAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ public String calculateCVV(String accountNo, T cvkA, T cvkB,
}

@Override
public String calculateCVV(String accountNo, T cvkA, T cvkB,
public String calculateCVD(String accountNo, T cvkA, T cvkB,
String expDate, String serviceCode) throws SMException {

List<Loggeable> cmdParameters = new ArrayList<>();
Expand All @@ -768,7 +768,7 @@ public String calculateCVV(String accountNo, T cvkA, T cvkB,
evt.addMessage(new SimpleMsg("command", "Calculate CVV/CVC", cmdParameters));
String result = null;
try {
result = calculateCVVImpl(accountNo, cvkA, cvkB, expDate, serviceCode);
result = calculateCVDImpl(accountNo, cvkA, cvkB, expDate, serviceCode);
evt.addMessage(new SimpleMsg("result", "Calculated CVV/CVC", result));
} catch (Exception e) {
evt.addMessage(e);
Expand Down Expand Up @@ -830,7 +830,7 @@ public boolean verifyCVV(String accountNo , T cvkA, T cvkB,
}

@Override
public boolean verifyCVV(String accountNo, T cvkA, T cvkB,
public boolean verifyCVD(String accountNo, T cvkA, T cvkB,
String cvv, String expDate, String serviceCode) throws SMException {

List<Loggeable> cmdParameters = new ArrayList<>();
Expand Down Expand Up @@ -1830,10 +1830,10 @@ protected String calculateCVVImpl(String accountNo, T cvkA, T cvkB,
* @param cvkB
* @param expDate
* @param serviceCode
* @return Card Verification Code/Value
* @return Card Verification Digit (Code/Value)
* @throws SMException
*/
protected String calculateCVVImpl(String accountNo, T cvkA, T cvkB,
protected String calculateCVDImpl(String accountNo, T cvkA, T cvkB,
String expDate, String serviceCode) throws SMException {
throw new UnsupportedOperationException("Operation not supported in: " + this.getClass().getName());
}
Expand Down
18 changes: 9 additions & 9 deletions jpos/src/main/java/org/jpos/security/SMAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ EncryptedPIN deriveIBMPIN(String accountNo, T pvk


/**
* Calaculate a Card Verification Code/Value
* Calaculate a Card Verification Code/Value.
*
* <p>NOTE: {@code cvkA} and {@code cvkB} should be single
* length keys but at least one of them may be double length key
Expand All @@ -837,7 +837,7 @@ EncryptedPIN deriveIBMPIN(String accountNo, T pvk
* @throws SMException
* @deprecated Issuers do not always follow the recommended 'yyMM' format.
* Using the {@code java.util.Date} prevents from format manipulating to
* solve problem. Use {@link #calculateCVV} with string version of {@code expDate}
* solve problem. Use {@link #calculateCVD} with string version of {@code expDate}
*/
@Deprecated
String calculateCVV(String accountNo, T cvkA, T cvkB,
Expand All @@ -846,7 +846,7 @@ String calculateCVV(String accountNo, T cvkA, T cvkB,


/**
* Calaculate a Card Verification Code/Value
* Calaculate a Card Verification Digit (Code/Value).
*
* <p>NOTE: {@code cvkA} and {@code cvkB} should be single
* length keys but at least one of them may be double length key
Expand All @@ -862,10 +862,10 @@ String calculateCVV(String accountNo, T cvkA, T cvkB,
* <li>"000" for printing CVV2/CVC2 on card's signature stripe</li>
* <li>"999" for inclusion iCVV/Chip CVC on EMV chip card</li>
* </ul>
* @return Card Verification Code/Value
* @return Card Verification Digit (Code/Value)
* @throws SMException
*/
String calculateCVV(String accountNo, T cvkA, T cvkB,
String calculateCVD(String accountNo, T cvkA, T cvkB,
String expDate, String serviceCode) throws SMException;


Expand Down Expand Up @@ -900,7 +900,7 @@ String calculateCAVV(String accountNo, T cvk, String upn,
String authrc, String sfarc) throws SMException;

/**
* Verify a Card Verification Code/Value
* Verify a Card Verification Code/Value.
*
* <p>NOTE: {@code cvkA} and {@code cvkB} should be single
* length keys but at least one of them may be double length key
Expand All @@ -921,15 +921,15 @@ String calculateCAVV(String accountNo, T cvk, String upn,
* @throws SMException
* @deprecated Issuers do not always follow the recommended 'yyMM' format.
* Using the {@code java.util.Date} prevents from format manipulating to
* solve problem. Use {@link #verifyCVV} with string version of {@code expDate}
* solve problem. Use {@link #verifyCVD} with string version of {@code expDate}
*/
@Deprecated
boolean verifyCVV(String accountNo, T cvkA, T cvkB,
String cvv, Date expDate, String serviceCode) throws SMException;


/**
* Verify a Card Verification Code/Value
* Verify a Card Verification Digit (Code/Value).
*
* <p>NOTE: {@code cvkA} and {@code cvkB} should be single
* length keys but at least one of them may be double length key
Expand All @@ -949,7 +949,7 @@ boolean verifyCVV(String accountNo, T cvkA, T cvkB,
* @return {@code true} if CVV/CVC is valid or {@code false} otherwise
* @throws SMException
*/
boolean verifyCVV(String accountNo, T cvkA, T cvkB,
boolean verifyCVD(String accountNo, T cvkA, T cvkB,
String cvv, String expDate, String serviceCode) throws SMException;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ protected String calculateCVVImpl(String accountNo, SecureDESKey cvkA, SecureDES
}

@Override
protected String calculateCVVImpl(String accountNo, SecureDESKey cvkA, SecureDESKey cvkB,
protected String calculateCVDImpl(String accountNo, SecureDESKey cvkA, SecureDESKey cvkB,
String expDate, String serviceCode) throws SMException {
return calculateCVD(accountNo, concatKeys(cvkA, cvkB), expDate, serviceCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,42 +697,42 @@ public void testTranslatePINImpl() throws Throwable {
}

@Test
public void testCalculateCVVImpl1() throws Throwable {
public void testCalculateCVDImpl1() throws Throwable {
String accountNo = "123456789012";
String expDate = "1108";
String serviceCode = "000";
String expected = "204";
String cvv = jcesecmod.calculateCVV(accountNo, cvk, null, expDate, serviceCode);
String cvv = jcesecmod.calculateCVD(accountNo, cvk, null, expDate, serviceCode);
assertEquals(expected, cvv);
}

@Test
public void testVerifyCVVImpl1() throws Throwable {
public void testVerifyCVDImpl1() throws Throwable {
String accountNo = "123456789012";
String expDate = "1108";
String serviceCode = "000";
String cvv = "204";
boolean result = jcesecmod.verifyCVV(accountNo, cvk, null, cvv, expDate, serviceCode);
boolean result = jcesecmod.verifyCVD(accountNo, cvk, null, cvv, expDate, serviceCode);
assertTrue(result);
}

@Test
public void testCalculateCVVImpl2() throws Throwable {
public void testCalculateCVDImpl2() throws Throwable {
String accountNo = "123456789012";
String expDate = "1108";
String serviceCode = "000";
String expected = "453";
String cvv = jcesecmod.calculateCVV(accountNo, cvkA, cvkB, expDate, serviceCode);
String cvv = jcesecmod.calculateCVD(accountNo, cvkA, cvkB, expDate, serviceCode);
assertEquals(expected, cvv);
}

@Test
public void testVerifyCVVImpl2() throws Throwable {
public void testVerifyCVDImpl2() throws Throwable {
String accountNo = "123456789012";
String expDate = "1108";
String serviceCode = "000";
String cvv = "453";
boolean result = jcesecmod.verifyCVV(accountNo, cvkA, cvkB, cvv, expDate, serviceCode);
boolean result = jcesecmod.verifyCVD(accountNo, cvkA, cvkB, cvv, expDate, serviceCode);
assertTrue(result);
}

Expand Down

0 comments on commit 0ce239d

Please sign in to comment.