mobile/android/base/background/fxa/FxAccount20LoginDelegate.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 package org.mozilla.gecko.background.fxa;
     7 import java.io.UnsupportedEncodingException;
     8 import java.security.GeneralSecurityException;
    10 import org.json.simple.JSONObject;
    11 import org.mozilla.gecko.background.fxa.FxAccountClient10.CreateDelegate;
    12 import org.mozilla.gecko.sync.Utils;
    14 /**
    15  * An abstraction around providing an email and authorization token to the auth
    16  * server.
    17  */
    18 public class FxAccount20LoginDelegate implements CreateDelegate {
    19   protected final byte[] emailUTF8;
    20   protected final byte[] authPW;
    22   public FxAccount20LoginDelegate(byte[] emailUTF8, byte[] quickStretchedPW) throws UnsupportedEncodingException, GeneralSecurityException {
    23     this.emailUTF8 = emailUTF8;
    24     this.authPW = FxAccountUtils.generateAuthPW(quickStretchedPW);
    25   }
    27   @SuppressWarnings("unchecked")
    28   @Override
    29   public JSONObject getCreateBody() throws FxAccountClientException {
    30     final JSONObject body = new JSONObject();
    31     try {
    32       body.put("email", new String(emailUTF8, "UTF-8"));
    33       body.put("authPW", Utils.byte2Hex(authPW));
    34       return body;
    35     } catch (UnsupportedEncodingException e) {
    36       throw new FxAccountClientException(e);
    37     }
    38   }
    39 }

mercurial