1 /*
2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
32 // This test requires special hardware.
33
34 import java.io.BufferedReader;
35 import java.io.ByteArrayOutputStream;
36 import java.io.FileReader;
37 import java.io.IOException;
38 import java.io.StringReader;
39 import javax.smartcardio.Card;
40 import javax.smartcardio.CardChannel;
41 import javax.smartcardio.CardTerminal;
42 import javax.smartcardio.CommandAPDU;
43 import javax.smartcardio.ResponseAPDU;
44
45 public class TestTransmit extends Utils {
46
47 private final static String CMD_MARKER = "C-APDU: ";
48 private final static String RES_MARKER = "R-APDU: ";
49
50 public static void main(String[] args) throws Exception {
51 CardTerminal terminal = getTerminal(args);
52
53 Card card = terminal.connect("T=0");
54 CardChannel channel = card.getBasicChannel();
55
56 BufferedReader reader = new BufferedReader(new FileReader("apdu.log"));
57
58 byte[] command = null;
59 while (true) {
60 String line = reader.readLine();
61 if (line == null) {
62 break;
63 }
64 if (line.startsWith(CMD_MARKER)) {
65 System.out.println(line);
66 line = line.substring(CMD_MARKER.length());
67 command = parse(line);
68 } else if (line.startsWith(RES_MARKER)) {
69 System.out.println(line);
70 line = line.substring(RES_MARKER.length());
71 Bytes response = parseWildcard(line);
|
1 /*
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
32 // This test requires special hardware.
33
34 import java.io.BufferedReader;
35 import java.io.ByteArrayOutputStream;
36 import java.io.FileReader;
37 import java.io.IOException;
38 import java.io.StringReader;
39 import javax.smartcardio.Card;
40 import javax.smartcardio.CardChannel;
41 import javax.smartcardio.CardTerminal;
42 import javax.smartcardio.CommandAPDU;
43 import javax.smartcardio.ResponseAPDU;
44
45 public class TestTransmit extends Utils {
46
47 private final static String CMD_MARKER = "C-APDU: ";
48 private final static String RES_MARKER = "R-APDU: ";
49
50 public static void main(String[] args) throws Exception {
51 CardTerminal terminal = getTerminal(args);
52 if (terminal == null) {
53 System.out.println("Skipping the test: " +
54 "no card terminals available");
55 return;
56 }
57
58 Card card = terminal.connect("T=0");
59 CardChannel channel = card.getBasicChannel();
60
61 BufferedReader reader = new BufferedReader(new FileReader("apdu.log"));
62
63 byte[] command = null;
64 while (true) {
65 String line = reader.readLine();
66 if (line == null) {
67 break;
68 }
69 if (line.startsWith(CMD_MARKER)) {
70 System.out.println(line);
71 line = line.substring(CMD_MARKER.length());
72 command = parse(line);
73 } else if (line.startsWith(RES_MARKER)) {
74 System.out.println(line);
75 line = line.substring(RES_MARKER.length());
76 Bytes response = parseWildcard(line);
|