Repository: mina Updated Branches: refs/heads/2.0 e5d1758cd -> cf5579e9a
Fixed teh last missing Javadoc in mina-core Project: http://git-wip-us.apache.org/repos/asf/mina/repo Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/cf5579e9 Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/cf5579e9 Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/cf5579e9 Branch: refs/heads/2.0 Commit: cf5579e9a3c62f34d3c4413fd2587c15e1306450 Parents: e5d1758 Author: Emmanuel Lécharny <elecha...@symas.com> Authored: Fri Dec 9 15:50:00 2016 +0100 Committer: Emmanuel Lécharny <elecha...@symas.com> Committed: Fri Dec 9 15:50:00 2016 +0100 ---------------------------------------------------------------------- .../handlers/http/AbstractAuthLogicHandler.java | 2 +- .../handlers/http/AbstractHttpLogicHandler.java | 15 ++- .../http/HttpAuthenticationMethods.java | 13 +- .../proxy/handlers/http/HttpProxyConstants.java | 26 ++-- .../proxy/handlers/http/HttpProxyRequest.java | 8 +- .../handlers/http/HttpSmartProxyHandler.java | 10 +- .../http/basic/HttpBasicAuthLogicHandler.java | 2 +- .../http/basic/HttpNoAuthLogicHandler.java | 2 +- .../http/digest/HttpDigestAuthLogicHandler.java | 2 +- .../http/ntlm/HttpNTLMAuthLogicHandler.java | 2 +- .../proxy/handlers/http/ntlm/NTLMResponses.java | 3 + .../handlers/socks/Socks4LogicHandler.java | 4 +- .../handlers/socks/Socks5LogicHandler.java | 13 +- .../handlers/socks/SocksProxyConstants.java | 119 ++++++++++++------- .../CompositeByteArrayRelativeWriter.java | 34 +++++- 15 files changed, 175 insertions(+), 80 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java index 5cded04..57ac6b4 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory; * @since MINA 2.0.0-M3 */ public abstract class AbstractAuthLogicHandler { - private final static Logger logger = LoggerFactory.getLogger(AbstractAuthLogicHandler.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractAuthLogicHandler.class); /** * The request to be handled by the proxy. http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractHttpLogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractHttpLogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractHttpLogicHandler.java index 61785c0..a314519 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractHttpLogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractHttpLogicHandler.java @@ -46,13 +46,13 @@ import org.slf4j.LoggerFactory; * @since MINA 2.0.0-M3 */ public abstract class AbstractHttpLogicHandler extends AbstractProxyLogicHandler { - private final static Logger LOGGER = LoggerFactory.getLogger(AbstractHttpLogicHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpLogicHandler.class); - private final static String DECODER = AbstractHttpLogicHandler.class.getName() + ".Decoder"; + private static final String DECODER = AbstractHttpLogicHandler.class.getName() + ".Decoder"; - private final static byte[] HTTP_DELIMITER = new byte[] { '\r', '\n', '\r', '\n' }; + private static final byte[] HTTP_DELIMITER = new byte[] { '\r', '\n', '\r', '\n' }; - private final static byte[] CRLF_DELIMITER = new byte[] { '\r', '\n' }; + private static final byte[] CRLF_DELIMITER = new byte[] { '\r', '\n' }; // Parsing vars @@ -114,6 +114,7 @@ public abstract class AbstractHttpLogicHandler extends AbstractProxyLogicHandler * @param nextFilter the next filter * @param buf the buffer holding received data */ + @Override public synchronized void messageReceived(final NextFilter nextFilter, final IoBuffer buf) throws ProxyAuthException { LOGGER.debug(" messageReceived()"); @@ -268,7 +269,7 @@ public abstract class AbstractHttpLogicHandler extends AbstractProxyLogicHandler } } catch (Exception ex) { if (ex instanceof ProxyAuthException) { - throw ((ProxyAuthException) ex); + throw (ProxyAuthException) ex; } throw new ProxyAuthException("Handshake failed", ex); @@ -334,12 +335,14 @@ public abstract class AbstractHttpLogicHandler extends AbstractProxyLogicHandler // Fires reconnection proxyIoSession.getConnector().connect(new IoSessionInitializer<ConnectFuture>() { + @Override public void initializeSession(final IoSession session, ConnectFuture future) { LOGGER.debug("Initializing new session: {}", session); session.setAttribute(ProxyIoSession.PROXY_SESSION, proxyIoSession); proxyIoSession.setSession(session); LOGGER.debug(" setting up proxyIoSession: {}", proxyIoSession); future.addListener(new IoFutureListener<ConnectFuture>() { + @Override public void operationComplete(ConnectFuture future) { // Reconnection is done so we send the // request to the proxy @@ -378,7 +381,7 @@ public abstract class AbstractHttpLogicHandler extends AbstractProxyLogicHandler throw new Exception("Invalid response code (" + statusLine[1] + "). Response: " + response); } - Map<String, List<String>> headers = new HashMap<String, List<String>>(); + Map<String, List<String>> headers = new HashMap<>(); for (int i = 1; i < responseLines.length; i++) { String[] args = responseLines[i].split(":\\s?", 2); http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java index 5f89490..924601c 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java @@ -33,8 +33,17 @@ import org.apache.mina.proxy.session.ProxyIoSession; * @since MINA 2.0.0-M3 */ public enum HttpAuthenticationMethods { - - NO_AUTH(1), BASIC(2), NTLM(3), DIGEST(4); + /** No authentication */ + NO_AUTH(1), + + /** Basic authentication */ + BASIC(2), + + /** NTLM (Microsoft) authentication */ + NTLM(3), + + /** Digest authentication */ + DIGEST(4); private final int id; http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyConstants.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyConstants.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyConstants.java index 7e07b96..fec0965 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyConstants.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyConstants.java @@ -26,62 +26,64 @@ package org.apache.mina.proxy.handlers.http; * @since MINA 2.0.0-M3 */ public class HttpProxyConstants { - /** * The HTTP CONNECT verb. */ - public final static String CONNECT = "CONNECT"; + public static final String CONNECT = "CONNECT"; /** * The HTTP GET verb. */ - public final static String GET = "GET"; + public static final String GET = "GET"; /** * The HTTP PUT verb. */ - public final static String PUT = "PUT"; + public static final String PUT = "PUT"; /** * The HTTP 1.0 protocol version string. */ - public final static String HTTP_1_0 = "HTTP/1.0"; + public static final String HTTP_1_0 = "HTTP/1.0"; /** * The HTTP 1.1 protocol version string. */ - public final static String HTTP_1_1 = "HTTP/1.1"; + public static final String HTTP_1_1 = "HTTP/1.1"; /** * The CRLF character sequence used in HTTP protocol to end each line. */ - public final static String CRLF = "\r\n"; + public static final String CRLF = "\r\n"; /** * The default keep-alive timeout we set to make proxy * connection persistent. Set to 300 ms. */ - public final static String DEFAULT_KEEP_ALIVE_TIME = "300"; + public static final String DEFAULT_KEEP_ALIVE_TIME = "300"; // ProxyRequest properties /** * The username property. Used in auth mechs. */ - public final static String USER_PROPERTY = "USER"; + public static final String USER_PROPERTY = "USER"; /** * The password property. Used in auth mechs. */ - public final static String PWD_PROPERTY = "PWD"; + public static final String PWD_PROPERTY = "PWD"; /** * The domain name property. Used in auth mechs. */ - public final static String DOMAIN_PROPERTY = "DOMAIN"; + public static final String DOMAIN_PROPERTY = "DOMAIN"; /** * The workstation name property. Used in auth mechs. */ - public final static String WORKSTATION_PROPERTY = "WORKSTATION"; + public static final String WORKSTATION_PROPERTY = "WORKSTATION"; + + private HttpProxyConstants() { + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyRequest.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyRequest.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyRequest.java index ce2b1fa..69cf7f1 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyRequest.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpProxyRequest.java @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; * @since MINA 2.0.0-M3 */ public class HttpProxyRequest extends ProxyRequest { - private final static Logger logger = LoggerFactory.getLogger(HttpProxyRequest.class); + private static final Logger logger = LoggerFactory.getLogger(HttpProxyRequest.class); /** * The HTTP verb. @@ -68,7 +68,7 @@ public class HttpProxyRequest extends ProxyRequest { * The additionnal properties supplied to use with the proxy for * authentication for example. */ - private transient Map<String, String> properties; + private Map<String, String> properties; /** * Constructor which creates a HTTP/1.0 CONNECT request to the specified @@ -189,7 +189,7 @@ public class HttpProxyRequest extends ProxyRequest { /** * @return the host to which we are connecting. */ - public synchronized final String getHost() { + public final synchronized String getHost() { if (host == null) { if (getEndpointAddress() != null && !getEndpointAddress().isUnresolved()) { host = getEndpointAddress().getHostName(); @@ -280,7 +280,7 @@ public class HttpProxyRequest extends ProxyRequest { if (getHeaders() != null) { for (Map.Entry<String, List<String>> header : getHeaders().entrySet()) { if (!hostHeaderFound) { - hostHeaderFound = header.getKey().equalsIgnoreCase("host"); + hostHeaderFound = "host".equalsIgnoreCase(header.getKey()); } for (String value : header.getValue()) { http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpSmartProxyHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpSmartProxyHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpSmartProxyHandler.java index 17b5a56..b6895c9 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpSmartProxyHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/HttpSmartProxyHandler.java @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory; * @since MINA 2.0.0-M3 */ public class HttpSmartProxyHandler extends AbstractHttpLogicHandler { - private final static Logger logger = LoggerFactory.getLogger(HttpSmartProxyHandler.class); + private static final Logger logger = LoggerFactory.getLogger(HttpSmartProxyHandler.class); /** * Has the HTTP proxy request been sent ? @@ -50,6 +50,11 @@ public class HttpSmartProxyHandler extends AbstractHttpLogicHandler { */ private AbstractAuthLogicHandler authHandler; + /** + * Creates a new HttpSmartProxyHandler instance + * + * @param proxyIoSession The Prowxy IoSession + */ public HttpSmartProxyHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); } @@ -59,6 +64,7 @@ public class HttpSmartProxyHandler extends AbstractHttpLogicHandler { * * @param nextFilter the next filter */ + @Override public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException { logger.debug(" doHandshake()"); @@ -98,7 +104,7 @@ public class HttpSmartProxyHandler extends AbstractHttpLogicHandler { List<String> values = response.getHeaders().get("Proxy-Authenticate"); ProxyIoSession proxyIoSession = getProxyIoSession(); - if (values == null || values.size() == 0) { + if (values == null || values.isEmpty()) { authHandler = HttpAuthenticationMethods.NO_AUTH.getNewHandler(proxyIoSession); } else if (getProxyIoSession().getPreferedOrder() == null) { http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java index de15bc0..d2184c0 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java @@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory; * @since MINA 2.0.0-M3 */ public class HttpBasicAuthLogicHandler extends AbstractAuthLogicHandler { - private final static Logger logger = LoggerFactory.getLogger(HttpBasicAuthLogicHandler.class); + private static final Logger logger = LoggerFactory.getLogger(HttpBasicAuthLogicHandler.class); /** * Build an HttpBasicAuthLogicHandler http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java index d2c8843..3085cf9 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java @@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory; * @since MINA 2.0.0-M3 */ public class HttpNoAuthLogicHandler extends AbstractAuthLogicHandler { - private final static Logger logger = LoggerFactory.getLogger(HttpNoAuthLogicHandler.class); + private static final Logger logger = LoggerFactory.getLogger(HttpNoAuthLogicHandler.class); /** * Build an HttpNoAuthLogicHandler http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/digest/HttpDigestAuthLogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/digest/HttpDigestAuthLogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/digest/HttpDigestAuthLogicHandler.java index 478f80c..7831436 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/digest/HttpDigestAuthLogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/digest/HttpDigestAuthLogicHandler.java @@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory; */ public class HttpDigestAuthLogicHandler extends AbstractAuthLogicHandler { - private final static Logger logger = LoggerFactory.getLogger(HttpDigestAuthLogicHandler.class); + private static final Logger logger = LoggerFactory.getLogger(HttpDigestAuthLogicHandler.class); /** * The challenge directives provided by the server. http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java index 6c73988..a6e168d 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java @@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory; */ public class HttpNTLMAuthLogicHandler extends AbstractAuthLogicHandler { - private final static Logger LOGGER = LoggerFactory.getLogger(HttpNTLMAuthLogicHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(HttpNTLMAuthLogicHandler.class); /** * The challenge provided by the server. http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java index b003998..93f3b95 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/NTLMResponses.java @@ -45,6 +45,9 @@ public class NTLMResponses { public static final byte[] LM_HASH_MAGIC_CONSTANT = new byte[]{ 'K', 'G', 'S', '!', '@', '#', '$', '%' }; + private NTLMResponses() { + } + /** * Calculates the LM Response for the given challenge, using the specified * password. http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks4LogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks4LogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks4LogicHandler.java index 7fc1d64..75e89d6 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks4LogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks4LogicHandler.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; */ public class Socks4LogicHandler extends AbstractSocksLogicHandler { - private final static Logger logger = LoggerFactory.getLogger(Socks4LogicHandler.class); + private static final Logger logger = LoggerFactory.getLogger(Socks4LogicHandler.class); /** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) @@ -52,6 +52,7 @@ public class Socks4LogicHandler extends AbstractSocksLogicHandler { * * @param nextFilter the next filter */ + @Override public void doHandshake(final NextFilter nextFilter) { logger.debug(" doHandshake()"); @@ -112,6 +113,7 @@ public class Socks4LogicHandler extends AbstractSocksLogicHandler { * @param nextFilter the next filter * @param buf the server response data buffer */ + @Override public void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { if (buf.remaining() >= SocksProxyConstants.SOCKS_4_RESPONSE_SIZE) { http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks5LogicHandler.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks5LogicHandler.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks5LogicHandler.java index 3b00cdb..89df353 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks5LogicHandler.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/Socks5LogicHandler.java @@ -44,27 +44,27 @@ import org.slf4j.LoggerFactory; */ public class Socks5LogicHandler extends AbstractSocksLogicHandler { - private final static Logger LOGGER = LoggerFactory.getLogger(Socks5LogicHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(Socks5LogicHandler.class); /** * The selected authentication method attribute key. */ - private final static String SELECTED_AUTH_METHOD = Socks5LogicHandler.class.getName() + ".SelectedAuthMethod"; + private static final String SELECTED_AUTH_METHOD = Socks5LogicHandler.class.getName() + ".SelectedAuthMethod"; /** * The current step in the handshake attribute key. */ - private final static String HANDSHAKE_STEP = Socks5LogicHandler.class.getName() + ".HandshakeStep"; + private static final String HANDSHAKE_STEP = Socks5LogicHandler.class.getName() + ".HandshakeStep"; /** * The Java GSS-API context attribute key. */ - private final static String GSS_CONTEXT = Socks5LogicHandler.class.getName() + ".GSSContext"; + private static final String GSS_CONTEXT = Socks5LogicHandler.class.getName() + ".GSSContext"; /** * Last GSS token received attribute key. */ - private final static String GSS_TOKEN = Socks5LogicHandler.class.getName() + ".GSSToken"; + private static final String GSS_TOKEN = Socks5LogicHandler.class.getName() + ".GSSToken"; /** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) @@ -81,6 +81,7 @@ public class Socks5LogicHandler extends AbstractSocksLogicHandler { * * @param nextFilter the next filter */ + @Override public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); @@ -282,6 +283,7 @@ public class Socks5LogicHandler extends AbstractSocksLogicHandler { } else if (step == SocksProxyConstants.SOCKS5_AUTH_STEP) { // This step can happen multiple times like in GSSAPI auth for instance buf = encodeAuthenticationPacket(request); + // If buf is null then go to the next step if (buf == null) { step = SocksProxyConstants.SOCKS5_REQUEST_STEP; @@ -307,6 +309,7 @@ public class Socks5LogicHandler extends AbstractSocksLogicHandler { * @param nextFilter the next filter * @param buf the buffered data received */ + @Override public synchronized void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { int step = ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue(); http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/SocksProxyConstants.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/SocksProxyConstants.java b/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/SocksProxyConstants.java index e5b465f..0517d54 100644 --- a/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/SocksProxyConstants.java +++ b/mina-core/src/main/java/org/apache/mina/proxy/handlers/socks/SocksProxyConstants.java @@ -29,120 +29,155 @@ public class SocksProxyConstants { /** * SOCKS versions field values. */ - public final static byte SOCKS_VERSION_4 = 0x04; + /** Socks V4 */ + public static final byte SOCKS_VERSION_4 = 0x04; - public final static byte SOCKS_VERSION_5 = 0x05; + /** Socks V5 */ + public static final byte SOCKS_VERSION_5 = 0x05; - public final static byte TERMINATOR = 0x00; + /** terminator */ + public static final byte TERMINATOR = 0x00; /** * The size of a server to client response in a SOCKS4/4a negotiation. */ - public final static int SOCKS_4_RESPONSE_SIZE = 8; + public static final int SOCKS_4_RESPONSE_SIZE = 8; /** * Invalid IP used in SOCKS 4a protocol to specify that the * client can't resolve the destination host's domain name. */ - public final static byte[] FAKE_IP = new byte[] { 0, 0, 0, 10 }; + public static final byte[] FAKE_IP = new byte[] { 0, 0, 0, 10 }; /** * Command codes. */ - public final static byte ESTABLISH_TCPIP_STREAM = 0x01; + /** TCPIP stream */ + public static final byte ESTABLISH_TCPIP_STREAM = 0x01; - public final static byte ESTABLISH_TCPIP_BIND = 0x02; + /** TCPIP bind */ + public static final byte ESTABLISH_TCPIP_BIND = 0x02; - public final static byte ESTABLISH_UDP_ASSOCIATE = 0x03; + /** UDP associate */ + public static final byte ESTABLISH_UDP_ASSOCIATE = 0x03; /** * SOCKS v4/v4a server reply codes. */ - public final static byte V4_REPLY_REQUEST_GRANTED = 0x5a; + /** Request granted */ + public static final byte V4_REPLY_REQUEST_GRANTED = 0x5a; - public final static byte V4_REPLY_REQUEST_REJECTED_OR_FAILED = 0x5b; + /** Request rejected or failed */ + public static final byte V4_REPLY_REQUEST_REJECTED_OR_FAILED = 0x5b; - public final static byte V4_REPLY_REQUEST_FAILED_NO_IDENTD = 0x5c; + /** Request failed not identified */ + public static final byte V4_REPLY_REQUEST_FAILED_NO_IDENTD = 0x5c; - public final static byte V4_REPLY_REQUEST_FAILED_ID_NOT_CONFIRMED = 0x5d; + /** Request failed identity not confirmed */ + public static final byte V4_REPLY_REQUEST_FAILED_ID_NOT_CONFIRMED = 0x5d; /** * SOCKS v5 server reply codes. */ - public final static byte V5_REPLY_SUCCEEDED = 0x00; + /** Success */ + public static final byte V5_REPLY_SUCCEEDED = 0x00; - public final static byte V5_REPLY_GENERAL_FAILURE = 0x01; + /** General failure */ + public static final byte V5_REPLY_GENERAL_FAILURE = 0x01; - public final static byte V5_REPLY_NOT_ALLOWED = 0x02; + /** Not allowed */ + public static final byte V5_REPLY_NOT_ALLOWED = 0x02; - public final static byte V5_REPLY_NETWORK_UNREACHABLE = 0x03; + /** Network unreachable */ + public static final byte V5_REPLY_NETWORK_UNREACHABLE = 0x03; - public final static byte V5_REPLY_HOST_UNREACHABLE = 0x04; + /** Host unreachable */ + public static final byte V5_REPLY_HOST_UNREACHABLE = 0x04; - public final static byte V5_REPLY_CONNECTION_REFUSED = 0x05; + /** Connection refused */ + public static final byte V5_REPLY_CONNECTION_REFUSED = 0x05; - public final static byte V5_REPLY_TTL_EXPIRED = 0x06; + /** TTL expired */ + public static final byte V5_REPLY_TTL_EXPIRED = 0x06; - public final static byte V5_REPLY_COMMAND_NOT_SUPPORTED = 0x07; + /** Command not supported */ + public static final byte V5_REPLY_COMMAND_NOT_SUPPORTED = 0x07; - public final static byte V5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED = 0x08; + /** Address type not supported */ + public static final byte V5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED = 0x08; - /** - * SOCKS v5 address types. - */ - public final static byte IPV4_ADDRESS_TYPE = 0x01; + /** IPV4 address types */ + public static final byte IPV4_ADDRESS_TYPE = 0x01; - public final static byte DOMAIN_NAME_ADDRESS_TYPE = 0x03; + /** Domain name address type */ + public static final byte DOMAIN_NAME_ADDRESS_TYPE = 0x03; - public final static byte IPV6_ADDRESS_TYPE = 0x04; + /** IPV6 address type */ + public static final byte IPV6_ADDRESS_TYPE = 0x04; /** * SOCKS v5 handshake steps. */ - public final static int SOCKS5_GREETING_STEP = 0; + /** Greeting step */ + public static final int SOCKS5_GREETING_STEP = 0; - public final static int SOCKS5_AUTH_STEP = 1; + /** Authentication step */ + public static final int SOCKS5_AUTH_STEP = 1; - public final static int SOCKS5_REQUEST_STEP = 2; + /** Request step */ + public static final int SOCKS5_REQUEST_STEP = 2; /** * SOCKS v5 authentication methods. */ - public final static byte NO_AUTH = 0x00; + /** No authentication */ + public static final byte NO_AUTH = 0x00; - public final static byte GSSAPI_AUTH = 0x01; + /** GSSAPI authentication */ + public static final byte GSSAPI_AUTH = 0x01; - public final static byte BASIC_AUTH = 0x02; + /** Basic authentication */ + public static final byte BASIC_AUTH = 0x02; - public final static byte NO_ACCEPTABLE_AUTH_METHOD = (byte) 0xFF; + /** Non acceptable method authentication */ + public static final byte NO_ACCEPTABLE_AUTH_METHOD = (byte) 0xFF; - public final static byte[] SUPPORTED_AUTH_METHODS = new byte[] { NO_AUTH, GSSAPI_AUTH, BASIC_AUTH }; + /** Supported authentication methods */ + public static final byte[] SUPPORTED_AUTH_METHODS = new byte[] { NO_AUTH, GSSAPI_AUTH, BASIC_AUTH }; - public final static byte BASIC_AUTH_SUBNEGOTIATION_VERSION = 0x01; + /** Basic authentication subnegociation version */ + public static final byte BASIC_AUTH_SUBNEGOTIATION_VERSION = 0x01; - public final static byte GSSAPI_AUTH_SUBNEGOTIATION_VERSION = 0x01; + /** GSSAPI authentication subnegociation version */ + public static final byte GSSAPI_AUTH_SUBNEGOTIATION_VERSION = 0x01; - public final static byte GSSAPI_MSG_TYPE = 0x01; + /** GSSAPI message type */ + public static final byte GSSAPI_MSG_TYPE = 0x01; /** * Kerberos providers OID's. */ - public final static String KERBEROS_V5_OID = "1.2.840.113554.1.2.2"; + /** Kerberos V5 OID */ + public static final String KERBEROS_V5_OID = "1.2.840.113554.1.2.2"; - public final static String MS_KERBEROS_V5_OID = "1.2.840.48018.1.2.2"; + /** Microsoft Kerberos V5 OID */ + public static final String MS_KERBEROS_V5_OID = "1.2.840.48018.1.2.2"; /** * Microsoft NTLM security support provider. */ - public final static String NTLMSSP_OID = "1.3.6.1.4.1.311.2.2.10"; + public static final String NTLMSSP_OID = "1.3.6.1.4.1.311.2.2.10"; + private SocksProxyConstants() { + } + /** * Return the string associated with the specified reply code. * * @param code the reply code * @return the reply string */ - public final static String getReplyCodeAsString(byte code) { + public static final String getReplyCodeAsString(byte code) { switch (code) { // v4 & v4a codes case V4_REPLY_REQUEST_GRANTED: http://git-wip-us.apache.org/repos/asf/mina/blob/cf5579e9/mina-core/src/main/java/org/apache/mina/util/byteaccess/CompositeByteArrayRelativeWriter.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/util/byteaccess/CompositeByteArrayRelativeWriter.java b/mina-core/src/main/java/org/apache/mina/util/byteaccess/CompositeByteArrayRelativeWriter.java index e24c678..3969831 100644 --- a/mina-core/src/main/java/org/apache/mina/util/byteaccess/CompositeByteArrayRelativeWriter.java +++ b/mina-core/src/main/java/org/apache/mina/util/byteaccess/CompositeByteArrayRelativeWriter.java @@ -44,6 +44,11 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative * An object that knows how to expand a <code>CompositeByteArray</code>. */ public interface Expander { + /** + * Expand a ByteBuffer by minSize bytes + * @param cba The ByteBuffer to expand + * @param minSize The new added size + */ void expand(CompositeByteArray cba, int minSize); } @@ -52,6 +57,10 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative * */ public static class NopExpander implements Expander { + /** + * {@inheritDoc} + */ + @Override public void expand(CompositeByteArray cba, int minSize) { // Do nothing. } @@ -68,11 +77,21 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative private final int newComponentSize; + /** + * Creates a new ChunkedExpander instance + * + * @param baf The byte array factory + * @param newComponentSize The new size + */ public ChunkedExpander(ByteArrayFactory baf, int newComponentSize) { this.baf = baf; this.newComponentSize = newComponentSize; } + /** + * {@inheritDoc} + */ + @Override public void expand(CompositeByteArray cba, int minSize) { int remaining = minSize; while (remaining > 0) { @@ -88,7 +107,11 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative * An object that knows how to flush a <code>ByteArray</code>. */ public interface Flusher { - // document free() behaviour + /** + * Flush a byte array + * + * @param ba The byte array to flush + */ void flush(ByteArray ba); } @@ -156,6 +179,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void skip(int length) { cursor.skip(length); } @@ -170,6 +194,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void put(byte b) { prepareForAccess(1); cursor.put(b); @@ -178,6 +203,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void put(IoBuffer bb) { prepareForAccess(bb.remaining()); cursor.put(bb); @@ -186,6 +212,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void putShort(short s) { prepareForAccess(2); cursor.putShort(s); @@ -194,6 +221,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void putInt(int i) { prepareForAccess(4); cursor.putInt(i); @@ -202,6 +230,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void putLong(long l) { prepareForAccess(8); cursor.putLong(l); @@ -210,6 +239,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void putFloat(float f) { prepareForAccess(4); cursor.putFloat(f); @@ -218,6 +248,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void putDouble(double d) { prepareForAccess(8); cursor.putDouble(d); @@ -226,6 +257,7 @@ public class CompositeByteArrayRelativeWriter extends CompositeByteArrayRelative /** * {@inheritDoc} */ + @Override public void putChar(char c) { prepareForAccess(2); cursor.putChar(c);