pier 01/08/08 18:18:49 Modified: webapp/java Constants.java.in WarpConfigurationHandler.java Log: Java implementation of context sharing between Tomcat and Apache. Revision Changes Path 1.10 +1 -1 jakarta-tomcat-connectors/webapp/java/Constants.java.in Index: Constants.java.in =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/Constants.java.in,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Constants.java.in 2001/08/08 23:11:29 1.9 +++ Constants.java.in 2001/08/09 01:18:49 1.10 @@ -140,7 +140,7 @@ * <br> * No payload:<br> */ - public static final int TYPE_CONF_ENUM_APPL=0x04; + public static final int TYPE_CONF_ENUM_DONE=0x04; /** * CONF_DEPLOY: The client attempts deploy a web application. 1.11 +106 -11 jakarta-tomcat-connectors/webapp/java/WarpConfigurationHandler.java Index: WarpConfigurationHandler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/webapp/java/WarpConfigurationHandler.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WarpConfigurationHandler.java 2001/07/25 01:30:46 1.10 +++ WarpConfigurationHandler.java 2001/08/09 01:18:49 1.11 @@ -64,11 +64,18 @@ import org.apache.catalina.Context; import org.apache.catalina.Deployer; import org.apache.catalina.Host; +import org.apache.catalina.Wrapper; import org.apache.catalina.core.StandardHost; import org.apache.catalina.core.StandardContext; +import org.apache.catalina.deploy.FilterMap; +import org.apache.catalina.deploy.SecurityConstraint; +import org.apache.catalina.deploy.SecurityCollection; public class WarpConfigurationHandler { + private static final String DEFAULT_SERVLET = + "org.apache.catalina.servlets.DefaultServlet"; + /* ==================================================================== */ /* Constructor */ /* ==================================================================== */ @@ -117,20 +124,108 @@ logger.log(msg); packet.setType(Constants.TYPE_ERROR); packet.writeString(msg); - connection.send(packet); - } else { - int k=connection.getConnector().applicationId(context); - packet.setType(Constants.TYPE_CONF_APPLIC); - packet.writeInteger(k); - packet.writeString(context.getDocBase()); connection.send(packet); - if (Constants.DEBUG) - logger.debug("Application \""+appl+"\" deployed "+ - "under <http://"+host+":"+port+path+ - "> with root="+context.getDocBase()+ - " ID="+k); + break; } + int k=connection.getConnector().applicationId(context); + packet.setType(Constants.TYPE_CONF_APPLIC); + packet.writeInteger(k); + packet.writeString(context.getDocBase()); + connection.send(packet); + if (Constants.DEBUG) + logger.debug("Application \""+appl+"\" deployed "+ + "under <http://"+host+":"+port+path+ + "> with root="+context.getDocBase()+ + " ID="+k); break; + } + + case Constants.TYPE_CONF_MAP: { + int id=packet.readInteger(); + Context context=connection.getConnector() + .applicationContext(id); + + if (context==null) { + String msg="Invalid application ID for mappings "+id; + logger.log(msg); + packet.reset(); + packet.setType(Constants.TYPE_ERROR); + packet.writeString(msg); + connection.send(packet); + break; + } + + String smap[]=context.findServletMappings(); + if (smap!=null) { + for (int x=0; x<smap.length; x++) { + Container c=context.findChild( + context.findServletMapping(smap[x])); + packet.reset(); + packet.setType(Constants.TYPE_CONF_MAP_DENY); + packet.writeString(smap[x]); + + if (c instanceof Wrapper) { + String servlet=((Wrapper)c).getServletClass(); + if (DEFAULT_SERVLET.equals(servlet)) { + packet.setType( + Constants.TYPE_CONF_MAP_ALLOW); + if (Constants.DEBUG) + logger.debug("Servlet mapping \""+ + smap[x]+"\" allowed"); + } else if (Constants.DEBUG) { + logger.debug("Servlet mapping \""+smap[x]+ + "\" denied"); + } + } + connection.send(packet); + } + } + + FilterMap fmap[]=context.findFilterMaps(); + if (fmap!=null) { + logger.log("Filter mappings ("+fmap.length+")"); + for (int x=0; x<fmap.length; x++) { + String map=fmap[x].getURLPattern(); + if (map!=null) { + if (Constants.DEBUG) + logger.debug("Filter mapping \""+map+ + "\" denied"); + packet.reset(); + packet.setType(Constants.TYPE_CONF_MAP_DENY); + packet.writeString(map); + connection.send(packet); + } + } + } + + SecurityConstraint scon[]=context.findConstraints(); + if (scon!=null) { + for (int x=0; x<scon.length; x++) { + SecurityCollection col[]=scon[x].findCollections(); + if (col!=null) { + for (int y=0; y<col.length; y++) { + String patt[]=col[y].findPatterns(); + if (patt!=null) { + for (int q=0; q<patt.length; q++) { + packet.reset(); + packet.setType( + Constants.TYPE_CONF_MAP_DENY); + packet.writeString(patt[x]); + connection.send(packet); + if (Constants.DEBUG) { + logger.debug("Seurity "+ + " mapping \""+patt[x]+ + "\""); + } + } + } + } + } + } + } + packet.reset(); + packet.setType(Constants.TYPE_CONF_MAP_DONE); + connection.send(packet); } case Constants.TYPE_CONF_DONE: {