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.

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

mercurial