commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbe...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/auth BasicScheme.java
Date Fri, 14 Nov 2003 02:28:49 GMT
mbecke      2003/11/13 18:28:49

  Modified:    httpclient/src/test/org/apache/commons/httpclient
                        TestAuthenticator.java
               httpclient/src/java/org/apache/commons/httpclient/auth
                        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
  1.33      +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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- TestAuthenticator.java	3 Oct 2003 20:57:36 -0000	1.32
  +++ TestAuthenticator.java	14 Nov 2003 02:28:49 -0000	1.33
  @@ -195,8 +195,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\"";
  
  
  
  1.7       +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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BasicScheme.java	13 Aug 2003 19:57:10 -0000	1.6
  +++ BasicScheme.java	14 Nov 2003 02:28:49 -0000	1.7
  @@ -163,6 +163,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


Mime
View raw message