/** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) * * @param proxyIoSession The original session */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
/** * @see AbstractSocksLogicHandler#AbstractSocksLogicHandler(ProxyIoSession) * * @param proxyIoSession The original session */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
/** * {@inheritDoc} */ public Socks5LogicHandler(final ProxyIoSession proxyIoSession) { super(proxyIoSession); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_GREETING_STEP); }
/** * Performs the handshake process. * * @param nextFilter the next filter */ @Override public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request, ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue()); }
/** * Performs the handshake process. * * @param nextFilter the next filter */ @Override public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request, ((Integer) getSession().getAttribute(HANDSHAKE_STEP)).intValue()); }
/** * Performs the handshake process. * * @param nextFilter the next filter */ public synchronized void doHandshake(final NextFilter nextFilter) { LOGGER.debug(" doHandshake()"); // Send request writeRequest(nextFilter, request, (Integer) getSession().getAttribute( HANDSHAKE_STEP)); }
/** * Handles incoming data during the handshake process. Should consume only the * handshake data from the buffer, leaving any extra data in place. * * @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(); if (step == SocksProxyConstants.SOCKS5_GREETING_STEP && buf.get(0) != SocksProxyConstants.SOCKS_VERSION_5) { throw new IllegalStateException("Wrong socks version running on server"); } if ((step == SocksProxyConstants.SOCKS5_GREETING_STEP || step == SocksProxyConstants.SOCKS5_AUTH_STEP) && buf.remaining() >= 2) { handleResponse(nextFilter, buf, step); } else if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP && buf.remaining() >= 5) { handleResponse(nextFilter, buf, step); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }
byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_REQUEST_STEP); break;
/** * Handles incoming data during the handshake process. Should consume only the * handshake data from the buffer, leaving any extra data in place. * * @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(); if (step == SocksProxyConstants.SOCKS5_GREETING_STEP && buf.get(0) != SocksProxyConstants.SOCKS_VERSION_5) { throw new IllegalStateException("Wrong socks version running on server"); } if ((step == SocksProxyConstants.SOCKS5_GREETING_STEP || step == SocksProxyConstants.SOCKS5_AUTH_STEP) && buf.remaining() >= 2) { handleResponse(nextFilter, buf, step); } else if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP && buf.remaining() >= 5) { handleResponse(nextFilter, buf, step); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }
byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_REQUEST_STEP); break;
/** * Closes the session. If any {@link GSSContext} is present in the session * then it is closed. * * @param message the error message */ @Override protected void closeSession(String message) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx != null) { try { ctx.dispose(); } catch (GSSException e) { e.printStackTrace(); super.closeSession(message, e); return; } } super.closeSession(message); } }
getSession().setAttribute(SELECTED_AUTH_METHOD, Byte.valueOf(method)); byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); byte[] token = new byte[s]; buf.get(token); getSession().setAttribute(GSS_TOKEN, token); len = 0; } else { byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); if (method == SocksProxyConstants.GSSAPI_AUTH) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null || !ctx.isEstablished()) { isAuthenticating = true; getSession().setAttribute(HANDSHAKE_STEP, ++step);
GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null) { ctx.requestInteg(false); getSession().setAttribute(GSS_CONTEXT, ctx); byte[] token = (byte[]) getSession().getAttribute(GSS_TOKEN); if (token != null) { LOGGER.debug(" Received Token[{}] = {}", token.length, ByteUtilities.asHex(token)); LOGGER.debug(" Sending Token[{}] = {}", token.length, ByteUtilities.asHex(token)); getSession().setAttribute(GSS_TOKEN, token); buf = IoBuffer.allocate(4 + token.length); buf.put(new byte[] { SocksProxyConstants.GSSAPI_AUTH_SUBNEGOTIATION_VERSION,
/** * Closes the session. If any {@link GSSContext} is present in the session * then it is closed. * * @param message the error message */ @Override protected void closeSession(String message) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx != null) { try { ctx.dispose(); } catch (GSSException e) { e.printStackTrace(); super.closeSession(message, e); return; } } super.closeSession(message); } }
GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null) { ctx.requestInteg(false); getSession().setAttribute(GSS_CONTEXT, ctx); byte[] token = (byte[]) getSession().getAttribute(GSS_TOKEN); if (token != null) { LOGGER.debug(" Received Token[{}] = {}", token.length, ByteUtilities.asHex(token)); getSession().setAttribute(GSS_TOKEN, token); buf = IoBuffer.allocate(4 + token.length); buf.put(new byte[] {
getSession().setAttribute(SELECTED_AUTH_METHOD, Byte.valueOf(method)); byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); byte[] token = new byte[s]; buf.get(token); getSession().setAttribute(GSS_TOKEN, token); len = 0; } else { byte method = ((Byte) getSession().getAttribute(Socks5LogicHandler.SELECTED_AUTH_METHOD)).byteValue(); if (method == SocksProxyConstants.GSSAPI_AUTH) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null || !ctx.isEstablished()) { isAuthenticating = true; getSession().setAttribute(HANDSHAKE_STEP, ++step);
GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx == null) { ctx.requestInteg(false); getSession().setAttribute(GSS_CONTEXT, ctx); byte[] token = (byte[]) getSession().getAttribute(GSS_TOKEN); if (token != null) { LOGGER.debug(" Received Token[{}] = {}", token.length, ByteUtilities.asHex(token)); LOGGER.debug(" Sending Token[{}] = {}", token.length, ByteUtilities.asHex(token)); getSession().setAttribute(GSS_TOKEN, token); buf = IoBuffer.allocate(4 + token.length); buf.put(new byte[] { SocksProxyConstants.GSSAPI_AUTH_SUBNEGOTIATION_VERSION,
byte method = (Byte) getSession().getAttribute( Socks5LogicHandler.SELECTED_AUTH_METHOD); getSession().setAttribute(HANDSHAKE_STEP, SocksProxyConstants.SOCKS5_REQUEST_STEP); break;
/** * Closes the session. If any {@link GSSContext} is present in the session * then it is closed. * * @param message the error message */ @Override protected void closeSession(String message) { GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT); if (ctx != null) { try { ctx.dispose(); } catch (GSSException e) { e.printStackTrace(); super.closeSession(message, e); return; } } super.closeSession(message); } }
/** * Handles incoming data during the handshake process. Should consume only the * handshake data from the buffer, leaving any extra data in place. * * @param nextFilter the next filter * @param buf the buffered data received */ public synchronized void messageReceived(final NextFilter nextFilter, final IoBuffer buf) { try { int step = (Integer) getSession().getAttribute(HANDSHAKE_STEP); if (step == SocksProxyConstants.SOCKS5_GREETING_STEP && buf.get(0) != SocksProxyConstants.SOCKS_VERSION_5) { throw new IllegalStateException( "Wrong socks version running on server"); } if ((step == SocksProxyConstants.SOCKS5_GREETING_STEP || step == SocksProxyConstants.SOCKS5_AUTH_STEP) && buf.remaining() >= 2) { handleResponse(nextFilter, buf, step); } else if (step == SocksProxyConstants.SOCKS5_REQUEST_STEP && buf.remaining() >= 5) { handleResponse(nextFilter, buf, step); } } catch (Exception ex) { closeSession("Proxy handshake failed: ", ex); } }