common/src/main/java/HTTPClient/AuthorizationInfo.java
/**
     * Tries to find the candidate in the current list of auth info for the
     * given request. The paths associated with each auth info are examined,
     * and the one with either the nearest direct parent or child is chosen.
     * This is used for preemptively sending auth info.
     *
     * @param  req  the Request
     * @return an AuthorizationInfo containing the info for the best match,
     *         or null if none found.
     */
Tries to find the candidate in the current list of auth info for the
given request. The paths associated with each auth info are examined,
and the one with either the nearest direct parent or child is chosen.
This is used for preemptively sending auth info.

@param  req  the Request
@return an AuthorizationInfo containing the info for the best match,
or null if none found.
Tries to find the candidate in the current list of auth info for the given request . The paths associated with each auth info are examined and the one with either the nearest direct parent or child is chosen . This is used for preemptively sending auth info . @param req the Request @return an AuthorizationInfo containing the info for the best match or null if none found .
static AuthorizationInfo findBest(RoRequest req)
    {
	String path = Util.getPath(req.getRequestURI());
	String host = req.getConnection().getHost();
	int    port = req.getConnection().getPort();
	Hashtable AuthList =
		    Util.getList(CntxtList, req.getConnection().getContext());
	Enumeration list = AuthList.elements();
	while (list.hasMoreElements())
	{
	    AuthorizationInfo info = (AuthorizationInfo) list.nextElement();
	    if (!info.host.equals(host)  ||  info.port != port)
		continue;
	    /*String[] paths = info.paths;
	    for (int idx=0; idx<paths.length; idx++)
	    {
		if (path.equals(paths[idx]))
		    return info;
	    } */
		return info;
	}
	AuthorizationInfo best = null;
	String base = path.substring(0, path.lastIndexOf('/')+1);
	int    min  = Integer.MAX_VALUE;
	list = AuthList.elements();
	while (list.hasMoreElements())
	{
	    AuthorizationInfo info = (AuthorizationInfo) list.nextElement();
	    if (!info.host.equals(host)  ||  info.port != port)
		continue;
	    String[] paths = info.paths;
	    for (int idx=0; idx<paths.length; idx++)
	    {
		String ibase =
			paths[idx].substring(0, paths[idx].lastIndexOf('/')+1);
		if (base.equals(ibase))
		    return info;
		if (base.startsWith(ibase))		
		{
		    int num_seg = 0, pos = ibase.length()-1;
		    while ((pos = base.indexOf('/', pos+1)) != -1)  num_seg++;
		    if (num_seg < min)
		    {
			min  = num_seg;
			best = info;
		    }
		}
		else if (ibase.startsWith(base))	
		{
		    int num_seg = 0, pos = base.length();
		    while ((pos = ibase.indexOf('/', pos+1)) != -1)  num_seg++;
		    if (num_seg < min)
		    {
			min  = num_seg;
			best = info;
		    }
		}
	    }
	}
	return best;
    }
static AuthorizationInfo findBest ( RoRequest req ) { String path = Util . getPath ( req . getRequestURI ( ) ) ; String host = req . getConnection ( ) . getHost ( ) ; int port = req . getConnection ( ) . getPort ( ) ; Hashtable AuthList = Util . getList ( CntxtList , req . getConnection ( ) . getContext ( ) ) ; Enumeration list = AuthList . elements ( ) ; while ( list . hasMoreElements ( ) ) { AuthorizationInfo info = ( AuthorizationInfo ) list . nextElement ( ) ; if ( ! info . host . equals ( host ) || info . port != port ) continue ; /*String[] paths = info.paths;
	    for (int idx=0; idx<paths.length; idx++)
	    {
		if (path.equals(paths[idx]))
		    return info;
	    } */ return info ; } AuthorizationInfo best = null ; String base = path . substring ( 0 , path . lastIndexOf ( '/' ) + 1 ) ; int min = Integer . MAX_VALUE ; list = AuthList . elements ( ) ; while ( list . hasMoreElements ( ) ) { AuthorizationInfo info = ( AuthorizationInfo ) list . nextElement ( ) ; if ( ! info . host . equals ( host ) || info . port != port ) continue ; String [ ] paths = info . paths ; for ( int idx = 0 ; idx < paths . length ; idx ++ ) { String ibase = paths [ idx ] . substring ( 0 , paths [ idx ] . lastIndexOf ( '/' ) + 1 ) ; if ( base . equals ( ibase ) ) return info ; if ( base . startsWith ( ibase ) ) { int num_seg = 0 , pos = ibase . length ( ) - 1 ; while ( ( pos = base . indexOf ( '/' , pos + 1 ) ) != - 1 ) num_seg ++ ; if ( num_seg < min ) { min = num_seg ; best = info ; } } else if ( ibase . startsWith ( base ) ) { int num_seg = 0 , pos = base . length ( ) ; while ( ( pos = ibase . indexOf ( '/' , pos + 1 ) ) != - 1 ) num_seg ++ ; if ( num_seg < min ) { min = num_seg ; best = info ; } } } } return best ; }
Tries to find the candidate in the current list of auth info for the
 given request.
Tries to find the candidate in the current list of auth info for the given request .
// First search for an exact match //No busco en el path porque el mismo siempre es vacio y sino nunca manda la autorizacion. // Now find the closest parent or child // strip the last path segment, leaving a trailing "/" // found a parent // found a child