1   //========================================================================
2   //Copyright 2006 Mort Bay Consulting Pty. Ltd.
3   //------------------------------------------------------------------------
4   //Licensed under the Apache License, Version 2.0 (the "License");
5   //you may not use this file except in compliance with the License.
6   //You may obtain a copy of the License at
7   //http://www.apache.org/licenses/LICENSE-2.0
8   //Unless required by applicable law or agreed to in writing, software
9   //distributed under the License is distributed on an "AS IS" BASIS,
10  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  //See the License for the specific language governing permissions and
12  //limitations under the License.
13  //========================================================================
14  
15  package org.mortbay.jetty.ajp;
16  
17  import java.io.IOException;
18  
19  import org.mortbay.io.EndPoint;
20  import org.mortbay.jetty.Connector;
21  import org.mortbay.jetty.Handler;
22  import org.mortbay.jetty.HttpConnection;
23  import org.mortbay.jetty.HttpSchemes;
24  import org.mortbay.jetty.Request;
25  import org.mortbay.jetty.Server;
26  import org.mortbay.jetty.bio.SocketConnector;
27  import org.mortbay.jetty.handler.ContextHandlerCollection;
28  import org.mortbay.jetty.handler.DefaultHandler;
29  import org.mortbay.jetty.handler.HandlerCollection;
30  import org.mortbay.jetty.nio.SelectChannelConnector;
31  import org.mortbay.log.Log;
32  
33  /**
34   * @author Greg Wilkins
35   * @author Markus Kobler markus(at)inquisitive-mind.com
36   * 
37   */
38  public class Ajp13SocketConnector extends SocketConnector
39  {
40      static String __secretWord = null;
41      static boolean __allowShutdown = false;
42      public Ajp13SocketConnector()
43      {
44          super.setHeaderBufferSize(Ajp13Packet.MAX_DATA_SIZE);
45          super.setRequestBufferSize(Ajp13Packet.MAX_DATA_SIZE);
46          super.setResponseBufferSize(Ajp13Packet.MAX_DATA_SIZE);
47          // IN AJP protocol the socket stay open, so
48          // by default the time out is set to 900 seconds
49          super.setMaxIdleTime(900000);
50      }
51  
52      protected void doStart() throws Exception
53      {
54          super.doStart();
55          Log.info("AJP13 is not a secure protocol. Please protect port {}",Integer.toString(getLocalPort()));
56      }
57      
58      
59  
60      /* ------------------------------------------------------------ */
61      /* (non-Javadoc)
62       * @see org.mortbay.jetty.bio.SocketConnector#customize(org.mortbay.io.EndPoint, org.mortbay.jetty.Request)
63       */
64      public void customize(EndPoint endpoint, Request request) throws IOException
65      {
66          super.customize(endpoint,request);
67          if (request.isSecure())
68              request.setScheme(HttpSchemes.HTTPS);
69      }
70  
71      /* ------------------------------------------------------------ */
72      protected HttpConnection newHttpConnection(EndPoint endpoint)
73      {
74          return new Ajp13Connection(this,endpoint,getServer());
75      }
76  
77      /* ------------------------------------------------------------ */
78      // Secured on a packet by packet bases not by connection
79      public boolean isConfidential(Request request)
80      {
81          throw new UnsupportedOperationException();
82      }
83  
84      /* ------------------------------------------------------------ */
85      // Secured on a packet by packet bases not by connection
86      public boolean isIntegral(Request request)
87      {
88          throw new UnsupportedOperationException();
89      }
90  
91      /* ------------------------------------------------------------ */
92      public void setHeaderBufferSize(int headerBufferSize)
93      {
94          Log.debug(Log.IGNORED);
95      }
96  
97      /* ------------------------------------------------------------ */
98      public void setRequestBufferSize(int requestBufferSize)
99      {
100         Log.debug(Log.IGNORED);
101     }
102 
103     /* ------------------------------------------------------------ */
104     public void setResponseBufferSize(int responseBufferSize)
105     {
106         Log.debug(Log.IGNORED);
107     }
108 
109     /* ------------------------------------------------------------ */
110     public void setAllowShutdown(boolean allowShutdown)
111     {
112         Log.warn("AJP13: Shutdown Request is: " + allowShutdown);
113         __allowShutdown = allowShutdown;
114     }
115 
116     /* ------------------------------------------------------------ */
117     public void setSecretWord(String secretWord)
118     {
119         Log.warn("AJP13: Shutdown Request secret word is : " + secretWord);
120         __secretWord = secretWord;
121     }
122 
123 }