You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by na...@locus.apache.org on 2000/09/23 20:39:48 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Container.java ContextManager.java

nacho       00/09/23 11:39:48

  Modified:    src/share/org/apache/tomcat/core Container.java
                        ContextManager.java
  Log:
  ContextManager:
  
  Passing authorize and authenticate to the new Hook system,
  test of the new perRequestInterceptors, it works cleanly.
  nothing changes in Realms
  
  Container:
  
  A minor hack to resolve a minor problem in between changes,
  this all will be rubbed out when hooks become the way,
  
  Revision  Changes    Path
  1.31      +5 -3      jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Container.java	2000/09/17 06:47:22	1.30
  +++ Container.java	2000/09/23 18:39:47	1.31
  @@ -454,8 +454,9 @@
        *   XXX incomplete implementation
        */
       public void addContextInterceptor( ContextInterceptor ci) {
  -	contextInterceptors.addElement( ci );
   	addInterceptor( (BaseInterceptor) ci );
  +        // XXX will be deprecated when hooks end testing
  +	contextInterceptors.addElement( ci );
       }
   
       /** Add a per/container request interceptor. It will be called back for
  @@ -464,10 +465,11 @@
        *   XXX incomplete implementation.
        */
       public void addRequestInterceptor( RequestInterceptor ri) {
  -	requestInterceptors.addElement( ri );
   	addInterceptor( (BaseInterceptor) ri );
  +        // XXX will be deprecated when hooks end testing
  +	requestInterceptors.addElement( ri );
   	if( ri instanceof ContextInterceptor )
  -	    addContextInterceptor( (ContextInterceptor)ri );
  +	        contextInterceptors.addElement( ri );
       }
   
       // -------------------- Getting the active interceptors 
  
  
  
  1.132     +17 -3     jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.131
  retrieving revision 1.132
  diff -u -r1.131 -r1.132
  --- ContextManager.java	2000/09/23 14:15:55	1.131
  +++ ContextManager.java	2000/09/23 18:39:47	1.132
  @@ -513,6 +513,17 @@
   	return ari;
       }
   
  +    public RequestInterceptor[] getRequestInterceptorszz( Request req , int hook_id) {
  +        Context ctx=req.getContext();
  +        // if Bad request (ctx == null) only global interceptors are called
  +        if( ctx == null )
  +           return defaultContainer.getInterceptors(hook_id);
  +        Container ct=ctx.getContainer();
  +        RequestInterceptor[] ari=ct.getInterceptors(hook_id);
  +
  +	return ari;
  +    }
  +
       public RequestInterceptor[] getRequestInterceptors() {
   	return defaultContainer.getRequestInterceptors();
       }
  @@ -621,6 +632,8 @@
   
       static int contextMap_ID=Container.getHookId( "contextMap");
       static int requestMap_ID=Container.getHookId( "requestMap");
  +    static int authorize_ID=Container.getHookId( "authorize");
  +    static int authenticate_ID=Container.getHookId( "authenticate");
   
   
       /** Will find the Handler for a servlet, assuming we already have
  @@ -655,8 +668,8 @@
        */
       public int doAuthenticate( Request req, Response res ) {
   	int status=0;
  -	RequestInterceptor reqI[]= getRequestInterceptors(req);
  -
  +//	RequestInterceptor reqI[]= getRequestInterceptors(req);
  +	BaseInterceptor reqI[]= req.getContext().getContainer().getInterceptors(authenticate_ID);
   	for( int i=0; i< reqI.length; i++ ) {
   	    status=reqI[i].authenticate( req, res );
   	    if ( status != 0 ) {
  @@ -673,7 +686,8 @@
        */
       public int doAuthorize( Request req, Response res, String roles[] ) {
   	int status=0;
  -	RequestInterceptor reqI[]= getRequestInterceptors(req);
  +//	RequestInterceptor reqI[]= getRequestInterceptors(req);
  +	BaseInterceptor reqI[]= req.getContext().getContainer().getInterceptors(authorize_ID);
   
   	for( int i=0; i< reqI.length; i++ ) {
   	    status = reqI[i].authorize( req, res, roles );