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

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

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.browserid.JSONWebTokenUtils;
michael@0 9 import org.mozilla.gecko.fxa.FxAccountConstants;
michael@0 10 import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate;
michael@0 11 import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LogMessage;
michael@0 12 import org.mozilla.gecko.sync.ExtendedJSONObject;
michael@0 13
michael@0 14 public class Cohabiting extends TokensAndKeysState {
michael@0 15 private static final String LOG_TAG = Cohabiting.class.getSimpleName();
michael@0 16
michael@0 17 public Cohabiting(String email, String uid, byte[] sessionToken, byte[] kA, byte[] kB, BrowserIDKeyPair keyPair) {
michael@0 18 super(StateLabel.Cohabiting, email, uid, sessionToken, kA, kB, keyPair);
michael@0 19 }
michael@0 20
michael@0 21 @Override
michael@0 22 public void execute(final ExecuteDelegate delegate) {
michael@0 23 delegate.getClient().sign(sessionToken, keyPair.getPublic().toJSONObject(), delegate.getCertificateDurationInMilliseconds(),
michael@0 24 new BaseRequestDelegate<String>(this, delegate) {
michael@0 25 @Override
michael@0 26 public void handleSuccess(String certificate) {
michael@0 27 if (FxAccountConstants.LOG_PERSONAL_INFORMATION) {
michael@0 28 try {
michael@0 29 FxAccountConstants.pii(LOG_TAG, "Fetched certificate: " + certificate);
michael@0 30 ExtendedJSONObject c = JSONWebTokenUtils.parseCertificate(certificate);
michael@0 31 if (c != null) {
michael@0 32 FxAccountConstants.pii(LOG_TAG, "Header : " + c.getObject("header"));
michael@0 33 FxAccountConstants.pii(LOG_TAG, "Payload : " + c.getObject("payload"));
michael@0 34 FxAccountConstants.pii(LOG_TAG, "Signature: " + c.getString("signature"));
michael@0 35 } else {
michael@0 36 FxAccountConstants.pii(LOG_TAG, "Could not parse certificate!");
michael@0 37 }
michael@0 38 } catch (Exception e) {
michael@0 39 FxAccountConstants.pii(LOG_TAG, "Could not parse certificate!");
michael@0 40 }
michael@0 41 }
michael@0 42 delegate.handleTransition(new LogMessage("sign succeeded"), new Married(email, uid, sessionToken, kA, kB, keyPair, certificate));
michael@0 43 }
michael@0 44 });
michael@0 45 }
michael@0 46 }

mercurial