| LEFT | RIGHT | 
|    1 package org.adblockplus.brazil; |    1 package org.adblockplus.brazil; | 
|    2  |    2  | 
|    3 import java.io.IOException; |    3 import java.io.IOException; | 
|    4 import java.io.InputStream; |    4 import java.io.InputStream; | 
|    5 import java.io.OutputStream; |    5 import java.io.OutputStream; | 
|    6 import java.net.InetAddress; |    6 import java.net.InetAddress; | 
|    7 import java.net.Socket; |    7 import java.net.Socket; | 
|    8 import java.util.Properties; |  | 
|    9  |    8  | 
|   10 import sunlabs.brazil.server.Handler; |  | 
|   11 import sunlabs.brazil.server.Request; |    9 import sunlabs.brazil.server.Request; | 
|   12 import sunlabs.brazil.server.Server; |   10 import sunlabs.brazil.server.Server; | 
|   13 import sunlabs.brazil.util.MatchString; |   11 import sunlabs.brazil.util.MatchString; | 
|   14  |   12  | 
|   15 /** |   13 /** | 
|   16  * <code>RequestHandler</code> implements a SSL tunnel. |   14  * <code>RequestHandler</code> implements a SSL tunnel. | 
|   17  *  |   15  *  | 
|   18  * The following configuration parameters are used to initialize this |   16  * The following configuration parameters are used to initialize this | 
|   19  * <code>Handler</code>: |   17  * <code>Handler</code>: | 
|   20  * <dl class=props> |   18  * <dl class=props> | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   38  * handler=https |   36  * handler=https | 
|   39  * https.class=org.adblockplus.brazil.SSLConnectionHandler |   37  * https.class=org.adblockplus.brazil.SSLConnectionHandler | 
|   40  * </pre> |   38  * </pre> | 
|   41  *  |   39  *  | 
|   42  * See the description under {@link sunlabs.brazil.server.Handler#respond |   40  * See the description under {@link sunlabs.brazil.server.Handler#respond | 
|   43  * respond} for a more detailed explanation. |   41  * respond} for a more detailed explanation. | 
|   44  *  |   42  *  | 
|   45  * Original source by Jochen Luell, PAW (http://paw-project.sourceforge.net/) |   43  * Original source by Jochen Luell, PAW (http://paw-project.sourceforge.net/) | 
|   46  */ |   44  */ | 
|   47  |   45  | 
|   48 public class SSLConnectionHandler implements Handler |   46 public class SSLConnectionHandler extends BaseRequestHandler | 
|   49 { |   47 { | 
|   50         public static final String PROXY_HOST = "proxyHost"; |  | 
|   51         public static final String PROXY_PORT = "proxyPort"; |  | 
|   52         public static final String AUTH = "auth"; |  | 
|   53  |  | 
|   54         private String prefix; |  | 
|   55  |  | 
|   56         private String proxyHost; |  | 
|   57         private int proxyPort = 80; |  | 
|   58         private String auth; |  | 
|   59  |  | 
|   60         @Override |  | 
|   61         public boolean init(Server server, String prefix) |  | 
|   62         { |  | 
|   63                 this.prefix = prefix; |  | 
|   64  |  | 
|   65                 Properties props = server.props; |  | 
|   66  |  | 
|   67                 proxyHost = props.getProperty(prefix + PROXY_HOST); |  | 
|   68  |  | 
|   69                 String s = props.getProperty(prefix + PROXY_PORT); |  | 
|   70                 try |  | 
|   71                 { |  | 
|   72                         proxyPort = Integer.decode(s).intValue(); |  | 
|   73                 } |  | 
|   74                 catch (Exception e) |  | 
|   75                 { |  | 
|   76                 } |  | 
|   77  |  | 
|   78                 auth = props.getProperty(prefix + AUTH); |  | 
|   79  |  | 
|   80                 return true; |  | 
|   81         } |  | 
|   82  |  | 
|   83         @Override |   48         @Override | 
|   84         public boolean respond(Request request) throws IOException |   49         public boolean respond(Request request) throws IOException | 
|   85         { |   50         { | 
|   86                 if (!request.method.equals("CONNECT")) |   51                 if (!request.method.equals("CONNECT")) | 
|   87                         return false; |   52                         return false; | 
|   88  |   53  | 
|   89                 request.log(Server.LOG_LOG, prefix, "SSL connection to " + reque
     st.url); |   54                 request.log(Server.LOG_LOG, prefix, "SSL connection to " + reque
     st.url); | 
|   90  |   55  | 
|   91                 String host = null; |   56                 String host = null; | 
|   92                 int port = 0; |   57                 int port = 0; | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  186                                 } |  151                                 } | 
|  187                                 out.flush(); |  152                                 out.flush(); | 
|  188                         } |  153                         } | 
|  189                         catch (IOException e) |  154                         catch (IOException e) | 
|  190                         { |  155                         { | 
|  191                                 e.printStackTrace(); |  156                                 e.printStackTrace(); | 
|  192                         } |  157                         } | 
|  193                 } |  158                 } | 
|  194         } |  159         } | 
|  195 } |  160 } | 
| LEFT | RIGHT |