sebb        2004/03/19 16:35:27

  Modified:    src/protocol/http/org/apache/jmeter/protocol/http/control
                        AuthManager.java
  Log:
  Refactor to give access to underlying Authorization entry (for use with HttpClient)
  
  Revision  Changes    Path
  1.11      +13 -5     
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java
  
  Index: AuthManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/AuthManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AuthManager.java  18 Feb 2004 23:56:23 -0000      1.10
  +++ AuthManager.java  20 Mar 2004 00:35:27 -0000      1.11
  @@ -153,6 +153,13 @@
   
       public String getAuthHeaderForURL(URL url)
       {
  +     Authorization auth = getAuthForURL(url);
  +     if (auth == null) return null;
  +     return  "Basic " + Base64Encoder.encode(auth.getUser() + ":" + auth.getPass());
  +    }
  +
  +    public Authorization getAuthForURL(URL url)
  +    {
           if (! isSupportedProtocol(url))
           {
               return null;
  @@ -196,16 +203,17 @@
           String s2= null;
           if (url2 != null) s2= url2.toString();
           
  +        // TODO should really return most specific (i.e. longest) match.
           for (PropertyIterator enum = getAuthObjects().iterator();
               enum.hasNext();
               )
           {
               Authorization auth = (Authorization) enum.next().getObjectValue();
               
  -            if (s1.startsWith(auth.getURL()) || s2 != null && 
s2.startsWith(auth.getURL()))
  +            String uRL = auth.getURL();
  +                     if (s1.startsWith(uRL) || s2 != null && s2.startsWith(uRL))
               {
  -                return "Basic "
  -                     + Base64Encoder.encode(auth.getUser() + ":" + auth.getPass());
  +                return auth;
               }
           }
           return null;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to