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