@Override public String[] interactive(ClientSession s, String name, String instruction, String lang, String[] prompt, boolean[] echo) { String[] answers = new String[prompt.length]; try { for (int i = 0; i < prompt.length; i++) { answers[i] = session.readLine(prompt[i] + " ", echo[i] ? null : '*'); } } catch (IOException e) { } return answers; } @Override
@Override public String[] interactive(ClientSession s, String name, String instruction, String lang, String[] prompt, boolean[] echo) { String[] answers = new String[prompt.length]; try { for (int i = 0; i < prompt.length; i++) { answers[i] = session.readLine(prompt[i] + " ", echo[i] ? null : '*'); } } catch (IOException e) { } return answers; } @Override
/** * Asks for confirmation (user has to press <code>y</code>) after presenting a prompt * @param prompt * @return */ protected boolean confirm(String prompt) throws IOException { String response = session.readLine(prompt, null); return "y".equals(response); }
private boolean confirm(Session session) throws IOException { for (;;) { String msg = "You are about to perform a start/stop/refresh load test on bundles.\nDo you wish to continue (yes/no): "; String str = session.readLine(msg, null); if ("yes".equalsIgnoreCase(str)) { return true; } if ("no".equalsIgnoreCase(str)) { return false; } } } }
private boolean confirm(Session session) throws IOException { for (;;) { String msg = "You are about to perform a start/stop/refresh load test on bundles.\nDo you wish to continue (yes/no): "; String str = session.readLine(msg, null); if ("yes".equalsIgnoreCase(str)) { return true; } if ("no".equalsIgnoreCase(str)) { return false; } } } }
@Override public Object execute() throws Exception { Subject subject = new Subject(); LoginContext loginContext = new LoginContext(realm, subject, callbacks -> { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback) callback).setName(user); } else if (callback instanceof PasswordCallback) { String password = SudoCommand.this.session.readLine("Password: ", '*'); ((PasswordCallback) callback).setPassword(password.toCharArray()); } else { throw new UnsupportedCallbackException(callback); } } }); loginContext.login(); final StringBuilder sb = new StringBuilder(); for (String s : command) { if (sb.length() > 0) { sb.append(" "); } sb.append(s); } JaasHelper.doAs(subject, (PrivilegedExceptionAction<Object>) () -> session.execute(sb)); loginContext.logout(); return null; }
@Override public Object execute() throws Exception { Subject subject = new Subject(); LoginContext loginContext = new LoginContext(realm, subject, callbacks -> { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback) callback).setName(user); } else if (callback instanceof PasswordCallback) { String password = SudoCommand.this.session.readLine("Password: ", '*'); ((PasswordCallback) callback).setPassword(password.toCharArray()); } else { throw new UnsupportedCallbackException(callback); } } }); loginContext.login(); final StringBuilder sb = new StringBuilder(); for (String s : command) { if (sb.length() > 0) { sb.append(" "); } sb.append(s); } JaasHelper.doAs(subject, (PrivilegedExceptionAction<Object>) () -> session.execute(sb)); loginContext.logout(); return null; }
private String readLine(String prompt, Character ch) throws IOException { Object oldIgnoreInterrupts = session.get(Session.IGNORE_INTERRUPTS); session.put(Session.IGNORE_INTERRUPTS, Boolean.TRUE); try { String line = session.readLine(prompt, ch); if (line == null) { throw new IOException("interrupted"); } return line; } finally { session.put(Session.IGNORE_INTERRUPTS, oldIgnoreInterrupts); } }
private String readLine(String prompt, Character ch) throws IOException { Object oldIgnoreInterrupts = session.get(Session.IGNORE_INTERRUPTS); session.put(Session.IGNORE_INTERRUPTS, Boolean.TRUE); try { String line = session.readLine(prompt, ch); if (line == null) { throw new IOException("interrupted"); } return line; } finally { session.put(Session.IGNORE_INTERRUPTS, oldIgnoreInterrupts); } }
private String readLine(String prompt, Character ch) throws IOException { Object oldIgnoreInterrupts = session.get(Session.IGNORE_INTERRUPTS); session.put(Session.IGNORE_INTERRUPTS, Boolean.TRUE); try { String line = session.readLine(prompt, ch); if (line == null) { throw new IOException("interrupted"); } return line; } finally { session.put(Session.IGNORE_INTERRUPTS, oldIgnoreInterrupts); } }
((NameCallback) callback).setName(user); } else if (callback instanceof PasswordCallback) { String password = SuCommand.this.session.readLine("Password: ", '*'); ((PasswordCallback) callback).setPassword(password.toCharArray()); } else {
return; String password = session.readLine("Password to encrypt: ", '*'); System.out.println("Encrypted password: " + cipher.encryptAndDecorate(password, masterPassword)); System.out.println("You can use this encrypted password when defining repositories and proxies"); String password = session.readLine("Master password to encrypt: ", '*'); String encryptedPassword = cipher.encryptAndDecorate(password, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION); System.out.println("Encrypted master password: " + encryptedPassword);
((NameCallback) callback).setName(user); } else if (callback instanceof PasswordCallback) { String password = SuCommand.this.session.readLine("Password: ", '*'); ((PasswordCallback) callback).setPassword(password.toCharArray()); } else {
+ "' already exists. Do you want to replace it [yes/no]? "); } else { answer = session.readLine(null, null);
str = session.readLine(msg, null); } catch (UnsupportedOperationException e) {
str = session.readLine(msg, null); } catch (UnsupportedOperationException e) {
+ "' already exists. Do you want to replace it [yes/no]? "); } else { answer = session.readLine(null, null);
+ "' already exists. Do you want to replace it [yes/no]? "); } else { answer = session.readLine(null, null);
log.debug("Prompting user for login"); if (username == null) { username = session.readLine("Login: ", null);
log.debug("Prompting user for login"); if (username == null) { username = session.readLine("Login: ", null);