/*** * The default RCommandClient constructor. Initializes the * default port to <code> DEFAULT_PORT </code>. ***/ public RCommandClient() { setDefaultPort(DEFAULT_PORT); }
/*** * The default RLoginClient constructor. Initializes the * default port to <code> DEFAULT_PORT </code>. ***/ public RLoginClient() { setDefaultPort(DEFAULT_PORT); }
/*** * The default RExecClient constructor. Initializes the * default port to <code> DEFAULT_PORT </code>. ***/ public RExecClient() { _errorStream_ = null; setDefaultPort(DEFAULT_PORT); }
getLocalAddress()); break; // got a socket server.close(); if (isRemoteVerificationEnabled() && !verifyRemote(socket))
InputStream _createErrorStream() throws IOException { ServerSocket server; Socket socket; server = _serverSocketFactory_.createServerSocket(0, 1, getLocalAddress()); _output_.write(Integer.toString(server.getLocalPort()).getBytes("UTF-8")); // $NON-NLS-1$ _output_.write(NULL_CHAR); _output_.flush(); socket = server.accept(); server.close(); if (__remoteVerificationEnabled && !verifyRemote(socket)) { socket.close(); throw new IOException( "Security violation: unexpected connection attempt by " + socket.getInetAddress().getHostAddress()); } return (new SocketInputStream(socket, socket.getInputStream())); }
/*** * Same as <code> rexec(username, password, command, false); </code> * @param username the user name * @param password the password * @param command the command to run * @throws IOException if an error occurs ***/ public void rexec(String username, String password, String command) throws IOException { rexec(username, password, command, false); }
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address and port. The * local port must lie between <code> MIN_CLIENT_PORT </code> and * <code> MAX_CLIENT_PORT </code> or an IllegalArgumentException will * be thrown. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * * @param host The remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @param localPort The local port to use. * @throws SocketException If the socket timeout could not be set. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @throws IllegalArgumentException If an invalid local port number * is specified. ***/ @Override public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SocketException, IOException, IllegalArgumentException { if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) { throw new IllegalArgumentException("Invalid port number " + localPort); } super.connect(host, port, localAddr, localPort); }
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the current host at a port in a range acceptable * to the BSD rshell daemon. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * * @param host The remote host. * @param port The port to connect to on the remote host. * @throws SocketException If the socket timeout could not be set. * @throws BindException If all acceptable rshell ports are in use. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. ***/ @Override public void connect(InetAddress host, int port) throws SocketException, IOException { connect(host, port, InetAddress.getLocalHost()); }
_errorStream_ = _createErrorStream(); _output_.write(username.getBytes(getCharset())); _output_.write(NULL_CHAR); _output_.write(password.getBytes(getCharset())); _output_.write(NULL_CHAR); _output_.write(command.getBytes(getCharset())); _output_.write(NULL_CHAR); _output_.flush();
/*** * Same as the other rlogin method, but no terminal speed is defined. * @param localUsername the local user * @param remoteUsername the remote user * @param terminalType the terminal type * @throws IOException on error ***/ public void rlogin(String localUsername, String remoteUsername, String terminalType) throws IOException { rexec(localUsername, remoteUsername, terminalType, false); }
/*** * Same as * <code> rcommand(localUsername, remoteUsername, command, false); </code> * @param localUsername the local user * @param remoteUsername the remote user * @param command the command * @throws IOException on error ***/ public void rcommand(String localUsername, String remoteUsername, String command) throws IOException { rcommand(localUsername, remoteUsername, command, false); }
throws IOException rexec(localUsername, remoteUsername, command, separateErrorStream);
/*** * Same as <code> rexec(username, password, command, false); </code> ***/ public void rexec(String username, String password, String command) throws IOException { rexec(username, password, command, false); }
throw new IllegalArgumentException("Invalid port number " + localPort); super.connect(hostname, port, localAddr, localPort);
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the specified local address using a port in a range * acceptable to the BSD rshell daemon. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * * @param hostname The remote host. * @param port The port to connect to on the remote host. * @param localAddr The local address to use. * @throws SocketException If the socket timeout could not be set. * @throws BindException If all acceptable rshell ports are in use. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. ***/ public void connect(String hostname, int port, InetAddress localAddr) throws SocketException, IOException { connect(InetAddress.getByName(hostname), port, localAddr); }
/*** * The default RCommandClient constructor. Initializes the * default port to <code> DEFAULT_PORT </code>. ***/ public RCommandClient() { setDefaultPort(DEFAULT_PORT); }
throws IOException rexec(localUsername, remoteUsername, terminalType + "/" + terminalSpeed, false);
/*** * Same as * <code> rcommand(localUsername, remoteUsername, command, false); </code> ***/ public void rcommand(String localUsername, String remoteUsername, String command) throws IOException { rcommand(localUsername, remoteUsername, command, false); }
/*** * Opens a Socket connected to a remote host at the specified port and * originating from the current host at a port in a range acceptable * to the BSD rshell daemon. * Before returning, {@link org.apache.commons.net.SocketClient#_connectAction_ _connectAction_() } * is called to perform connection initialization actions. * * @param hostname The name of the remote host. * @param port The port to connect to on the remote host. * @throws SocketException If the socket timeout could not be set. * @throws BindException If all acceptable rshell ports are in use. * @throws IOException If the socket could not be opened. In most * cases you will only want to catch IOException since SocketException is * derived from it. * @throws UnknownHostException If the hostname cannot be resolved. ***/ @Override public void connect(String hostname, int port) throws SocketException, IOException, UnknownHostException { connect(InetAddress.getByName(hostname), port, InetAddress.getLocalHost()); }