@Override public Object execute() throws Exception { System.out.println("Printing of stacktraces set to " + print); session.put(Session.PRINT_STACK_TRACES, print); return null; }
@Override public Object execute() throws Exception { System.out.println("Printing of stacktraces set to " + print); session.put(Session.PRINT_STACK_TRACES, print); return null; }
@Override public Object execute() throws Exception { if (mode == null) { System.out.println(session.get(Session.COMPLETION_MODE)); } else if (!mode.equalsIgnoreCase("global") && !mode.equalsIgnoreCase("first") && !mode.equalsIgnoreCase("subshell")) { System.err.println("The completion mode is not correct. The valid modes are: global, first, subshell. See documentation for details."); } else { session.put(Session.COMPLETION_MODE, mode.toLowerCase()); } return null; }
@Override public Object execute() throws Exception { if (mode == null) { System.out.println(session.get(Session.COMPLETION_MODE)); } else if (!mode.equalsIgnoreCase("global") && !mode.equalsIgnoreCase("first") && !mode.equalsIgnoreCase("subshell")) { System.err.println("The completion mode is not correct. The valid modes are: global, first, subshell. See documentation for details."); } else { session.put(Session.COMPLETION_MODE, mode.toLowerCase()); } return null; }
protected Object doExecute() throws Exception { String oldPid = (String) this.session.get(PROPERTY_CONFIG_PID); if (oldPid != null && oldPid.equals(pid) && !force) { System.err.println("This config is being edited. Cancel / update first, or use the --force option"); return null; } this.configRepository.delete(pid); if (oldPid != null && oldPid.equals(pid) && !force) { this.session.put(PROPERTY_CONFIG_PID, null); this.session.put(PROPERTY_CONFIG_PROPS, null); } 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); } }
protected Object doExecute() throws Exception { String oldPid = (String) this.session.get(PROPERTY_CONFIG_PID); if (oldPid != null && oldPid.equals(pid) && !force) { System.err.println("This config is being edited. Cancel / update first, or use the --force option"); return null; } this.configRepository.delete(pid); if (oldPid != null && oldPid.equals(pid) && !force) { this.session.put(PROPERTY_CONFIG_PID, null); this.session.put(PROPERTY_CONFIG_PROPS, null); } 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); } }
@Override protected void doExecute(Session session) throws Exception { // get the current sub-shell String currentSubShell = (String) session.get(Session.SUBSHELL); if (!currentSubShell.isEmpty()) { if (currentSubShell.contains(":")) { int index = currentSubShell.lastIndexOf(":"); session.put(Session.SUBSHELL, currentSubShell.substring(0, index)); } else { session.put(Session.SUBSHELL, ""); } String currentScope = (String) session.get(Session.SCOPE); int index = currentScope.indexOf(":"); session.put(Session.SCOPE, currentScope.substring(index + 1)); } } }
public void unregisterSession(org.apache.karaf.shell.api.console.Session session) { try { if (session != null && session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME) != null) { String agentId = (String) session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME); session.put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, null); if (agentId != null) { locals.remove(agentId); } } } catch (Throwable e) { LOGGER.warn("Error stopping ssh agent for local console", e); } }
public void unregisterSession(org.apache.karaf.shell.api.console.Session session) { try { if (session != null && session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME) != null) { String agentId = (String) session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME); session.put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, null); if (agentId != null) { locals.remove(agentId); } } } catch (Throwable e) { LOGGER.warn("Error stopping ssh agent for local console", e); } }
public void registerSession(org.apache.karaf.shell.api.console.Session session) { try { String user = (String) session.get("USER"); SshAgent agent = new AgentImpl(); URL url = getClass().getClassLoader().getResource("karaf.key"); InputStream is = url.openStream(); ObjectInputStream r = new ObjectInputStream(is); KeyPair keyPair = (KeyPair) r.readObject(); agent.addIdentity(keyPair, "karaf"); String agentId = "local:" + user; session.put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, agentId); locals.put(agentId, agent); } catch (Throwable e) { LOGGER.warn("Error starting ssh agent for local console", e); } }
public void registerSession(org.apache.karaf.shell.api.console.Session session) { try { String user = (String) session.get("USER"); SshAgent agent = new AgentImpl(); URL url = getClass().getClassLoader().getResource("karaf.key"); InputStream is = url.openStream(); ObjectInputStream r = new ObjectInputStream(is); KeyPair keyPair = (KeyPair) r.readObject(); agent.addIdentity(keyPair, "karaf"); String agentId = "local:" + user; session.put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, agentId); locals.put(agentId, agent); } catch (Throwable e) { LOGGER.warn("Error starting ssh agent for local console", e); } }