Bug 1102488 - Part 0: Make FxAccountConstants independent of Logger. r=rnewman

--HG--
extra : source : 8d1d39582e497c2c47400740304bdc98f0aef0a7
This commit is contained in:
Nick Alexander 2014-11-20 15:07:35 -08:00
Родитель d26b42bddf
Коммит 39aec96f04
17 изменённых файлов: 73 добавлений и 74 удалений

Просмотреть файл

@ -35,13 +35,13 @@ public class FxAccountAgeLockoutHelper {
// Otherwise, find out how long it's been since we last failed. // Otherwise, find out how long it's been since we last failed.
long millsecondsSinceLastFailedAgeCheck = elapsedRealtime - ELAPSED_REALTIME_OF_LAST_FAILED_AGE_CHECK; long millsecondsSinceLastFailedAgeCheck = elapsedRealtime - ELAPSED_REALTIME_OF_LAST_FAILED_AGE_CHECK;
boolean isLockedOut = millsecondsSinceLastFailedAgeCheck < FxAccountConstants.MINIMUM_TIME_TO_WAIT_AFTER_AGE_CHECK_FAILED_IN_MILLISECONDS; boolean isLockedOut = millsecondsSinceLastFailedAgeCheck < FxAccountConstants.MINIMUM_TIME_TO_WAIT_AFTER_AGE_CHECK_FAILED_IN_MILLISECONDS;
FxAccountConstants.pii(LOG_TAG, "Checking if locked out: it's been " + millsecondsSinceLastFailedAgeCheck + "ms " + FxAccountUtils.pii(LOG_TAG, "Checking if locked out: it's been " + millsecondsSinceLastFailedAgeCheck + "ms " +
"since last lockout, so " + (isLockedOut ? "yes." : "no.")); "since last lockout, so " + (isLockedOut ? "yes." : "no."));
return isLockedOut; return isLockedOut;
} }
public static synchronized void lockOut(long elapsedRealtime) { public static synchronized void lockOut(long elapsedRealtime) {
FxAccountConstants.pii(LOG_TAG, "Locking out at time: " + elapsedRealtime); FxAccountUtils.pii(LOG_TAG, "Locking out at time: " + elapsedRealtime);
ELAPSED_REALTIME_OF_LAST_FAILED_AGE_CHECK = Math.max(elapsedRealtime, ELAPSED_REALTIME_OF_LAST_FAILED_AGE_CHECK); ELAPSED_REALTIME_OF_LAST_FAILED_AGE_CHECK = Math.max(elapsedRealtime, ELAPSED_REALTIME_OF_LAST_FAILED_AGE_CHECK);
} }
@ -60,8 +60,8 @@ public class FxAccountAgeLockoutHelper {
int thisYear = Calendar.getInstance().get(Calendar.YEAR); int thisYear = Calendar.getInstance().get(Calendar.YEAR);
int approximateAge = thisYear - yearOfBirth; int approximateAge = thisYear - yearOfBirth;
boolean oldEnough = approximateAge >= FxAccountConstants.MINIMUM_AGE_TO_CREATE_AN_ACCOUNT; boolean oldEnough = approximateAge >= FxAccountConstants.MINIMUM_AGE_TO_CREATE_AN_ACCOUNT;
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
FxAccountConstants.pii(LOG_TAG, "Age check " + (oldEnough ? "passes" : "fails") + FxAccountUtils.pii(LOG_TAG, "Age check " + (oldEnough ? "passes" : "fails") +
": age is " + approximateAge + " = " + thisYear + " - " + yearOfBirth); ": age is " + approximateAge + " = " + thisYear + " - " + yearOfBirth);
} }
return oldEnough; return oldEnough;
@ -79,7 +79,7 @@ public class FxAccountAgeLockoutHelper {
} }
if (!Arrays.asList(yearItems).contains(yearText)) { if (!Arrays.asList(yearItems).contains(yearText)) {
// This should never happen, but let's be careful. // This should never happen, but let's be careful.
FxAccountConstants.pii(LOG_TAG, "Failed age check: year text was not found in item list."); FxAccountUtils.pii(LOG_TAG, "Failed age check: year text was not found in item list.");
return false; return false;
} }
Integer yearOfBirth; Integer yearOfBirth;
@ -88,7 +88,7 @@ public class FxAccountAgeLockoutHelper {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// Any non-numbers in the list are ranges (and we say as much to // Any non-numbers in the list are ranges (and we say as much to
// translators in the resource file), so these people pass the age check. // translators in the resource file), so these people pass the age check.
FxAccountConstants.pii(LOG_TAG, "Passed age check: year text was found in item list but was not a number."); FxAccountUtils.pii(LOG_TAG, "Passed age check: year text was found in item list but was not a number.");
return true; return true;
} }
return passesAgeCheck(yearOfBirth); return passesAgeCheck(yearOfBirth);

Просмотреть файл

@ -13,7 +13,6 @@ import java.util.concurrent.Executor;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountClientException.FxAccountClientRemoteException; import org.mozilla.gecko.background.fxa.FxAccountClientException.FxAccountClientRemoteException;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.sync.ExtendedJSONObject; import org.mozilla.gecko.sync.ExtendedJSONObject;
import org.mozilla.gecko.sync.Utils; import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.sync.net.BaseResource; import org.mozilla.gecko.sync.net.BaseResource;
@ -206,7 +205,7 @@ public class FxAccountClient20 extends FxAccountClient10 implements FxAccountCli
final RequestDelegate<LoginResponse> delegate) { final RequestDelegate<LoginResponse> delegate) {
byte[] quickStretchedPW; byte[] quickStretchedPW;
try { try {
FxAccountConstants.pii(LOG_TAG, "Trying user provided email: '" + new String(emailUTF8, "UTF-8") + "'" ); FxAccountUtils.pii(LOG_TAG, "Trying user provided email: '" + new String(emailUTF8, "UTF-8") + "'" );
quickStretchedPW = stretcher.getQuickStretchedPW(emailUTF8); quickStretchedPW = stretcher.getQuickStretchedPW(emailUTF8);
} catch (Exception e) { } catch (Exception e) {
delegate.handleError(e); delegate.handleError(e);
@ -233,7 +232,7 @@ public class FxAccountClient20 extends FxAccountClient10 implements FxAccountCli
}; };
Logger.info(LOG_TAG, "Server returned alternate email; retrying login with provided email."); Logger.info(LOG_TAG, "Server returned alternate email; retrying login with provided email.");
FxAccountConstants.pii(LOG_TAG, "Trying server provided email: '" + alternateEmail + "'" ); FxAccountUtils.pii(LOG_TAG, "Trying server provided email: '" + alternateEmail + "'" );
try { try {
// Nota bene: this is not recursive, since we call the fixed password // Nota bene: this is not recursive, since we call the fixed password

Просмотреть файл

@ -35,6 +35,16 @@ public class FxAccountUtils {
public static final int NUMBER_OF_QUICK_STRETCH_ROUNDS = 1000; public static final int NUMBER_OF_QUICK_STRETCH_ROUNDS = 1000;
// For extra debugging. Not final so it can be changed from Fennec, or from
// an add-on.
public static boolean LOG_PERSONAL_INFORMATION = false;
public static void pii(String tag, String message) {
if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
Logger.info(tag, "$$FxA PII$$: " + message);
}
}
public static String bytes(String string) throws UnsupportedEncodingException { public static String bytes(String string) throws UnsupportedEncodingException {
return Utils.byte2Hex(string.getBytes("UTF-8")); return Utils.byte2Hex(string.getBytes("UTF-8"));
} }

Просмотреть файл

@ -6,7 +6,6 @@
package org.mozilla.gecko.fxa; package org.mozilla.gecko.fxa;
import org.mozilla.gecko.background.common.GlobalConstants; import org.mozilla.gecko.background.common.GlobalConstants;
import org.mozilla.gecko.background.common.log.Logger;
public class FxAccountConstants { public class FxAccountConstants {
public static final String GLOBAL_LOG_TAG = "FxAccounts"; public static final String GLOBAL_LOG_TAG = "FxAccounts";
@ -18,16 +17,6 @@ public class FxAccountConstants {
public static final String STAGE_AUTH_SERVER_ENDPOINT = "https://api-accounts.stage.mozaws.net/v1"; public static final String STAGE_AUTH_SERVER_ENDPOINT = "https://api-accounts.stage.mozaws.net/v1";
public static final String STAGE_TOKEN_SERVER_ENDPOINT = "https://token.stage.mozaws.net/1.0/sync/1.5"; public static final String STAGE_TOKEN_SERVER_ENDPOINT = "https://token.stage.mozaws.net/1.0/sync/1.5";
// For extra debugging. Not final so it can be changed from Fennec, or from
// an add-on.
public static boolean LOG_PERSONAL_INFORMATION = false;
public static void pii(String tag, String message) {
if (LOG_PERSONAL_INFORMATION) {
Logger.info(tag, "$$FxA PII$$: " + message);
}
}
// You must be at least 14 years old to create a Firefox Account. // You must be at least 14 years old to create a Firefox Account.
public static final int MINIMUM_AGE_TO_CREATE_AN_ACCOUNT = 14; public static final int MINIMUM_AGE_TO_CREATE_AN_ACCOUNT = 14;

Просмотреть файл

@ -324,7 +324,7 @@ abstract public class FxAccountAbstractSetupActivity extends FxAccountAbstractAc
} }
// For great debugging. // For great debugging.
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
fxAccount.dump(); fxAccount.dump();
} }
@ -403,9 +403,9 @@ abstract public class FxAccountAbstractSetupActivity extends FxAccountAbstractAc
// This sets defaults as well as extracting from extras, so it's not conditional. // This sets defaults as well as extracting from extras, so it's not conditional.
updateServersFromIntentExtras(getIntent()); updateServersFromIntentExtras(getIntent());
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
FxAccountConstants.pii(LOG_TAG, "Using auth server: " + authServerEndpoint); FxAccountUtils.pii(LOG_TAG, "Using auth server: " + authServerEndpoint);
FxAccountConstants.pii(LOG_TAG, "Using sync server: " + syncServerEndpoint); FxAccountUtils.pii(LOG_TAG, "Using sync server: " + syncServerEndpoint);
} }
updateCustomServerView(); updateCustomServerView();

Просмотреть файл

@ -19,8 +19,8 @@ import org.mozilla.gecko.background.fxa.FxAccountClient10.RequestDelegate;
import org.mozilla.gecko.background.fxa.FxAccountClient20; import org.mozilla.gecko.background.fxa.FxAccountClient20;
import org.mozilla.gecko.background.fxa.FxAccountClient20.LoginResponse; import org.mozilla.gecko.background.fxa.FxAccountClient20.LoginResponse;
import org.mozilla.gecko.background.fxa.FxAccountClientException.FxAccountClientRemoteException; import org.mozilla.gecko.background.fxa.FxAccountClientException.FxAccountClientRemoteException;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.background.fxa.PasswordStretcher; import org.mozilla.gecko.background.fxa.PasswordStretcher;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.tasks.FxAccountCreateAccountTask; import org.mozilla.gecko.fxa.tasks.FxAccountCreateAccountTask;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -250,10 +250,10 @@ public class FxAccountCreateAccountActivity extends FxAccountAbstractSetupActivi
? selectedEngines ? selectedEngines
: null; : null;
if (FxAccountAgeLockoutHelper.passesAgeCheck(yearEdit.getText().toString(), yearItems)) { if (FxAccountAgeLockoutHelper.passesAgeCheck(yearEdit.getText().toString(), yearItems)) {
FxAccountConstants.pii(LOG_TAG, "Passed age check."); FxAccountUtils.pii(LOG_TAG, "Passed age check.");
createAccount(email, password, engines); createAccount(email, password, engines);
} else { } else {
FxAccountConstants.pii(LOG_TAG, "Failed age check!"); FxAccountUtils.pii(LOG_TAG, "Failed age check!");
FxAccountAgeLockoutHelper.lockOut(SystemClock.elapsedRealtime()); FxAccountAgeLockoutHelper.lockOut(SystemClock.elapsedRealtime());
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
redirectToActivity(FxAccountCreateAccountNotAllowedActivity.class); redirectToActivity(FxAccountCreateAccountNotAllowedActivity.class);
@ -304,7 +304,7 @@ public class FxAccountCreateAccountActivity extends FxAccountAbstractSetupActivi
selectedEngines.put("history", checkedItems[INDEX_HISTORY]); selectedEngines.put("history", checkedItems[INDEX_HISTORY]);
selectedEngines.put("tabs", checkedItems[INDEX_TABS]); selectedEngines.put("tabs", checkedItems[INDEX_TABS]);
selectedEngines.put("passwords", checkedItems[INDEX_PASSWORDS]); selectedEngines.put("passwords", checkedItems[INDEX_PASSWORDS]);
FxAccountConstants.pii(LOG_TAG, "Updating selectedEngines: " + selectedEngines.toString()); FxAccountUtils.pii(LOG_TAG, "Updating selectedEngines: " + selectedEngines.toString());
} }
}; };

Просмотреть файл

@ -9,6 +9,7 @@ import java.util.Locale;
import org.mozilla.gecko.R; import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountAgeLockoutHelper; import org.mozilla.gecko.background.fxa.FxAccountAgeLockoutHelper;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants; import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.sync.setup.activities.ActivityUtils; import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
@ -133,7 +134,7 @@ public class FxAccountGetStartedActivity extends AccountAuthenticatorActivity {
TextView oldFirefox = (TextView) findViewById(R.id.old_firefox); TextView oldFirefox = (TextView) findViewById(R.id.old_firefox);
String text = getResources().getString(R.string.fxaccount_getting_started_old_firefox); String text = getResources().getString(R.string.fxaccount_getting_started_old_firefox);
final String url = FirefoxAccounts.getOldSyncUpgradeURL(getResources(), Locale.getDefault()); final String url = FirefoxAccounts.getOldSyncUpgradeURL(getResources(), Locale.getDefault());
FxAccountConstants.pii(LOG_TAG, "Old Firefox url is: " + url); // Don't want to leak locale in particular. FxAccountUtils.pii(LOG_TAG, "Old Firefox url is: " + url); // Don't want to leak locale in particular.
ActivityUtils.linkTextView(oldFirefox, text, url); ActivityUtils.linkTextView(oldFirefox, text, url);
} }
} }

Просмотреть файл

@ -10,6 +10,7 @@ import java.util.Set;
import org.mozilla.gecko.R; import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.background.preferences.PreferenceFragment; import org.mozilla.gecko.background.preferences.PreferenceFragment;
import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants; import org.mozilla.gecko.fxa.FxAccountConstants;
@ -145,7 +146,7 @@ public class FxAccountStatusFragment
tabsPreference = (CheckBoxPreference) ensureFindPreference("tabs"); tabsPreference = (CheckBoxPreference) ensureFindPreference("tabs");
passwordsPreference = (CheckBoxPreference) ensureFindPreference("passwords"); passwordsPreference = (CheckBoxPreference) ensureFindPreference("passwords");
if (!FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (!FxAccountUtils.LOG_PERSONAL_INFORMATION) {
removeDebugButtons(); removeDebugButtons();
} else { } else {
connectDebugButtons(); connectDebugButtons();

Просмотреть файл

@ -17,7 +17,6 @@ import org.mozilla.gecko.background.fxa.FxAccountClientException.FxAccountClient
import org.mozilla.gecko.background.fxa.FxAccountUtils; import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.background.fxa.PasswordStretcher; import org.mozilla.gecko.background.fxa.PasswordStretcher;
import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.fxa.login.Engaged; import org.mozilla.gecko.fxa.login.Engaged;
import org.mozilla.gecko.fxa.login.State; import org.mozilla.gecko.fxa.login.State;
@ -156,7 +155,7 @@ public class FxAccountUpdateCredentialsActivity extends FxAccountAbstractSetupAc
fxAccount.requestSync(FirefoxAccounts.FORCE); fxAccount.requestSync(FirefoxAccounts.FORCE);
// For great debugging. // For great debugging.
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
fxAccount.dump(); fxAccount.dump();
} }

Просмотреть файл

@ -516,14 +516,14 @@ public class AndroidFxAccount {
* <b>For debugging only!</b> * <b>For debugging only!</b>
*/ */
public void dump() { public void dump() {
if (!FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (!FxAccountUtils.LOG_PERSONAL_INFORMATION) {
return; return;
} }
ExtendedJSONObject o = toJSONObject(); ExtendedJSONObject o = toJSONObject();
ArrayList<String> list = new ArrayList<String>(o.keySet()); ArrayList<String> list = new ArrayList<String>(o.keySet());
Collections.sort(list); Collections.sort(list);
for (String key : list) { for (String key : list) {
FxAccountConstants.pii(LOG_TAG, key + ": " + o.get(key)); FxAccountUtils.pii(LOG_TAG, key + ": " + o.get(key));
} }
} }

Просмотреть файл

@ -4,9 +4,9 @@
package org.mozilla.gecko.fxa.login; package org.mozilla.gecko.fxa.login;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.browserid.BrowserIDKeyPair; import org.mozilla.gecko.browserid.BrowserIDKeyPair;
import org.mozilla.gecko.browserid.JSONWebTokenUtils; import org.mozilla.gecko.browserid.JSONWebTokenUtils;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate; import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate;
import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LogMessage; import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LogMessage;
import org.mozilla.gecko.sync.ExtendedJSONObject; import org.mozilla.gecko.sync.ExtendedJSONObject;
@ -24,19 +24,19 @@ public class Cohabiting extends TokensAndKeysState {
new BaseRequestDelegate<String>(this, delegate) { new BaseRequestDelegate<String>(this, delegate) {
@Override @Override
public void handleSuccess(String certificate) { public void handleSuccess(String certificate) {
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
try { try {
FxAccountConstants.pii(LOG_TAG, "Fetched certificate: " + certificate); FxAccountUtils.pii(LOG_TAG, "Fetched certificate: " + certificate);
ExtendedJSONObject c = JSONWebTokenUtils.parseCertificate(certificate); ExtendedJSONObject c = JSONWebTokenUtils.parseCertificate(certificate);
if (c != null) { if (c != null) {
FxAccountConstants.pii(LOG_TAG, "Header : " + c.getObject("header")); FxAccountUtils.pii(LOG_TAG, "Header : " + c.getObject("header"));
FxAccountConstants.pii(LOG_TAG, "Payload : " + c.getObject("payload")); FxAccountUtils.pii(LOG_TAG, "Payload : " + c.getObject("payload"));
FxAccountConstants.pii(LOG_TAG, "Signature: " + c.getString("signature")); FxAccountUtils.pii(LOG_TAG, "Signature: " + c.getString("signature"));
} else { } else {
FxAccountConstants.pii(LOG_TAG, "Could not parse certificate!"); FxAccountUtils.pii(LOG_TAG, "Could not parse certificate!");
} }
} catch (Exception e) { } catch (Exception e) {
FxAccountConstants.pii(LOG_TAG, "Could not parse certificate!"); FxAccountUtils.pii(LOG_TAG, "Could not parse certificate!");
} }
} }
delegate.handleTransition(new LogMessage("sign succeeded"), new Married(email, uid, sessionToken, kA, kB, keyPair, certificate)); delegate.handleTransition(new LogMessage("sign succeeded"), new Married(email, uid, sessionToken, kA, kB, keyPair, certificate));

Просмотреть файл

@ -9,7 +9,6 @@ import java.security.NoSuchAlgorithmException;
import org.mozilla.gecko.background.fxa.FxAccountClient10.TwoKeys; import org.mozilla.gecko.background.fxa.FxAccountClient10.TwoKeys;
import org.mozilla.gecko.background.fxa.FxAccountUtils; import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.browserid.BrowserIDKeyPair; import org.mozilla.gecko.browserid.BrowserIDKeyPair;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate; import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate;
import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.AccountVerified; import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.AccountVerified;
import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LocalError; import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LocalError;
@ -61,10 +60,10 @@ public class Engaged extends State {
byte[] kB; byte[] kB;
try { try {
kB = FxAccountUtils.unwrapkB(unwrapkB, result.wrapkB); kB = FxAccountUtils.unwrapkB(unwrapkB, result.wrapkB);
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
FxAccountConstants.pii(LOG_TAG, "Fetched kA: " + Utils.byte2Hex(result.kA)); FxAccountUtils.pii(LOG_TAG, "Fetched kA: " + Utils.byte2Hex(result.kA));
FxAccountConstants.pii(LOG_TAG, "And wrapkB: " + Utils.byte2Hex(result.wrapkB)); FxAccountUtils.pii(LOG_TAG, "And wrapkB: " + Utils.byte2Hex(result.wrapkB));
FxAccountConstants.pii(LOG_TAG, "Giving kB : " + Utils.byte2Hex(kB)); FxAccountUtils.pii(LOG_TAG, "Giving kB : " + Utils.byte2Hex(kB));
} }
} catch (Exception e) { } catch (Exception e) {
delegate.handleTransition(new RemoteError(e), new Separated(email, uid, verified)); delegate.handleTransition(new RemoteError(e), new Separated(email, uid, verified));

Просмотреть файл

@ -17,7 +17,6 @@ import org.json.simple.parser.ParseException;
import org.mozilla.gecko.background.fxa.FxAccountUtils; import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.browserid.BrowserIDKeyPair; import org.mozilla.gecko.browserid.BrowserIDKeyPair;
import org.mozilla.gecko.browserid.JSONWebTokenUtils; import org.mozilla.gecko.browserid.JSONWebTokenUtils;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate; import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate;
import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LogMessage; import org.mozilla.gecko.fxa.login.FxAccountLoginTransition.LogMessage;
import org.mozilla.gecko.sync.ExtendedJSONObject; import org.mozilla.gecko.sync.ExtendedJSONObject;
@ -61,23 +60,23 @@ public class Married extends TokensAndKeysState {
// invalid-timestamp errors from the token server. // invalid-timestamp errors from the token server.
final long expiresAt = JSONWebTokenUtils.DEFAULT_FUTURE_EXPIRES_AT_IN_MILLISECONDS; final long expiresAt = JSONWebTokenUtils.DEFAULT_FUTURE_EXPIRES_AT_IN_MILLISECONDS;
String assertion = JSONWebTokenUtils.createAssertion(keyPair.getPrivate(), certificate, audience, issuer, null, expiresAt); String assertion = JSONWebTokenUtils.createAssertion(keyPair.getPrivate(), certificate, audience, issuer, null, expiresAt);
if (!FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (!FxAccountUtils.LOG_PERSONAL_INFORMATION) {
return assertion; return assertion;
} }
try { try {
FxAccountConstants.pii(LOG_TAG, "Generated assertion: " + assertion); FxAccountUtils.pii(LOG_TAG, "Generated assertion: " + assertion);
ExtendedJSONObject a = JSONWebTokenUtils.parseAssertion(assertion); ExtendedJSONObject a = JSONWebTokenUtils.parseAssertion(assertion);
if (a != null) { if (a != null) {
FxAccountConstants.pii(LOG_TAG, "aHeader : " + a.getObject("header")); FxAccountUtils.pii(LOG_TAG, "aHeader : " + a.getObject("header"));
FxAccountConstants.pii(LOG_TAG, "aPayload : " + a.getObject("payload")); FxAccountUtils.pii(LOG_TAG, "aPayload : " + a.getObject("payload"));
FxAccountConstants.pii(LOG_TAG, "aSignature: " + a.getString("signature")); FxAccountUtils.pii(LOG_TAG, "aSignature: " + a.getString("signature"));
String certificate = a.getString("certificate"); String certificate = a.getString("certificate");
if (certificate != null) { if (certificate != null) {
ExtendedJSONObject c = JSONWebTokenUtils.parseCertificate(certificate); ExtendedJSONObject c = JSONWebTokenUtils.parseCertificate(certificate);
FxAccountConstants.pii(LOG_TAG, "cHeader : " + c.getObject("header")); FxAccountUtils.pii(LOG_TAG, "cHeader : " + c.getObject("header"));
FxAccountConstants.pii(LOG_TAG, "cPayload : " + c.getObject("payload")); FxAccountUtils.pii(LOG_TAG, "cPayload : " + c.getObject("payload"));
FxAccountConstants.pii(LOG_TAG, "cSignature: " + c.getString("signature")); FxAccountUtils.pii(LOG_TAG, "cSignature: " + c.getString("signature"));
// Print the relevant timestamps in sorted order with labels. // Print the relevant timestamps in sorted order with labels.
HashMap<Long, String> map = new HashMap<Long, String>(); HashMap<Long, String> map = new HashMap<Long, String>();
map.put(a.getObject("payload").getLong("iat"), "aiat"); map.put(a.getObject("payload").getLong("iat"), "aiat");
@ -87,16 +86,16 @@ public class Married extends TokensAndKeysState {
ArrayList<Long> values = new ArrayList<Long>(map.keySet()); ArrayList<Long> values = new ArrayList<Long>(map.keySet());
Collections.sort(values); Collections.sort(values);
for (Long value : values) { for (Long value : values) {
FxAccountConstants.pii(LOG_TAG, map.get(value) + ": " + value); FxAccountUtils.pii(LOG_TAG, map.get(value) + ": " + value);
} }
} else { } else {
FxAccountConstants.pii(LOG_TAG, "Could not parse certificate!"); FxAccountUtils.pii(LOG_TAG, "Could not parse certificate!");
} }
} else { } else {
FxAccountConstants.pii(LOG_TAG, "Could not parse assertion!"); FxAccountUtils.pii(LOG_TAG, "Could not parse assertion!");
} }
} catch (Exception e) { } catch (Exception e) {
FxAccountConstants.pii(LOG_TAG, "Got exception dumping assertion debug info."); FxAccountUtils.pii(LOG_TAG, "Got exception dumping assertion debug info.");
} }
return assertion; return assertion;
} }
@ -107,8 +106,8 @@ public class Married extends TokensAndKeysState {
} }
public String getClientState() { public String getClientState() {
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
FxAccountConstants.pii(LOG_TAG, "Client state: " + this.clientState); FxAccountUtils.pii(LOG_TAG, "Client state: " + this.clientState);
} }
return this.clientState; return this.clientState;
} }

Просмотреть файл

@ -8,10 +8,10 @@ import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.browserid.BrowserIDKeyPair; import org.mozilla.gecko.browserid.BrowserIDKeyPair;
import org.mozilla.gecko.browserid.DSACryptoImplementation; import org.mozilla.gecko.browserid.DSACryptoImplementation;
import org.mozilla.gecko.browserid.RSACryptoImplementation; import org.mozilla.gecko.browserid.RSACryptoImplementation;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.login.State.StateLabel; import org.mozilla.gecko.fxa.login.State.StateLabel;
import org.mozilla.gecko.sync.ExtendedJSONObject; import org.mozilla.gecko.sync.ExtendedJSONObject;
import org.mozilla.gecko.sync.NonObjectJSONException; import org.mozilla.gecko.sync.NonObjectJSONException;
@ -135,15 +135,15 @@ public class StateFactory {
} }
protected static void logMigration(State from, State to) { protected static void logMigration(State from, State to) {
if (!FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (!FxAccountUtils.LOG_PERSONAL_INFORMATION) {
return; return;
} }
try { try {
FxAccountConstants.pii(LOG_TAG, "V1 persisted state is: " + from.toJSONObject().toJSONString()); FxAccountUtils.pii(LOG_TAG, "V1 persisted state is: " + from.toJSONObject().toJSONString());
} catch (Exception e) { } catch (Exception e) {
Logger.warn(LOG_TAG, "Error producing JSON representation of V1 state.", e); Logger.warn(LOG_TAG, "Error producing JSON representation of V1 state.", e);
} }
FxAccountConstants.pii(LOG_TAG, "Generated new V2 state: " + to.toJSONObject().toJSONString()); FxAccountUtils.pii(LOG_TAG, "Generated new V2 state: " + to.toJSONObject().toJSONString());
} }
protected static State migrateV1toV2(StateLabel stateLabel, State state) throws NoSuchAlgorithmException { protected static State migrateV1toV2(StateLabel stateLabel, State state) throws NoSuchAlgorithmException {

Просмотреть файл

@ -10,6 +10,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.FxAccountConstants; import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
@ -112,7 +113,7 @@ public class FxAccountUpgradeReceiver extends BroadcastReceiver {
try { try {
final AndroidFxAccount fxAccount = new AndroidFxAccount(context, account); final AndroidFxAccount fxAccount = new AndroidFxAccount(context, account);
// For great debugging. // For great debugging.
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
fxAccount.dump(); fxAccount.dump();
} }
State state = fxAccount.getState(); State state = fxAccount.getState();

Просмотреть файл

@ -7,7 +7,7 @@ package org.mozilla.gecko.fxa.sync;
import org.mozilla.gecko.BrowserLocaleManager; import org.mozilla.gecko.BrowserLocaleManager;
import org.mozilla.gecko.R; import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.fxa.FxAccountConstants; import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.fxa.activities.FxAccountStatusActivity; import org.mozilla.gecko.fxa.activities.FxAccountStatusActivity;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.fxa.login.State; import org.mozilla.gecko.fxa.login.State;
@ -70,7 +70,7 @@ public class FxAccountNotificationManager {
final String title = context.getResources().getString(R.string.fxaccount_sync_sign_in_error_notification_title); final String title = context.getResources().getString(R.string.fxaccount_sync_sign_in_error_notification_title);
final String text = context.getResources().getString(R.string.fxaccount_sync_sign_in_error_notification_text, state.email); final String text = context.getResources().getString(R.string.fxaccount_sync_sign_in_error_notification_text, state.email);
Logger.info(LOG_TAG, "State " + state.getStateLabel() + " needs action; offering notification with title: " + title); Logger.info(LOG_TAG, "State " + state.getStateLabel() + " needs action; offering notification with title: " + title);
FxAccountConstants.pii(LOG_TAG, "And text: " + text); FxAccountUtils.pii(LOG_TAG, "And text: " + text);
final Intent notificationIntent = new Intent(context, FxAccountStatusActivity.class); final Intent notificationIntent = new Intent(context, FxAccountStatusActivity.class);
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

Просмотреть файл

@ -17,6 +17,7 @@ import java.util.concurrent.Executors;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountClient; import org.mozilla.gecko.background.fxa.FxAccountClient;
import org.mozilla.gecko.background.fxa.FxAccountClient20; import org.mozilla.gecko.background.fxa.FxAccountClient20;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
import org.mozilla.gecko.background.fxa.SkewHandler; import org.mozilla.gecko.background.fxa.SkewHandler;
import org.mozilla.gecko.browserid.BrowserIDKeyPair; import org.mozilla.gecko.browserid.BrowserIDKeyPair;
import org.mozilla.gecko.browserid.JSONWebTokenUtils; import org.mozilla.gecko.browserid.JSONWebTokenUtils;
@ -315,7 +316,7 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
@Override @Override
public void handleSuccess(final TokenServerToken token) { public void handleSuccess(final TokenServerToken token) {
FxAccountConstants.pii(LOG_TAG, "Got token! uid is " + token.uid + " and endpoint is " + token.endpoint + "."); FxAccountUtils.pii(LOG_TAG, "Got token! uid is " + token.uid + " and endpoint is " + token.endpoint + ".");
if (!didReceiveBackoff) { if (!didReceiveBackoff) {
// We must be OK to touch this token server. // We must be OK to touch this token server.
@ -358,9 +359,9 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
FxAccountGlobalSession globalSession = null; FxAccountGlobalSession globalSession = null;
try { try {
final ClientsDataDelegate clientsDataDelegate = new SharedPreferencesClientsDataDelegate(sharedPrefs, getContext()); final ClientsDataDelegate clientsDataDelegate = new SharedPreferencesClientsDataDelegate(sharedPrefs, getContext());
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
FxAccountConstants.pii(LOG_TAG, "Client device name is: '" + clientsDataDelegate.getClientName() + "'."); FxAccountUtils.pii(LOG_TAG, "Client device name is: '" + clientsDataDelegate.getClientName() + "'.");
FxAccountConstants.pii(LOG_TAG, "Client device data last modified: " + clientsDataDelegate.getLastModifiedTimestamp()); FxAccountUtils.pii(LOG_TAG, "Client device data last modified: " + clientsDataDelegate.getLastModifiedTimestamp());
} }
// We compute skew over time using SkewHandler. This yields an unchanging // We compute skew over time using SkewHandler. This yields an unchanging
@ -444,7 +445,7 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter {
Logger.info(LOG_TAG, "Account last synced at: " + fxAccount.getLastSyncedTimestamp()); Logger.info(LOG_TAG, "Account last synced at: " + fxAccount.getLastSyncedTimestamp());
if (FxAccountConstants.LOG_PERSONAL_INFORMATION) { if (FxAccountUtils.LOG_PERSONAL_INFORMATION) {
fxAccount.dump(); fxAccount.dump();
} }