001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.emv.cryptogram; 020 021import org.jpos.security.ARPCMethod; 022import org.jpos.security.MKDMethod; 023import org.jpos.security.SKDMethod; 024 025/** 026 * VISA Cryptogram Specification 027 * 028 * @author Rainer Reyes 029 */ 030public class VISACryptogram implements CryptogramSpec { 031 032 private final Integer number; 033 private final CryptogramDataBuilder dataBuilder; 034 private final ARPCMethod arpcMethod; 035 private final SKDMethod skdMethod; 036 037 public VISACryptogram(String cryptogramVersionNumber) { 038 this.number = Integer.parseInt(cryptogramVersionNumber, 16); 039 if (number == 10) { 040 this.dataBuilder = new CVN10DataBuilder(); 041 this.arpcMethod = ARPCMethod.METHOD_1; 042 this.skdMethod = SKDMethod.VSDC; 043 } else if (number == 18) { // CVN 18 044 this.dataBuilder = new CVN18DataBuilder(); 045 this.arpcMethod = ARPCMethod.METHOD_2; 046 this.skdMethod = SKDMethod.EMV_CSKD; 047 } else if (number == 34) {//CVN '22' 048 this.dataBuilder = new CVN22DataBuilder(); 049 this.arpcMethod = ARPCMethod.METHOD_2; 050 this.skdMethod = SKDMethod.EMV_CSKD; 051 } else { 052 throw new IllegalArgumentException("Cryptogram version not supported"); 053 } 054 } 055 056 057 @Override 058 public MKDMethod getMKDMethod() { 059 return MKDMethod.OPTION_A; 060 } 061 062 @Override 063 public SKDMethod getSKDMethod() { 064 return skdMethod; 065 } 066 067 @Override 068 public ARPCMethod getARPCMethod() { 069 return arpcMethod; 070 } 071 072 @Override 073 public CryptogramDataBuilder getDataBuilder() { 074 return dataBuilder; 075 } 076}