Wed, 31 Dec 2014 07:22:50 +0100
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.fxa.login;
7 import org.mozilla.gecko.browserid.BrowserIDKeyPair;
8 import org.mozilla.gecko.sync.ExtendedJSONObject;
9 import org.mozilla.gecko.sync.Utils;
11 public abstract class TokensAndKeysState extends State {
12 protected final byte[] sessionToken;
13 protected final byte[] kA;
14 protected final byte[] kB;
15 protected final BrowserIDKeyPair keyPair;
17 public TokensAndKeysState(StateLabel stateLabel, String email, String uid, byte[] sessionToken, byte[] kA, byte[] kB, BrowserIDKeyPair keyPair) {
18 super(stateLabel, email, uid, true);
19 Utils.throwIfNull(sessionToken, kA, kB, keyPair);
20 this.sessionToken = sessionToken;
21 this.kA = kA;
22 this.kB = kB;
23 this.keyPair = keyPair;
24 }
26 @Override
27 public ExtendedJSONObject toJSONObject() {
28 ExtendedJSONObject o = super.toJSONObject();
29 // Fields are non-null by constructor.
30 o.put("sessionToken", Utils.byte2Hex(sessionToken));
31 o.put("kA", Utils.byte2Hex(kA));
32 o.put("kB", Utils.byte2Hex(kB));
33 o.put("keyPair", keyPair.toJSONObject());
34 return o;
35 }
37 @Override
38 public Action getNeededAction() {
39 return Action.None;
40 }
41 }