Mercurial > 510Connectbot
comparison src/net/sourceforge/jsocks/server/ServerAuthenticator.java @ 0:0ce5cc452d02
initial version
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 22 May 2014 10:41:19 -0700 |
parents | |
children | 205ee2873330 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0ce5cc452d02 |
---|---|
1 package net.sourceforge.jsocks.server; | |
2 | |
3 import java.io.IOException; | |
4 import java.io.InputStream; | |
5 import java.io.OutputStream; | |
6 import java.net.DatagramPacket; | |
7 import java.net.Socket; | |
8 | |
9 import net.sourceforge.jsocks.ProxyMessage; | |
10 import net.sourceforge.jsocks.UDPEncapsulation; | |
11 | |
12 /** | |
13 Classes implementing this interface should provide socks server with | |
14 authentication and authorization of users. | |
15 **/ | |
16 public interface ServerAuthenticator { | |
17 | |
18 /** | |
19 This method is called when a new connection accepted by the server. | |
20 <p> | |
21 At this point no data have been extracted from the connection. It is | |
22 responsibility of this method to ensure that the next byte in the | |
23 stream after this method have been called is the first byte of the | |
24 socks request message. For SOCKSv4 there is no authentication data and | |
25 the first byte in the stream is part of the request. With SOCKSv5 however | |
26 there is an authentication data first. It is expected that implementaions | |
27 will process this authentication data. | |
28 <p> | |
29 If authentication was successful an instance of ServerAuthentication | |
30 should be returned, it later will be used by the server to perform | |
31 authorization and some other things. If authentication fails null should | |
32 be returned, or an exception may be thrown. | |
33 | |
34 @param s Accepted Socket. | |
35 @return An instance of ServerAuthenticator to be used for this connection | |
36 or null | |
37 */ | |
38 ServerAuthenticator startSession(Socket s) throws IOException; | |
39 | |
40 /** | |
41 This method should return input stream which should be used on the | |
42 accepted socket. | |
43 <p> | |
44 SOCKSv5 allows to have multiple authentication methods, and these methods | |
45 might require some kind of transformations being made on the data. | |
46 <p> | |
47 This method is called on the object returned from the startSession | |
48 function. | |
49 */ | |
50 InputStream getInputStream(); | |
51 /** | |
52 This method should return output stream to use to write to the accepted | |
53 socket. | |
54 <p> | |
55 SOCKSv5 allows to have multiple authentication methods, and these methods | |
56 might require some kind of transformations being made on the data. | |
57 <p> | |
58 This method is called on the object returned from the startSession | |
59 function. | |
60 */ | |
61 OutputStream getOutputStream(); | |
62 | |
63 /** | |
64 This method should return UDPEncapsulation, which should be used | |
65 on the datagrams being send in/out. | |
66 <p> | |
67 If no transformation should be done on the datagrams, this method | |
68 should return null. | |
69 <p> | |
70 This method is called on the object returned from the startSession | |
71 function. | |
72 */ | |
73 | |
74 UDPEncapsulation getUdpEncapsulation(); | |
75 | |
76 /** | |
77 This method is called when a request have been read. | |
78 <p> | |
79 Implementation should decide wether to grant request or not. Returning | |
80 true implies granting the request, false means request should be rejected. | |
81 <p> | |
82 This method is called on the object returned from the startSession | |
83 function. | |
84 @param msg Request message. | |
85 @return true to grant request, false to reject it. | |
86 */ | |
87 boolean checkRequest(ProxyMessage msg); | |
88 | |
89 /** | |
90 This method is called when datagram is received by the server. | |
91 <p> | |
92 Implementaions should decide wether it should be forwarded or dropped. | |
93 It is expecteed that implementation will use datagram address and port | |
94 information to make a decision, as well as anything else. Address and | |
95 port of the datagram are always correspond to remote machine. It is | |
96 either destination or source address. If out is true address is destination | |
97 address, else it is a source address, address of the machine from which | |
98 datagram have been received for the client. | |
99 <p> | |
100 Implementaions should return true if the datagram is to be forwarded, and | |
101 false if the datagram should be dropped. | |
102 <p> | |
103 This method is called on the object returned from the startSession | |
104 function. | |
105 | |
106 @param out If true the datagram is being send out(from the client), | |
107 otherwise it is an incoming datagram. | |
108 @return True to forward datagram false drop it silently. | |
109 */ | |
110 boolean checkRequest(DatagramPacket dp, boolean out); | |
111 | |
112 /** | |
113 This method is called when session is completed. Either due to normal | |
114 termination or due to any error condition. | |
115 <p> | |
116 This method is called on the object returned from the startSession | |
117 function. | |
118 */ | |
119 void endSession(); | |
120 } |