You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mb...@apache.org on 2003/11/14 03:26:16 UTC

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth BasicScheme.java

mbecke      2003/11/13 18:26:16

  Modified:    httpclient/src/test/org/apache/commons/httpclient Tag:
                        HTTPCLIENT_2_0_BRANCH TestAuthenticator.java
               httpclient/src/java/org/apache/commons/httpclient/auth Tag:
                        HTTPCLIENT_2_0_BRANCH BasicScheme.java
  Log:
  Fixes basic authentication to work with ISO-8859-1 user names and passwords.
  
  PR: 24671
  Submitted by: Michael Becke
  Reviewed by: Oleg Kalnichevski
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.25.2.4  +16 -6     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java
  
  Index: TestAuthenticator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestAuthenticator.java,v
  retrieving revision 1.25.2.3
  retrieving revision 1.25.2.4
  diff -u -r1.25.2.3 -r1.25.2.4
  --- TestAuthenticator.java	11 Sep 2003 09:04:34 -0000	1.25.2.3
  +++ TestAuthenticator.java	14 Nov 2003 02:26:16 -0000	1.25.2.4
  @@ -219,8 +219,18 @@
           String expected = "Basic " + HttpConstants.getString(Base64.encode(HttpConstants.getBytes("username:password")));
           assertEquals(expected,method.getRequestHeader("Authorization").getValue());
       }
  -
  -
  +    
  +    public void testBasicAuthenticationWith88591Chars() throws Exception {
  +        int[] germanChars = { 0xE4, 0x2D, 0xF6, 0x2D, 0xFc };
  +        StringBuffer buffer = new StringBuffer();
  +        for (int i = 0; i < germanChars.length; i++) {
  +            buffer.append((char)germanChars[i]); 
  +        }
  +        
  +        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("dh", buffer.toString());
  +        assertEquals("Basic ZGg65C32Lfw=", BasicScheme.authenticate(credentials));
  +    }
  +    
       public void testBasicAuthenticationWithMutlipleRealms() throws Exception {
           String challenge1 = "Basic realm=\"realm1\"";
           String challenge2 = "Basic realm=\"realm2\"";
  
  
  
  No                   revision
  No                   revision
  1.4.2.2   +4 -4      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/BasicScheme.java
  
  Index: BasicScheme.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth/BasicScheme.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- BasicScheme.java	13 Aug 2003 19:58:14 -0000	1.4.2.1
  +++ BasicScheme.java	14 Nov 2003 02:26:16 -0000	1.4.2.2
  @@ -161,6 +161,6 @@
           buffer.append(credentials.getPassword());
           
           return "Basic " + HttpConstants.getAsciiString(
  -            Base64.encode(HttpConstants.getBytes(buffer.toString())));
  +            Base64.encode(HttpConstants.getContentBytes(buffer.toString())));
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org