001: //========================================================================
002: //Copyright 2006 Mort Bay Consulting Pty. Ltd.
003: //------------------------------------------------------------------------
004: //Licensed under the Apache License, Version 2.0 (the "License");
005: //you may not use this file except in compliance with the License.
006: //You may obtain a copy of the License at
007: //http://www.apache.org/licenses/LICENSE-2.0
008: //Unless required by applicable law or agreed to in writing, software
009: //distributed under the License is distributed on an "AS IS" BASIS,
010: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011: //See the License for the specific language governing permissions and
012: //limitations under the License.
013: //========================================================================
014:
015: package org.mortbay.jetty.ajp;
016:
017: import org.mortbay.io.EndPoint;
018: import org.mortbay.jetty.Connector;
019: import org.mortbay.jetty.Handler;
020: import org.mortbay.jetty.HttpConnection;
021: import org.mortbay.jetty.Request;
022: import org.mortbay.jetty.Server;
023: import org.mortbay.jetty.bio.SocketConnector;
024: import org.mortbay.jetty.handler.ContextHandlerCollection;
025: import org.mortbay.jetty.handler.DefaultHandler;
026: import org.mortbay.jetty.handler.HandlerCollection;
027: import org.mortbay.jetty.nio.SelectChannelConnector;
028: import org.mortbay.jetty.security.HashUserRealm;
029: import org.mortbay.jetty.security.UserRealm;
030: import org.mortbay.jetty.webapp.WebAppContext;
031: import org.mortbay.log.Log;
032:
033: /**
034: * @author Greg Wilkins
035: * @author Markus Kobler markus(at)inquisitive-mind.com
036: *
037: */
038: public class Ajp13SocketConnector extends SocketConnector {
039:
040: public Ajp13SocketConnector() {
041: super .setHeaderBufferSize(Ajp13Packet.MAX_DATA_SIZE);
042: super .setRequestBufferSize(Ajp13Packet.MAX_DATA_SIZE);
043: super .setResponseBufferSize(Ajp13Packet.MAX_DATA_SIZE);
044: }
045:
046: protected void doStart() throws Exception {
047: Log
048: .info(
049: "AJP13 is not a secure protocol. Please protect port {}",
050: Integer.toString(getPort()));
051: super .doStart();
052: }
053:
054: protected HttpConnection newHttpConnection(EndPoint endpoint) {
055: return new Ajp13Connection(this , endpoint, getServer());
056: }
057:
058: // Secured on a packet by packet bases not by connection
059: public boolean isConfidential(Request request) {
060: throw new UnsupportedOperationException();
061: }
062:
063: // Secured on a packet by packet bases not by connection
064: public boolean isIntegral(Request request) {
065: throw new UnsupportedOperationException();
066: }
067:
068: public void setHeaderBufferSize(int headerBufferSize) {
069: Log.debug(Log.IGNORED);
070: }
071:
072: public void setRequestBufferSize(int requestBufferSize) {
073: Log.debug(Log.IGNORED);
074: }
075:
076: public void setResponseBufferSize(int responseBufferSize) {
077: Log.debug(Log.IGNORED);
078: }
079:
080: /* TODO temp main - just to help testing */
081: public static void main(String[] args) throws Exception {
082: Server server = new Server();
083:
084: SocketConnector socketConnector = new SocketConnector();
085: socketConnector.setPort(8080);
086:
087: Ajp13SocketConnector connector = new Ajp13SocketConnector();
088:
089: connector.setPort(8009);
090: server.setConnectors(new Connector[] { socketConnector,
091: connector });
092: HandlerCollection handlers = new HandlerCollection();
093: ContextHandlerCollection contexts = new ContextHandlerCollection();
094: handlers.setHandlers(new Handler[] { contexts,
095: new DefaultHandler() });
096: server.setHandler(handlers);
097:
098: HashUserRealm userRealm = new HashUserRealm();
099: userRealm.setName("Test Realm");
100: userRealm.setConfig("../../etc/realm.properties");
101: server.setUserRealms(new UserRealm[] { userRealm });
102:
103: WebAppContext.addWebApplications(server, "../../webapps",
104: "../../etc/webdefault.xml", false, false);
105:
106: server.start();
107: server.join();
108: }
109: }
|