Secure iNet Factory

com.jscape.inet.bsd
Class Rlogin

java.lang.Object
  extended by com.jscape.inet.bsd.Rexec
      extended by com.jscape.inet.bsd.Rlogin
All Implemented Interfaces:
java.io.Serializable

public class Rlogin
extends Rexec
implements java.io.Serializable

Implements the functionality of a BSD rloginsh client.

Example Usage:

 Rlogin rlogin = new Rlogin("remote.host.com", "johndoe", "johndoe", "vt100");
 try
 {
   rlogin.connect();
   rlogin.execute();
   OutputReader reader = new OutputReader(rlogin.getInputStream(), System.out);
   InputWriter writer = new InputWriter(System.in, rlogin.getOutputStream());
   reader.setPriority(Thread.currentThread().getPriority() + 1);
   reader.start();
   writer.setDaemon(true);
   writer.start();
   try
   {
     reader.join();
     writer.interrupt();
   }
   catch(InterruptedException e)
   {
   }
 )
 catch(Exception e)
 {
   System.out.println(e);
 }
 

See Also:
Serialized Form

Constructor Summary
Rlogin()
          Initializes the Rlogin object with port set to 513.
Rlogin(java.lang.String remoteHost, java.lang.String username, java.lang.String localUsername, java.lang.String terminalType)
          Initializes the Rlogin object with port set to 513 and all connection parameters.
 
Method Summary
 void connect()
          Initializes input and output streams to handle stdin and stdout of the remote host.
 void execute()
          Executes rlogin negotiation with remote host.
 java.lang.String getLocalUsername()
          Gets the local username to be sent to the remote host.
 int getTerminalSpeed()
          Gets the speed of terminal emulation.
 java.lang.String getTerminalType()
          Gets the terminal type to be used to distinguish between formating characters and normal text.
 void setLocalUsername(java.lang.String localUsername)
          Sets the username of the user originating the connection.
 void setTerminalSpeed(int terminalSpeed)
          Sets the speed of terminal emulation.
 void setTerminalType(java.lang.String terminalType)
          Sets the terminal type to be used to distinguish between formating characters and normal text.
 
Methods inherited from class com.jscape.inet.bsd.Rexec
addBsdListener, clearProxySettings, disconnect, getBsdListeners, getCommand, getErrorStream, getInputStream, getOutputStream, getPassword, getPort, getRemoteHost, getTimeout, getUsername, hasErrorStream, removeBsdListener, setCommand, setPassword, setPort, setProxyAuthentication, setProxyHost, setProxyType, setRemoteHost, setTimeout, setUsername
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rlogin

public Rlogin()
Initializes the Rlogin object with port set to 513. All connection parameters must be set using member functions.


Rlogin

public Rlogin(java.lang.String remoteHost,
              java.lang.String username,
              java.lang.String localUsername,
              java.lang.String terminalType)
Initializes the Rlogin object with port set to 513 and all connection parameters.

Parameters:
remoteHost - the Internet name of the remote host.
username - the username of the user, whose credentials are to be used to execute the command.
localUsername - the username of the user who is initiating the connection.
terminalType - the terminal type.
Method Detail

connect

public void connect()
             throws BsdException
Initializes input and output streams to handle stdin and stdout of the remote host. Before calling this method, all connection parameters must be set.

Overrides:
connect in class Rexec
Throws:
BsdException - if connection can not be established.

execute

public void execute()
             throws BsdException
Executes rlogin negotiation with remote host. After calling this method, stdout of the remote host is received through an InputStream returned by getInputStream() method. stdin can be accessed through an OutputStream returned by getOutputStream(). Further interaction with rlogin service is exclusively done through these two streams.

To properly terminate connection, use disconnect() method. Beware that remote process will finish after EOF is sent to stdout, so disconnecting too early will not terminate remote process.

Overrides:
execute in class Rexec
Throws:
BsdException - if rsh negotiation fails.
See Also:
Rexec.getInputStream()

setLocalUsername

public void setLocalUsername(java.lang.String localUsername)
Sets the username of the user originating the connection. Unix restrictions apply - only 8 characters are allowed. Any excess is removed.

Parameters:
localUsername - the local username to be sent to the remote host.

getLocalUsername

public java.lang.String getLocalUsername()
Gets the local username to be sent to the remote host.

Returns:
local username to be sent.

setTerminalType

public void setTerminalType(java.lang.String terminalType)
Sets the terminal type to be used to distinguish between formating characters and normal text. Blank string for terminal type indicates "dumb" terminal type on most unices.

Unix restrictions apply - only 8 characters are allowed. Any excess is removed.

Parameters:
terminalType - the terminal type to be sent to the remote host.

getTerminalType

public java.lang.String getTerminalType()
Gets the terminal type to be used to distinguish between formating characters and normal text.

Returns:
the terminal type to be used.

setTerminalSpeed

public void setTerminalSpeed(int terminalSpeed)
Sets the speed of terminal emulation. The remote host will restrict data flow to this speed. Leaving this parameter to zero will cause default terminal speed to be used (system dependent).

Parameters:
terminalSpeed - the terminal speed to be used.

getTerminalSpeed

public int getTerminalSpeed()
Gets the speed of terminal emulation.

Returns:
the terminal speed to be used.

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved