Class Socks5LogicHandler

All Implemented Interfaces:
ProxyLogicHandler

public class Socks5LogicHandler extends AbstractSocksLogicHandler
Socks5LogicHandler.java - SOCKS5 authentication mechanisms logic handler.
Since:
MINA 2.0.0-M3
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • SELECTED_AUTH_METHOD

      private static final String SELECTED_AUTH_METHOD
      The selected authentication method attribute key.
    • HANDSHAKE_STEP

      private static final String HANDSHAKE_STEP
      The current step in the handshake attribute key.
    • GSS_CONTEXT

      private static final String GSS_CONTEXT
      The Java GSS-API context attribute key.
    • GSS_TOKEN

      private static final String GSS_TOKEN
      Last GSS token received attribute key.
  • Constructor Details

  • Method Details

    • doHandshake

      public void doHandshake(IoFilter.NextFilter nextFilter)
      Performs the handshake process.
      Parameters:
      nextFilter - the next filter
    • encodeInitialGreetingPacket

      private IoBuffer encodeInitialGreetingPacket(SocksProxyRequest request)
      Encodes the initial greeting packet.
      Parameters:
      request - the socks proxy request data
      Returns:
      the encoded buffer
    • encodeProxyRequestPacket

      private IoBuffer encodeProxyRequestPacket(SocksProxyRequest request)
      Encodes the proxy authorization request packet.
      Parameters:
      request - the socks proxy request data
      Returns:
      the encoded buffer
    • encodeAuthenticationPacket

      private IoBuffer encodeAuthenticationPacket(SocksProxyRequest request) throws GSSException
      Encodes the authentication packet for supported authentication methods.
      Parameters:
      request - the socks proxy request data
      Returns:
      the encoded buffer, if null then authentication step is over and handshake process can jump immediately to the next step without waiting for a server reply.
      Throws:
      GSSException - when something fails while using GSSAPI
    • encodeGSSAPIAuthenticationPacket

      private IoBuffer encodeGSSAPIAuthenticationPacket(SocksProxyRequest request) throws GSSException
      Encodes the authentication packet for supported authentication methods.
      Parameters:
      request - the socks proxy request data
      Returns:
      the encoded buffer
      Throws:
      GSSException - when something fails while using GSSAPI
    • writeRequest

      private void writeRequest(IoFilter.NextFilter nextFilter, SocksProxyRequest request, int step)
      Encodes a SOCKS5 request and writes it to the next filter so it can be sent to the proxy server.
      Parameters:
      nextFilter - the next filter
      request - the request to send.
      step - the current step in the handshake process
    • messageReceived

      public void messageReceived(IoFilter.NextFilter nextFilter, IoBuffer buf)
      Handles incoming data during the handshake process. Should consume only the handshake data from the buffer, leaving any extra data in place.
      Parameters:
      nextFilter - the next filter
      buf - the buffered data received
    • handleResponse

      protected void handleResponse(IoFilter.NextFilter nextFilter, IoBuffer buf, int step) throws Exception
      Handle a SOCKS v5 response from the proxy server.
      Parameters:
      nextFilter - the next filter
      buf - the buffered data received
      step - the current step in the authentication process
      Throws:
      Exception - If something went wrong
    • closeSession

      protected void closeSession(String message)
      Closes the session. If any GSSContext is present in the session then it is closed.
      Overrides:
      closeSession in class AbstractProxyLogicHandler
      Parameters:
      message - the error message