source: 3thparty/jmessenger/src/nu/fw/jeti/plugins/filetransfer/socks5/jsocks/ServerAuthenticator.java @ 3952

Revision 3952, 4.2 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)

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