本文整理汇总了Java中javax.smartcardio.ATR类的典型用法代码示例。如果您正苦于以下问题:Java ATR类的具体用法?Java ATR怎么用?Java ATR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ATR类属于javax.smartcardio包,在下文中一共展示了ATR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SimulatedBeIDCard
import javax.smartcardio.ATR; //导入依赖的package包/类
public SimulatedBeIDCard(final String profile) {
super(null);
final InputStream atrInputStream = SimulatedBeIDCard.class
.getResourceAsStream("/" + profile + "_ATR.bin");
try {
setATR(new ATR(IOUtils.toByteArray(atrInputStream)));
} catch (final IOException ioex) {
// missing _ATR file, set ATR from testcard
setATR(new ATR(new byte[]{0x3b, (byte) 0x98, 0x13, 0x40, 0x0a,
(byte) 0xa5, 0x03, 0x01, 0x01, 0x01, (byte) 0xad, 0x13,
0x11}));
}
setFilesFromProfile(profile);
}
示例2: setUp
import javax.smartcardio.ATR; //导入依赖的package包/类
@Before
public void setUp() {
this.simulatedBeIDCard = new ArrayList<SimulatedCard>(numberOfCards);
for (int i = 0; i < numberOfCards; i++) {
this.simulatedBeIDCard.add(new SimulatedCard(new ATR(new byte[]{
0x3b, (byte) 0x98, (byte) i, 0x40, (byte) i, (byte) i,
(byte) i, (byte) i, 0x01, 0x01, (byte) 0xad, 0x13, 0x10})));
}
this.simulatedCardTerminal = new ArrayList<SimulatedCardTerminal>(
numberOfTerminals);
for (int i = 0; i < numberOfTerminals; i++) {
this.simulatedCardTerminal.add(new SimulatedCardTerminal(
"Fedix SCR " + i));
}
this.simulatedCardTerminals = new SimulatedCardTerminals();
}
示例3: connect
import javax.smartcardio.ATR; //导入依赖的package包/类
@Override
public Card connect(String protocol) throws CardException {
try {
HashMap<String, Object> m = new HashMap<>();
m.put("cmd", "CONNECT");
m.put("protocol", protocol);
client.send(m);
// Read back the response
Map<String, Object> r = client.recv();
if (r.containsKey("CONNECT") && ((String)r.get("CONNECT")).equals("OK")) {
if (r.containsKey("atr") && r.containsKey("protocol") && r.containsKey("reader")) {
terminalName = (String) r.get("reader");
atr = new ATR(HexUtils.stringToBin((String) r.get("atr")));
this.protocol = ((String) r.get("protocol"));
return new JSONCard(this);
}
}
throw new CardException("Could not connect to client");
} catch (IOException e) {
throw new CardException("Could not connect to client", e);
}
}
示例4: CardImpl
import javax.smartcardio.ATR; //导入依赖的package包/类
CardImpl(TerminalImpl terminal, String protocol) throws PCSCException {
this.terminal = terminal;
int sharingMode = SCARD_SHARE_SHARED;
int connectProtocol;
if (protocol.equals("*")) {
connectProtocol = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;
} else if (protocol.equalsIgnoreCase("T=0")) {
connectProtocol = SCARD_PROTOCOL_T0;
} else if (protocol.equalsIgnoreCase("T=1")) {
connectProtocol = SCARD_PROTOCOL_T1;
} else if (protocol.equalsIgnoreCase("direct")) {
// testing
connectProtocol = 0;
sharingMode = SCARD_SHARE_DIRECT;
} else {
throw new IllegalArgumentException("Unsupported protocol " + protocol);
}
cardId = SCardConnect(terminal.contextId, terminal.name, sharingMode, connectProtocol);
byte[] status = new byte[2];
byte[] atrBytes = SCardStatus(cardId, status);
atr = new ATR(atrBytes);
this.protocol = status[1] & 0xff;
basicChannel = new ChannelImpl(this, 0);
state = State.OK;
}
示例5: matchesEidAtr
import javax.smartcardio.ATR; //导入依赖的package包/类
private boolean matchesEidAtr(ATR atr) {
byte[] atrBytes = atr.getBytes();
if (atrBytes.length != ATR_PATTERN.length) {
return false;
}
for (int idx = 0; idx < atrBytes.length; idx++) {
atrBytes[idx] &= ATR_MASK[idx];
}
if (Arrays.equals(atrBytes, ATR_PATTERN)) {
return true;
}
return false;
}
示例6: Emulator_connection_card
import javax.smartcardio.ATR; //导入依赖的package包/类
Emulator_connection_card(Emulator_connection_terminal terminal,
JCard jcard, ATR atr, int verbosity)
{
if(verbosity > 0) {
System.out.println("JC card constructor");
}
this.terminal = terminal;
this.jcard = jcard;
this.smio_atr = atr;
this.verbosity = verbosity;
owner = null;
}
示例7: getATR
import javax.smartcardio.ATR; //导入依赖的package包/类
@Override
public ATR getATR() {
if (mSession.getATR() != null) {
return new ATR(mSession.getATR());
}
return null;
}
示例8: setUp
import javax.smartcardio.ATR; //导入依赖的package包/类
@Before
public void setUp() {
this.simulatedBeIDCards = new ArrayList<BeIDCard>(numberOfCards);
for (int i = 0; i < numberOfCards; i++) {
this.simulatedBeIDCards.add(new BeIDCard(new SimulatedCard(new ATR(
new byte[]{0x3b, (byte) 0x98, (byte) i, 0x40, (byte) i,
(byte) i, (byte) i, (byte) i, 0x01, 0x01,
(byte) 0xad, 0x13, 0x10}))));
}
}
示例9: matchesEidAtr
import javax.smartcardio.ATR; //导入依赖的package包/类
private boolean matchesEidAtr(final ATR atr) {
final byte[] atrBytes = atr.getBytes();
if (atrBytes.length != ATR_PATTERN.length) {
return false;
}
for (int idx = 0; idx < atrBytes.length; idx++) {
atrBytes[idx] &= ATR_MASK[idx];
}
if (Arrays.equals(atrBytes, ATR_PATTERN)) {
return true;
}
return false;
}
示例10: matchesEidAtr
import javax.smartcardio.ATR; //导入依赖的package包/类
public static boolean matchesEidAtr(ATR atr) { // from eid-applet-core...PcscEid.java
byte[] atrBytes = atr.getBytes();
if (atrBytes.length != ATR_PATTERN.length) {
return false;
}
for (int idx = 0; idx < atrBytes.length; idx++) {
atrBytes[idx] &= ATR_MASK[idx];
}
if (Arrays.equals(atrBytes, ATR_PATTERN)) {
return true;
}
return false;
}
示例11: JnaCard
import javax.smartcardio.ATR; //导入依赖的package包/类
public JnaCard(Winscard.WinscardLibInfo libInfo, JnaCardTerminal cardTerminal, Winscard.SCardHandle scardHandle, ATR atr, int protocol) {
this.libInfo = libInfo;
this.cardTerminal = cardTerminal;
this.scardHandle = scardHandle;
this.atr = atr;
this.protocol = protocol;
getProtocol(); // make sure it is valid.
}
示例12: testGetAtr
import javax.smartcardio.ATR; //导入依赖的package包/类
@Test public void testGetAtr() throws CardException {
List<CardTerminal> terminalList = terminals.list();
CardTerminal terminal = terminalList.get(0);
Card connection = terminal.connect("*");
ATR atr = connection.getATR();
byte[] atrBytes = atr.getBytes();
assertNotSame(0, atrBytes.length);
boolean hasNonZeroAtr = false;
for (int i = 0; i < atrBytes.length; i++) {
hasNonZeroAtr = hasNonZeroAtr || atrBytes[i] != 0;
}
assertTrue(hasNonZeroAtr);
}
示例13: getATR
import javax.smartcardio.ATR; //导入依赖的package包/类
@Override
public ATR getATR() {
throw new UnsupportedOperationException("Not supported yet.");
}
示例14: getATR
import javax.smartcardio.ATR; //导入依赖的package包/类
@Override
public ATR getATR() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
示例15: getATR
import javax.smartcardio.ATR; //导入依赖的package包/类
public ATR getATR() {
return smio_atr;
}