private void setUserName(Session session, String userName) { // Jsch 0.1.54 picks up the user name from the ssh config, even if an // explicit user name was given! We must correct that if ~/.ssh/config // has a different user name. if (userName == null || userName.isEmpty() || userName.equals(session.getUserName())) { return; } try { Class<?>[] parameterTypes = { String.class }; Method method = Session.class.getDeclaredMethod("setUserName", //$NON-NLS-1$ parameterTypes); method.setAccessible(true); method.invoke(session, userName); } catch (NullPointerException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { LOG.error(MessageFormat.format(JGitText.get().sshUserNameError, userName, session.getUserName()), e); } }
private static URIish createURI(Session session) { URIish uri = new URIish(); uri = uri.setScheme("ssh"); //$NON-NLS-1$ uri = uri.setUser(session.getUserName()); uri = uri.setHost(session.getHost()); uri = uri.setPort(session.getPort()); return uri; }
public String getUsername() { return session.getUserName(); }
public String getUser() { return session.getUserName(); }
public String getId() { return "//" + session.getUserName() + "@" + session.getHost() + "/"; }
private void setUserName(Session session, String userName) { // Jsch 0.1.54 picks up the user name from the ssh config, even if an // explicit user name was given! We must correct that if ~/.ssh/config // has a different user name. if (userName == null || userName.isEmpty() || userName.equals(session.getUserName())) { return; } try { Class<?>[] parameterTypes = { String.class }; Method method = Session.class.getDeclaredMethod("setUserName", //$NON-NLS-1$ parameterTypes); method.setAccessible(true); method.invoke(session, userName); } catch (NullPointerException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { LOG.error(MessageFormat.format(JGitText.get().sshUserNameError, userName, session.getUserName()), e); } }
import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Database db = agentContext.getCurrentDatabase(); String user = session.getUserName(); int accLevel = db.queryAccess(user); int accPriv = db.queryAccessPrivileges(user); boolean blnCanWriteCalendar = false; boolean blnCanReadCalendar = false; blnCanWriteCalendar = ((accPriv & Database.DBACL_WRITE_PUBLIC_DOCS) > 0) | accLevel > ACL.LEVEL_AUTHOR; blnCanReadCalendar = ((accPriv & Database.DBACL_READ_PUBLIC_DOCS) > 0) | accLevel >= ACL.LEVEL_READER; } catch(Exception e) { e.printStackTrace(); } } }
public boolean start(Session session) throws Exception { this.userinfo = session.getUserInfo(); this.packet = session.packet; this.buf = packet.getBuffer(); this.username = session.getUserName(); return true; } }
public boolean start(Session session) throws Exception{ this.userinfo=session.getUserInfo(); this.packet=session.packet; this.buf=packet.getBuffer(); this.username=session.getUserName(); return true; } }
public boolean start(Session session) throws Exception{ this.userinfo=session.getUserInfo(); this.packet=session.packet; this.buf=packet.getBuffer(); this.username=session.getUserName(); return true; } }
public boolean start(Session session) throws Exception{ this.userinfo=session.getUserInfo(); this.packet=session.packet; this.buf=packet.getBuffer(); this.username=session.getUserName(); return true; } }
@Override public String getId() { return "//" + session.getUserName() + "@" + session.getHost() + ":" + session.getPort() + "/"; }
@Override public String getPassword() { // pass along password if provided (but only one time!) if (JschConnect.this.uri.getPassword() != null) { if (this.returnedPassword) { // prevent possible infinite loop! throw new IllegalStateException("Password prompted too many times"); } this.returnedPassword = true; return JschConnect.this.uri.getPassword(); } // joelauer@hosts's password: String prompt = String.format("%1s@%2s's password: ", jschSession.getUserName(), jschSession.getHost()); char[] password = Contexts.passwordPrompt(prompt); // THIS IS UNFORTUNATE SINCE THIS STRING IS INTERNED... return new String(password); }
NotesAPITest nat = new NotesAPITest(); NotesThread.sinitThread(); Session sess1 = NotesFactory.createSession(); System.out.println(sess1.getUserName()); Database database = sess1.getDatabase("", "mailfile"); View calendarView = database.getView("($Calendar)"); DateTime dt = sess1.createDateTime("today"); ViewEntryCollection vec = calendarView.getAllEntriesByKey(dt, true); ViewEntry entry = vec.getFirstEntry(); while (entry != null) { Document caldoc = entry.getDocument(); System.out.println("Subject: " + caldoc.getItemValueString("Subject")); System.out.println("Chair Person: " + caldoc.getItemValueString("Chair")); System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "StartDateTime") ); System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "EndDateTime") ); System.out.println("Required: " + caldoc.getItemValueString("RequiredAttendees")); entry = vec.getNextEntry(); }
@Override public CliProcess execute(String command) { try { Session session = createSession(); LOGGER.info("Executing on {}@{}:{}: {}", session.getUserName(), session.getHost(), session.getPort(), command); ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); JSchCliProcess process = new JSchCliProcess(session, channel); process.connect(); return process; } catch (JSchException | IOException exception) { throw new RuntimeException(exception); } }
@Override public CliProcess execute(String command) { try { Session session = createSession(); LOGGER.info("Executing on {}@{}:{}: {}", session.getUserName(), session.getHost(), session.getPort(), command); ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); JSchCliProcess process = new JSchCliProcess(session, channel); process.connect(); return process; } catch (JSchException | IOException exception) { throw new RuntimeException(exception); } }
@Override public void upload(Path file, String remotePath) { Session session = null; try { session = createSession(); LOGGER.info("Uploading {} onto {}@{}:{}:{}", file, session.getUserName(), session.getHost(), session.getPort(), remotePath); ChannelExec channel = (ChannelExec) session.openChannel("exec"); String command = "scp -t " + remotePath; channel.setCommand(command); OutputStream out = channel.getOutputStream(); InputStream in = channel.getInputStream(); sendSCPFile(file, channel, in, out); } catch (JSchException | IOException exception) { Throwables.propagate(exception); } finally { if (session != null) session.disconnect(); } }
private static URIish createURI(Session session) { URIish uri = new URIish(); uri = uri.setScheme("ssh"); //$NON-NLS-1$ uri = uri.setUser(session.getUserName()); uri = uri.setHost(session.getHost()); uri = uri.setPort(session.getPort()); return uri; }
private static URIish createURI(Session session) { URIish uri = new URIish(); uri = uri.setScheme("ssh"); //$NON-NLS-1$ uri = uri.setUser(session.getUserName()); uri = uri.setHost(session.getHost()); uri = uri.setPort(session.getPort()); return uri; }
" on server - " + session.getHost() + ":" + session.getPort() + " connecting user name - " + session.getUserName(), e);