├── cardgui ├── .gitignore ├── cardgui.jpg ├── src │ ├── lib │ │ └── images.jar │ ├── main │ │ ├── resources │ │ │ └── log4j.properties │ │ └── java │ │ │ ├── com │ │ │ └── indarsoft │ │ │ │ ├── cardgui │ │ │ │ ├── Main.java │ │ │ │ ├── FrmAlert.java │ │ │ │ ├── MainComposite.java │ │ │ │ ├── FrmControls.java │ │ │ │ ├── keys │ │ │ │ │ └── LoadKeysFrm.java │ │ │ │ └── card │ │ │ │ │ └── CardFrm.java │ │ │ │ └── cardutl │ │ │ │ ├── beans │ │ │ │ ├── PinBlockKey.java │ │ │ │ ├── BinKey.java │ │ │ │ └── ProcessedCardData.java │ │ │ │ ├── xml │ │ │ │ ├── XmlKeyData.java │ │ │ │ └── LoadXmlKeys.java │ │ │ │ ├── file │ │ │ │ └── CardFile.java │ │ │ │ ├── card │ │ │ │ └── ProcessCard.java │ │ │ │ └── batch │ │ │ │ └── Main.java │ │ │ └── org │ │ │ └── eclipse │ │ │ └── wb │ │ │ └── swt │ │ │ └── SWTResourceManager.java │ └── test │ │ └── java │ │ └── com │ │ └── indarsoft │ │ └── cardutl │ │ └── test │ │ ├── CardFileTest.java │ │ └── LoadXmlKeysTest.java ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.jboss.ide.eclipse.as.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── cardgui.bat ├── data │ ├── cards.txt │ ├── cards.txt.out │ └── config │ │ ├── key_old.xml │ │ └── key.xml ├── cardutl.bat ├── .project ├── resources │ └── log4j.properties ├── .classpath ├── readme.txt ├── pom.xml └── log │ └── cryptocardutl.log ├── DEPENDENCIES.txt ├── README.md └── LICENSE /cardgui/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /cardgui/cardgui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jporras66/cardgui/HEAD/cardgui/cardgui.jpg -------------------------------------------------------------------------------- /cardgui/src/lib/images.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jporras66/cardgui/HEAD/cardgui/src/lib/images.jar -------------------------------------------------------------------------------- /cardgui/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cardgui/.settings/org.jboss.ide.eclipse.as.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.jboss.ide.eclipse.as.core.singledeployable.deployableList=src/main/java/es/indarsoft/cryptocard/symmetrickey/Zpk.java\n 3 | -------------------------------------------------------------------------------- /cardgui/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | encoding/data=UTF-8 7 | -------------------------------------------------------------------------------- /cardgui/cardgui.bat: -------------------------------------------------------------------------------- 1 | REM @ECHO OFF 2 | REM 3 | REM 4 | SET JRE_HOME="C:\Java\jdk1.8.0_92" 5 | REM 6 | SET JRE=%JRE_HOME% 7 | SET PATH=%JRE%\bin;%PATH% 8 | SET CLASSPATH=%JRE_HOME%\jre\lib;.\data\config 9 | REM 10 | %JRE%\bin\java -jar cryptocardUtl-1.0.0.jar 11 | REM -------------------------------------------------------------------------------- /DEPENDENCIES.txt: -------------------------------------------------------------------------------- 1 | Tools 2 | ======== 3 | - JDK 1.6.x or above 4 | - Maven 5 | 6 | Software Packages 7 | ================= 8 | - utl-1.0.0.jar https://github.com/jporras66/utilities 9 | - cryptocard-1.0.0.jar https://github.com/jporras66/cryptocard 10 | 11 | First you need to download an build both jar libs 12 | -------------------------------------------------------------------------------- /cardgui/data/cards.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Card Number Service ExpDate Dki PinValType Pvv PinBlock 3 | # Code (YYMM) Offset Type 4 | # 5 | 4000000000000002 201 1601 1 VISA_PVV 3309 ISOFORMAT0 6 | 5200000000000007 201 1601 1 IBM_OFFSET 6441 ISOFORMAT0 7 | 5300000000000006 201 1601 1 IBM_OFFSET 6441 ISOFORMAT0 8 | 9704151300007029 201 1601 1 IBM_OFFSET 353235 ISOFORMAT0 9 | # 10 | 11 | -------------------------------------------------------------------------------- /cardgui/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Define the root logger with appender file 3 | #log = /usr/home/log4j 4 | # 5 | log = ./log 6 | log4j.rootLogger = DEBUG, FILE 7 | 8 | # Define the file appender 9 | log4j.appender.FILE=org.apache.log4j.FileAppender 10 | log4j.appender.FILE.File=${log}/cryptocardutl.log 11 | 12 | # Define the layout for file appender 13 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 14 | #log4j.appender.FILE.layout.conversionPattern=%m%n 15 | log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %t %x %5p %10c # %m%n 16 | # -------------------------------------------------------------------------------- /cardgui/cardutl.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM 3 | REM Parameters : 4 | REM data directory 5 | REM data\config directory 6 | REM 7 | REM 8 | SET JRE_HOME="C:\Java\jdk1.8.0_92" 9 | REM 10 | SET JRE=%JRE_HOME% 11 | SET PATH=%JRE%\bin;%PATH% 12 | SET CLASSPATH=%JRE_HOME%\jre\lib;.\data\config 13 | REM 14 | REM Usage is : cardutl.bat 15 | REM 16 | REM 17 | REM %JRE%\bin\java -cp cryptocardUtl-1.0.0.jar es.indarsoft.cardutl.batch.Main %1 %2 18 | %JRE%\bin\java -cp cryptocardUtl-1.0.0.jar es.indarsoft.cardutl.batch.Main cards.txt key.xml 19 | REM -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardgui/Main.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardgui; 2 | 3 | import org.eclipse.jface.window.*; 4 | import org.eclipse.swt.widgets.*; 5 | 6 | public class Main extends ApplicationWindow { 7 | 8 | public Main() { 9 | super(null); 10 | } 11 | 12 | protected Control createContents(Composite parent) { 13 | 14 | @SuppressWarnings("unused") 15 | MainComposite mc = new MainComposite(parent); 16 | return parent; 17 | } 18 | 19 | public static void main(String[] args) { 20 | Main mn = new Main(); 21 | mn.setBlockOnOpen(true); 22 | mn.open(); 23 | Display.getCurrent().dispose(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /cardgui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | cardgui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardgui/FrmAlert.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardgui; 2 | 3 | import org.eclipse.swt.SWT; 4 | import org.eclipse.swt.widgets.MessageBox; 5 | import org.eclipse.swt.widgets.Shell; 6 | 7 | public class FrmAlert { 8 | 9 | public FrmAlert(Shell sh, String msg) { 10 | 11 | MessageBox messageBox = new MessageBox(sh, SWT.ICON_ERROR | SWT.ABORT); 12 | 13 | messageBox.setText("Error !!"); 14 | messageBox.setMessage(msg); 15 | int buttonID = messageBox.open(); 16 | switch (buttonID) { 17 | case SWT.YES: 18 | // saves changes ... 19 | case SWT.NO: 20 | // exits here ... 21 | break; 22 | case SWT.CANCEL: 23 | // does nothing ... 24 | } 25 | // System.out.println(buttonID); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cardgui/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.8 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 13 | org.eclipse.jdt.core.compiler.release=disabled 14 | org.eclipse.jdt.core.compiler.source=1.8 15 | -------------------------------------------------------------------------------- /cardgui/data/cards.txt.out: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # Card Number Service ExpDate Dki PinValType PinValDat Pvv/ Pin cvv icvv cvv2 Track2 PinBlock Clear Encrypted 4 | # Code (YYMM) Offset cvc icvc cvc2 Type Pinblock Pinblock 5 | # 6 | 4000000000000002 201 1601 1 VISA_PVV N/A 3309 1111 481 177 779 4000000000000002=160120113309481 ISOFORMAT0 041111FFFFFFFFFF C117B58700DAE402 7 | 5200000000000007 201 1601 1 IBM_OFFSET THALES8000 6441 1111 314 304 517 5200000000000007D16012011314 ISOFORMAT0 041111FFFFFFFFFF C117B58700DAE402 8 | 5300000000000006 201 1601 1 IBM_OFFSET THALES7000 6441 8866 929 518 329 5300000000000006D16012011929 ISOFORMAT0 048866FFFFFFFFFF 2D71AFD5298DBDCF 9 | 9704151300007029 201 1601 1 IBM_OFFSET THALES7000 353235 345678 203 405 059 9704151300007029D16012011203 ISOFORMAT0 06341729CFFFF8FD 209CD458155075F5 10 | -------------------------------------------------------------------------------- /cardgui/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # http://www.tutorialspoint.com/log4j/log4j_logging_files.htm 3 | # 4 | # Define the root logger with appender file 5 | #log = /usr/home/log4j 6 | # 7 | log = ./log 8 | #log4j.rootLogger = DEBUG, FILE 9 | log4j.rootLogger=DEBUG, stdout 10 | 11 | # Define the file appender 12 | log4j.appender.FILE=org.apache.log4j.FileAppender 13 | log4j.appender.FILE.File=${log}/iso8583core.log 14 | 15 | 16 | # Define the layout for file appender 17 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 18 | log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %t %x %5p %10c # %m%n 19 | # 20 | # Direct log messages to stdout 21 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 22 | log4j.appender.stdout.Target=System.out 23 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 24 | #log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 25 | #log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %t %x %5p %10c # %m%n 26 | # -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardgui/MainComposite.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardgui; 2 | 3 | import org.eclipse.swt.SWT; 4 | import org.eclipse.swt.widgets.Composite; 5 | 6 | import com.indarsoft.cardgui.card.CardFrm; 7 | 8 | public class MainComposite extends Composite { 9 | 10 | protected CardFrm cardfrm; 11 | 12 | // protected LoadKeysFrm lkfrm ; 13 | // protected String panNumber = "" ; 14 | 15 | public MainComposite(Composite parent) { 16 | 17 | super(parent, SWT.NONE); 18 | parent.getShell().setText("CryptoCard GUI"); 19 | 20 | cardfrm = new CardFrm(this); 21 | cardfrm.setLocation(0, 0); 22 | cardfrm.pack(); 23 | // 24 | // lkfrm = new LoadKeysFrm(this); 25 | // lkfrm.setLocation(0, 125); 26 | // lkfrm.pack(); 27 | // 28 | pack(); 29 | // setIds(this); 30 | // clearFields() ; 31 | // 32 | } 33 | 34 | protected CardFrm getCardFrm() { 35 | return this.cardfrm; 36 | } 37 | 38 | /* 39 | * protected void setPanNumber (String s){ this.panNumber = s ; } 40 | */ 41 | } -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardutl/beans/PinBlockKey.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardutl.beans; 2 | 3 | import com.indarsoft.cryptocard.symmetrickey.DesKeyException; 4 | import com.indarsoft.cryptocard.symmetrickey.Zpk; 5 | import com.indarsoft.cryptocard.types.PinBlockFormatType; 6 | 7 | public class PinBlockKey { 8 | 9 | private Zpk zpk ; 10 | private PinBlockFormatType pinBlockFormatType ; 11 | 12 | public PinBlockKey (String zpkValue , PinBlockFormatType pinBlockFormatType ) throws DesKeyException { 13 | 14 | /*try { 15 | this.zpk = new Zpk(zpkValue); 16 | this.pinBlockFormatType = pinBlockFormatType ; 17 | } 18 | catch ( Exception ex){ 19 | System.out.println( ex.getMessage() ) ; 20 | throw new Exception(ex.getMessage() ); 21 | }*/ 22 | this.zpk = new Zpk(zpkValue); 23 | this.pinBlockFormatType = pinBlockFormatType ; 24 | } 25 | 26 | public Zpk getZpk(){ 27 | return zpk ; 28 | } 29 | 30 | public PinBlockFormatType getPinBlockFormatType(){ 31 | return pinBlockFormatType ; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardutl/xml/XmlKeyData.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardutl.xml; 2 | 3 | import java.util.Hashtable; 4 | 5 | import com.indarsoft.cardutl.beans.BinKey; 6 | import com.indarsoft.cardutl.beans.PinBlockKey; 7 | 8 | public class XmlKeyData { 9 | // Hashtable de PinBlocks Keys 10 | private Hashtable ahpinBlockKey = new Hashtable(500) ; 11 | // Hashtable de BinNumber Keys 12 | private Hashtable ahBinKey = new Hashtable(500) ; 13 | 14 | public XmlKeyData() { 15 | 16 | } 17 | 18 | public void putPinBlock (PinBlockKey pinBlockKey ) { 19 | String pinBlockFormatType = pinBlockKey.getPinBlockFormatType().toString() ; 20 | ahpinBlockKey.put ( pinBlockFormatType , pinBlockKey ) ; 21 | } 22 | 23 | public PinBlockKey getPinBlock( String pinBlockFormatType ){ 24 | return (PinBlockKey) ahpinBlockKey.get ( pinBlockFormatType ) ; 25 | } 26 | 27 | public void putBinKey(BinKey binKey ){ 28 | ahBinKey.put ( binKey.getBinNumber() , binKey ) ; 29 | } 30 | 31 | public BinKey getBinKey( String binNumber ){ 32 | BinKey b = ahBinKey.get ( binNumber ) ; 33 | //return (BinKey) ahBinKey.get ( binNumber ) ; 34 | return b ; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /cardgui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardgui/FrmControls.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardgui; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.eclipse.swt.widgets.Composite; 6 | import org.eclipse.swt.widgets.Control; 7 | import org.eclipse.swt.widgets.Text; 8 | 9 | public class FrmControls { 10 | 11 | private static final String EMPTY = ""; 12 | private ArrayList ctrl = new ArrayList(); 13 | private Integer count = 0; 14 | 15 | public FrmControls(Composite c) { 16 | 17 | setIds(c); 18 | 19 | } 20 | 21 | private void setIds(Composite cmp) { 22 | 23 | Control[] children = cmp.getChildren(); 24 | for (int j = 0; j < children.length; j++) { 25 | if (children[j] instanceof Composite) { 26 | setIds((Composite) children[j]); 27 | } else { 28 | Control d = children[j]; 29 | d.setData(count); 30 | ctrl.add(d); 31 | // System.out.println("control ID/name : " + d.getData() +"-" + 32 | // d.toString()); 33 | ++count; 34 | } 35 | } 36 | } 37 | 38 | public void clearFields() { 39 | for (int j = 0; j < ctrl.size(); j++) { 40 | Control c = ctrl.get(j); 41 | String str = c.getClass().toString(); 42 | // System.out.println("control class : " + str ) ; 43 | if (str.equals("class org.eclipse.swt.widgets.Text")) { 44 | Text txt = (Text) c; 45 | txt.setText(EMPTY); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /cardgui/data/config/key_old.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0123456789ABCDEF0123456789ABCDEF 6 | 7 | 8 | 9 | 0123456789ABCDEF0123456789ABCDEF 10 | 11 | 12 | 13 | 14 | 15 | 0123456789ABCDEF0123456789ABCDEF 16 | 17 | 18 | 19 | 0123456789ABCDEF0123456789ABCDEF 20 | 0123456789ABCDEF0123456789ABCDEF 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 04 29 | 9876543276543210 30 | 01 31 | 15 32 | F 33 | 0123456789ABCDEF0123456789ABCDEF 34 | 35 | 36 | 37 | 0123456789ABCDEF0123456789ABCDEF 38 | 0123456789ABCDEF0123456789ABCDEF 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /cardgui/src/test/java/com/indarsoft/cardutl/test/CardFileTest.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardutl.test; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | 9 | import org.junit.Test; 10 | 11 | import com.indarsoft.cardutl.file.CardFile; 12 | import com.indarsoft.cryptocard.card.Card; 13 | import com.indarsoft.utl.Utl; 14 | 15 | public class CardFileTest { 16 | 17 | private static final String separator = File.separator ; 18 | private static final String testfilename = "cards.txt"; 19 | 20 | @Test 21 | public void testReadArrayListRecord() { 22 | 23 | String fileName = Utl.getPwd() + separator + "data" + separator + testfilename ; 24 | CardFile u = new CardFile( fileName ) ; 25 | 26 | try{ 27 | ArrayList als = u.readArrayListRecord ( ) ; 28 | for (int i=0; i< als.size(); i++){ 29 | System.out.println("testReadArrayListRecord : " + als.get(i) ); 30 | } 31 | } 32 | catch( IOException e){ 33 | System.out.println ( e.getMessage() ) ; 34 | System.out.println("testReadArrayListRecord : KO !!") ; 35 | assertFalse( true) ; 36 | } 37 | 38 | System.out.println("testReadArrayListRecord : OK !!") ; 39 | assertTrue( true) ; 40 | 41 | } 42 | 43 | @Test 44 | public void testReadArrayListCard() { 45 | 46 | String fileName = Utl.getPwd() + separator + "data" + separator + testfilename ; 47 | CardFile u = new CardFile( fileName ) ; 48 | 49 | try{ 50 | 51 | ArrayList alc = u.readArrayListCard ( ) ; 52 | for (int i=0; i< alc.size(); i++){ 53 | System.out.println("testReadArrayListCard : " + alc.get(i).getPanNumber() + "-" + alc.get(i).getPvv() + "-" + alc.get(i).getOffset()); 54 | } 55 | } 56 | catch( IOException e){ 57 | System.out.println ( e.getMessage() ) ; 58 | System.out.println("testReadArrayListCard : KO !!" ); 59 | assertFalse( true) ; 60 | } 61 | System.out.println("testReadArrayListCard : OK !!" ); 62 | assertTrue( true) ; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cardgui 2 | ======= 3 | 4 | Cryptography for VISA/MASTERCAD card (and others). PIN (PVV/IBM OFFSET), CVV, CVV2, ICVV, PINBLOCK (clear or encrypted) 5 | 6 | 1. Cryptography for VISA/MASTERCAD card (and others). 7 | 8 | PIN (PVV/IBM OFFSET), CVV, CVV2, ICVV, PINBLOCK (clear or encrypted) 9 | JAVA JDK 1.7.0_65. 10 | 11 | 3. Edit key file .\data\config\key.xml 12 | 13 | ZPK Zone Pin Key. Pin block validation can be ISOFORMAT0 or ISOFORMAT3. 14 | 15 | Per BIN number adds : 16 | - Add CVKs pair, one for CVV/ICVV (or CVC/ICVC) and another for CVV2 ( or CVC2 ). 17 | - One PVK for every BIN number. 18 | Pin validation Type can be Visa PVV or IBM_3624_OFFSET. 19 | For IBM_3624_OFFSET type pin validation data type can be (THALES700 or THALES800) 20 | - THALES7000 Pin Validation Data is calculated as follows: 21 | * Refer to Thales 7000 manual - 9.4 IBM PIN Offset (command code value 'DE' ) 22 | * - Computes Account Number : Takes the 12 right-most digits of the account number, excluding check digit. 23 | * - Inserts the last 5 digits of the account number (previous data) in a given position 24 | * - Returns this data 25 | - THALES8000 Pin Validation Data is calculated as follows: 26 | * Refer to Thales HSM 8000 Host Command Reference Manual - Generate an IBM PIN Offset (command code value 'DE' ) 27 | * - Takes characters from Pan Number starting at position and ending at ( 1 <= sp < ep <= 15 ) 28 | * - Add pad character , until a 16 characters length is completed. 29 | * - Returns this data 30 | 31 | 4. Batch utility 32 | 33 | - Create your own file with cards to be processed ( use .\data\cards.txt as a template ) 34 | - All fields are mandatory. 35 | - Lines that contains an '#' character, are considered as a comment. 36 | 37 | - Open a cmd window and execute : 38 | .\cardutl.bat 39 | - Once finished, go to .\data and check .out file (and .\log\cryptocardutl.log for warnings and errors). 40 | 41 | 5. Window utility 42 | 43 | - Edit cardgui.bat and point JRE_HOME variable to your JRE (my JRE version is from jdk1.7.0_65) 44 | - Execute cardgui.bat 45 | 46 | 47 | -------------------------------------------------------------------------------- /cardgui/readme.txt: -------------------------------------------------------------------------------- 1 | 1. Cryptography for VISA/MASTERCAD card (and others). 2 | 3 | PIN (PVV/IBM OFFSET), CVV, CVV2, ICVV, PINBLOCK (clear or encrypted) 4 | 5 | 2. Verify your JDK (version 1.7.0_65 or above) . Open a Command Line Window 6 | 7 | C:>echo %JRE_HOME% 8 | "C:\Program Files\Java\jre7" 9 | 10 | C:>java -version 11 | java version "1.7.0_72" 12 | Java(TM) SE Runtime Environment (build 1.7.0_72-b14) 13 | Java HotSpot(TM) Client VM (build 24.72-b04, mixed mode, sharing) 14 | 15 | Edit cardgui.bat and cardutl.bat and update variable : JRE_HOME 16 | 17 | 3. Edit key file .\data\config\key.xml 18 | 19 | ZPK Zone Pin Key. Pin block validation can be ISOFORMAT0 or ISOFORMAT3. 20 | 21 | Per BIN number adds : 22 | - Add CVKs pair, one for CVV/ICVV (or CVC/ICVC) and another for CVV2 ( or CVC2 ). 23 | - One PVK for every BIN number. 24 | Pin validation Type can be Visa PVV or IBM_3624_OFFSET. 25 | For IBM_3624_OFFSET type pin validation data type can be (THALES700 or THALES800) 26 | - THALES7000 Pin Validation Data is calculated as follows: 27 | * Refer to Thales 7000 manual - 9.4 IBM PIN Offset (command code value 'DE' ) 28 | * - Computes Account Number : Takes the 12 right-most digits of the account number, excluding check digit. 29 | * - Inserts the last 5 digits of the account number (previous data) in a given position 30 | * - Returns this data 31 | - THALES8000 Pin Validation Data is calculated as follows: 32 | * Refer to Thales HSM 8000 Host Command Reference Manual - Generate an IBM PIN Offset (command code value 'DE' ) 33 | * - Takes characters from Pan Number starting at position and ending at ( 1 <= sp < ep <= 15 ) 34 | * - Add pad character , until a 16 characters length is completed. 35 | * - Returns this data 36 | 37 | 4. Batch utility 38 | 39 | - Create your own file with cards to be processed ( use .\data\cards.txt as a template ) 40 | - All fields are mandatory. 41 | - Lines that contains an '#' character, are considered as a comment. 42 | 43 | - Open a cmd window and execute : 44 | .\cardutl.bat 45 | - Once finished, go to .\data and check .out file (and .\log\cryptocardutl.log for warnings and errors). 46 | 47 | 5. GUI utility 48 | 49 | - Edit cardgui.bat and point JRE_HOME variable to your JRE 50 | - Execute cardgui.bat 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /cardgui/data/config/key.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0123456789ABCDEF0123456789ABCDEF 6 | 7 | 8 | 9 | 0123456789ABCDEF0123456789ABCDEF 10 | 11 | 12 | 13 | 14 | 15 | 0123456789ABCDEF0123456789ABCDEF 16 | 17 | 18 | 19 | 0123456789ABCDEF0123456789ABCDEF 20 | 0123456789ABCDEF0123456789ABCDEF 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 04 29 | 9876543276543210 30 | 01 31 | 15 32 | F 33 | 0123456789ABCDEF0123456789ABCDEF 34 | 35 | 36 | 37 | 0123456789ABCDEF0123456789ABCDEF 38 | 0123456789ABCDEF0123456789ABCDEF 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 06 47 | 12 48 | 9876543276543210 49 | 0123456789ABCDEF0123456789ABCDEF 50 | 51 | 52 | 53 | 0123456789ABCDEF0123456789ABCDEF 54 | 0123456789ABCDEF0123456789ABCDEF 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 06 63 | 12 64 | 0123456789012345 65 | 9B3D3BABF2EA0B7F136D49D36832FEC4 66 | 67 | 68 | 69 | 0123456789ABCDEF0123456789ABCDEF 70 | 0123456789ABCDEF0123456789ABCDEF 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardutl/file/CardFile.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardutl.file; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.indarsoft.cryptocard.card.Card; 6 | import com.indarsoft.cryptocard.card.CardException; 7 | import com.indarsoft.cryptocard.types.PinBlockFormatType; 8 | import com.indarsoft.cryptocard.types.PinValidationType; 9 | 10 | import java.util.ArrayList; 11 | import java.io.FileReader; 12 | import java.io.BufferedReader; 13 | import java.io.IOException; 14 | 15 | public class CardFile { 16 | 17 | static Logger log = Logger.getLogger( CardFile.class.getName() ); 18 | private String fileName ; 19 | 20 | public CardFile ( String fileName ){ 21 | 22 | this.fileName = fileName ; 23 | } 24 | 25 | public ArrayList readArrayListRecord() throws IOException { 26 | 27 | BufferedReader bri = new BufferedReader(new FileReader( this.fileName ) ); 28 | 29 | String line; 30 | ArrayList als = new ArrayList() ; 31 | 32 | while((line = bri.readLine()) != null) { 33 | als.add( line ) ; 34 | } 35 | bri.close(); 36 | 37 | return als ; 38 | } 39 | 40 | public ArrayList readArrayListCard ( ) throws IOException { 41 | 42 | 43 | ArrayList als = readArrayListRecord ( ) ; 44 | ArrayList alCard = new ArrayList() ; 45 | 46 | for (int i=0; i alc; 42 | private static BufferedWriter bro ; 43 | 44 | public static void main( String[] args ) { 45 | 46 | Main cu = new Main(); 47 | cu.checkUsage ( args ) ; 48 | // 49 | BASEDIR = Utl.getPwd(); 50 | cardFile = BASEDIR + separator + "data" + separator + cardFileName ; 51 | xmlFile = BASEDIR + separator + "data" + separator + "config" + separator + xmlKeyFileName ; 52 | outFile = cardFile + ".out" ; 53 | 54 | System.out.println("starting ....") ; 55 | 56 | try { 57 | bro = new BufferedWriter(new FileWriter( outFile ) ); 58 | cu.writeHeader() ; 59 | }catch ( IOException ex){ 60 | doExit ( "BufferedWriter : "+ ex.getMessage() ) ; 61 | } 62 | /* 63 | * Load Keys in ./data/config DIR 64 | */ 65 | lk = new LoadXmlKeys(xmlFile) ; 66 | try { 67 | xmlkeyData = lk.loadXMLData() ; 68 | } 69 | catch ( Exception ex){ 70 | doExit ( "LoadXmlKeys : "+ ex.getMessage() ) ; 71 | } 72 | /* 73 | * Load Card's txt ./data DIR and process every card 74 | */ 75 | alc = cu.loadCardFile( cardFile ) ; 76 | for (int i=0; i< alc.size(); i++){ 77 | Card a = alc.get( i ) ; 78 | cu.processCard( a ) ; 79 | } 80 | // 81 | try { 82 | bro.close(); 83 | } catch (IOException ex) { 84 | doExit ( "loadCardFile : " + ex.getMessage() ) ; 85 | } 86 | 87 | System.out.println("finishing ....") ; 88 | System.exit(0); 89 | } 90 | 91 | /* --------------------------------------------------------------------------------------------------------- */ 92 | 93 | 94 | 95 | private ArrayList loadCardFile (String fileName){ 96 | 97 | ArrayList alc = null ; 98 | CardFile u = new CardFile( fileName ) ; 99 | try{ 100 | alc = u.readArrayListCard() ; 101 | } 102 | catch( IOException ex){ 103 | doExit ( ex.getMessage() ) ; 104 | } 105 | return alc ; 106 | } 107 | 108 | 109 | private void processCard ( Card card ) { 110 | 111 | BinKey binkey = xmlkeyData.getBinKey( card.getPanNumber().substring( 0, 6) ) ; 112 | 113 | String str = card.getPinBlockFormatType().toString() ; 114 | PinBlockKey pinBlockKey = xmlkeyData.getPinBlock( str ) ; 115 | 116 | ProcessedCardData pcd = ProcessCard.doit(card, binkey, pinBlockKey) ; 117 | // 118 | // Adjust detailed line for output printing 119 | // 120 | String pinvalue = pcd.getPin() ; 121 | if ( pinvalue.equals( NF ) ){ 122 | pinvalue = pinvalue + "\t"; 123 | } 124 | 125 | String track2value = pcd.getTrack2() ; 126 | if ( track2value.length() < 32 ){ 127 | track2value = track2value + " "; // adds 4 blanks 128 | } 129 | // 130 | String detailedline = "\t"+ pcd.getPanNumber() + "\t" + pcd.getServiceCode() + "\t\t" + pcd.getExpirationDate() + "\t"+ pcd.getDki() + "\t" + pcd.getPinValType() + "\t" +pcd.getPinValidationDataType() +"\t"+ pcd.getPvv_offset() + "\t" + pinvalue ; 131 | detailedline = detailedline + "\t" + pcd.getCvv() + "\t\t" + pcd.getIcvv() + "\t\t" + pcd.getCvv2() ; 132 | detailedline = detailedline + "\t\t" + track2value ; 133 | detailedline = detailedline + "\t" + pcd.getPinblockValType() + "\t" + pcd.getClearPinblock() + "\t"+ pcd.getEncryptedPinblock() +"\n"; 134 | 135 | writeline (detailedline) ; 136 | // 137 | // Process all dki's 138 | // 139 | /* 140 | * if the issuer (BIN) uses the PIN Verification Service (PVS) for 141 | some, but not for all issued cards, the PIN Verification Data field 142 | (both PVKI and PVV) should be zero-filled on those cards not 143 | using the PVS. If the issuer does not use the PVS for any cards in 144 | a card range, the zero-fill requirement is not needed. 145 | Refer to Chapter 6 for more information on the PVKI and PVV. 146 | * 147 | */ 148 | String newpinvalue = pcd.getPin() ; 149 | if ( newpinvalue.equals( NF ) ){ 150 | for ( int k = 1; k < 6 ; k ++){ 151 | try { 152 | card.setPvki( k ); 153 | pcd = ProcessCard.doit(card, binkey, pinBlockKey) ; 154 | // 155 | String computedPin = pcd.getPin() ; 156 | if ( ! computedPin.equals( NF ) ){ 157 | String dummy = "\t\t\t\t\t\t\t\t\t\t"+ pcd.getDki() + "\t\t" +"\t\t\t\t" + pcd.getPvv_offset() + "\t\t\t\t"+pcd.getPinValidationDataType() + "\t" + computedPin ; 158 | dummy = dummy + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + pcd.getClearPinblock() + "\t"+ pcd.getEncryptedPinblock() +"\n"; 159 | writeline (dummy) ; 160 | } 161 | // 162 | 163 | } catch (CardException e) { 164 | log.warn( "Process all dki's " + e.getMessage() ) ; 165 | } 166 | } 167 | } 168 | } 169 | 170 | 171 | private void checkUsage( String[] a ){ 172 | 173 | String osName = System.getProperty("os.name").toLowerCase() ; 174 | String cmdExt =""; 175 | 176 | if ( osName.contains("windows") ){ 177 | cmdExt = "bat" ; 178 | }else{ 179 | cmdExt = "sh" ; 180 | } 181 | 182 | if ( a.length != 2 ){ 183 | System.out.println("Usage is : cardutl." + cmdExt + " ") ; 184 | System.out.println("Example : cardutl." + cmdExt + " cards.txt key.xml ") ; 185 | System.out.println("GoodBye .. :-)") ; 186 | System.exit(-1); 187 | //cardFileName = "cards.txt"; 188 | //xmlKeyFileName = "key.xml"; 189 | }else{ 190 | cardFileName = a[0] ; 191 | xmlKeyFileName = a[1] ; 192 | } 193 | } 194 | 195 | private void writeHeader () throws IOException { 196 | bro.write("#\n") ; 197 | bro.write("#\n") ; 198 | bro.write("# Card Number Service ExpDate Dki PinValType PinValDat Pvv/ Pin cvv icvv cvv2 Track2 PinBlock Clear Encrypted \n") ; 199 | bro.write("# Code (YYMM) Offset cvc icvc cvc2 Type Pinblock Pinblock \n") ; 200 | bro.write("#\n") ; 201 | } 202 | 203 | private void writeline ( String line ) { 204 | 205 | try{ 206 | bro.write( line ); 207 | } 208 | catch ( IOException ex){ 209 | String errMsg = "exit(-1) : " + ex.getMessage(); 210 | doExit( errMsg ); 211 | } 212 | } 213 | 214 | private static void doExit ( String errMsg ){ 215 | 216 | log.debug( "exit(-1) : " + errMsg ) ; 217 | System.exit(-1); 218 | } 219 | 220 | } 221 | -------------------------------------------------------------------------------- /cardgui/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.indarsoft 6 | cryptocardUtl 7 | 1.0.0 8 | jar 9 | 10 | cryptocardUtl 11 | http://indarsoft.com 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | swt-repo 20 | https://swt-repo.googlecode.com/svn/repo/ 21 | 22 | 23 | 24 | 25 | 26 | junit 27 | junit 28 | 4.11 29 | test 30 | 31 | 32 | log4j 33 | log4j 34 | 1.2.16 35 | 36 | 37 | com.indarsoft 38 | utl 39 | 1.0.0 40 | 41 | 42 | com.indarsoft 43 | cryptocard 44 | 1.0.0 45 | 46 | 54 | 55 | 56 | 57 | org.eclipse.ui 58 | org.eclipse.ui.workbench 59 | 60 | 3.103.0.v20120530-1824 61 | 62 | 63 | 64 | 65 | images 66 | images 67 | system 68 | 1.0.0 69 | ${basedir}\src\lib\images.jar 70 | 71 | 72 | 73 | 74 | 75 | windows_amd64 76 | 77 | 78 | Windows 79 | amd64 80 | 81 | 82 | 83 | 84 | org.eclipse.swt 85 | org.eclipse.swt.win32.win32.x86_64 86 | 4.4 87 | 88 | 89 | 90 | 91 | linux_amd64_gtk2 92 | 93 | 94 | linux 95 | amd64 96 | 97 | 98 | 99 | 100 | org.eclipse.swt 101 | swt-gtk-linux-x86_64 102 | 4.4 103 | 104 | 105 | 106 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 133 | 134 | org.apache.maven.plugins 135 | maven-jar-plugin 136 | 2.2 137 | 138 | 139 | 140 | true 141 | lib/ 142 | 143 | com.indarsoft.cardgui.Main 144 | 145 | 146 | fjavier.porras@gmail.com 147 | 148 | 149 | 150 | 151 | 152 | 158 | 159 | org.apache.maven.plugins 160 | maven-dependency-plugin 161 | 2.8 162 | 163 | 164 | copy-dependencies 165 | prepare-package 166 | 167 | copy-dependencies 168 | 169 | 170 | ${project.build.directory}/lib 171 | false 172 | false 173 | true 174 | 175 | 176 | 177 | 178 | 179 | 180 | org.apache.maven.plugins 181 | maven-compiler-plugin 182 | 2.3.2 183 | 184 | 1.8 185 | 1.8 186 | 187 | 188 | 189 | 190 | org.apache.maven.plugins 191 | maven-source-plugin 192 | 2.0.4 193 | 194 | 195 | attach-sources 196 | 197 | jar 198 | 199 | 200 | 201 | 202 | 203 | 204 | maven-resources-plugin 205 | 2.6 206 | 207 | 208 | copy-resources 209 | validate 210 | 211 | copy-resources 212 | 213 | 214 | 215 | 216 | ${project.build.directory} 217 | 218 | 222 | 223 | ${basedir}/target/data 224 | ${basedir}/data 225 | 226 | 227 | ${basedir}/target/log 228 | ${basedir}/log 229 | 230 | 231 | ${basedir}/target 232 | ${basedir} 233 | 234 | readme.txt 235 | cardutl.bat 236 | cardgui.bat 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardutl/xml/LoadXmlKeys.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardutl.xml; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import javax.xml.parsers.DocumentBuilder; 7 | import javax.xml.parsers.DocumentBuilderFactory; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | 10 | import org.apache.log4j.Logger; 11 | import org.w3c.dom.Document; 12 | import org.w3c.dom.Element; 13 | import org.w3c.dom.NamedNodeMap; 14 | import org.w3c.dom.Node; 15 | import org.w3c.dom.NodeList; 16 | import org.xml.sax.SAXException; 17 | 18 | import com.indarsoft.cardutl.beans.BinKey; 19 | import com.indarsoft.cardutl.beans.PinBlockKey; 20 | import com.indarsoft.cryptocard.symmetrickey.DesKeyException; 21 | import com.indarsoft.cryptocard.types.PinBlockFormatType; 22 | import com.indarsoft.cryptocard.types.PinValidationType; 23 | 24 | public class LoadXmlKeys { 25 | 26 | static Logger log = Logger.getLogger( LoadXmlKeys.class.getName() ); 27 | 28 | private String fileName ; 29 | private Document dom ; 30 | private Element docEle ; 31 | private BinKey binKey ; 32 | private PinBlockKey pinBlockKey; 33 | private XmlKeyData xmlkeyData = new XmlKeyData() ; 34 | 35 | public LoadXmlKeys ( String xmlFileData ) { 36 | 37 | this.fileName = xmlFileData ; 38 | } 39 | 40 | 41 | public XmlKeyData loadXMLData() { 42 | // 43 | File data = new File(fileName); 44 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 45 | 46 | DocumentBuilder dBuilder; 47 | try { 48 | dBuilder = dbf.newDocumentBuilder(); 49 | this.dom = dBuilder.parse(data) ; 50 | } catch (ParserConfigurationException | SAXException | IOException e) { 51 | log.error ( "dBuilder + dom : " + e.getMessage() ) ; 52 | return null ; 53 | } 54 | 55 | this.docEle = dom.getDocumentElement(); 56 | getRootElement(); 57 | getPinBlockValidation() ; 58 | getBinNumber() ; 59 | return xmlkeyData ; // Return HashTable 60 | } 61 | 62 | private void getRootElement( ){ 63 | 64 | Element elementroot = (Element) dom.getDocumentElement(); 65 | elementroot.normalize(); 66 | 67 | NamedNodeMap rootatr = elementroot.getAttributes(); 68 | 69 | for (int i = 0; i < rootatr.getLength(); i++) { 70 | Node theAttribute = rootatr.item(i); 71 | if (theAttribute.getNodeName() == "GROUP_NAME"){ 72 | @SuppressWarnings("unused") 73 | String name = theAttribute.getNodeValue() ; 74 | } 75 | } 76 | } 77 | 78 | 79 | private void getPinBlockValidation() { 80 | 81 | NodeList nl = this.docEle.getElementsByTagName("PINBLOCK_VALIDATION"); 82 | if(nl != null && nl.getLength() > 0) { 83 | for(int i = 0 ; i < nl.getLength();i++) { 84 | 85 | Element el = (Element)nl.item(i); 86 | 87 | getPinBlockValidationElements(el) ; 88 | 89 | if ( pinBlockKey == null || pinBlockKey.getPinBlockFormatType() == null || pinBlockKey.getZpk() == null ) { 90 | log.error ( "getPinBlockValidationElements " ) ; 91 | }else{ 92 | xmlkeyData.putPinBlock ( pinBlockKey ); 93 | } 94 | } 95 | } 96 | } 97 | 98 | private void getPinBlockValidationElements(Element el) { 99 | 100 | String pinblockValidationTypeStr = el.getAttribute("VALIDATION_TYPE"); 101 | String zpkValue = getTextValue(el,"ZPK"); 102 | PinBlockFormatType pinBlockFormatType = null ; 103 | 104 | try { 105 | if ( pinblockValidationTypeStr.equals( PinBlockFormatType.ISOFORMAT0.toString() )){ 106 | pinBlockFormatType = PinBlockFormatType.ISOFORMAT0 ; 107 | pinBlockKey = new PinBlockKey (zpkValue, pinBlockFormatType); 108 | }else{ 109 | if ( pinblockValidationTypeStr.equals( PinBlockFormatType.ISOFORMAT3.toString() ) ){ 110 | pinBlockFormatType = PinBlockFormatType.ISOFORMAT3 ; 111 | pinBlockKey = new PinBlockKey (zpkValue, pinBlockFormatType); 112 | }else{ 113 | log.error ( "getPinBlockValidationElements not found pinBlockFormatType " ) ; 114 | } 115 | } 116 | 117 | } 118 | catch ( DesKeyException e ){ 119 | log.error ( "DesKeyException getPinBlockValidationElements : " + e.getMessage() ) ; 120 | } 121 | 122 | } 123 | 124 | private void getBinNumber() { 125 | 126 | NodeList nl = this.docEle.getElementsByTagName("BIN"); 127 | if(nl != null && nl.getLength() > 0) { 128 | for(int i = 0 ; i < nl.getLength();i++) { 129 | 130 | Element el = (Element)nl.item(i); 131 | binKey = new BinKey( el.getAttribute("NUMBER") ); 132 | 133 | getPinValidation(el ) ; 134 | getCvvValidation(el ) ; 135 | 136 | xmlkeyData.putBinKey( binKey ); 137 | 138 | } 139 | } 140 | } 141 | 142 | private void getPinValidation(Element aElement ) { 143 | // 144 | String pinValidationTypeStr=""; 145 | String pinValidationDataTypeStr ="" ; 146 | String pvkValue=""; 147 | int pvki = 0 ; 148 | // 149 | int pingLength= 0; 150 | String decimalizationTable=""; 151 | int panStartPosition = 0; 152 | int panEndPosition = 0; 153 | char panPadCharacter = 0x00; 154 | // 155 | NodeList nl = aElement.getElementsByTagName("PIN_VALIDATION"); 156 | for(int i = 0 ; i < nl.getLength();i++) { 157 | 158 | Element el = (Element)nl.item(i); 159 | 160 | pinValidationTypeStr = el.getAttribute("VALIDATION_TYPE"); 161 | pinValidationDataTypeStr= el.getAttribute("PINVALIDATIONDATA_TYPE"); 162 | pvkValue = getTextValue(el,"PVK"); 163 | 164 | 165 | if (pinValidationTypeStr.equals( PinValidationType.IBM_3624_OFFSET.toString() )){ 166 | 167 | pingLength = Integer.parseInt( getTextValue(el,"PIN_LENGTH") ); 168 | binKey.setPinLength( pingLength ) ; 169 | decimalizationTable = getTextValue(el,"DECIMALIZATION_TABLE"); 170 | binKey.setDecimalizationTable( decimalizationTable ) ; 171 | 172 | if ( pinValidationDataTypeStr.equals ( "THALES8000") ) { 173 | 174 | panStartPosition = Integer.parseInt( getTextValue(el,"PAN_START_POSITION") ) ; 175 | panEndPosition = Integer.parseInt( getTextValue(el,"PAN_END_POSITION") ) ; 176 | panPadCharacter = getTextValue(el,"PAN_PAD_CHARACTER").charAt(0) ; 177 | binKey.setPinValidationDataType(pinValidationDataTypeStr); 178 | binKey.setPanStartPosition( panStartPosition ); 179 | binKey.setPanEndPosition( panEndPosition ); 180 | binKey.setPanPadCharacter ( panPadCharacter ); 181 | }else 182 | if ( pinValidationDataTypeStr.equals ( "THALES7000") ) { 183 | binKey.setPinValidationDataType(pinValidationDataTypeStr); 184 | int insertPosition = Integer.parseInt( getTextValue(el,"INSERT_POSITION") ); 185 | binKey.setInsertPosition(insertPosition); 186 | 187 | }else{ 188 | log.error ( "pinValidationDataType not found for IBM_3624_OFFSET " ) ; 189 | } 190 | 191 | } 192 | 193 | //log.error ( "getPinBlockValidationElements not found pinBlockFormatType " ) ; 194 | if ( el.getNodeType() == Node.ELEMENT_NODE ) { 195 | 196 | Element ael = (Element) el; 197 | NodeList anl = ael.getElementsByTagName("PVK"); 198 | 199 | for (int k = 0; k < anl.getLength();k++){ 200 | Element bel = (Element)anl.item(k); 201 | pvki = Integer.parseInt( bel.getAttribute("PVKI") ) ; 202 | } 203 | } 204 | 205 | try{ 206 | //String str = PinValidationType.VISA_PVV.toString() ; 207 | if ( pinValidationTypeStr.equals( PinValidationType.VISA_PVV.toString() )){ 208 | binKey.setPinValidationType( PinValidationType.VISA_PVV ) ; 209 | } 210 | if ( pinValidationTypeStr.equals( PinValidationType.IBM_3624_OFFSET.toString() ) ){ 211 | binKey.setPinValidationType( PinValidationType.IBM_3624_OFFSET ) ; 212 | } 213 | 214 | binKey.setPvk( pvkValue, pvki) ; 215 | 216 | } 217 | catch ( DesKeyException e ){ 218 | log.error ( "setPinValidationType + setPvk : " + e.getMessage() ) ; 219 | } 220 | } 221 | } 222 | 223 | private void getCvvValidation(Element aElement ) { 224 | // 225 | String validationType=""; 226 | String dateFormat=""; 227 | String cvkValue = ""; 228 | // 229 | NodeList nl = aElement.getElementsByTagName("CVK"); 230 | for(int i = 0 ; i < nl.getLength();i++) { 231 | 232 | Element el = (Element)nl.item(i); 233 | 234 | validationType = el.getAttribute("TYPE"); 235 | dateFormat = el.getAttribute("DATEFORMAT"); 236 | cvkValue = el.getTextContent() ; 237 | 238 | try { 239 | if ( validationType.equals("CVV")){ 240 | binKey.setCvv(cvkValue) ; 241 | binKey.setCvvKeyDateFormat(dateFormat) ; 242 | }else 243 | if ( validationType.equals("CVV2")){ 244 | binKey.setCvv2(cvkValue) ; 245 | binKey.setCvv2KeyDateFormat(dateFormat) ; 246 | } 247 | } 248 | catch ( DesKeyException e ){ 249 | log.error ( "getCvvValidation : " + e.getMessage() ) ; 250 | } 251 | } 252 | } 253 | 254 | /** 255 | * I take a com.indarsoft.cardutl.xml element and the tag name, look for the tag and get 256 | * the text content 257 | * i.e for John org.inds.cardutl.xml snippet if 258 | * the Element points to employee node and tagName is name I will return John 259 | * @param ele 260 | * @param tagName 261 | * @return 262 | */ 263 | private String getTextValue(Element ele, String tagName) { 264 | String textVal = null; 265 | NodeList nl = ele.getElementsByTagName(tagName); 266 | if(nl != null && nl.getLength() > 0) { 267 | Element el = (Element)nl.item(0); 268 | textVal = el.getFirstChild().getNodeValue(); 269 | } 270 | 271 | return textVal; 272 | } 273 | 274 | /** 275 | * Calls getTextValue and returns a int value 276 | * @param ele 277 | * @param tagName 278 | * @return 279 | */ 280 | @SuppressWarnings("unused") 281 | private int getIntValue(Element ele, String tagName) { 282 | 283 | //in production application you would catch the exception 284 | return Integer.parseInt(getTextValue(ele,tagName)); 285 | } 286 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /cardgui/log/cryptocardutl.log: -------------------------------------------------------------------------------- 1 | 2015-04-07 17:50:33,985 main ERROR com.indarsoft.cardutl.xml.LoadXmlKeys # pinValidationDataType not found for IBM_3624_OFFSET 2 | 2015-04-08 08:59:18,786 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 3 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 4 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 5 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 6 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 7 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 8 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 9 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 3 10 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 11 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 12 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 4 13 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 14 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 15 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 5 16 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 17 | 2015-04-08 08:59:18,817 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 18 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 19 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 20 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 21 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 22 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 23 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 24 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 25 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 3 26 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 27 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 28 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 4 29 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 30 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 31 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 5 32 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 33 | 2015-04-08 08:59:28,115 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 34 | 2015-04-08 09:08:28,611 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 35 | 2015-04-08 09:09:13,972 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 36 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 37 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 38 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 39 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 40 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 41 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 42 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 43 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 3 44 | 2015-04-08 09:09:23,909 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 45 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 46 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 4 47 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 48 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 49 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 5 50 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 51 | 2015-04-08 09:09:23,925 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 52 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 53 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 54 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 55 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 56 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 57 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 58 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 59 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 3 60 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 61 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 62 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 4 63 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 64 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 65 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 5 66 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pinValidationType in card is VISA_PVV does not match pinValidationType in binkey 520000-IBM_3624_OFFSET 67 | 2015-04-08 09:09:34,330 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 5200000000000007 pin validation type : VISA_PVV does not match bin : IBM_3624_OFFSET 68 | 2015-04-08 09:10:14,217 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 69 | 2015-04-08 09:12:38,412 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 70 | 2015-04-08 09:13:28,002 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 71 | 2015-04-08 09:15:13,685 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 72 | 2015-04-08 09:15:53,285 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 73 | 2015-04-08 09:15:58,137 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 74 | 2015-04-08 09:16:02,318 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 75 | 2015-04-08 09:27:27,082 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 76 | 2015-04-08 09:28:23,508 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 77 | 2015-04-08 09:29:57,491 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 78 | 2015-04-08 09:31:54,215 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 79 | 2015-04-08 09:32:12,907 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 80 | 2015-04-08 09:32:39,394 main WARN com.indarsoft.cardutl.card.ProcessCard # panNumber : 4000000000000002 pvki in Pvk 0123456789ABCDEF0123456789ABCDEF is : 1 does not match with pvki 2 81 | -------------------------------------------------------------------------------- /cardgui/src/main/java/org/eclipse/wb/swt/SWTResourceManager.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Google, Inc. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * Google, Inc. - initial API and implementation 10 | *******************************************************************************/ 11 | package org.eclipse.wb.swt; 12 | 13 | import java.io.FileInputStream; 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | import org.eclipse.swt.SWT; 20 | import org.eclipse.swt.graphics.Color; 21 | import org.eclipse.swt.graphics.Cursor; 22 | import org.eclipse.swt.graphics.Font; 23 | import org.eclipse.swt.graphics.FontData; 24 | import org.eclipse.swt.graphics.GC; 25 | import org.eclipse.swt.graphics.Image; 26 | import org.eclipse.swt.graphics.ImageData; 27 | import org.eclipse.swt.graphics.RGB; 28 | import org.eclipse.swt.graphics.Rectangle; 29 | import org.eclipse.swt.widgets.Display; 30 | 31 | /** 32 | * Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc. 33 | *

34 | * !!! IMPORTANT !!! Application code must explicitly invoke the dispose() method to release the 35 | * operating system resources managed by cached objects when those objects and OS resources are no longer 36 | * needed (e.g. on application shutdown) 37 | *

38 | * This class may be freely distributed as part of any application or plugin. 39 | *

40 | * @author scheglov_ke 41 | * @author Dan Rubel 42 | */ 43 | public class SWTResourceManager { 44 | //////////////////////////////////////////////////////////////////////////// 45 | // 46 | // Color 47 | // 48 | //////////////////////////////////////////////////////////////////////////// 49 | private static Map m_colorMap = new HashMap(); 50 | /** 51 | * Returns the system {@link Color} matching the specific ID. 52 | * 53 | * @param systemColorID 54 | * the ID value for the color 55 | * @return the system {@link Color} matching the specific ID 56 | */ 57 | public static Color getColor(int systemColorID) { 58 | Display display = Display.getCurrent(); 59 | return display.getSystemColor(systemColorID); 60 | } 61 | /** 62 | * Returns a {@link Color} given its red, green and blue component values. 63 | * 64 | * @param r 65 | * the red component of the color 66 | * @param g 67 | * the green component of the color 68 | * @param b 69 | * the blue component of the color 70 | * @return the {@link Color} matching the given red, green and blue component values 71 | */ 72 | public static Color getColor(int r, int g, int b) { 73 | return getColor(new RGB(r, g, b)); 74 | } 75 | /** 76 | * Returns a {@link Color} given its RGB value. 77 | * 78 | * @param rgb 79 | * the {@link RGB} value of the color 80 | * @return the {@link Color} matching the RGB value 81 | */ 82 | public static Color getColor(RGB rgb) { 83 | Color color = m_colorMap.get(rgb); 84 | if (color == null) { 85 | Display display = Display.getCurrent(); 86 | color = new Color(display, rgb); 87 | m_colorMap.put(rgb, color); 88 | } 89 | return color; 90 | } 91 | /** 92 | * Dispose of all the cached {@link Color}'s. 93 | */ 94 | public static void disposeColors() { 95 | for (Color color : m_colorMap.values()) { 96 | color.dispose(); 97 | } 98 | m_colorMap.clear(); 99 | } 100 | //////////////////////////////////////////////////////////////////////////// 101 | // 102 | // Image 103 | // 104 | //////////////////////////////////////////////////////////////////////////// 105 | /** 106 | * Maps image paths to images. 107 | */ 108 | private static Map m_imageMap = new HashMap(); 109 | /** 110 | * Returns an {@link Image} encoded by the specified {@link InputStream}. 111 | * 112 | * @param stream 113 | * the {@link InputStream} encoding the image data 114 | * @return the {@link Image} encoded by the specified input stream 115 | */ 116 | protected static Image getImage(InputStream stream) throws IOException { 117 | try { 118 | Display display = Display.getCurrent(); 119 | ImageData data = new ImageData(stream); 120 | if (data.transparentPixel > 0) { 121 | return new Image(display, data, data.getTransparencyMask()); 122 | } 123 | return new Image(display, data); 124 | } finally { 125 | stream.close(); 126 | } 127 | } 128 | /** 129 | * Returns an {@link Image} stored in the file at the specified path. 130 | * 131 | * @param path 132 | * the path to the image file 133 | * @return the {@link Image} stored in the file at the specified path 134 | */ 135 | public static Image getImage(String path) { 136 | Image image = m_imageMap.get(path); 137 | if (image == null) { 138 | try { 139 | image = getImage(new FileInputStream(path)); 140 | m_imageMap.put(path, image); 141 | } catch (Exception e) { 142 | image = getMissingImage(); 143 | m_imageMap.put(path, image); 144 | } 145 | } 146 | return image; 147 | } 148 | /** 149 | * Returns an {@link Image} stored in the file at the specified path relative to the specified class. 150 | * 151 | * @param clazz 152 | * the {@link Class} relative to which to find the image 153 | * @param path 154 | * the path to the image file, if starts with '/' 155 | * @return the {@link Image} stored in the file at the specified path 156 | */ 157 | public static Image getImage(Class clazz, String path) { 158 | String key = clazz.getName() + '|' + path; 159 | Image image = m_imageMap.get(key); 160 | if (image == null) { 161 | try { 162 | image = getImage(clazz.getResourceAsStream(path)); 163 | m_imageMap.put(key, image); 164 | } catch (Exception e) { 165 | image = getMissingImage(); 166 | m_imageMap.put(key, image); 167 | } 168 | } 169 | return image; 170 | } 171 | private static final int MISSING_IMAGE_SIZE = 10; 172 | /** 173 | * @return the small {@link Image} that can be used as placeholder for missing image. 174 | */ 175 | private static Image getMissingImage() { 176 | Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); 177 | // 178 | GC gc = new GC(image); 179 | gc.setBackground(getColor(SWT.COLOR_RED)); 180 | gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); 181 | gc.dispose(); 182 | // 183 | return image; 184 | } 185 | /** 186 | * Style constant for placing decorator image in top left corner of base image. 187 | */ 188 | public static final int TOP_LEFT = 1; 189 | /** 190 | * Style constant for placing decorator image in top right corner of base image. 191 | */ 192 | public static final int TOP_RIGHT = 2; 193 | /** 194 | * Style constant for placing decorator image in bottom left corner of base image. 195 | */ 196 | public static final int BOTTOM_LEFT = 3; 197 | /** 198 | * Style constant for placing decorator image in bottom right corner of base image. 199 | */ 200 | public static final int BOTTOM_RIGHT = 4; 201 | /** 202 | * Internal value. 203 | */ 204 | protected static final int LAST_CORNER_KEY = 5; 205 | /** 206 | * Maps images to decorated images. 207 | */ 208 | @SuppressWarnings("unchecked") 209 | private static Map>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; 210 | /** 211 | * Returns an {@link Image} composed of a base image decorated by another image. 212 | * 213 | * @param baseImage 214 | * the base {@link Image} that should be decorated 215 | * @param decorator 216 | * the {@link Image} to decorate the base image 217 | * @return {@link Image} The resulting decorated image 218 | */ 219 | public static Image decorateImage(Image baseImage, Image decorator) { 220 | return decorateImage(baseImage, decorator, BOTTOM_RIGHT); 221 | } 222 | /** 223 | * Returns an {@link Image} composed of a base image decorated by another image. 224 | * 225 | * @param baseImage 226 | * the base {@link Image} that should be decorated 227 | * @param decorator 228 | * the {@link Image} to decorate the base image 229 | * @param corner 230 | * the corner to place decorator image 231 | * @return the resulting decorated {@link Image} 232 | */ 233 | public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) { 234 | if (corner <= 0 || corner >= LAST_CORNER_KEY) { 235 | throw new IllegalArgumentException("Wrong decorate corner"); 236 | } 237 | Map> cornerDecoratedImageMap = m_decoratedImageMap[corner]; 238 | if (cornerDecoratedImageMap == null) { 239 | cornerDecoratedImageMap = new HashMap>(); 240 | m_decoratedImageMap[corner] = cornerDecoratedImageMap; 241 | } 242 | Map decoratedMap = cornerDecoratedImageMap.get(baseImage); 243 | if (decoratedMap == null) { 244 | decoratedMap = new HashMap(); 245 | cornerDecoratedImageMap.put(baseImage, decoratedMap); 246 | } 247 | // 248 | Image result = decoratedMap.get(decorator); 249 | if (result == null) { 250 | Rectangle bib = baseImage.getBounds(); 251 | Rectangle dib = decorator.getBounds(); 252 | // 253 | result = new Image(Display.getCurrent(), bib.width, bib.height); 254 | // 255 | GC gc = new GC(result); 256 | gc.drawImage(baseImage, 0, 0); 257 | if (corner == TOP_LEFT) { 258 | gc.drawImage(decorator, 0, 0); 259 | } else if (corner == TOP_RIGHT) { 260 | gc.drawImage(decorator, bib.width - dib.width, 0); 261 | } else if (corner == BOTTOM_LEFT) { 262 | gc.drawImage(decorator, 0, bib.height - dib.height); 263 | } else if (corner == BOTTOM_RIGHT) { 264 | gc.drawImage(decorator, bib.width - dib.width, bib.height - dib.height); 265 | } 266 | gc.dispose(); 267 | // 268 | decoratedMap.put(decorator, result); 269 | } 270 | return result; 271 | } 272 | /** 273 | * Dispose all of the cached {@link Image}'s. 274 | */ 275 | public static void disposeImages() { 276 | // dispose loaded images 277 | { 278 | for (Image image : m_imageMap.values()) { 279 | image.dispose(); 280 | } 281 | m_imageMap.clear(); 282 | } 283 | // dispose decorated images 284 | for (int i = 0; i < m_decoratedImageMap.length; i++) { 285 | Map> cornerDecoratedImageMap = m_decoratedImageMap[i]; 286 | if (cornerDecoratedImageMap != null) { 287 | for (Map decoratedMap : cornerDecoratedImageMap.values()) { 288 | for (Image image : decoratedMap.values()) { 289 | image.dispose(); 290 | } 291 | decoratedMap.clear(); 292 | } 293 | cornerDecoratedImageMap.clear(); 294 | } 295 | } 296 | } 297 | //////////////////////////////////////////////////////////////////////////// 298 | // 299 | // Font 300 | // 301 | //////////////////////////////////////////////////////////////////////////// 302 | /** 303 | * Maps font names to fonts. 304 | */ 305 | private static Map m_fontMap = new HashMap(); 306 | /** 307 | * Maps fonts to their bold versions. 308 | */ 309 | private static Map m_fontToBoldFontMap = new HashMap(); 310 | /** 311 | * Returns a {@link Font} based on its name, height and style. 312 | * 313 | * @param name 314 | * the name of the font 315 | * @param height 316 | * the height of the font 317 | * @param style 318 | * the style of the font 319 | * @return {@link Font} The font matching the name, height and style 320 | */ 321 | public static Font getFont(String name, int height, int style) { 322 | return getFont(name, height, style, false, false); 323 | } 324 | /** 325 | * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline 326 | * flags are also supported. 327 | * 328 | * @param name 329 | * the name of the font 330 | * @param size 331 | * the size of the font 332 | * @param style 333 | * the style of the font 334 | * @param strikeout 335 | * the strikeout flag (warning: Windows only) 336 | * @param underline 337 | * the underline flag (warning: Windows only) 338 | * @return {@link Font} The font matching the name, height, style, strikeout and underline 339 | */ 340 | public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { 341 | String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline; 342 | Font font = m_fontMap.get(fontName); 343 | if (font == null) { 344 | FontData fontData = new FontData(name, size, style); 345 | if (strikeout || underline) { 346 | try { 347 | Class logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ 348 | Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$ 349 | if (logFont != null && logFontClass != null) { 350 | if (strikeout) { 351 | logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ 352 | } 353 | if (underline) { 354 | logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$ 355 | } 356 | } 357 | } catch (Throwable e) { 358 | System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$ 359 | } 360 | } 361 | font = new Font(Display.getCurrent(), fontData); 362 | m_fontMap.put(fontName, font); 363 | } 364 | return font; 365 | } 366 | /** 367 | * Returns a bold version of the given {@link Font}. 368 | * 369 | * @param baseFont 370 | * the {@link Font} for which a bold version is desired 371 | * @return the bold version of the given {@link Font} 372 | */ 373 | public static Font getBoldFont(Font baseFont) { 374 | Font font = m_fontToBoldFontMap.get(baseFont); 375 | if (font == null) { 376 | FontData fontDatas[] = baseFont.getFontData(); 377 | FontData data = fontDatas[0]; 378 | font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); 379 | m_fontToBoldFontMap.put(baseFont, font); 380 | } 381 | return font; 382 | } 383 | /** 384 | * Dispose all of the cached {@link Font}'s. 385 | */ 386 | public static void disposeFonts() { 387 | // clear fonts 388 | for (Font font : m_fontMap.values()) { 389 | font.dispose(); 390 | } 391 | m_fontMap.clear(); 392 | // clear bold fonts 393 | for (Font font : m_fontToBoldFontMap.values()) { 394 | font.dispose(); 395 | } 396 | m_fontToBoldFontMap.clear(); 397 | } 398 | //////////////////////////////////////////////////////////////////////////// 399 | // 400 | // Cursor 401 | // 402 | //////////////////////////////////////////////////////////////////////////// 403 | /** 404 | * Maps IDs to cursors. 405 | */ 406 | private static Map m_idToCursorMap = new HashMap(); 407 | /** 408 | * Returns the system cursor matching the specific ID. 409 | * 410 | * @param id 411 | * int The ID value for the cursor 412 | * @return Cursor The system cursor matching the specific ID 413 | */ 414 | public static Cursor getCursor(int id) { 415 | Integer key = Integer.valueOf(id); 416 | Cursor cursor = m_idToCursorMap.get(key); 417 | if (cursor == null) { 418 | cursor = new Cursor(Display.getDefault(), id); 419 | m_idToCursorMap.put(key, cursor); 420 | } 421 | return cursor; 422 | } 423 | /** 424 | * Dispose all of the cached cursors. 425 | */ 426 | public static void disposeCursors() { 427 | for (Cursor cursor : m_idToCursorMap.values()) { 428 | cursor.dispose(); 429 | } 430 | m_idToCursorMap.clear(); 431 | } 432 | //////////////////////////////////////////////////////////////////////////// 433 | // 434 | // General 435 | // 436 | //////////////////////////////////////////////////////////////////////////// 437 | /** 438 | * Dispose of cached objects and their underlying OS resources. This should only be called when the cached 439 | * objects are no longer needed (e.g. on application shutdown). 440 | */ 441 | public static void dispose() { 442 | disposeColors(); 443 | disposeImages(); 444 | disposeFonts(); 445 | disposeCursors(); 446 | } 447 | } -------------------------------------------------------------------------------- /cardgui/src/main/java/com/indarsoft/cardgui/card/CardFrm.java: -------------------------------------------------------------------------------- 1 | package com.indarsoft.cardgui.card; 2 | 3 | import java.io.File; 4 | 5 | import org.eclipse.swt.*; 6 | import org.eclipse.swt.widgets.*; 7 | import org.eclipse.swt.events.SelectionAdapter; 8 | import org.eclipse.swt.events.SelectionEvent; 9 | import org.eclipse.wb.swt.SWTResourceManager; 10 | import org.eclipse.swt.graphics.Color; 11 | import org.eclipse.swt.graphics.RGB; 12 | import org.eclipse.swt.graphics.Rectangle; 13 | 14 | import com.indarsoft.cardgui.FrmAlert; 15 | import com.indarsoft.cardgui.FrmControls; 16 | import com.indarsoft.cardutl.beans.BinKey; 17 | import com.indarsoft.cardutl.beans.PinBlockKey; 18 | import com.indarsoft.cardutl.beans.ProcessedCardData; 19 | import com.indarsoft.cardutl.card.ProcessCard; 20 | import com.indarsoft.cardutl.xml.LoadXmlKeys; 21 | import com.indarsoft.cardutl.xml.XmlKeyData; 22 | import com.indarsoft.cryptocard.card.Card; 23 | import com.indarsoft.cryptocard.card.CardException; 24 | import com.indarsoft.cryptocard.types.PinBlockFormatType; 25 | import com.indarsoft.cryptocard.types.PinValidationType; 26 | import com.indarsoft.utl.Utl; 27 | 28 | public class CardFrm extends Composite { 29 | 30 | private Text txtcardpanNumber; 31 | private Text txtcardExpDate; 32 | private Text txtcardServCode; 33 | private Button btnVisaPvv; 34 | private Button btnIbmOffset; 35 | private Button btnIsopinblock0; 36 | private Button btnIsopinblock3; 37 | private Button btnfind; 38 | private Button btnClear; 39 | // 40 | private static final String NA = "N/A"; 41 | private static final String NF = "N/F"; 42 | private Text txtkeyPvk; 43 | private Text txtkeydki; 44 | private Text txtkeyPinlength; 45 | private Text txtkeyCvk; 46 | private Text txtkeyDateformatCvv; 47 | private Text txtkeyCvk2; 48 | private Text txtkeyDateformatCvv2; 49 | private Text txtkeyZpk; 50 | private Text txtkeyPinblockFormat; 51 | private Button btnLoadKeys; 52 | // 53 | private Text txtrspin; 54 | private Text txtdrsdki; 55 | private Text txtrscvv; 56 | private Text txtrscvv2; 57 | private Text txtrsicvv; 58 | private Label lblCvv; 59 | private Label lblIcvv; 60 | private Text txtrsclearpinblock; 61 | private Label lblClearPinblock; 62 | private Text txtrsencryptedpinblock; 63 | private Label lblEncryptedPinblock; 64 | private Label lblrsmessage; 65 | // 66 | private Shell sh = this.getShell(); 67 | private String xmlFile = ""; 68 | private Card card = null; 69 | private XmlKeyData xmlkeyData = null; 70 | private Text txtcardPvv; 71 | private Text txtcarddki; 72 | private Label lblPvvoffset; 73 | // 74 | private boolean validKeys = false ; 75 | // 76 | public CardFrm(Composite parent) { 77 | super(parent, SWT.NONE); 78 | setLayout(null); 79 | Group groupcard = new Group(this, SWT.SHADOW_ETCHED_IN); 80 | groupcard.setBounds(10, 10, 294, 165); 81 | // group.setBounds(0, 0, 295, 150); 82 | 83 | groupcard.setText("Card Data"); 84 | groupcard.setLayout(null); 85 | 86 | Label lblCard = new Label(groupcard, SWT.NONE); 87 | lblCard.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 88 | lblCard.setBounds(new Rectangle(0, 0, 0, 16)); 89 | lblCard.setBounds(12, 25, 91, 17); 90 | lblCard.setText("PAN Number"); 91 | 92 | Label lblExpdate = new Label(groupcard, SWT.NONE); 93 | lblExpdate.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 94 | lblExpdate.setBounds(new Rectangle(0, 0, 0, 16)); 95 | lblExpdate.setBounds(141, 25, 56, 17); 96 | lblExpdate.setText("ExpDate"); 97 | 98 | Label lblService = new Label(groupcard, SWT.NONE); 99 | lblService.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 100 | lblService.setBounds(new Rectangle(0, 0, 0, 16)); 101 | lblService.setBounds(204, 25, 65, 17); 102 | lblService.setText("ServCode"); 103 | 104 | txtcardpanNumber = new Text(groupcard, SWT.BORDER); 105 | txtcardpanNumber.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 106 | txtcardpanNumber.setBounds(12, 46, 135, 21); 107 | 108 | txtcardExpDate = new Text(groupcard, SWT.BORDER); 109 | txtcardExpDate.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 110 | txtcardExpDate.setBounds(152, 46, 46, 21); 111 | 112 | txtcardServCode = new Text(groupcard, SWT.BORDER); 113 | txtcardServCode.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 114 | txtcardServCode.setBounds(204, 46, 46, 21); 115 | 116 | Group pinValidationType = new Group(groupcard, SWT.SHADOW_ETCHED_IN); 117 | pinValidationType.setBounds(9, 68, 244, 68); 118 | 119 | btnVisaPvv = new Button(pinValidationType, SWT.RADIO); 120 | btnVisaPvv.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 121 | btnVisaPvv.setSelection(true); 122 | btnVisaPvv.setBounds(10, 15, 90, 17); 123 | btnVisaPvv.setText("Visa PVV"); 124 | 125 | btnIbmOffset = new Button(pinValidationType, SWT.RADIO); 126 | btnIbmOffset.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 127 | btnIbmOffset.setBounds(130, 15, 104, 17); 128 | btnIbmOffset.setText("IBM Offset"); 129 | 130 | Label lblDki_2 = new Label(pinValidationType, SWT.NONE); 131 | lblDki_2.setText("dki"); 132 | lblDki_2.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 133 | lblDki_2.setBounds(new Rectangle(0, 0, 0, 16)); 134 | lblDki_2.setBounds(20, 40, 32, 17); 135 | 136 | txtcarddki = new Text(pinValidationType, SWT.BORDER); 137 | txtcarddki.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 138 | txtcarddki.setBounds(51, 38, 34, 21); 139 | 140 | lblPvvoffset = new Label(pinValidationType, SWT.NONE); 141 | lblPvvoffset.setText("pvv/offset"); 142 | lblPvvoffset.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 143 | lblPvvoffset.setBounds(new Rectangle(0, 0, 0, 16)); 144 | lblPvvoffset.setBounds(108, 38, 58, 17); 145 | 146 | txtcardPvv = new Text(pinValidationType, SWT.BORDER); 147 | txtcardPvv.setFont(SWTResourceManager.getFont("Calibri", 9,SWT.NORMAL)); 148 | txtcardPvv.setBounds(172, 38, 62, 21); 149 | 150 | Group pinBlockFormatType = new Group(groupcard, SWT.NONE); 151 | pinBlockFormatType.setBounds(9, 130, 244, 35); 152 | 153 | btnIsopinblock0 = new Button(pinBlockFormatType, SWT.RADIO); 154 | btnIsopinblock0.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 155 | btnIsopinblock0.setSelection(true); 156 | btnIsopinblock0.setText("IsoPinblock0"); 157 | btnIsopinblock0.setBounds(3, 15, 108, 17); 158 | 159 | btnIsopinblock3 = new Button(pinBlockFormatType, SWT.RADIO); 160 | btnIsopinblock3.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 161 | btnIsopinblock3.setText("IsoPinblock3"); 162 | btnIsopinblock3.setBounds(130, 15, 108, 17); 163 | 164 | btnfind = new Button(groupcard, SWT.NONE); 165 | btnfind.setBounds(260, 46, 28, 25); 166 | btnfind.setSelection(true); 167 | btnfind.setToolTipText("find"); 168 | btnfind.setImage(SWTResourceManager.getImage(CardFrm.class, "/images/find_obj.gif")); 169 | 170 | btnClear = new Button(groupcard, SWT.NONE); 171 | btnClear.setBounds(260, 76, 28, 25); 172 | btnClear.setToolTipText("clear"); 173 | btnClear.setImage(SWTResourceManager.getImage(CardFrm.class, "/images/clear.gif")); 174 | groupcard.pack(); 175 | // 176 | Group groupkey = new Group(this, SWT.SHADOW_ETCHED_IN); 177 | groupkey.setBounds(10, 180, 470, 280); 178 | groupkey.setText("Load Keys"); 179 | Label lblPvk = new Label(groupkey, SWT.NONE); 180 | lblPvk.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 181 | lblPvk.setSize(23, 17); 182 | lblPvk.setText("Pvk"); 183 | lblPvk.setLocation(20, 20); 184 | lblPvk.pack(); 185 | 186 | Label lblDki = new Label(groupkey, SWT.NONE); 187 | lblDki.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 188 | lblDki.setBounds(301, 20, 25, 17); 189 | lblDki.setText("dki"); 190 | 191 | Label lblPinlength = new Label(groupkey, SWT.NONE); 192 | lblPinlength.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 193 | lblPinlength.setBounds(332, 20, 81, 17); 194 | lblPinlength.setText("Pin Length"); 195 | 196 | txtkeyPvk = new Text(groupkey, SWT.BORDER); 197 | txtkeyPvk.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 198 | txtkeyPvk.setEditable(false); 199 | txtkeyPvk.setBounds(20, 41, 275, 21); 200 | 201 | txtkeydki = new Text(groupkey, SWT.BORDER); 202 | txtkeydki.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 203 | txtkeydki.setEditable(false); 204 | txtkeydki.setBounds(301, 41, 36, 21); 205 | 206 | txtkeyPinlength = new Text(groupkey, SWT.BORDER); 207 | txtkeyPinlength.setFont(SWTResourceManager.getFont("Calibri", 9,SWT.NORMAL)); 208 | txtkeyPinlength.setEditable(false); 209 | txtkeyPinlength.setBounds(350, 41, 36, 21); 210 | 211 | Label lblNewLabel = new Label(groupkey, SWT.NONE); 212 | lblNewLabel.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 213 | lblNewLabel.setBounds(20, 80, 203, 17); 214 | lblNewLabel.setText("Cvk for cvv/icvv or cvc/icvc"); 215 | 216 | Label lblDateFormat = new Label(groupkey, SWT.NONE); 217 | lblDateFormat.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 218 | lblDateFormat.setBounds(301, 80, 85, 17); 219 | lblDateFormat.setText("Date Format"); 220 | 221 | txtkeyCvk = new Text(groupkey, SWT.BORDER); 222 | txtkeyCvk.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 223 | txtkeyCvk.setEditable(false); 224 | txtkeyCvk.setBounds(20, 101, 275, 21); 225 | 226 | txtkeyDateformatCvv = new Text(groupkey, SWT.BORDER); 227 | txtkeyDateformatCvv.setFont(SWTResourceManager.getFont("Calibri", 9, 228 | SWT.NORMAL)); 229 | txtkeyDateformatCvv.setEditable(false); 230 | txtkeyDateformatCvv.setBounds(301, 101, 76, 21); 231 | 232 | Label lblNewLabel_1 = new Label(groupkey, SWT.NONE); 233 | lblNewLabel_1.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 234 | lblNewLabel_1.setBounds(21, 141, 167, 17); 235 | lblNewLabel_1.setText("Cvk for cvv2 or cvc2"); 236 | 237 | Label label = new Label(groupkey, SWT.NONE); 238 | label.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 239 | label.setText("Date Format"); 240 | label.setBounds(301, 141, 85, 17); 241 | 242 | txtkeyCvk2 = new Text(groupkey, SWT.BORDER); 243 | txtkeyCvk2.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 244 | txtkeyCvk2.setEditable(false); 245 | txtkeyCvk2.setBounds(20, 162, 275, 21); 246 | 247 | txtkeyDateformatCvv2 = new Text(groupkey, SWT.BORDER); 248 | txtkeyDateformatCvv2.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 249 | txtkeyDateformatCvv2.setEditable(false); 250 | txtkeyDateformatCvv2.setBounds(301, 162, 76, 21); 251 | 252 | Label lblZpkForPinblock = new Label(groupkey, SWT.NONE); 253 | lblZpkForPinblock.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 254 | lblZpkForPinblock.setBounds(20, 201, 113, 17); 255 | lblZpkForPinblock.setText("Zpk for Pinblock"); 256 | 257 | txtkeyZpk = new Text(groupkey, SWT.BORDER); 258 | txtkeyZpk.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 259 | txtkeyZpk.setEditable(false); 260 | txtkeyZpk.setBounds(20, 222, 275, 21); 261 | 262 | txtkeyPinblockFormat = new Text(groupkey, SWT.BORDER); 263 | txtkeyPinblockFormat.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 264 | txtkeyPinblockFormat.setEditable(false); 265 | txtkeyPinblockFormat.setBounds(20, 248, 275, 21); 266 | 267 | btnLoadKeys = new Button(groupkey, SWT.PUSH); 268 | btnLoadKeys.setToolTipText("load keys"); 269 | btnLoadKeys.setImage(SWTResourceManager.getImage(CardFrm.class, "/images/key_add.png")); 270 | btnLoadKeys.setSize(28, 26); 271 | btnLoadKeys.setLocation(418, 41); 272 | btnLoadKeys.pack(); 273 | 274 | Group result = new Group(this, SWT.NONE); 275 | result.setText("Card Result"); 276 | result.setBounds(311, 10, 305, 163); 277 | 278 | Label lblPin = new Label(result, SWT.NONE); 279 | lblPin.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 280 | lblPin.setBounds(new Rectangle(0, 0, 0, 16)); 281 | lblPin.setBounds(12, 25, 32, 17); 282 | lblPin.setText("pin"); 283 | 284 | txtrspin = new Text(result, SWT.BORDER); 285 | txtrspin.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 286 | txtrspin.setBounds(12, 46, 68, 21); 287 | 288 | Label lblDki_1 = new Label(result, SWT.NONE); 289 | lblDki_1.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 290 | lblDki_1.setBounds(new Rectangle(0, 0, 0, 16)); 291 | lblDki_1.setBounds(87, 25, 32, 17); 292 | lblDki_1.setText("dki"); 293 | 294 | txtdrsdki = new Text(result, SWT.BORDER); 295 | txtdrsdki.setFont(SWTResourceManager 296 | .getFont("Calibri", 9, SWT.NORMAL)); 297 | txtdrsdki.setBounds(86, 46, 33, 21); 298 | 299 | Label lblCvvcvc = new Label(result, SWT.NONE); 300 | lblCvvcvc.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 301 | lblCvvcvc.setBounds(new Rectangle(0, 0, 0, 16)); 302 | lblCvvcvc.setBounds(125, 25, 32, 17); 303 | lblCvvcvc.setText("cvv"); 304 | 305 | txtrscvv = new Text(result, SWT.BORDER); 306 | txtrscvv.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 307 | txtrscvv.setBounds(125, 46, 43, 21); 308 | 309 | lblCvv = new Label(result, SWT.NONE); 310 | lblCvv.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 311 | lblCvv.setBounds(new Rectangle(0, 0, 0, 16)); 312 | lblCvv.setBounds(174, 25, 32, 17); 313 | lblCvv.setText("cvv2"); 314 | 315 | txtrscvv2 = new Text(result, SWT.BORDER); 316 | txtrscvv2.setFont(SWTResourceManager 317 | .getFont("Calibri", 9, SWT.NORMAL)); 318 | txtrscvv2.setBounds(174, 46, 43, 21); 319 | 320 | lblIcvv = new Label(result, SWT.NONE); 321 | lblIcvv.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 322 | lblIcvv.setBounds(new Rectangle(0, 0, 0, 16)); 323 | lblIcvv.setBounds(223, 25, 32, 17); 324 | lblIcvv.setText("icvv\r\n"); 325 | 326 | txtrsicvv = new Text(result, SWT.BORDER); 327 | txtrsicvv.setFont(SWTResourceManager 328 | .getFont("Calibri", 9, SWT.NORMAL)); 329 | txtrsicvv.setBounds(223, 46, 43, 21); 330 | 331 | lblClearPinblock = new Label(result, SWT.NONE); 332 | lblClearPinblock.setFont(SWTResourceManager.getFont("Calibri", 9,SWT.NORMAL)); 333 | lblClearPinblock.setBounds(12, 86, 105, 17); 334 | lblClearPinblock.setText("Clear Pinblock"); 335 | 336 | txtrsclearpinblock = new Text(result, SWT.BORDER); 337 | txtrsclearpinblock.setFont(SWTResourceManager.getFont("Calibri", 9,SWT.NORMAL)); 338 | txtrsclearpinblock.setBounds(12, 107, 135, 21); 339 | 340 | lblEncryptedPinblock = new Label(result, SWT.NONE); 341 | lblEncryptedPinblock.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 342 | lblEncryptedPinblock.setBounds(160, 86, 135, 17); 343 | lblEncryptedPinblock.setText("Encrypted Pinblock"); 344 | 345 | txtrsencryptedpinblock = new Text(result, SWT.BORDER); 346 | txtrsencryptedpinblock.setFont(SWTResourceManager.getFont("Calibri", 9, SWT.NORMAL)); 347 | txtrsencryptedpinblock.setBounds(160, 107, 135, 21); 348 | 349 | lblrsmessage = new Label(result, SWT.NONE); 350 | lblrsmessage.setBounds(12, 138, 283, 15); 351 | // 352 | btnVisaPvv.addSelectionListener(new SelectionAdapter() { 353 | @Override 354 | public void widgetSelected(SelectionEvent e) { 355 | 356 | if (xmlkeyData != null) { 357 | String msg = validateCard(); 358 | if (!msg.equals("")) { 359 | @SuppressWarnings("unused") 360 | FrmAlert alert = new FrmAlert(sh, msg); 361 | } else { 362 | fillDataKeys(card.getPanNumber().substring(0, 6), card 363 | .getPinBlockFormatType().toString(), xmlkeyData); 364 | } 365 | } 366 | } 367 | }); 368 | // 369 | btnIsopinblock0.addSelectionListener(new SelectionAdapter() { 370 | @Override 371 | public void widgetSelected(SelectionEvent e) { 372 | 373 | if (xmlkeyData != null) { 374 | String msg = validateCard(); 375 | if (!msg.equals("")) { 376 | @SuppressWarnings("unused") 377 | FrmAlert alert = new FrmAlert(sh, msg); 378 | } else { 379 | fillDataKeys(card.getPanNumber().substring(0, 6), card 380 | .getPinBlockFormatType().toString(), xmlkeyData); 381 | } 382 | } 383 | } 384 | }); 385 | // 386 | btnfind.addSelectionListener(new SelectionAdapter() { 387 | 388 | public void widgetSelected(SelectionEvent event) { 389 | 390 | String msg = validateCard(); 391 | if (!msg.equals("")) { 392 | @SuppressWarnings("unused") 393 | FrmAlert alert = new FrmAlert(sh, msg); 394 | }else if (xmlkeyData == null || !validKeys) { 395 | @SuppressWarnings("unused") 396 | FrmAlert alert = new FrmAlert(sh, "Please load a valid key file !!"); 397 | } else { 398 | fillDataKeys(card.getPanNumber().substring(0, 6), card 399 | .getPinBlockFormatType().toString(), xmlkeyData); 400 | if ( validKeys ){ 401 | computeResult(); 402 | }/*else{ 403 | @SuppressWarnings("unused") 404 | FrmAlert alert = new FrmAlert(sh, "Please load a valid key file !!"); 405 | }*/ 406 | 407 | } 408 | } 409 | 410 | }); 411 | // 412 | btnClear.addSelectionListener(new SelectionAdapter() { 413 | 414 | public void widgetSelected(SelectionEvent event) { 415 | 416 | clearScreen(); 417 | } 418 | 419 | }); 420 | // 421 | btnLoadKeys.addSelectionListener(new SelectionAdapter() { 422 | 423 | public void widgetSelected(SelectionEvent event) { 424 | 425 | String msg = validateCard(); 426 | if (!msg.equals("")) { 427 | @SuppressWarnings("unused") 428 | FrmAlert alert = new FrmAlert(sh, msg); 429 | } else { 430 | FileDialog dlg = new FileDialog(new Shell(), SWT.OPEN); 431 | String fileName = dlg.open(); 432 | String dir = Utl.getPwd(); 433 | dir = dir + File.separator + "data" + File.separator 434 | + "config"; 435 | dlg.setFilterPath(dir); 436 | if (fileName != null) { 437 | xmlFile = fileName; 438 | xmlkeyData = loadKeys(xmlFile); 439 | fillDataKeys(card.getPanNumber().substring(0, 6), card 440 | .getPinBlockFormatType().toString(), xmlkeyData); 441 | } 442 | } 443 | } 444 | }); 445 | // 446 | } 447 | 448 | private String validateCard() { 449 | 450 | String str = ""; 451 | try { 452 | 453 | card = new Card(txtcardpanNumber.getText()); 454 | card.setExpirationDate(txtcardExpDate.getText()); 455 | card.setServiceCode(txtcardServCode.getText()); 456 | 457 | if (txtcarddki.getText().equals("")) { 458 | str = "please inform card dki value !!"; 459 | return str; 460 | } else { 461 | int z = Integer.parseInt(txtcarddki.getText()); 462 | card.setPvki(z); 463 | } 464 | 465 | if (btnVisaPvv.getSelection()) { 466 | card.setPinValidationType(PinValidationType.VISA_PVV); 467 | card.setPvv(txtcardPvv.getText()); 468 | 469 | } 470 | if (btnIbmOffset.getSelection()) { 471 | card.setPinValidationType(PinValidationType.IBM_3624_OFFSET); 472 | card.setOffset(txtcardPvv.getText()); 473 | } 474 | 475 | if (btnIsopinblock0.getSelection()) { 476 | card.setPinBlockFormatType(PinBlockFormatType.ISOFORMAT0); 477 | } 478 | if (btnIsopinblock3.getSelection()) { 479 | card.setPinBlockFormatType(PinBlockFormatType.ISOFORMAT3); 480 | } 481 | 482 | } catch (Exception e) { 483 | str = e.getMessage(); 484 | return str; 485 | } 486 | 487 | return ""; 488 | } 489 | 490 | private void clearScreen() { 491 | 492 | FrmControls frmcnt = new FrmControls(this.getParent()); 493 | frmcnt.clearFields(); 494 | // btnfind.setEnabled(true); 495 | btnVisaPvv.setSelection(true); 496 | btnIbmOffset.setSelection(false); 497 | btnIsopinblock0.setSelection(true); 498 | btnIsopinblock3.setSelection(false); 499 | lblrsmessage.setText(""); 500 | //xmlkeyData = null; 501 | validKeys = false ; 502 | } 503 | 504 | /* 505 | * Load Keys from XML com.indarsoft.cardutl.file in ./data/config DIR 506 | */ 507 | private XmlKeyData loadKeys(String xmlFile) { 508 | 509 | LoadXmlKeys lk = new LoadXmlKeys(xmlFile); 510 | XmlKeyData xmlkeyData = null; 511 | try { 512 | xmlkeyData = lk.loadXMLData(); 513 | } catch (Exception ex) { 514 | System.out.println(ex.getMessage()); 515 | } 516 | return xmlkeyData; 517 | } 518 | 519 | private void fillDataKeys(String binNumber, String pinBlockFormatType, XmlKeyData xmlkeyData) { 520 | // 521 | initializeData(NA); 522 | // 523 | String str = ""; 524 | BinKey b = xmlkeyData.getBinKey(binNumber) ; 525 | if ( b == null ){ // binNUmber not found 526 | //btnfind.setEnabled(false); 527 | validKeys = false ; 528 | @SuppressWarnings("unused") 529 | FrmAlert alert = new FrmAlert(sh, "Please load a valid key file !!"); 530 | return ; 531 | }else{ 532 | //btnfind.setEnabled(true); 533 | } 534 | 535 | if ( xmlkeyData.getBinKey(binNumber).getPinValidationType().equals(PinValidationType.VISA_PVV) 536 | && btnVisaPvv.getSelection()) { 537 | str = xmlkeyData.getBinKey(binNumber).getPvk().getKeyAsString(); 538 | txtkeyPvk.setText(str); 539 | str = Integer.toString(xmlkeyData.getBinKey(binNumber).getPvk() 540 | .getPvki()); 541 | txtkeydki.setText(str); 542 | str = Integer.toString(xmlkeyData.getBinKey(binNumber) 543 | .getPinLength()); 544 | if (!str.equals("0")) { 545 | txtkeyPinlength.setText(str); 546 | } 547 | } 548 | if (xmlkeyData.getBinKey(binNumber).getPinValidationType() 549 | .equals(PinValidationType.IBM_3624_OFFSET) 550 | && btnIbmOffset.getSelection()) { 551 | str = xmlkeyData.getBinKey(binNumber).getPvk().getKeyAsString(); 552 | txtkeyPvk.setText(str); 553 | str = Integer.toString(xmlkeyData.getBinKey(binNumber).getPvk() 554 | .getPvki()); 555 | txtkeydki.setText(str); 556 | str = Integer.toString(xmlkeyData.getBinKey(binNumber) 557 | .getPinLength()); 558 | if (!str.equals("0")) { 559 | txtkeyPinlength.setText(str); 560 | } 561 | } 562 | // 563 | str = xmlkeyData.getBinKey(binNumber).getCvvKey().getKeyAsString(); 564 | txtkeyCvk.setText(str); 565 | str = xmlkeyData.getBinKey(binNumber).getCvvKeyDateFormat(); 566 | txtkeyDateformatCvv.setText(str); 567 | // 568 | str = xmlkeyData.getBinKey(binNumber).getCvv2Key().getKeyAsString(); 569 | txtkeyCvk2.setText(str); 570 | str = xmlkeyData.getBinKey(binNumber).getCvv2KeyDateFormat(); 571 | txtkeyDateformatCvv2.setText(str); 572 | // 573 | str = xmlkeyData.getPinBlock(pinBlockFormatType).getZpk() 574 | .getKeyAsString(); 575 | txtkeyZpk.setText(str); 576 | str = xmlkeyData.getPinBlock(pinBlockFormatType) 577 | .getPinBlockFormatType().toString(); 578 | txtkeyPinblockFormat.setText(str); 579 | // 580 | validKeys = true ; 581 | // 582 | } 583 | 584 | private void initializeData(String str) { 585 | 586 | txtkeyPvk.setText(str); 587 | txtkeydki.setText(str); 588 | txtkeyPinlength.setText(str); 589 | txtkeyCvk.setText(str); 590 | txtkeyDateformatCvv.setText(str); 591 | txtkeyCvk2.setText(str); 592 | txtkeyDateformatCvv2.setText(str); 593 | txtkeyZpk.setText(str); 594 | txtkeyPinblockFormat.setText(str); 595 | // 596 | txtrspin.setText(""); 597 | txtdrsdki.setText(""); 598 | txtrscvv.setText(""); 599 | txtrscvv2.setText(""); 600 | txtrsicvv.setText(""); 601 | txtrsclearpinblock.setText(""); 602 | txtrsencryptedpinblock.setText(""); 603 | lblrsmessage.setText(""); 604 | } 605 | 606 | private void computeResult() { 607 | 608 | BinKey binkey = xmlkeyData.getBinKey(card.getPanNumber() 609 | .substring(0, 6)); 610 | String str = card.getPinBlockFormatType().toString(); 611 | PinBlockKey pinBlockKey = xmlkeyData.getPinBlock(str); 612 | ProcessedCardData pcd = null; 613 | 614 | pcd = ProcessCard.doit(card, binkey, pinBlockKey); 615 | // 616 | txtrspin.setText(pcd.getPin()); 617 | String w = Integer.toString(pcd.getDki()); 618 | txtdrsdki.setText(w); 619 | txtrscvv.setText(pcd.getCvv()); 620 | txtrscvv2.setText(pcd.getCvv2()); 621 | txtrsicvv.setText(pcd.getIcvv()); 622 | txtrsclearpinblock.setText(pcd.getClearPinblock()); 623 | txtrsencryptedpinblock.setText(pcd.getEncryptedPinblock()); 624 | // 625 | // if pin N/F try all dki's until 626 | // 627 | String returnedpinvalue = pcd.getPin(); 628 | if (returnedpinvalue.equals(NF)) { 629 | for (int k = 1; k < 6; k++) { 630 | try { 631 | card.setPvki(k); 632 | pcd = ProcessCard.doit(card, binkey, pinBlockKey); 633 | String triedPin = pcd.getPin(); 634 | if (!triedPin.equals(NF)) { 635 | txtrspin.setText(pcd.getPin()); 636 | w = Integer.toString(pcd.getDki()); 637 | txtdrsdki.setText(w); 638 | txtrsclearpinblock.setText(pcd.getClearPinblock()); 639 | txtrsencryptedpinblock.setText(pcd 640 | .getEncryptedPinblock()); 641 | lblrsmessage.setText("Cannot find pin for dki " 642 | + txtcarddki.getText() 643 | + " but found pin for dki " + w + " !! "); 644 | Color color= new Color(Display.getCurrent(),new RGB(0,0,255)); 645 | lblrsmessage.setForeground( color ); 646 | break; 647 | } 648 | } catch (CardException e) { 649 | // log.warn( "Process all dki's " + e.getMessage() ) ; 650 | } 651 | } 652 | } 653 | } 654 | } 655 | --------------------------------------------------------------------------------