Class Socks5LogicHandler
java.lang.Object
org.apache.mina.proxy.AbstractProxyLogicHandler
org.apache.mina.proxy.handlers.socks.AbstractSocksLogicHandler
org.apache.mina.proxy.handlers.socks.Socks5LogicHandler
- All Implemented Interfaces:
ProxyLogicHandler
Socks5LogicHandler.java - SOCKS5 authentication mechanisms logic handler.
- Since:
- MINA 2.0.0-M3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe Java GSS-API context attribute key.private static final StringLast GSS token received attribute key.private static final StringThe current step in the handshake attribute key.private static final org.slf4j.Loggerprivate static final StringThe selected authentication method attribute key.Fields inherited from class AbstractSocksLogicHandler
request -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcloseSession(String message) Closes the session.voiddoHandshake(IoFilter.NextFilter nextFilter) Performs the handshake process.private IoBufferEncodes the authentication packet for supported authentication methods.private IoBufferEncodes the authentication packet for supported authentication methods.private IoBufferEncodes the initial greeting packet.private IoBufferEncodes the proxy authorization request packet.protected voidhandleResponse(IoFilter.NextFilter nextFilter, IoBuffer buf, int step) Handle a SOCKS v5 response from the proxy server.voidmessageReceived(IoFilter.NextFilter nextFilter, IoBuffer buf) Handles incoming data during the handshake process.private voidwriteRequest(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.Methods inherited from class AbstractProxyLogicHandler
closeSession, enqueueWriteRequest, flushPendingWriteRequests, getProxyFilter, getProxyIoSession, getSession, isHandshakeComplete, setHandshakeComplete, writeData
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
SELECTED_AUTH_METHOD
The selected authentication method attribute key. -
HANDSHAKE_STEP
The current step in the handshake attribute key. -
GSS_CONTEXT
The Java GSS-API context attribute key. -
GSS_TOKEN
Last GSS token received attribute key.
-
-
Constructor Details
-
Socks5LogicHandler
- Parameters:
proxyIoSession- The original session- See Also:
-
-
Method Details
-
doHandshake
Performs the handshake process.- Parameters:
nextFilter- the next filter
-
encodeInitialGreetingPacket
Encodes the initial greeting packet.- Parameters:
request- the socks proxy request data- Returns:
- the encoded buffer
-
encodeProxyRequestPacket
Encodes the proxy authorization request packet.- Parameters:
request- the socks proxy request data- Returns:
- the encoded buffer
-
encodeAuthenticationPacket
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
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
Encodes a SOCKS5 request and writes it to the next filter so it can be sent to the proxy server.- Parameters:
nextFilter- the next filterrequest- the request to send.step- the current step in the handshake process
-
messageReceived
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 filterbuf- 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 filterbuf- the buffered data receivedstep- the current step in the authentication process- Throws:
Exception- If something went wrong
-
closeSession
Closes the session. If anyGSSContextis present in the session then it is closed.- Overrides:
closeSessionin classAbstractProxyLogicHandler- Parameters:
message- the error message
-