source: branches/2.2/jabberit_messenger/java_source/src/nu/fw/jeti/plugins/filetransfer/socks5/jsocks/SocksException.java @ 3102

Revision 3102, 2.5 KB checked in by amuller, 14 years ago (diff)

Ticket #986 - Efetuado merge para o Branch 2.2( atualizacao do modulo)

  • Property svn:executable set to *
Line 
1package nu.fw.jeti.plugins.filetransfer.socks5.jsocks;
2
3/**
4 Exception thrown by various socks classes to indicate errors
5 with protocol or unsuccessfull server responses.
6*/
7public class SocksException extends java.io.IOException{
8   /**
9    Construct a SocksException with given errorcode.
10    <p>
11    Tries to look up message which corresponds to this error code.
12    @param errCode Error code for this exception.
13   */
14   public SocksException(int errCode){
15       this.errCode = errCode;
16       if((errCode >> 16) == 0){
17          //Server reply error message
18          errString = errCode <= serverReplyMessage.length ?
19                      serverReplyMessage[errCode] :
20                      UNASSIGNED_ERROR_MESSAGE;
21       }else{
22          //Local error
23          errCode = (errCode >> 16) -1;
24          errString = errCode <= localErrorMessage.length ?
25                      localErrorMessage[errCode] :
26                      UNASSIGNED_ERROR_MESSAGE;
27       }
28   }
29   /**
30    Constructs a SocksException with given error code and message.
31    @param errCode  Error code.
32    @param errString Error Message.
33   */
34   public SocksException(int errCode,String errString){
35       this.errCode = errCode;
36       this.errString = errString;
37   }
38   /**
39    Get the error code associated with this exception.
40    @return Error code associated with this exception.
41   */
42   public int getErrorCode(){
43      return errCode;
44   }
45   /**
46    Get human readable representation of this exception.
47    @return String represntation of this exception.
48   */
49   public String toString(){
50      return errString;
51   }
52
53   static final String UNASSIGNED_ERROR_MESSAGE =
54                  "Unknown error message";
55   static final String serverReplyMessage[] = {
56                  "Succeeded",
57                  "General SOCKS server failure",
58                  "Connection not allowed by ruleset",
59                  "Network unreachable",
60                  "Host unreachable",
61                  "Connection refused",
62                  "TTL expired",
63                  "Command not supported",
64                  "Address type not supported" };
65
66   static final String localErrorMessage[] ={
67                  "SOCKS server not specified",
68                  "Unable to contact SOCKS server",
69                  "IO error",
70                  "None of Authentication methods are supported",
71                  "Authentication failed",
72                  "General SOCKS fault" };
73
74   String errString;
75   int errCode;
76
77}//End of SocksException class
78
Note: See TracBrowser for help on using the repository browser.