View Javadoc

1   // ========================================================================
2   // Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses.
12  // ========================================================================
13  
14  package org.eclipse.jetty.ajp;
15  
16  import java.io.IOException;
17  
18  import org.eclipse.jetty.http.HttpSchemes;
19  import org.eclipse.jetty.io.Connection;
20  import org.eclipse.jetty.io.EndPoint;
21  import org.eclipse.jetty.server.Request;
22  import org.eclipse.jetty.server.bio.SocketConnector;
23  import org.eclipse.jetty.util.log.Log;
24  
25  /**
26   *
27   *
28   *
29   */
30  public class Ajp13SocketConnector extends SocketConnector
31  {
32      static String __secretWord = null;
33      static boolean __allowShutdown = false;
34      public Ajp13SocketConnector()
35      {
36          super.setRequestHeaderSize(Ajp13Packet.MAX_DATA_SIZE);
37          super.setResponseHeaderSize(Ajp13Packet.MAX_DATA_SIZE);
38          super.setRequestBufferSize(Ajp13Packet.MAX_DATA_SIZE);
39          super.setResponseBufferSize(Ajp13Packet.MAX_DATA_SIZE);
40          // IN AJP protocol the socket stay open, so
41          // by default the time out is set to 0 seconds
42          super.setMaxIdleTime(0);
43      }
44  
45      @Override
46      protected void doStart() throws Exception
47      {
48          super.doStart();
49          Log.info("AJP13 is not a secure protocol. Please protect port {}",Integer.toString(getLocalPort()));
50      }
51  
52  
53  
54      /* ------------------------------------------------------------ */
55      /* (non-Javadoc)
56       * @see org.eclipse.jetty.server.bio.SocketConnector#customize(org.eclipse.io.EndPoint, org.eclipse.jetty.server.Request)
57       */
58      @Override
59      public void customize(EndPoint endpoint, Request request) throws IOException
60      {
61          super.customize(endpoint,request);
62          if (request.isSecure())
63              request.setScheme(HttpSchemes.HTTPS);
64          
65          System.err.println("Customize "+endpoint+" "+request);
66          
67      }
68  
69      /* ------------------------------------------------------------ */
70      @Override
71      protected Connection newConnection(EndPoint endpoint)
72      {
73          return new Ajp13Connection(this,endpoint,getServer());
74      }
75  
76      /* ------------------------------------------------------------ */
77      // Secured on a packet by packet bases not by connection
78      @Override
79      public boolean isConfidential(Request request)
80      {
81          return ((Ajp13Request) request).isSslSecure();
82      }
83  
84      /* ------------------------------------------------------------ */
85      // Secured on a packet by packet bases not by connection
86      @Override
87      public boolean isIntegral(Request request)
88      {
89          return ((Ajp13Request) request).isSslSecure();
90      }
91  
92      /* ------------------------------------------------------------ */
93      @Override
94      public void setHeaderBufferSize(int headerBufferSize)
95      {
96          Log.debug(Log.IGNORED);
97      }
98  
99      /* ------------------------------------------------------------ */
100     @Override
101     public void setRequestBufferSize(int requestBufferSize)
102     {
103         Log.debug(Log.IGNORED);
104     }
105 
106     /* ------------------------------------------------------------ */
107     @Override
108     public void setResponseBufferSize(int responseBufferSize)
109     {
110         Log.debug(Log.IGNORED);
111     }
112 
113     /* ------------------------------------------------------------ */
114     public void setAllowShutdown(boolean allowShutdown)
115     {
116         Log.warn("AJP13: Shutdown Request is: " + allowShutdown);
117         __allowShutdown = allowShutdown;
118     }
119 
120     /* ------------------------------------------------------------ */
121     public void setSecretWord(String secretWord)
122     {
123         Log.warn("AJP13: Shutdown Request secret word is : " + secretWord);
124         __secretWord = secretWord;
125     }
126 
127 }