コード例 #1
0
 /**
  * Issues a ISO VERIFY on the remote terminal.
  *
  * @param p2 P2 parameter in the VERIFY APDU
  * @param text to be displayed to the user
  * @return true if VERIFY returned 0x9000, false otherwise
  * @throws IOException when communication fails
  */
 public boolean verifyPIN(int p2, String text) throws IOException, UserCancelExcption {
   Map<String, Object> m = JSONProtocol.cmd("verify");
   m.put("p2", p2);
   m.put("text", text);
   pipe.send(m);
   return JSONProtocol.check(m, pipe.recv());
 }
コード例 #2
0
 /**
  * Shows a message on the screen
  *
  * @param text message to be shown
  * @throws IOException when communication fails
  */
 public void statusMessage(String text) throws IOException {
   Map<String, Object> m = JSONProtocol.cmd("message");
   m.put("text", text);
   pipe.send(m);
   if (!JSONProtocol.check(m, pipe.recv())) {
     throw new IOException("Could not display status");
   }
 }
コード例 #3
0
 /**
  * Shows a dialog message to the user and returns the pressed button.
  *
  * @param message text to display to the user
  * @return {@link Button} that was pressed by the user
  * @throws IOException when communication fails
  */
 public Button dialog(String message) throws IOException, UserCancelExcption {
   Map<String, Object> m = JSONProtocol.cmd("dialog");
   m.put("text", message);
   pipe.send(m);
   Map<String, Object> r = pipe.recv();
   if (!JSONProtocol.check(m, r) || !r.containsKey("button")) {
     throw new IOException("Unknown button pressed");
   }
   return Button.valueOf(((String) r.get("button")).toUpperCase());
 }
コード例 #4
0
 /**
  * Asks for input from the user.
  *
  * @param message text to display to the user
  * @return null or input
  * @throws IOException when communication fails
  */
 public String input(String message) throws IOException, UserCancelExcption {
   Map<String, Object> m = JSONProtocol.cmd("input");
   m.put("text", message);
   pipe.send(m);
   Map<String, Object> r = pipe.recv();
   if (!JSONProtocol.check(m, r) || !r.containsKey("value")) {
     throw new IOException("No value");
   }
   return (String) r.get("value");
 }
コード例 #5
0
 /**
  * Shows the response of the APDU to the user.
  *
  * <p>Normally this requires the verification of a PIN code beforehand.
  *
  * @param message text to display to the user
  * @param apdu APDU to send to the terminal
  * @return {@link Button} that was pressed by the user
  * @throws IOException when communication fails
  */
 public Button decrypt(String message, byte[] apdu) throws IOException, UserCancelExcption {
   Map<String, Object> m = JSONProtocol.cmd("decrypt");
   m.put("text", message);
   m.put("bytes", HexUtils.bin2hex(apdu));
   pipe.send(m);
   Map<String, Object> r = pipe.recv();
   if (JSONProtocol.check(m, r)) {
     return Button.valueOf(((String) r.get("button")).toUpperCase());
   } else {
     throw new IOException("Unknown button pressed");
   }
 }
コード例 #6
0
 public void stop(String message) {
   try {
     Map<String, Object> m = JSONProtocol.cmd("stop");
     m.put("text", message);
     pipe.send(m);
   } catch (IOException e) {
   }
   close();
 }
コード例 #7
0
 public int select(String message, Map<Integer, String> choices)
     throws IOException, UserCancelExcption {
   Map<String, Object> m = JSONProtocol.cmd("select");
   for (Map.Entry<Integer, String> e : choices.entrySet()) {
     m.put(e.getKey().toString(), e.getValue());
   }
   m.put("text", message);
   pipe.send(m);
   Map<String, Object> r = pipe.recv();
   if (!JSONProtocol.check(m, r) || !r.containsKey("value")) {
     throw new IOException("No value");
   }
   try {
     return Integer.valueOf((String) r.get("value"));
   } catch (NumberFormatException e) {
     throw new IOException("Choice was not numeric", e);
   }
 }