diff --git a/mobile/android/base/background/fxa/FxAccountClient20.java b/mobile/android/base/background/fxa/FxAccountClient20.java index 477fce1d83a0..36f6cba91138 100644 --- a/mobile/android/base/background/fxa/FxAccountClient20.java +++ b/mobile/android/base/background/fxa/FxAccountClient20.java @@ -4,7 +4,10 @@ package org.mozilla.gecko.background.fxa; +import java.io.UnsupportedEncodingException; import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLEncoder; import java.util.concurrent.Executor; import org.json.simple.JSONObject; @@ -94,13 +97,35 @@ public class FxAccountClient20 extends FxAccountClient10 implements FxAccountCli post(resource, body, delegate); } - public void createAccount(final byte[] emailUTF8, final byte[] quickStretchedPW, final boolean getKeys, final boolean preVerified, + /** + * Create account/create URI, encoding query parameters carefully. + *
+ * This is equivalent to android.net.Uri.Builder
, which is not
+ * present in our JUnit 4 tests.
+ */
+ protected URI getCreateAccountURI(final boolean getKeys, final String service) throws UnsupportedEncodingException, URISyntaxException {
+ if (service == null) {
+ throw new IllegalArgumentException("service must not be null");
+ }
+ final StringBuilder sb = new StringBuilder(serverURI); // serverURI always has a trailing slash.
+ sb.append("account/create?service=");
+ // Be very careful that query parameters are encoded correctly!
+ sb.append(URLEncoder.encode(service, "UTF-8"));
+ if (getKeys) {
+ sb.append("&keys=true");
+ }
+ return new URI(sb.toString());
+ }
+
+ public void createAccount(final byte[] emailUTF8, final byte[] quickStretchedPW,
+ final boolean getKeys,
+ final boolean preVerified,
+ final String service,
final RequestDelegate