- java.lang.Object
-
- javax.smartcardio.Card
-
public abstract class Card extends Object
已建立连接的智能卡。 通过调用CardTerminal.connect()获得卡对象。- 从以下版本开始:
- 1.6
- 另请参见:
-
CardTerminal
-
-
构造方法摘要
构造方法 变量 构造器 描述 protectedCard()构造一个新的Card对象。
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 abstract voidbeginExclusive()请求独家访问此卡。abstract voiddisconnect(boolean reset)断开与此卡的连接。abstract voidendExclusive()释放先前使用beginExclusive建立的独占访问权限。abstract ATRgetATR()返回此卡的ATR。abstract CardChannelgetBasicChannel()返回基本逻辑通道的CardChannel。abstract StringgetProtocol()返回此卡使用的协议。abstract CardChannelopenLogicalChannel()打开卡的新逻辑通道并返回它。abstract byte[]transmitControlCommand(int controlCode, byte[] command)将控制命令发送到终端设备。
-
-
-
构造方法详细信息
-
Card
protected Card()
构造一个新的Card对象。此构造函数仅由子类调用。 应用程序应调用CardTerminal.connect()方法以获取Card对象。
-
-
方法详细信息
-
getATR
public abstract ATR getATR()
返回此卡的ATR。- 结果
- 这张卡的ATR。
-
getProtocol
public abstract String getProtocol()
返回此卡使用的协议。- 结果
- 该卡使用的协议,例如“T = 0”或“T = 1”
-
getBasicChannel
public abstract CardChannel getBasicChannel()
返回基本逻辑通道的CardChannel。 基本逻辑信道的信道号为0。- 结果
- CardChannel用于基本逻辑通道
- 异常
-
SecurityException- 如果存在SecurityManager且调用者没有所需的permission -
IllegalStateException- 如果此卡对象已通过 disconnect()方法处理
-
openLogicalChannel
public abstract CardChannel openLogicalChannel() throws CardException
打开卡的新逻辑通道并返回它。 通过发出应使用格式[00 70 00 00 01]的MANAGE CHANNEL命令打开该通道。- 结果
- 已打开的逻辑通道
- 异常
-
SecurityException- 如果存在SecurityManager且调用者没有所需的permission -
CardException- 无法打开新的逻辑通道 -
IllegalStateException- 如果此卡对象已通过 disconnect()方法处理
-
beginExclusive
public abstract void beginExclusive() throws CardException请求独家访问此卡。一旦线程调用了
beginExclusive,只允许此线程与此卡通信,直到它调用endExclusive。 尝试通信的其他线程将收到CardException。应用程序必须确保正确释放独占访问权限。 这可以通过在
try ... finally块中执行beginExclusive()和endExclusive调用来实现。- 异常
-
SecurityException- 如果存在SecurityManager且调用者没有所需的permission -
CardException- 如果已设置独占访问权限或无法建立独占访问权限 -
IllegalStateException- 如果此卡对象已通过 disconnect()方法处理
-
endExclusive
public abstract void endExclusive() throws CardException释放先前使用beginExclusive建立的独占访问权限。- 异常
-
SecurityException- 如果存在SecurityManager且调用者没有所需的permission -
IllegalStateException- 如果活动线程当前没有对此卡的独占访问权限,或者此卡对象已通过 disconnect()方法处理 -
CardException- 如果操作失败
-
transmitControlCommand
public abstract byte[] transmitControlCommand(int controlCode, byte[] command) throws CardException将控制命令发送到终端设备。例如,这可用于控制终端功能,如内置密码键盘或生物识别。
- 参数
-
controlCode- 命令的控制代码 -
command- 命令数据 - 结果
- 来自终端设备的响应
- 异常
-
SecurityException- 如果存在SecurityManager且调用者没有所需的permission -
NullPointerException- 如果command为null -
CardException- 如果卡操作失败 -
IllegalStateException- 如果此卡对象已通过 disconnect()方法处理
-
disconnect
public abstract void disconnect(boolean reset) throws CardException断开与此卡的连接。 此方法返回后,调用此对象或与此对象关联的CardChannels中需要与卡交互的方法将引发IllegalStateException。- 参数
-
reset- 断开连接后是否重置卡。 - 异常
-
CardException- 如果卡操作失败 -
SecurityException- 如果存在SecurityManager且调用者没有所需的permission
-
-