net.i2p.sam
Class SAMv3Handler

java.lang.Object
  extended by net.i2p.sam.SAMHandler
      extended by net.i2p.sam.SAMv1Handler
          extended by net.i2p.sam.SAMv3Handler
All Implemented Interfaces:
java.lang.Runnable, SAMDatagramReceiver, SAMRawReceiver, SAMStreamReceiver

public class SAMv3Handler
extends SAMv1Handler

Class able to handle a SAM version 3 client connection.

Author:
mkvore

Nested Class Summary
static class SAMv3Handler.DatagramServer
           
static class SAMv3Handler.MessageDispatcher
           
(package private) static interface SAMv3Handler.Session
           
 class SAMv3Handler.SessionRecord
           
static class SAMv3Handler.SessionsDB
           
 
Field Summary
protected  SAMv3DatagramSession datagramSession
           
protected  SAMv3RawSession rawSession
           
protected  SAMv3Handler.Session session
           
static SAMv3Handler.SessionsDB sSessionsHash
           
(package private)  boolean stolenSocket
           
(package private)  boolean streamForwardingSocket
           
protected  SAMv3StreamSession streamSession
           
 
Fields inherited from class net.i2p.sam.SAMv1Handler
__id, _id, verMajorId, verMinorId
 
Fields inherited from class net.i2p.sam.SAMHandler
bridge, i2cpProps, socket, thread, verMajor, verMinor
 
Constructor Summary
SAMv3Handler(java.nio.channels.SocketChannel s, int verMajor, int verMinor)
          Create a new SAM version 3 handler.
SAMv3Handler(java.nio.channels.SocketChannel s, int verMajor, int verMinor, java.util.Properties i2cpProps)
          Create a new SAM version 3 handler.
 
Method Summary
protected  void die()
           
protected  boolean execSessionMessage(java.lang.String opcode, java.util.Properties props)
           
protected  boolean execStreamAccept(java.util.Properties props)
           
protected  boolean execStreamConnect(java.util.Properties props)
           
protected  boolean execStreamForwardIncoming(java.util.Properties props)
           
protected  boolean execStreamMessage(java.lang.String opcode, java.util.Properties props)
           
 java.lang.String getClientIP()
           
protected  SAMDatagramSession getDatagramSession()
           
protected  SAMRawSession getRawSession()
           
protected  SAMStreamSession getStreamSession()
           
 void handle()
          Actually handle the SAM protocol.
(package private)  SAMv3DatagramSession newSAMDatagramSession(java.lang.String login)
           
(package private)  SAMv3RawSession newSAMRawSession(java.lang.String login)
           
(package private)  SAMv3StreamSession newSAMStreamSession(java.lang.String login)
           
 void notifyStreamIncomingConnection(Destination d)
           
static void notifyStreamIncomingConnection(java.nio.channels.SocketChannel client, Destination d)
           
 void notifyStreamResult(boolean verbose, java.lang.String result, java.lang.String message)
           
 void stealSocket()
           
 boolean verifVersion()
           
 
Methods inherited from class net.i2p.sam.SAMv1Handler
execDatagramMessage, execDestMessage, execNamingMessage, execRawMessage, execStreamClose, execStreamSend, newSAMStreamSession, notifyStreamDisconnection, notifyStreamIncomingConnection, notifyStreamOutgoingConnection, notifyStreamSendBufferFree, receiveDatagramBytes, receiveRawBytes, receiveStreamBytes, stopDatagramReceiving, stopRawReceiving, stopStreamReceiving, streamSendAnswer
 
Methods inherited from class net.i2p.sam.SAMHandler
closeClientSocket, getClientSocket, getWriteLock, run, setBridge, shouldStop, startHandling, stopHandling, toString, writeBytes, writeBytes, writeString, writeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rawSession

protected SAMv3RawSession rawSession

datagramSession

protected SAMv3DatagramSession datagramSession

streamSession

protected SAMv3StreamSession streamSession

session

protected SAMv3Handler.Session session

sSessionsHash

public static SAMv3Handler.SessionsDB sSessionsHash

stolenSocket

boolean stolenSocket

streamForwardingSocket

boolean streamForwardingSocket
Constructor Detail

SAMv3Handler

public SAMv3Handler(java.nio.channels.SocketChannel s,
                    int verMajor,
                    int verMinor)
             throws SAMException,
                    java.io.IOException
Create a new SAM version 3 handler. This constructor expects that the SAM HELLO message has been still answered (and stripped) from the socket input stream.

Parameters:
s - Socket attached to a SAM client
verMajor - SAM major version to manage (should be 3)
verMinor - SAM minor version to manage
Throws:
SAMException
java.io.IOException

SAMv3Handler

public SAMv3Handler(java.nio.channels.SocketChannel s,
                    int verMajor,
                    int verMinor,
                    java.util.Properties i2cpProps)
             throws SAMException,
                    java.io.IOException
Create a new SAM version 3 handler. This constructor expects that the SAM HELLO message has been still answered (and stripped) from the socket input stream.

Parameters:
s - Socket attached to a SAM client
verMajor - SAM major version to manage (should be 3)
verMinor - SAM minor version to manage
i2cpProps - properties to configure the I2CP connection (host, port, etc)
Throws:
SAMException
java.io.IOException
Method Detail

getRawSession

protected SAMRawSession getRawSession()
Overrides:
getRawSession in class SAMv1Handler

getDatagramSession

protected SAMDatagramSession getDatagramSession()
Overrides:
getDatagramSession in class SAMv1Handler

getStreamSession

protected SAMStreamSession getStreamSession()
Overrides:
getStreamSession in class SAMv1Handler

verifVersion

public boolean verifVersion()
Overrides:
verifVersion in class SAMv1Handler

getClientIP

public java.lang.String getClientIP()

stealSocket

public void stealSocket()

handle

public void handle()
Description copied from class: SAMHandler
Actually handle the SAM protocol.

Overrides:
handle in class SAMv1Handler

die

protected void die()

execSessionMessage

protected boolean execSessionMessage(java.lang.String opcode,
                                     java.util.Properties props)
Overrides:
execSessionMessage in class SAMv1Handler

newSAMStreamSession

SAMv3StreamSession newSAMStreamSession(java.lang.String login)
                                 throws java.io.IOException,
                                        DataFormatException,
                                        SAMException
Throws:
java.io.IOException
DataFormatException
SAMException

newSAMRawSession

SAMv3RawSession newSAMRawSession(java.lang.String login)
                           throws java.io.IOException,
                                  DataFormatException,
                                  SAMException,
                                  I2PSessionException
Throws:
java.io.IOException
DataFormatException
SAMException
I2PSessionException

newSAMDatagramSession

SAMv3DatagramSession newSAMDatagramSession(java.lang.String login)
                                     throws java.io.IOException,
                                            DataFormatException,
                                            SAMException,
                                            I2PSessionException
Throws:
java.io.IOException
DataFormatException
SAMException
I2PSessionException

execStreamMessage

protected boolean execStreamMessage(java.lang.String opcode,
                                    java.util.Properties props)
Overrides:
execStreamMessage in class SAMv1Handler

execStreamConnect

protected boolean execStreamConnect(java.util.Properties props)
Overrides:
execStreamConnect in class SAMv1Handler

execStreamForwardIncoming

protected boolean execStreamForwardIncoming(java.util.Properties props)

execStreamAccept

protected boolean execStreamAccept(java.util.Properties props)

notifyStreamResult

public void notifyStreamResult(boolean verbose,
                               java.lang.String result,
                               java.lang.String message)
                        throws java.io.IOException
Throws:
java.io.IOException

notifyStreamIncomingConnection

public void notifyStreamIncomingConnection(Destination d)
                                    throws java.io.IOException
Throws:
java.io.IOException

notifyStreamIncomingConnection

public static void notifyStreamIncomingConnection(java.nio.channels.SocketChannel client,
                                                  Destination d)
                                           throws java.io.IOException
Throws:
java.io.IOException