Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | package org.mozilla.gecko.fxa.login; |
michael@0 | 6 | |
michael@0 | 7 | import org.mozilla.gecko.browserid.BrowserIDKeyPair; |
michael@0 | 8 | import org.mozilla.gecko.sync.ExtendedJSONObject; |
michael@0 | 9 | import org.mozilla.gecko.sync.Utils; |
michael@0 | 10 | |
michael@0 | 11 | public abstract class TokensAndKeysState extends State { |
michael@0 | 12 | protected final byte[] sessionToken; |
michael@0 | 13 | protected final byte[] kA; |
michael@0 | 14 | protected final byte[] kB; |
michael@0 | 15 | protected final BrowserIDKeyPair keyPair; |
michael@0 | 16 | |
michael@0 | 17 | public TokensAndKeysState(StateLabel stateLabel, String email, String uid, byte[] sessionToken, byte[] kA, byte[] kB, BrowserIDKeyPair keyPair) { |
michael@0 | 18 | super(stateLabel, email, uid, true); |
michael@0 | 19 | Utils.throwIfNull(sessionToken, kA, kB, keyPair); |
michael@0 | 20 | this.sessionToken = sessionToken; |
michael@0 | 21 | this.kA = kA; |
michael@0 | 22 | this.kB = kB; |
michael@0 | 23 | this.keyPair = keyPair; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | @Override |
michael@0 | 27 | public ExtendedJSONObject toJSONObject() { |
michael@0 | 28 | ExtendedJSONObject o = super.toJSONObject(); |
michael@0 | 29 | // Fields are non-null by constructor. |
michael@0 | 30 | o.put("sessionToken", Utils.byte2Hex(sessionToken)); |
michael@0 | 31 | o.put("kA", Utils.byte2Hex(kA)); |
michael@0 | 32 | o.put("kB", Utils.byte2Hex(kB)); |
michael@0 | 33 | o.put("keyPair", keyPair.toJSONObject()); |
michael@0 | 34 | return o; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | @Override |
michael@0 | 38 | public Action getNeededAction() { |
michael@0 | 39 | return Action.None; |
michael@0 | 40 | } |
michael@0 | 41 | } |