You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2002/02/26 04:26:55 UTC

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

billbarker    02/02/25 19:26:55

  Modified:    src/share/org/apache/tomcat/core Request.java
  Log:
  Fix NPE when using AccessLog without having a ROOT context defined.
  
  Now we won't attempt to authenticate if we haven't (successfully) done a ContextMap (in line with the servlet spec).
  
  Fix for bug #6604
  Reported by: John Swapceinski jswap@yahoo.com
  
  Revision  Changes    Path
  1.113     +14 -11    jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- Request.java	10 Sep 2001 06:43:01 -0000	1.112
  +++ Request.java	26 Feb 2002 03:26:55 -0000	1.113
  @@ -562,20 +562,23 @@
   
       public String getRemoteUser() {
   	if( notAuthenticated ) {
  -	    notAuthenticated=false;
  +	    Context ctx = getContext();
  +	    if( ctx != null ) {
  +		notAuthenticated=false;
   
  -	    // Call all authentication callbacks. If any of them is able to
  -	    // 	identify the user it will set the principal in req.
  -	    int status=0;
  -	    BaseInterceptor reqI[]= getContext().getContainer().
  -		getInterceptors(Container.H_authenticate);
  -	    for( int i=0; i< reqI.length; i++ ) {
  -		status=reqI[i].authenticate( this, response );
  -		if ( status != BaseInterceptor.DECLINED ) {
  -		    break;
  +		// Call all authentication callbacks. If any of them is able to
  +		// 	identify the user it will set the principal in req.
  +		int status=0;
  +		BaseInterceptor reqI[]= ctx.getContainer().
  +		    getInterceptors(Container.H_authenticate);
  +		for( int i=0; i< reqI.length; i++ ) {
  +		    status=reqI[i].authenticate( this, response );
  +		    if ( status != BaseInterceptor.DECLINED ) {
  +			break;
  +		    }
   		}
  +		//context.log("Auth " + remoteUser );
   	    }
  -	    //context.log("Auth " + remoteUser );
   	}
   	return remoteUser;
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>