Bug 730637 - Base64 support for HttpClient in Android 2.1. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Mon, 27 Feb 2012 10:23:33 -0800
changeset 87837 2cd9b8fc084d3a04c819454c10c79c7af10b5258
parent 87836 289cd639ff3418020d6adb18153a1b0b4c9de552
child 87838 5805c445b8412cb602a4b5a4b80cb67e4a5eff4a
push id6522
push userrnewman@mozilla.com
push dateMon, 27 Feb 2012 18:23:53 +0000
treeherdermozilla-inbound@a9ccef50c388 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs730637
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 730637 - Base64 support for HttpClient in Android 2.1. r=nalexander
mobile/android/base/httpclientandroidlib/androidextra/HttpClientAndroidLog.java
mobile/android/base/httpclientandroidlib/client/RedirectStrategy.java
mobile/android/base/httpclientandroidlib/client/utils/Idn.java
mobile/android/base/httpclientandroidlib/client/utils/JdkIdn.java
mobile/android/base/httpclientandroidlib/client/utils/Rfc3492Idn.java
mobile/android/base/httpclientandroidlib/cookie/ClientCookie.java
mobile/android/base/httpclientandroidlib/impl/auth/BasicScheme.java
mobile/android/base/httpclientandroidlib/impl/auth/NTLMEngineImpl.java
mobile/android/base/httpclientandroidlib/impl/client/DefaultRedirectStrategy.java
mobile/android/base/httpclientandroidlib/impl/cookie/BestMatchSpec.java
mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965CommentUrlAttributeHandler.java
mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965DiscardAttributeHandler.java
mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965DomainAttributeHandler.java
mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965VersionAttributeHandler.java
--- a/mobile/android/base/httpclientandroidlib/androidextra/HttpClientAndroidLog.java
+++ b/mobile/android/base/httpclientandroidlib/androidextra/HttpClientAndroidLog.java
@@ -77,9 +77,9 @@ public class HttpClientAndroidLog {
 	public void info(Object message) {
 		Log.i(logTag, message.toString());
 	}
 
 	public void info(Object message, Throwable t) {
 		Log.i(logTag, message.toString(), t);
 	}
 	
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/client/RedirectStrategy.java
+++ b/mobile/android/base/httpclientandroidlib/client/RedirectStrategy.java
@@ -73,9 +73,9 @@ public interface RedirectStrategy {
      *
      * @return redirected request
      */
     HttpUriRequest getRedirect(
             HttpRequest request,
             HttpResponse response,
             HttpContext context) throws ProtocolException;
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/client/utils/Idn.java
+++ b/mobile/android/base/httpclientandroidlib/client/utils/Idn.java
@@ -38,9 +38,9 @@ package ch.boye.httpclientandroidlib.cli
 public interface Idn {
     /**
      * Converts a name from its punycode representation to Unicode.
      * The name may be a single hostname or a dot-separated qualified domain name.
      * @param punycode the Punycode representation
      * @return the Unicode domain name
      */
     String toUnicode(String punycode);
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/client/utils/JdkIdn.java
+++ b/mobile/android/base/httpclientandroidlib/client/utils/JdkIdn.java
@@ -67,9 +67,9 @@ public class JdkIdn implements Idn {
         } catch (IllegalAccessException e) {
             throw new IllegalStateException(e.getMessage(), e);
         } catch (InvocationTargetException e) {
             Throwable t = e.getCause();
             throw new RuntimeException(t.getMessage(), t);
         }
     }
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/client/utils/Rfc3492Idn.java
+++ b/mobile/android/base/httpclientandroidlib/client/utils/Rfc3492Idn.java
@@ -118,9 +118,9 @@ public class Rfc3492Idn implements Idn {
             i = i % (output.length() + 1);
             // {if n is a basic code point then fail}
             output.insert(i, (char) n);
             i++;
         }
         return output.toString();
     }
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/cookie/ClientCookie.java
+++ b/mobile/android/base/httpclientandroidlib/cookie/ClientCookie.java
@@ -54,9 +54,9 @@ public interface ClientCookie extends Co
     public static final String PORT_ATTR       = "port";
     public static final String COMMENTURL_ATTR = "commenturl";
     public static final String DISCARD_ATTR    = "discard";
 
     String getAttribute(String name);
 
     boolean containsAttribute(String name);
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/impl/auth/BasicScheme.java
+++ b/mobile/android/base/httpclientandroidlib/impl/auth/BasicScheme.java
@@ -23,17 +23,17 @@
  * <http://www.apache.org/>.
  *
  */
 
 package ch.boye.httpclientandroidlib.impl.auth;
 
 import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
 
-import android.util.Base64;
+import org.mozilla.apache.commons.codec.binary.Base64;
 import ch.boye.httpclientandroidlib.Header;
 import ch.boye.httpclientandroidlib.HttpRequest;
 import ch.boye.httpclientandroidlib.auth.AuthenticationException;
 import ch.boye.httpclientandroidlib.auth.Credentials;
 import ch.boye.httpclientandroidlib.auth.AUTH;
 import ch.boye.httpclientandroidlib.auth.InvalidCredentialsException;
 import ch.boye.httpclientandroidlib.auth.MalformedChallengeException;
 import ch.boye.httpclientandroidlib.auth.params.AuthParams;
@@ -156,18 +156,18 @@ public class BasicScheme extends RFC2617
             throw new IllegalArgumentException("charset may not be null");
         }
 
         StringBuilder tmp = new StringBuilder();
         tmp.append(credentials.getUserPrincipal().getName());
         tmp.append(":");
         tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
 
-        byte[] base64password = Base64.encode(
-                EncodingUtils.getBytes(tmp.toString(), charset), Base64.NO_WRAP);
+        byte[] base64password = Base64.encodeBase64(
+                EncodingUtils.getBytes(tmp.toString(), charset));
 
         CharArrayBuffer buffer = new CharArrayBuffer(32);
         if (proxy) {
             buffer.append(AUTH.PROXY_AUTH_RESP);
         } else {
             buffer.append(AUTH.WWW_AUTH_RESP);
         }
         buffer.append(": Basic ");
--- a/mobile/android/base/httpclientandroidlib/impl/auth/NTLMEngineImpl.java
+++ b/mobile/android/base/httpclientandroidlib/impl/auth/NTLMEngineImpl.java
@@ -28,17 +28,17 @@ package ch.boye.httpclientandroidlib.imp
 
 import java.security.Key;
 import java.security.MessageDigest;
 import java.util.Arrays;
 
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 
-import android.util.Base64;
+import org.mozilla.apache.commons.codec.binary.Base64;
 import ch.boye.httpclientandroidlib.util.EncodingUtils;
 
 /**
  * Provides an implementation for NTLMv1, NTLMv2, and NTLM2 Session forms of the NTLM
  * authentication protocol.
  *
  * @since 4.1
  */
@@ -607,18 +607,18 @@ final class NTLMEngineImpl implements NT
         private int currentOutputPosition = 0;
 
         /** Constructor to use when message contents are not yet known */
         NTLMMessage() {
         }
 
         /** Constructor to use when message contents are known */
         NTLMMessage(String messageBody, int expectedType) throws NTLMEngineException {
-            messageContents = Base64.decode(EncodingUtils.getBytes(messageBody,
-                    DEFAULT_CHARSET), Base64.NO_WRAP);
+            messageContents = Base64.decodeBase64(EncodingUtils.getBytes(messageBody,
+                    DEFAULT_CHARSET));
             // Look for NTLM message
             if (messageContents.length < SIGNATURE.length)
                 throw new NTLMEngineException("NTLM message decoding error - packet too short");
             int i = 0;
             while (i < SIGNATURE.length) {
                 if (messageContents[i] != SIGNATURE[i])
                     throw new NTLMEngineException(
                             "NTLM message expected - instead got unrecognized bytes");
@@ -741,17 +741,17 @@ final class NTLMEngineImpl implements NT
                 byte[] tmp = new byte[currentOutputPosition];
                 for (int i = 0; i < currentOutputPosition; i++) {
                     tmp[i] = messageContents[i];
                 }
                 resp = tmp;
             } else {
                 resp = messageContents;
             }
-            return EncodingUtils.getAsciiString(Base64.encode(resp, Base64.NO_WRAP));
+            return EncodingUtils.getAsciiString(Base64.encodeBase64(resp));
         }
 
     }
 
     /** Type 1 message assembly class */
     static class Type1Message extends NTLMMessage {
         protected byte[] hostBytes;
         protected byte[] domainBytes;
--- a/mobile/android/base/httpclientandroidlib/impl/client/DefaultRedirectStrategy.java
+++ b/mobile/android/base/httpclientandroidlib/impl/client/DefaultRedirectStrategy.java
@@ -194,9 +194,9 @@ public class DefaultRedirectStrategy imp
         String method = request.getRequestLine().getMethod();
         if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
             return new HttpHead(uri);
         } else {
             return new HttpGet(uri);
         }
     }
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/impl/cookie/BestMatchSpec.java
+++ b/mobile/android/base/httpclientandroidlib/impl/cookie/BestMatchSpec.java
@@ -213,9 +213,9 @@ public class BestMatchSpec implements Co
         return getStrict().getVersionHeader();
     }
 
     @Override
     public String toString() {
         return "best-match";
     }
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965CommentUrlAttributeHandler.java
+++ b/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965CommentUrlAttributeHandler.java
@@ -59,9 +59,9 @@ public class RFC2965CommentUrlAttributeH
       public void validate(final Cookie cookie, final CookieOrigin origin)
               throws MalformedCookieException {
       }
 
       public boolean match(final Cookie cookie, final CookieOrigin origin) {
           return true;
       }
 
-  }
\ No newline at end of file
+  }
--- a/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965DiscardAttributeHandler.java
+++ b/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965DiscardAttributeHandler.java
@@ -59,9 +59,9 @@ public class RFC2965DiscardAttributeHand
       public void validate(final Cookie cookie, final CookieOrigin origin)
               throws MalformedCookieException {
       }
 
       public boolean match(final Cookie cookie, final CookieOrigin origin) {
           return true;
       }
 
-  }
\ No newline at end of file
+  }
--- a/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965DomainAttributeHandler.java
+++ b/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965DomainAttributeHandler.java
@@ -186,9 +186,9 @@ public class RFC2965DomainAttributeHandl
             return false;
         }
         // effective host name minus domain must not contain any dots
         String effectiveHostWithoutDomain = host.substring(
                 0, host.length() - cookieDomain.length());
         return effectiveHostWithoutDomain.indexOf('.') == -1;
     }
 
-}
\ No newline at end of file
+}
--- a/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965VersionAttributeHandler.java
+++ b/mobile/android/base/httpclientandroidlib/impl/cookie/RFC2965VersionAttributeHandler.java
@@ -90,9 +90,9 @@ public class RFC2965VersionAttributeHand
             }
         }
     }
 
     public boolean match(final Cookie cookie, final CookieOrigin origin) {
         return true;
     }
 
-}
\ No newline at end of file
+}