public boolean confirm(String prompt) { return "yes".equalsIgnoreCase(getReader().readLine(prompt)); }
public void print(String s) { if (isInteractive()) getReader().getTerminal().writer().print(s); else { try { out.write(s.getBytes()); out.flush(); } catch (IOException ignored) { ignored.printStackTrace(); } } }
public void exec(CLIContext ctx, String[] args) throws Exception { ctx.getReader().getTerminal().puts(InfoCmp.Capability.clear_screen); } }
public void exec(CLIContext cli, String[] args) throws Exception { Terminal term = cli.getReader().getTerminal(); cli.println("TERM=" + term.getClass().getSimpleName() + "/" + term.getType()); } }
public void exec(CLIContext cli, String[] args) { try { String[] params = new String[args.length - 1]; System.arraycopy(args, 1, params, 0, params.length); PrintStream os = new PrintStream(cli.getReader().getTerminal().output()); new org.jpos.security.jceadapter.Console().exec(os,os,params); } catch (Exception e) { e.printStackTrace(); } } }
private boolean unlock (CLIContext cli) throws NoSuchPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, NoSuchProviderException, InvalidKeyException { return cs.unlock(new SensitiveString(cli.getReader().readLine("Password: ", '*'))); } }
private void decrypt (CLIContext cli, String sKeyId, String cryptogram) throws Exception { UUID jobId = UUID.randomUUID(); UUID keyId = UUID.fromString(sKeyId); byte[] cleartext; try { if (cs.isLocked()) { cs.loadKey(jobId, keyId, cli.getReader().readLine("Password: ", '*').toCharArray()); } byte[] clearText = cs.aesDecrypt(jobId, keyId, Base64.getDecoder().decode(cryptogram)); cli.println (ISOUtil.hexdump(clearText)); } catch (PGPException e) { throw new IllegalArgumentException("Invalid password/key - " + e.getMessage()); } finally { cs.unloadKey(jobId, keyId); } } }
public void exec(CLIContext cli, String[] args) throws Exception { try (BinLogReader bl = new BinLogReader(new File((String) cli.getUserData().get("binlog")))) { while (bl.hasNext(10000L)) { BinLog.Entry ref = bl.next(); cli.println(String.format("%06d@%08d %s", ref.ref().getFileNumber(), ref.ref().getOffset(), ISOUtil.hexdump(ref.get()))); cli.getReader().getTerminal().flush(); } } catch (Exception e) { e.printStackTrace(); } } }
public void exec(CLIContext cli, String[] args) throws Exception { this.p = new PrintStream(cli.getReader().getTerminal().output()); this.cli = cli; this.ansi = false; // cli.getReader().getTerminal().isAnsiSupported(); if (args.length == 1) { usage(cli); return; } for (int i = 1; i < args.length; i++) { try { Logger logger = (Logger) NameRegistrar.get("logger." + args[i]); logger.addListener(this); } catch (NameRegistrar.NotFoundException e) { cli.println("Logger " + args[i] + " not found -- ignored."); } } // cli.getReader().readCharacter(new char[]{'q', 'Q'}); cli.getReader().readLine(); for (int i = 1; i < args.length; i++) { try { Logger logger = (Logger) NameRegistrar.get("logger." + args[i]); logger.removeListener(this); } catch (NameRegistrar.NotFoundException ignored) { // NOPMD OK to happen } } }
Terminal term= cli.getReader().getTerminal();
((CLICommand) cmd).exec(ctx, args); } else if (cmd instanceof Command) { Terminal t = ctx.getReader().getTerminal(); ((Command) cmd).exec (t.input(), t.output(), t.output(), args);