01: package test;
02:
03: import socks.*;
04: import socks.server.*;
05: import java.net.Socket;
06:
07: /** Test file for UserPasswordAuthentictor */
08:
09: public class UPSOCKS implements UserValidation {
10: String user, password;
11:
12: UPSOCKS(String user, String password) {
13: this .user = user;
14: this .password = password;
15: }
16:
17: public boolean isUserValid(String user, String password, Socket s) {
18: System.err.println("User:" + user + "\tPassword:" + password);
19: System.err.println("Socket:" + s);
20: return (user.equals(this .user) && password
21: .equals(this .password));
22: }
23:
24: public static void main(String args[]) {
25: String user, password;
26:
27: if (args.length == 2) {
28: user = args[0];
29: password = args[1];
30: } else {
31: user = "user";
32: password = "password";
33: }
34:
35: UPSOCKS us = new UPSOCKS(user, password);
36: UserPasswordAuthenticator auth = new UserPasswordAuthenticator(
37: us);
38: ProxyServer server = new ProxyServer(auth);
39:
40: server.setLog(System.out);
41: server.start(1080);
42: }
43: }
|