View Javadoc

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.jetty.security.HashUserRealm;
32  import org.mortbay.jetty.security.UserRealm;
33  import org.mortbay.jetty.webapp.WebAppContext;
34  import org.mortbay.log.Log;
35  
36  import org.mortbay.jetty.deployer.WebAppDeployer;
37  
38  /**
39   * @author Greg Wilkins
40   * @author Markus Kobler markus(at)inquisitive-mind.com
41   * 
42   */
43  public class Ajp13SocketConnector extends SocketConnector
44  {
45      static String __secretWord = null;
46      static boolean __allowShutdown = false;
47      public Ajp13SocketConnector()
48      {
49          super.setHeaderBufferSize(Ajp13Packet.MAX_DATA_SIZE);
50          super.setRequestBufferSize(Ajp13Packet.MAX_DATA_SIZE);
51          super.setResponseBufferSize(Ajp13Packet.MAX_DATA_SIZE);
52          // IN AJP protocol the socket stay open, so
53          // by default the time out is set to 900 seconds
54          super.setMaxIdleTime(900000);
55      }
56  
57      protected void doStart() throws Exception
58      {
59          super.doStart();
60          Log.info("AJP13 is not a secure protocol. Please protect port {}",Integer.toString(getLocalPort()));
61      }
62      
63      
64  
65      /* ------------------------------------------------------------ */
66      /* (non-Javadoc)
67       * @see org.mortbay.jetty.bio.SocketConnector#customize(org.mortbay.io.EndPoint, org.mortbay.jetty.Request)
68       */
69      public void customize(EndPoint endpoint, Request request) throws IOException
70      {
71          super.customize(endpoint,request);
72          if (request.isSecure())
73              request.setScheme(HttpSchemes.HTTPS);
74      }
75  
76      /* ------------------------------------------------------------ */
77      protected HttpConnection newHttpConnection(EndPoint endpoint)
78      {
79          return new Ajp13Connection(this,endpoint,getServer());
80      }
81  
82      /* ------------------------------------------------------------ */
83      // Secured on a packet by packet bases not by connection
84      public boolean isConfidential(Request request)
85      {
86          return ((Ajp13Request) request).isSslSecure();
87      }
88  
89      /* ------------------------------------------------------------ */
90      // Secured on a packet by packet bases not by connection
91      public boolean isIntegral(Request request)
92      {
93          return ((Ajp13Request) request).isSslSecure();
94      }
95  
96      /* ------------------------------------------------------------ */
97      public void setHeaderBufferSize(int headerBufferSize)
98      {
99          Log.debug(Log.IGNORED);
100     }
101 
102     /* ------------------------------------------------------------ */
103     public void setRequestBufferSize(int requestBufferSize)
104     {
105         Log.debug(Log.IGNORED);
106     }
107 
108     /* ------------------------------------------------------------ */
109     public void setResponseBufferSize(int responseBufferSize)
110     {
111         Log.debug(Log.IGNORED);
112     }
113 
114     /* ------------------------------------------------------------ */
115     public void setAllowShutdown(boolean allowShutdown)
116     {
117         Log.warn("AJP13: Shutdown Request is: " + allowShutdown);
118         __allowShutdown = allowShutdown;
119     }
120 
121     /* ------------------------------------------------------------ */
122     public void setSecretWord(String secretWord)
123     {
124         Log.warn("AJP13: Shutdown Request secret word is : " + secretWord);
125         __secretWord = secretWord;
126     }
127 
128 }