本文整理汇总了Java中sasc.iso7816.SmartCardException类的典型用法代码示例。如果您正苦于以下问题:Java SmartCardException类的具体用法?Java SmartCardException怎么用?Java SmartCardException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SmartCardException类属于sasc.iso7816包,在下文中一共展示了SmartCardException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: externalAuthenticate
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
/**
*
* @param cryptogram mandatory 8 bytes from issuer
* @param proprietaryData optional 1-8 bytes (proprietary)
* @throws TerminalException
*/
public void externalAuthenticate(byte[] cryptogram, byte[] proprietaryData) throws TerminalException {
EMVApplication app = card.getSelectedApplication();
verifyAppInitialized(app);
byte[] command;
Log.commandHeader("Send EXTERNAL AUTHENTICATE command");
command = EMVAPDUCommands.externalAuthenticate(cryptogram, proprietaryData);
CardResponse externalAuthenticateResponse = EMVUtil.sendCmd(terminal, command);
//No data field is returned in the response message
//'9000' indicates a successful execution of the command.
//'6300' indicates "Issuer authentication failed".
if (externalAuthenticateResponse.getSW() != SW.SUCCESS.getSW()) {
if (externalAuthenticateResponse.getSW() == SW.AUTHENTICATION_FAILED.getSW()) {
throw new SmartCardException("Issuer authentication failed");
}
throw new SmartCardException("Unexpected response: " + Util.short2Hex(externalAuthenticateResponse.getSW()));
}
}
示例2: readTransactionLog
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
/**
* Based on a patch by Thomas Souvignet -FR-
*/
private void readTransactionLog(EMVApplication app) throws TerminalException {
//read all the log records
LogEntry logEntry = app.getLogEntry();
int sfi = logEntry.getSFI().getValue();
for (int recordNum = 1; recordNum <= logEntry.getNumberOfRecords(); recordNum++) {
Log.commandHeader("Send READ RECORD to read LOG ENTRY SFI " + sfi + " record " + recordNum);
byte[] command = EMVAPDUCommands.readRecord(recordNum, logEntry.getSFI().getValue());
CardResponse readAppDataResponse = EMVUtil.sendCmdNoParse(terminal, command);
byte SW1 = (byte) readAppDataResponse.getSW1();
byte SW2 = (byte) readAppDataResponse.getSW2();
if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
app.addTransactionLogRecord(readAppDataResponse.getData());
} else if (SW1 == (byte) 0x6a && SW2 == (byte) 0x83) {
return;
} else {
//Any SW1 SW2 other than '9000' passed to the application layer as a result
//of reading any record shall cause the transaction (not entry log) to be terminated [spec]
throw new SmartCardException("Reading application data failed for SFI " + sfi + " Record Number: " + recordNum);
}
}
}
示例3: CVMList
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public CVMList(byte[] data){
if(data.length < 8 ){
throw new IllegalArgumentException("Length is less than 8. Length=" + data.length);
}
ByteArrayInputStream bis = new ByteArrayInputStream(data);
amountField = new byte[4];
secondAmountField = new byte[4];
bis.read(amountField, 0, amountField.length);
bis.read(secondAmountField, 0, secondAmountField.length);
if(bis.available() % 2 != 0 ){
throw new SmartCardException("CMVRules data is not a multiple of 2. Length=" + data.length);
}
while(bis.available() > 0){
byte[] tmp = new byte[2];
bis.read(tmp, 0, tmp.length);
cvRules.add(new CVRule(tmp[0], tmp[1], amountField, secondAmountField));
}
}
示例4: ApplicationElementaryFile
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public ApplicationElementaryFile(byte[] data){
if(data.length != 4){
throw new SmartCardException("Applicaton Elementary File length must be equal to 4. Data length="+data.length);
}
int sfiNumber = data[0] >>> 3;
sfi = new ShortFileIdentifier(sfiNumber);
startRecordNumber = data[1] & 0xFF;
if(startRecordNumber == 0){
throw new SmartCardException("Applicaton Elementary File: Start Record number cannot be 0");
}
endRecordNumber = data[2] & 0xFF;
if(endRecordNumber < startRecordNumber){
throw new SmartCardException("Applicaton Elementary File: End Record number ("+endRecordNumber+") < Start Record number ("+startRecordNumber+")");
}
numRecordsInvolvedInOfflineDataAuthentication = data[3] & 0xFF;
}
示例5: PAN
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public PAN(String inputString) {
if (inputString.length() < 8) {
throw new SmartCardException("Invalid PAN length: " + inputString.length());
}
this.panStr = inputString.toUpperCase();
mii = Short.parseShort(panStr.substring(0, 1));
iin = new IssuerIdentificationNumber(Util.fromHexString(panStr.substring(0, 6)));
//The PAN is transferred as 'cn' (compressed numeric):
//Compressed numeric data elements consist of two numeric digits
//(having values in the range Hex '0'–'9') per byte.
//These data elements are left justified and padded with
//trailing hexadecimal 'F's.
int trailingPadIndex = panStr.indexOf('F');
if(trailingPadIndex != -1){
panStr = panStr.substring(0, trailingPadIndex);
}
//Check that actual PAN length (without padding, is not longer than 19 digits)
if (panStr.length() > 19) {
throw new SmartCardException("Invalid PAN length: " + panStr.length());
}
accountNumber = Long.parseLong(panStr.substring(6, panStr.length() - 1));
valid = PAN.isValidPAN(panStr);
}
示例6: Track2EquivalentData
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public Track2EquivalentData(byte[] data) {
if (data.length > 19) {
throw new SmartCardException("Invalid Track2EquivalentData length: " + data.length);
}
String str = Util.byteArrayToHexString(data).toUpperCase();
//Field Separator (Hex 'D')
int fieldSepIndex = str.indexOf('D');
pan = new PAN(str.substring(0, fieldSepIndex));
//Skip Field Separator
int YY = Util.binaryHexCodedDecimalToInt(str.substring(fieldSepIndex + 1, fieldSepIndex + 3));
int MM = Util.binaryHexCodedDecimalToInt(str.substring(fieldSepIndex + 3, fieldSepIndex + 5));
Calendar cal = Calendar.getInstance();
cal.set(2000 + YY, MM - 1, 0, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
this.expirationDate = cal.getTime();
serviceCode = new ServiceCode(str.substring(fieldSepIndex + 5, fieldSepIndex + 8).toCharArray());
int padIndex = str.indexOf('F', fieldSepIndex + 8);
if (padIndex != -1) {
//Padded with one Hex 'F' if needed to ensure whole bytes
discretionaryData = str.substring(fieldSepIndex + 8, padIndex);
} else {
discretionaryData = str.substring(fieldSepIndex + 8);
}
}
示例7: verifyAppInitialized
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
private void verifyAppInitialized(EMVApplication app) {
if (app == null) {
throw new SmartCardException("No application selected. Call selectApplication(Application) and initializeApplicationProcessing() first");
}
if (!app.isInitializedOnICC()) {
throw new SmartCardException("Application " + Util.prettyPrintHexNoWrap(app.getAID().getAIDBytes()) + " not initialized on ICC initializeApplicationProcessing() first");
}
}
示例8: verifyAllAppRecordsInAFLRead
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
private void verifyAllAppRecordsInAFLRead(EMVApplication app) {
if (app == null) {
throw new SmartCardException("No application selected. Call selectApplication(Application) and initializeApplicationProcessing() first");
}
verifyAppInitialized(app);
if (!app.isAllAppRecordsInAFLRead()) {
throw new SmartCardException("Records indicated in the Application File Locator have not been read.");
}
}
示例9: ApplicationFileLocator
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public ApplicationFileLocator(byte[] data){
if(data.length % 4 != 0) throw new SmartCardException("Length is not a multiple of 4. Length="+data.length);
ByteArrayInputStream bis = new ByteArrayInputStream(data);
while(bis.available() > 0){
byte[] tmp = new byte[4];
bis.read(tmp, 0, tmp.length);
aefList.add(new ApplicationElementaryFile(tmp));
}
}
示例10: LanguagePreference
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public LanguagePreference(byte[] data) {
if (data.length < 2 || data.length > 8 || data.length % 2 != 0) {
throw new SmartCardException("Array length must be an even number between 2 (inclusive) and 8 (inclusive). Length=" + data.length);
}
prefs = new ArrayList<Locale>();
int numLang = data.length / 2;
for (int i = 0; i < numLang; i++) {
String s = String.valueOf((char) data[i * 2]) + String.valueOf((char) data[i * 2 + 1]);
prefs.add(new Locale(s));
}
}
示例11: setExpirationDate
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public void setExpirationDate(byte[] dateBytes) {
if (dateBytes.length != 3) {
throw new SmartCardException("Byte array length must be 3. Length=" + dateBytes.length);
}
int YY = Util.binaryCodedDecimalToInt(dateBytes[0]);
int MM = Util.binaryCodedDecimalToInt(dateBytes[1]);
int DD = Util.binaryCodedDecimalToInt(dateBytes[2]);
Calendar cal = Calendar.getInstance();
cal.set(2000 + YY, MM - 1, DD, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
this.applicationExpirationDate = cal.getTime();
}
示例12: setEffectiveDate
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public void setEffectiveDate(byte[] dateBytes) {
if (dateBytes.length != 3) {
throw new SmartCardException("Byte array length must be 3. Length=" + dateBytes.length);
}
int YY = Util.binaryCodedDecimalToInt(dateBytes[0]);
int MM = Util.binaryCodedDecimalToInt(dateBytes[1]);
int DD = Util.binaryCodedDecimalToInt(dateBytes[2]);
Calendar cal = Calendar.getInstance();
cal.set(2000 + YY, MM - 1, DD, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
this.applicationEffectiveDate = cal.getTime();
}
示例13: IBAN
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public IBAN(byte[] iban) {
if(iban.length > 34) {
throw new SmartCardException("Invalid IBAN length: " + iban.length);
}
this.iban = Util.getSafePrintChars(iban);
countryCode = this.iban.substring(0, 2);
if ("de".equalsIgnoreCase(countryCode)) {
bankNumber = this.iban.substring(2, 10);
accountNumber = this.iban.substring(10);
}
}
示例14: calculateCAPublicKeyCheckSum
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public static byte[] calculateCAPublicKeyCheckSum(byte[] rid, byte[] caPublicKeyIndex, byte[] caPublicKeyMod, byte[] caPublicKeyExp) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(rid.length + caPublicKeyIndex.length + caPublicKeyMod.length + caPublicKeyExp.length);
stream.write(rid, 0, rid.length);
stream.write(caPublicKeyIndex, 0, caPublicKeyIndex.length);
stream.write(caPublicKeyMod, 0, caPublicKeyMod.length);
stream.write(caPublicKeyExp, 0, caPublicKeyExp.length);
byte[] sha1Result;
try {
sha1Result = Util.calculateSHA1(stream.toByteArray());
} catch (NoSuchAlgorithmException ex) {
throw new SmartCardException("SHA-1 hash algorithm not available", ex);
}
return sha1Result;
}
示例15: BankIdentifierCode
import sasc.iso7816.SmartCardException; //导入依赖的package包/类
public BankIdentifierCode(byte[] value) {
if(value.length != 8 && value.length != 11) {
throw new SmartCardException("Invalid BIC length: " + value.length);
}
this.bic = value;
this.bankCode = Util.getSafePrintChars(bic, 0, 4);
this.countryCode = Util.getSafePrintChars(bic, 4, 2);
this.locationCode = Util.getSafePrintChars(bic, 6, 2);
if(value.length == 11){
this.branchCode = Util.getSafePrintChars(bic, 8, 3);
}
}