|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.gedeon.telnetservice.Session
public class Session
The Telnet Session is the main engine for a telnet connection; it handles inputs and outputs,
keeping telnet state, responding to telnet specific commands, and notifies the Telnet Session
Controller of important events (such as client input, client screen resize, etc) through the
available notify*
methods of ActionListener
s provided by registered
TelnetServiceExtension
.
The typical connection life cycle is as follows:
SessionState
instance. Only one state is created per
session. It included in most calls from the session, and allows the integrating components to
store their state;SessionListener
s are notified that the connection was
established; this means that interaction with the user is going to start as of that point.isActive
method returns false
; at
which point the connection is terminated and the Session is stopped).
Note that the core classes of this service library do not separate between login, password, and
different state-based prompts; it is up to each Action Listener and Prompt Decorator to know what
to display based on its Session State properties. The Action Listeners will also need to instruct
the Console Delegate to suppress echo when it is expecting the user to type a password, for
example. (this is done through ConsoleDelegate.setSuppressOutput(boolean)
.
Note: The telnetservice-jaas
implementation of the Telnet Session Controller that is JAAS compliant and that takes care of the
login procedure if it is needed by the configured LoginModule
.
Field Summary | |
---|---|
static int |
CHAR_BACKSPACE
|
static int |
CHAR_ESC
|
static int |
CHAR_TAB
|
protected Thread |
current
The session thread |
static String |
implementedOptions
Byte array of telnet options we can and want to negociate about, all other commands will result in a DONT or WONT response. Those implemented so far are: TELNET_OPTION_TOGGLEFLOWCONTROL TELNET_OPTION_LINEMODE TELNET_OPTION_WINDOWSIZE TELNET_OPTION_TERMINAL_TYPE TELNET_OPTION_ECHO |
protected InputStream |
input
The connection socket input stream |
protected OutputStream |
output
The connection socket output stream |
protected Socket |
socket
The connection socket |
static int |
TELNET_AYT
Are you there: Send back to the NVT some visible evidence that the AYT was received. |
static int |
TELNET_DO
|
static int |
TELNET_DONT
|
static int |
TELNET_EC
Erase character: The receiver should delete the last preceding undeleted character from the data stream. |
static int |
TELNET_GA
|
static int |
TELNET_IAC
|
static int |
TELNET_NOP
|
static byte |
TELNET_OPTION_ECHO
|
static byte |
TELNET_OPTION_LINEMODE
|
static byte |
TELNET_OPTION_LINEMODE_FORWARDMASK
|
static byte |
TELNET_OPTION_LINEMODE_MODE
|
static byte |
TELNET_OPTION_LINEMODE_MODE_EDIT
|
static byte |
TELNET_OPTION_LINEMODE_MODE_LIT_ECHO
|
static byte |
TELNET_OPTION_LINEMODE_MODE_MODE_ACK
|
static byte |
TELNET_OPTION_LINEMODE_MODE_SOFT_TAB
|
static byte |
TELNET_OPTION_LINEMODE_MODE_TRAPSIG
|
static byte |
TELNET_OPTION_SUPRESSGOAHEAD
|
static byte |
TELNET_OPTION_TERMINAL_TYPE
|
static byte |
TELNET_OPTION_TERMINAL_TYPE_IS
|
static byte |
TELNET_OPTION_TERMINAL_TYPE_SEND
|
static byte |
TELNET_OPTION_TOGGLEFLOWCONTROL
|
static byte |
TELNET_OPTION_WINDOWSIZE
|
static int |
TELNET_SB
|
static int |
TELNET_SE
|
static byte[] |
TELNET_SEQUENCE_GOAHEAD
|
static int |
TELNET_WILL
|
static int |
TELNET_WONT
|
Method Summary | |
---|---|
void |
addSessionListener(SessionListener listener)
|
protected void |
appendActiveText(char c)
|
protected void |
appendActiveText(String txt,
int offsetUpdateMask)
|
void |
backspaceActiveText(int count)
|
protected void |
close()
Close all connections |
protected void |
commitActiveText()
|
Date |
getConnectionTimestamp()
|
ConsoleDelegate |
getConsoleDelegate()
|
OutputFormat |
getOutputFormat()
|
SocketAddress |
getRemoteSocketAddress()
|
SessionState |
getSessionState()
|
void |
notifyConnectionEstablished(SessionState sessionState)
|
void |
notifyConnectionLost(SessionState sessionState)
|
void |
output(SessionState sessionState,
Object subject)
Shortcut method for calling the session's OutputFormat to format the
subject then calling the ConsoleDelegate to write the outcome
to the console. |
void |
removeAllSessionListeners()
|
void |
removeSessionListener(SessionListener listener)
|
protected void |
replaceActiveText(String txt,
int offsetUpdateMask)
|
void |
run()
Session run main loop |
void |
start()
Start the session daemon: setup telnet options, then start the input processing. |
void |
stop()
Stop this session |
protected void |
write(byte[] bbuf,
int off,
int len)
|
protected void |
write(char[] cbuf,
int off,
int len)
|
protected void |
write(String txt)
|
protected void |
writeln(String txt)
|
protected void |
writePrompt()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Socket socket
protected Thread current
protected InputStream input
protected OutputStream output
public static final int CHAR_BACKSPACE
public static final int CHAR_TAB
public static final int CHAR_ESC
public static final byte TELNET_OPTION_ECHO
public static final byte TELNET_OPTION_SUPRESSGOAHEAD
public static final byte TELNET_OPTION_TERMINAL_TYPE
public static final byte TELNET_OPTION_TERMINAL_TYPE_IS
public static final byte TELNET_OPTION_TERMINAL_TYPE_SEND
public static final byte TELNET_OPTION_WINDOWSIZE
public static final byte TELNET_OPTION_TOGGLEFLOWCONTROL
public static final byte TELNET_OPTION_LINEMODE
public static final byte TELNET_OPTION_LINEMODE_MODE
public static final byte TELNET_OPTION_LINEMODE_MODE_EDIT
public static final byte TELNET_OPTION_LINEMODE_MODE_TRAPSIG
public static final byte TELNET_OPTION_LINEMODE_MODE_MODE_ACK
public static final byte TELNET_OPTION_LINEMODE_MODE_SOFT_TAB
public static final byte TELNET_OPTION_LINEMODE_MODE_LIT_ECHO
public static final byte TELNET_OPTION_LINEMODE_FORWARDMASK
public static final int TELNET_SE
public static final int TELNET_NOP
public static final int TELNET_AYT
public static final int TELNET_EC
public static final int TELNET_GA
public static final int TELNET_SB
public static final int TELNET_WILL
public static final int TELNET_WONT
public static final int TELNET_DO
public static final int TELNET_DONT
public static final int TELNET_IAC
public static final byte[] TELNET_SEQUENCE_GOAHEAD
public static final String implementedOptions
Method Detail |
---|
public ConsoleDelegate getConsoleDelegate()
public OutputFormat getOutputFormat()
public void start() throws TelnetServiceException
TelnetServiceException
public void stop()
protected void close()
public void run()
run
in interface Runnable
protected void writePrompt()
protected void write(byte[] bbuf, int off, int len)
protected void write(char[] cbuf, int off, int len)
protected void write(String txt)
protected void writeln(String txt)
public void backspaceActiveText(int count)
protected void appendActiveText(char c)
protected void appendActiveText(String txt, int offsetUpdateMask)
protected void replaceActiveText(String txt, int offsetUpdateMask)
protected void commitActiveText()
public void addSessionListener(SessionListener listener)
public void removeAllSessionListeners()
public void removeSessionListener(SessionListener listener)
public void notifyConnectionEstablished(SessionState sessionState)
public void notifyConnectionLost(SessionState sessionState)
public SessionState getSessionState()
public SocketAddress getRemoteSocketAddress()
public Date getConnectionTimestamp()
public void output(SessionState sessionState, Object subject)
OutputFormat
to format the
subject
then calling the ConsoleDelegate
to write the outcome
to the console.
sessionState
- the current session statesubject
- the item to be output
OutputFormatException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |