@Override public Object onCommand(Command command) throws Exception { if (command.is("ping")) { return "pong"; } else if (command.is("echoargs")) { HashMap<String, Object> res = new HashMap<>(); res.put("simple", command.getParams()); res.put("key", command.getKeyParams()); return res; } throw new IllegalArgumentException("unknown command: " + command.getName()); } });
private void doCall(Map<String, Object> input, int serial) { try { Object result = target.onCommand(new Command(input)); sendToRemote("ref", serial, "result", result); } catch (RemoteException e) { sendErrorNoExceptions(serial, e.getRemoteErrorClass(), e.getRemoteErrorText()); } catch (Exception e) { sendErrorNoExceptions(serial, e.getClass().getSimpleName(), e.getMessage()); } }
private Object decryptBlock(Command command) throws EncryptionError { try { synchronized (remoteSessionKey) { Bytes ciphertext = command.getParam(0); if (ciphertext == null) { throw new IllegalStateException("missing block data"); } Binder plain = Boss.unpack(remoteSessionKey.etaDecrypt(ciphertext.toArray())); inputQueue.put(plain); } } catch (SymmetricKey.AuthenticationFailed authenticationFailed) { throw new EncryptionError("authentication failed on bitrusted block"); } catch (InterruptedException e) { Thread.interrupted(); } catch (Exception e) { log.wtf("failed to process block", e); e.printStackTrace(); } return null; }
/** * The handshake and transport command processing * * @param command * * @return * * @throws Exception */ @Override public Object onCommand(Command command) throws Exception { // log.d(toString()+" cmd "+command.getName()); switch (command.getName()) { case "hello": return onHello(Binder.from(command.getKeyParams())); case "block": return decryptBlock(command); } return null; }
Farcall f = new Farcall(bc); f.start(cmd -> { switch (cmd.getName()) { case "ping": return "pong";
a.asyncCommands(); a.start(command -> { switch (command.getName()) { case "wait": synchronized (lock) {