diff -r 000000000000 -r 6474c204b198 mobile/android/base/fxa/login/TokensAndKeysState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mobile/android/base/fxa/login/TokensAndKeysState.java Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,41 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko.fxa.login; + +import org.mozilla.gecko.browserid.BrowserIDKeyPair; +import org.mozilla.gecko.sync.ExtendedJSONObject; +import org.mozilla.gecko.sync.Utils; + +public abstract class TokensAndKeysState extends State { + protected final byte[] sessionToken; + protected final byte[] kA; + protected final byte[] kB; + protected final BrowserIDKeyPair keyPair; + + public TokensAndKeysState(StateLabel stateLabel, String email, String uid, byte[] sessionToken, byte[] kA, byte[] kB, BrowserIDKeyPair keyPair) { + super(stateLabel, email, uid, true); + Utils.throwIfNull(sessionToken, kA, kB, keyPair); + this.sessionToken = sessionToken; + this.kA = kA; + this.kB = kB; + this.keyPair = keyPair; + } + + @Override + public ExtendedJSONObject toJSONObject() { + ExtendedJSONObject o = super.toJSONObject(); + // Fields are non-null by constructor. + o.put("sessionToken", Utils.byte2Hex(sessionToken)); + o.put("kA", Utils.byte2Hex(kA)); + o.put("kB", Utils.byte2Hex(kB)); + o.put("keyPair", keyPair.toJSONObject()); + return o; + } + + @Override + public Action getNeededAction() { + return Action.None; + } +}