mobile/android/base/fxa/login/State.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.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate;
     8 import org.mozilla.gecko.sync.ExtendedJSONObject;
     9 import org.mozilla.gecko.sync.Utils;
    11 public abstract class State {
    12   public static final long CURRENT_VERSION = 2L;
    14   public enum StateLabel {
    15     Engaged,
    16     Cohabiting,
    17     Married,
    18     Separated,
    19     Doghouse,
    20   }
    22   public enum Action {
    23     NeedsUpgrade,
    24     NeedsPassword,
    25     NeedsVerification,
    26     None,
    27   }
    29   protected final StateLabel stateLabel;
    30   public final String email;
    31   public final String uid;
    32   public final boolean verified;
    34   public State(StateLabel stateLabel, String email, String uid, boolean verified) {
    35     Utils.throwIfNull(email, uid);
    36     this.stateLabel = stateLabel;
    37     this.email = email;
    38     this.uid = uid;
    39     this.verified = verified;
    40   }
    42   public StateLabel getStateLabel() {
    43     return this.stateLabel;
    44   }
    46   public ExtendedJSONObject toJSONObject() {
    47     ExtendedJSONObject o = new ExtendedJSONObject();
    48     o.put("version", State.CURRENT_VERSION);
    49     o.put("email", email);
    50     o.put("uid", uid);
    51     o.put("verified", verified);
    52     return o;
    53   }
    55   public State makeSeparatedState() {
    56     return new Separated(email, uid, verified);
    57   }
    59   public State makeDoghouseState() {
    60     return new Doghouse(email, uid, verified);
    61   }
    63   public abstract void execute(ExecuteDelegate delegate);
    65   public abstract Action getNeededAction();
    66 }

mercurial