mobile/android/base/fxa/login/TokensAndKeysState.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/fxa/login/TokensAndKeysState.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +package org.mozilla.gecko.fxa.login;
     1.9 +
    1.10 +import org.mozilla.gecko.browserid.BrowserIDKeyPair;
    1.11 +import org.mozilla.gecko.sync.ExtendedJSONObject;
    1.12 +import org.mozilla.gecko.sync.Utils;
    1.13 +
    1.14 +public abstract class TokensAndKeysState extends State {
    1.15 +  protected final byte[] sessionToken;
    1.16 +  protected final byte[] kA;
    1.17 +  protected final byte[] kB;
    1.18 +  protected final BrowserIDKeyPair keyPair;
    1.19 +
    1.20 +  public TokensAndKeysState(StateLabel stateLabel, String email, String uid, byte[] sessionToken, byte[] kA, byte[] kB, BrowserIDKeyPair keyPair) {
    1.21 +    super(stateLabel, email, uid, true);
    1.22 +    Utils.throwIfNull(sessionToken, kA, kB, keyPair);
    1.23 +    this.sessionToken = sessionToken;
    1.24 +    this.kA = kA;
    1.25 +    this.kB = kB;
    1.26 +    this.keyPair = keyPair;
    1.27 +  }
    1.28 +
    1.29 +  @Override
    1.30 +  public ExtendedJSONObject toJSONObject() {
    1.31 +    ExtendedJSONObject o = super.toJSONObject();
    1.32 +    // Fields are non-null by constructor.
    1.33 +    o.put("sessionToken", Utils.byte2Hex(sessionToken));
    1.34 +    o.put("kA", Utils.byte2Hex(kA));
    1.35 +    o.put("kB", Utils.byte2Hex(kB));
    1.36 +    o.put("keyPair", keyPair.toJSONObject());
    1.37 +    return o;
    1.38 +  }
    1.39 +
    1.40 +  @Override
    1.41 +  public Action getNeededAction() {
    1.42 +    return Action.None;
    1.43 +  }
    1.44 +}

mercurial