use of sockslib.server.manager.UserManager in project bnd by bndtools.
the class HttpClientProxyTest method createSecureSocks5.
private void createSecureSocks5() throws IOException, InterruptedException {
UserManager userManager = new MemoryBasedUserManager();
userManager.create(new User("proxyuser", "good"));
SocksServerBuilder builder = SocksServerBuilder.newSocks5ServerBuilder();
builder.setBindPort(++socksProxyPort);
builder.setUserManager(userManager);
builder.addSocksMethods(new UsernamePasswordMethod(new UsernamePasswordAuthenticator() {
@Override
public void doAuthenticate(Credentials arg0, Session arg1) throws AuthenticationException {
// does not get called?
System.out.println("Authenticating");
super.doAuthenticate(arg0, arg1);
authenticationCalled.set(true);
}
}));
socks5Proxy = builder.build();
socks5Proxy.getSessionManager().addSessionListener("abc", new SessionListener() {
@Override
public void onException(Session arg0, Exception arg1) {
System.err.println("Exception " + arg0 + " " + arg1);
arg1.printStackTrace();
exception.set(arg1);
}
@Override
public void onCommand(Session arg0, CommandMessage arg1) throws CloseSessionException {
System.err.println("Command " + arg0 + " " + arg1);
}
@Override
public void onClose(Session arg0) {
System.err.println("Close " + arg0);
}
@Override
public void onCreate(Session arg0) throws CloseSessionException {
System.err.println("Create " + arg0);
created.incrementAndGet();
}
});
socks5Proxy.start();
}
use of sockslib.server.manager.UserManager in project bnd by bndtools.
the class Standalone method createSecureSocks5.
void createSecureSocks5() throws IOException, InterruptedException {
UserManager userManager = new MemoryBasedUserManager();
userManager.create(new User("proxyuser", "good"));
SocksServerBuilder builder = SocksServerBuilder.newSocks5ServerBuilder();
builder.setBindPort(9090);
// builder.setUserManager(userManager);
UsernamePasswordMethod usernamePasswordMethod = new UsernamePasswordMethod();
usernamePasswordMethod.setAuthenticator(new UsernamePasswordAuthenticator() {
@Override
public void doAuthenticate(Credentials arg0, Session arg1) throws AuthenticationException {
super.doAuthenticate(arg0, arg1);
System.out.println("Auth " + arg0 + " " + arg1);
}
});
builder.setSocksMethods(usernamePasswordMethod).setUserManager(userManager);
socks5Proxy = builder.build();
socks5Proxy.getSessionManager().addSessionListener("abc", new SessionListener() {
@Override
public void onException(Session arg0, Exception arg1) {
System.err.println("Exception " + arg0 + " " + arg1);
arg1.printStackTrace();
}
@Override
public void onCommand(Session arg0, CommandMessage arg1) throws CloseSessionException {
System.err.println("Command " + arg0 + " " + arg1);
}
@Override
public void onClose(Session arg0) {
System.err.println("Close " + arg0);
}
@Override
public void onCreate(Session arg0) throws CloseSessionException {
System.err.println("Create " + arg0);
}
});
socks5Proxy.start();
}
use of sockslib.server.manager.UserManager in project bnd by bndtools.
the class IndexedReposWithComms method createSecureSocks5.
private void createSecureSocks5() throws IOException, InterruptedException {
UserManager userManager = new MemoryBasedUserManager();
userManager.create(new User("proxyuser", "good"));
SocksServerBuilder builder = SocksServerBuilder.newSocks5ServerBuilder();
builder.setBindAddr(InetAddress.getLoopbackAddress());
builder.setBindPort(9090);
builder.setUserManager(userManager);
builder.addSocksMethods(new UsernamePasswordMethod(new UsernamePasswordAuthenticator() {
@Override
public void doAuthenticate(Credentials arg0, Session arg1) throws AuthenticationException {
// does not get called?
System.out.println("Authenticating");
super.doAuthenticate(arg0, arg1);
}
}));
socks5Proxy = builder.build();
socks5Proxy.getSessionManager().addSessionListener("abc", new SessionListener() {
@Override
public void onException(Session arg0, Exception arg1) {
System.err.println("Exception " + arg0 + " " + arg1);
arg1.printStackTrace();
}
@Override
public void onCommand(Session arg0, CommandMessage arg1) throws CloseSessionException {
System.err.println("Command " + arg0 + " " + arg1);
}
@Override
public void onClose(Session arg0) {
System.err.println("Close " + arg0);
}
@Override
public void onCreate(Session arg0) throws CloseSessionException {
System.err.println("Create " + arg0);
}
});
socks5Proxy.start();
}
Aggregations