## net.i2p.sam
Class SAMv3Handler

    java.lang.Object
      net.i2p.sam.SAMHandler
          net.i2p.sam.SAMv1Handler
              net.i2p.sam.SAMv3Handler

All Implemented Interfaces:
  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(SocketChannel s, int verMajor, int verMinor)` Create a new SAM version 3 handler.
`SAMv3Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps)` Create a new SAM version 3 handler.

Method Summary
`protected void` `die()`
`protected boolean` `execSessionMessage(String opcode, Properties props)`
`protected boolean` `execStreamAccept(Properties props)`
`protected boolean` `execStreamConnect(Properties props)`
`protected boolean` `execStreamForwardIncoming(Properties props)`
`protected boolean` `execStreamMessage(String opcode, Properties props)`
`String` `getClientIP()`
`protected SAMDatagramSession` `getDatagramSession()`
`protected SAMRawSession` `getRawSession()`
`protected SAMStreamSession` `getStreamSession()`
`void` `handle()` Actually handle the SAM protocol.
`(package private) SAMv3DatagramSession` `newSAMDatagramSession(String login)`
`(package private) SAMv3RawSession` `newSAMRawSession(String login)`
`(package private) SAMv3StreamSession` `newSAMStreamSession(String login)`
`void` `notifyStreamIncomingConnection(Destination d)`
`static void` `notifyStreamIncomingConnection(SocketChannel client, Destination d)`
`void` `notifyStreamResult(boolean verbose, String result, 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(SocketChannel s,
                        int verMajor,
                        int verMinor)
                 throws SAMException,
                        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`
    `IOException`

### SAMv3Handler

    public SAMv3Handler(SocketChannel s,
                        int verMajor,
                        int verMinor,
                        Properties i2cpProps)
                 throws SAMException,
                        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`
    `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 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(String opcode,
                                         Properties props)

  Overrides:
    `execSessionMessage` in class `SAMv1Handler`

### newSAMStreamSession

    SAMv3StreamSession newSAMStreamSession(String login)
                                     throws IOException,
                                            DataFormatException,
                                            SAMException

  Throws:
    `IOException`
    `DataFormatException`
    `SAMException`

### newSAMRawSession

    SAMv3RawSession newSAMRawSession(String login)
                               throws IOException,
                                      DataFormatException,
                                      SAMException,
                                      I2PSessionException

  Throws:
    `IOException`
    `DataFormatException`
    `SAMException`
    `I2PSessionException`

### newSAMDatagramSession

    SAMv3DatagramSession newSAMDatagramSession(String login)
                                         throws IOException,
                                                DataFormatException,
                                                SAMException,
                                                I2PSessionException

  Throws:
    `IOException`
    `DataFormatException`
    `SAMException`
    `I2PSessionException`

### execStreamMessage

    protected boolean execStreamMessage(String opcode,
                                        Properties props)

  Overrides:
    `execStreamMessage` in class `SAMv1Handler`

### execStreamConnect

    protected boolean execStreamConnect(Properties props)

  Overrides:
    `execStreamConnect` in class `SAMv1Handler`

### execStreamForwardIncoming

    protected boolean execStreamForwardIncoming(Properties props)

### execStreamAccept

    protected boolean execStreamAccept(Properties props)

### notifyStreamResult

    public void notifyStreamResult(boolean verbose,
                                   String result,
                                   String message)
                            throws IOException

  Throws:
    `IOException`

### notifyStreamIncomingConnection

    public void notifyStreamIncomingConnection(Destination d)
                                        throws IOException

  Throws:
    `IOException`

### notifyStreamIncomingConnection

    public static void notifyStreamIncomingConnection(SocketChannel client,
                                                      Destination d)
                                               throws IOException

  Throws:
    `IOException`