private void initAuth(Arguments arguments, SocksServerBuilder builder) throws IllegalArgumentException { String authValue = arguments.getValue(Arrays.asList("-a", "--auth"), null); if (authValue != null) { UserManager userManager = new MemoryBasedUserManager(); for (String user : authValue.split(",")) { String[] userPassword = user.split(":"); String username = userPassword[0]; String password = userPassword[1]; userManager.create(new User(username, password)); } builder.setSocksMethods(new UsernamePasswordMethod()).setUserManager(userManager); } else { builder.setSocksMethods(new NoAuthenticationRequiredMethod()); } }
private void initAuth(Arguments arguments, SocksServerBuilder builder) throws IllegalArgumentException { String authValue = arguments.getValue(Arrays.asList("-a", "--auth"), null); if (authValue != null) { UserManager userManager = new MemoryBasedUserManager(); for (String user : authValue.split(",")) { String[] userPassword = user.split(":"); String username = userPassword[0]; String password = userPassword[1]; userManager.create(new User(username, password)); } builder.setSocksMethods(new UsernamePasswordMethod()).setUserManager(userManager); } else { builder.setSocksMethods(new NoAuthenticationRequiredMethod()); } }
/** * Builds a {@link SocksProxyServer} which support SOCKS5 protocol bind at a specified port. * This SOCKS5 server will accept all requests from clients with no authentication. * * @param bindPort The port that server listened. * @return Instance of {@link SocksProxyServer}. */ public static SocksProxyServer buildAnonymousSocks5Server(int bindPort) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).build(); }
/** * Builds a {@link SocksProxyServer} which support SOCKS5 protocol bind at a specified port. * This SOCKS5 server will accept all requests from clients with no authentication. * * @param bindPort The port that server listened. * @return Instance of {@link SocksProxyServer}. */ public static SocksProxyServer buildAnonymousSocks5Server(int bindPort) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).build(); }
/** * Builds a SSL based {@link SocksProxyServer} with no authentication required. * * @param bindPort The port that server listened. * @param configuration SSL configuration * @return Instance of {@link SocksProxyServer} */ public static SocksProxyServer buildAnonymousSSLSocks5Server(int bindPort, SSLConfiguration configuration) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).useSSL(configuration).build(); }
/** * Builds a SSL based {@link SocksProxyServer} with no authentication required. * * @param bindPort The port that server listened. * @param configuration SSL configuration * @return Instance of {@link SocksProxyServer} */ public static SocksProxyServer buildAnonymousSSLSocks5Server(int bindPort, SSLConfiguration configuration) { return newSocks5ServerBuilder().setSocksMethods(new NoAuthenticationRequiredMethod()) .setBindPort(bindPort).useSSL(configuration).build(); }