IC卡应用系统开发-(一)卡片读写

本文档介绍了如何基于PC/SC标准来实现IC卡的读写功能,详细探讨了卡片读写的相关技术和流程。
摘要由CSDN通过智能技术生成
<script type="text/javascript"> google_ad_client = "pub-8800625213955058"; /* 336x280, 创建于 07-11-21 */ google_ad_slot = "0989131976"; google_ad_width = 336; google_ad_height = 280; // </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> 最近在开发一个基于CPU卡应用的J2EE项目,应用服务器用的是Weblogic,数据库是oracle, 开发工具jbuilder2005.系统架构是:客户端(pc/sc读写器) <应用服务器> <加密机,应用服务器> <数据库服务器. 客户端首先要安装ic读写器驱动(必须支持pc sc规范),然后到pcscworkgroup网站下载文件installocf.class和reference_impl.class. 运行> java installOCF 按照提示一步一步进行安装操作. 运行>java Reference_Impl 默认安装操作. 在安装完后将thirdparty/OCF1.2/lib/OCFPCSC1.DLL和thirdparty/OCF1.2/lib/OCFPCSCM.DLL拷贝到jdk的bin目录. 在jbuilder工程文件目录下建立opencard.properties文件,内容如下, # Configure the CardService Registry: # Use the service factory for the IBM MultiFunction Cards OpenCard.services = opencard.opt.util.PassThruCardServiceFactory #OpenCard.services = com.ibm.opencard.factory.MFCCardServiceFactory # OpenCard.services = com.slb.opencard.CyberflexAccess.CyberflexAccessCardServiceFactory # Configure the CardTerminal Registry: com.ibm.opencard.terminal.pcscmig.PcscMigCardTerminalFactory OpenCard.terminals = com.ibm.opencard.terminal.pcsc10.Pcsc10CardTerminalFactory # Configure Tracing. Detailed for all samples only: OpenCard.trace = opencard:8 在jbuilder中建立pcsc库. toolsconfigurelibraries 在user home下建立pcsc10,在required libraries选项卡中选择安装的目录下lib下的所有文件. 我用的读写期是某公司的,命令集与PBOC稍有改动,但基本格式是按照PCSC的. 我建立了3个文件: 接口文件:IReader.java,用于程序将来兼容其他读写器; 实现文件:ReaderMA,java,实现接口, 异常文件:ReaderException,用户捕获异常及错误处理. 实现文件如下: package com.microapp.application.reader; /** *

Title: 基于PC/SC标准的读写器实现

* *

Description:

* *

Copyright: Copyright (c) 2005

* *

Company: 我的软件公司

* * @author etd group * @version 1.0 */ import java.util.*; import opencard.core.*; import opencard.core.service.*; import opencard.core.terminal.*; import opencard.core.util.*; import opencard.opt.util.*; public class ReaderMA implements IReader { private static final int IFD_TIMEOUT = 5; // unit: seconds private static final int MAX_APDU_SIZE = 200; // unit: byte private static final int SW1_OK = (byte)0x90; private static final int SW2_OK = 0x00; private static final int RESPONSE_OK = 0x61; private static SmartCard sc = null; private static PassThruCardService ptcs = null; private static CardRequest cr = null; private static CommandAPDU capdu = null; private static ResponseAPDU rapdu = null; byte[] rbuf = null; public ReaderMA() { } /** * 复位 * @throws ReaderPCSCException */ public byte[] Reset() throws ReaderException { try { if (cr == null) { SmartCard.start(); cr = new CardRequest(CardRequest.ANYCARD, null, PassThruC
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值