michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.fxa.login; michael@0: michael@0: import org.mozilla.gecko.browserid.BrowserIDKeyPair; michael@0: import org.mozilla.gecko.sync.ExtendedJSONObject; michael@0: import org.mozilla.gecko.sync.Utils; michael@0: michael@0: public abstract class TokensAndKeysState extends State { michael@0: protected final byte[] sessionToken; michael@0: protected final byte[] kA; michael@0: protected final byte[] kB; michael@0: protected final BrowserIDKeyPair keyPair; michael@0: michael@0: public TokensAndKeysState(StateLabel stateLabel, String email, String uid, byte[] sessionToken, byte[] kA, byte[] kB, BrowserIDKeyPair keyPair) { michael@0: super(stateLabel, email, uid, true); michael@0: Utils.throwIfNull(sessionToken, kA, kB, keyPair); michael@0: this.sessionToken = sessionToken; michael@0: this.kA = kA; michael@0: this.kB = kB; michael@0: this.keyPair = keyPair; michael@0: } michael@0: michael@0: @Override michael@0: public ExtendedJSONObject toJSONObject() { michael@0: ExtendedJSONObject o = super.toJSONObject(); michael@0: // Fields are non-null by constructor. michael@0: o.put("sessionToken", Utils.byte2Hex(sessionToken)); michael@0: o.put("kA", Utils.byte2Hex(kA)); michael@0: o.put("kB", Utils.byte2Hex(kB)); michael@0: o.put("keyPair", keyPair.toJSONObject()); michael@0: return o; michael@0: } michael@0: michael@0: @Override michael@0: public Action getNeededAction() { michael@0: return Action.None; michael@0: } michael@0: }