}
private void checkForBackup() {
- String filename=CategoryList.BACKUP_FILENAME;
+ String filename=Constants.BACKUP_FILENAME;
File restoreFile=new File(filename);
if (!restoreFile.exists()) {
return;
super.onPause();
if (debug) Log.d(TAG, "onResume()");
- if (CategoryList.isSignedIn()==true) {
+ if (RuntimeSecrets.isSignedIn()) {
if (debug) Log.d(TAG,"already signed in");
Intent callbackIntent = new Intent();
- callbackIntent.putExtra("salt", CategoryList.getSalt());
- callbackIntent.putExtra("masterKey", CategoryList.getMasterKey());
+ callbackIntent.putExtra("salt", RuntimeSecrets.getSalt());
+ callbackIntent.putExtra("masterKey", RuntimeSecrets.getMasterKey());
setResult(RESULT_OK, callbackIntent);
finish();
return;
super.onActivityResult(requestCode, resultCode, i);
if ((requestCode== REQUEST_RESTORE) && (resultCode == RESULT_OK)) {
- Log.d(TAG,"returning masterkey: "+CategoryList.getMasterKey());
+ Log.d(TAG,"returning masterkey: "+RuntimeSecrets.getMasterKey());
Intent callbackIntent = new Intent();
- callbackIntent.putExtra("salt", CategoryList.getSalt());
- callbackIntent.putExtra("masterKey", CategoryList.getMasterKey());
+ callbackIntent.putExtra("salt", RuntimeSecrets.getSalt());
+ callbackIntent.putExtra("masterKey", RuntimeSecrets.getMasterKey());
setResult(RESULT_OK, callbackIntent);
finish();
}
package org.openintents.safe;
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
import android.app.Activity;
import android.content.BroadcastReceiver;
*
* @author Randy McEoin
*/
-public class CategoryEdit extends Activity {
+public class CategoryEdit extends FrontDooringActivity {
private static final boolean debug = false;
private static String TAG = "CategoryEdit";
private Long RowId;
boolean populated = false;
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (debug) Log.d(TAG,"onCreate("+icicle+")");
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
String title = getResources().getString(R.string.app_name) + " - " +
getResources().getString(R.string.edit_entry);
setTitle(title);
populated=true;
}
- @Override
- protected void onPause() {
- super.onPause();
- if (debug) Log.d(TAG, "onPause");
-
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
- }
-
@Override
protected void onResume() {
super.onResume();
if (debug) Log.d(TAG, "onResume");
- if (!CategoryList.isSignedIn()) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
Passwords.Initialize(this);
}
populated=true;
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
import org.openintents.safe.service.ServiceDispatchImpl;
import org.openintents.util.IntentUtils;
import org.openintents.util.SecureDelete;
+import org.openintents.util.FrontDooringListActivity;
import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
* @author Randy McEoin
* @author Steven Osborn - http://steven.bitsetters.com
*/
-public class CategoryList extends ListActivity {
+public class CategoryList extends FrontDooringListActivity {
private static boolean debug = false;
private static final String TAG = "CategoryList";
private static final int ABOUT_KEY = IMPORT_PROGRESS_KEY + 2;
public static final int MAX_CATEGORIES = 256;
-
- private static final String EXPORT_FILENAME = "/sdcard/oisafe.csv";
- public static final String BACKUP_FILENAME = "/sdcard/oisafe.xml";
- private static final String PASSWORDSAFE_IMPORT_FILENAME = "/sdcard/passwordsafe.csv";
public static final String KEY_ID = "id"; // Intent keys
private Thread backupThread=null;
- private static String salt;
- private static String masterKey;
-
private List<CategoryEntry> rows=null;
private CategoryListItemAdapter catAdapter=null;
private Intent restartTimerIntent=null;
private boolean lockOnScreenLock=true;
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
- if (debug) Log.d(TAG,"caught ACTION_SCREEN_OFF");
- if (lockOnScreenLock) {
- masterKey=null;
- }
- } else if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- lockAndShutFrontDoor();
- }
- }
- };
-
public Handler myViewUpdateHandler = new Handler(){
// @Override
public void handleMessage(Message msg) {
if (debug) Log.d(TAG,"onResume()");
- if (isSignedIn()==false) {
- Intent frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
-
showFirstTimeWarningDialog();
if (Passwords.getPrePopulate()==true)
{
try { backupThread.join(maxWaitToDie); }
catch(InterruptedException e){} // ignore
}
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
}
@Override
if (debug) Log.d(TAG,"onStop()");
}
- @Override
- public void onDestroy() {
- super.onDestroy();
-
- if (debug) Log.d(TAG,"onDestroy()");
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
- }
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenuInfo menuInfo) {
case BACKUP_PROGRESS_KEY: {
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage(getString(R.string.backup_progress)+
- " "+BACKUP_FILENAME);
+ " "+Constants.BACKUP_FILENAME);
dialog.setIndeterminate(false);
dialog.setCancelable(false);
return dialog;
return null;
}
- /**
- * Returns the current status of signedIn.
- *
- * @return True if signed in
- */
- public static boolean isSignedIn() {
- if ((salt != null) && (masterKey != null)) {
- return true;
- }
- return false;
- }
-
-
- /**
- * Sets signedIn status to false.
- *
- * @see org.openintents.safe.CategoryList#isSignedIn
- */
- public static void setSignedOut() {
- if (debug) Log.d(TAG,"setSignedOut()");
- masterKey=null;
- }
/**
* Populates the category ListView
*/
return super.onCreateOptionsMenu(menu);
}
- static void setSalt(String saltIn) {
- salt = saltIn;
- }
-
- static String getSalt() {
- return salt;
- }
-
- static void setMasterKey(String key) {
- masterKey = key;
- }
-
- static String getMasterKey() {
- return masterKey;
- }
-
private void addCategoryActivity() {
if (debug) Log.d(TAG,"addCategoryActivity()");
Intent i = new Intent(this, CategoryEdit.class);
private String backupDatabase() {
Backup backup=new Backup(this);
- backup.write(BACKUP_FILENAME);
+ backup.write(Constants.BACKUP_FILENAME);
return backup.getResult();
}
Intent serviceIntent = new Intent();
serviceIntent.setClass(this, ServiceDispatchImpl.class );
stopService(serviceIntent);
- masterKey=null;
+ RuntimeSecrets.setSignedOut();
Intent frontdoor = new Intent(this, Safe.class);
frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
startActivity(frontdoor);
}
private void restoreDatabase() {
-// Restore restore=new Restore(myViewUpdateHandler, this);
-
-// restore.read(BACKUP_FILENAME, masterKey);
Intent i = new Intent(this, Restore.class);
startActivityForResult(i,REQUEST_RESTORE);
}
public boolean exportDatabase(){
if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- String filename=EXPORT_FILENAME;
+ String filename=Constants.EXPORT_FILENAME;
try {
CSVWriter writer = new CSVWriter(new FileWriter(filename), ',');
public void importDatabase(){
final String filename;
- File oiImport=new File(EXPORT_FILENAME);
- File pwsImport=new File(PASSWORDSAFE_IMPORT_FILENAME);
+ File oiImport=new File(Constants.EXPORT_FILENAME);
+ File pwsImport=new File(Constants.PASSWORDSAFE_IMPORT_FILENAME);
if (oiImport.exists() || !pwsImport.exists()) {
- filename=EXPORT_FILENAME;
+ filename=Constants.EXPORT_FILENAME;
}else{
- filename=PASSWORDSAFE_IMPORT_FILENAME;
+ filename=Constants.PASSWORDSAFE_IMPORT_FILENAME;
}
File csvFile=new File(filename);
if (!csvFile.exists()) {
importMessage=getString(R.string.import_file_error);
}
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// Intent frontdoor = new Intent(this, FrontDoor.class);
-// frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
-}
\ No newline at end of file
+}
import java.util.List;
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
import android.app.Activity;
import android.app.Dialog;
*
* @author Randy McEoin
*/
-public class ChangePass extends Activity {
+public class ChangePass extends FrontDooringActivity {
private static boolean debug = false;
private static final String TAG = "ChangePass";
}
};
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
/**
* Called when the activity is first created.
*/
if (debug) Log.d(TAG,"onCreate()");
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
setContentView(R.layout.chg_pass);
String title = getResources().getString(R.string.app_name) + " - " +
getResources().getString(R.string.change_password);
try { changePassThread.join(maxWaitToDie); }
catch(InterruptedException e){} // ignore
}
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
}
@Override
super.onResume();
if (debug) Log.d(TAG,"onResume()");
-
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
Passwords.Initialize(this);
}
dbHelper.commit();
- PassList.setMasterKey(newPass);
- CategoryList.setMasterKey(newPass);
+ RuntimeSecrets.setMasterKey(newPass);
dbHelper.close();
}
}
return false;
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
--- /dev/null
+/* A new central holding place for some constants that got scattered around */
+
+package org.openintents.safe;
+
+public class Constants {
+ public static final String EXPORT_FILENAME = "/sdcard/oisafe.csv";
+ public static final String BACKUP_FILENAME = "/sdcard/oisafe.xml";
+ public static final String PASSWORDSAFE_IMPORT_FILENAME = "/sdcard/passwordsafe.csv";
+}
}\r
\r
if (debug) Log.d(TAG, "Original file path: " + originalFile);\r
- if (CategoryList.isSignedIn()==false) {\r
+ if (RuntimeSecrets.isSignedIn()==false) {\r
Intent frontdoor = new Intent(getContext(), Safe.class);\r
frontdoor.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r
getContext().startActivity(frontdoor); \r
private static final String TABLE_CIPHER_ACCESS = "cipher_access";
private static final int DATABASE_VERSION = 4;
private static String TAG = "DBHelper";
- Context myCtx;
private static final String DBVERSION_CREATE =
"create table " + TABLE_DBVERSION + " ("
// "drop table " + TABLE_CIPHER_ACCESS + ";";
private SQLiteDatabase db;
- private static boolean needsPrePopulation=false;
- private static boolean needsUpgrade=false;
+ private boolean needsPrePopulation=false;
+ private boolean needsUpgrade=false;
/**
*
* @param ctx
*/
public DBHelper(Context ctx) {
- myCtx = ctx;
try {
- db = myCtx.openOrCreateDatabase(DATABASE_NAME, 0,null);
+ db = ctx.openOrCreateDatabase(DATABASE_NAME, 0,null);
// Check for the existence of the DBVERSION table
// If it doesn't exist than create the overall data,
import java.io.InputStream;
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
import android.app.Activity;
import android.content.BroadcastReceiver;
*
* @author Randy McEoin
*/
-public class Help extends Activity {
+public class Help extends FrontDooringActivity {
private static boolean debug = false;
private static String TAG = "Help";
// Menu Item order
public static final int CLOSE_HELP_INDEX = Menu.FIRST;
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
//Setup layout
setContentView(R.layout.help);
String title = getResources().getString(R.string.app_name) + " - " +
}
- @Override
- protected void onPause() {
- super.onPause();
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- if (debug) Log.d(TAG,"onResume()");
-
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
}
return super.onOptionsItemSelected(item);
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
-}
\ No newline at end of file
+}
final String action = thisIntent.getAction();\r
Intent callbackIntent = getIntent(); \r
int callbackResult = RESULT_CANCELED;\r
- PassList.setSalt(salt);\r
- CategoryList.setSalt(salt);\r
- PassList.setMasterKey(masterKey);\r
- CategoryList.setMasterKey(masterKey);\r
+ RuntimeSecrets.setSalt(salt);\r
+ RuntimeSecrets.setMasterKey(masterKey);\r
\r
if (debug) Log.d(TAG,"actionDispatch()");\r
if ((salt==null) || (salt=="")) {\r
Intent serviceIntent = new Intent();
serviceIntent.setClass(LogOffActivity.this, ServiceDispatchImpl.class );
stopService(serviceIntent);
- CategoryList.setSignedOut();
+ RuntimeSecrets.setSignedOut();
/*
Intent intent = new Intent(LogOffActivity.this, FrontDoor.class);
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
import android.app.Activity;
import android.app.AlertDialog;
* @author Steven Osborn - http://steven.bitsetters.com
* @author Randy McEoin
*/
-public class PassEdit extends Activity {
+public class PassEdit extends FrontDooringActivity {
private static boolean debug = false;
private static String TAG = "PassEdit";
public static boolean entryEdited = false;
boolean populated = false;
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
return;
}
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
String title = getResources().getString(R.string.app_name) + " - "
+ getResources().getString(R.string.edit_entry);
setTitle(title);
}
});
restoreMe();
-
- sendBroadcast (restartTimerIntent);
}
@Override
if (isFinishing() && discardEntry==false) {
savePassword();
}
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
}
@Override
if (debug) Log.d(TAG,"onResume()");
- if (CategoryList.isSignedIn()==false) {
-// if (Passwords.isCryptoInitialized()) {
-// saveState();
-// }
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
-
Passwords.Initialize(this);
populateFields();
}
}
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
import java.security.SecureRandom;
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
-import android.app.Activity;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.util.Log;
*
* @author Steven Osborn - http://steven.bitsetters.com
*/
-public class PassGen extends Activity {
+public class PassGen extends FrontDooringActivity {
private static boolean debug = false;
private static String TAG = "PassGen";
Button copy_entry;
Button cancel;
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
private final OnClickListener update_click = new OnClickListener() {
public void onClick(View v) {
genPassword();
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
setContentView(R.layout.pass_gen);
String title = getString(R.string.app_name) + " - " +
}
- @Override
- protected void onPause() {
- super.onPause();
-
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- if (debug) Log.d(TAG,"IllegalArgumentException");
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
return false;
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
Intent frontdoor;
private Intent restartTimerIntent=null;
- private static String salt;
- private static String masterKey;
-
private Thread fillerThread=null;
private List<PassEntry> rows=null;
if (debug) Log.d(TAG,"onResume()");
- if (CategoryList.isSignedIn()==false) {
+ if (RuntimeSecrets.isSignedIn()==false) {
startActivity(frontdoor);
return;
}
return super.onCreateOptionsMenu(menu);
}
- static void setSalt(String saltIn) {
- salt = saltIn;
- }
-
- static String getSalt() {
- return salt;
- }
-
- static void setMasterKey(String key) {
- masterKey = key;
- }
-
- static String getMasterKey() {
- return masterKey;
- }
-
private void addPassword() {
Intent i = new Intent(this, PassEdit.class);
i.putExtra(PassList.KEY_ID, (long)-1);
if (debug) Log.d(TAG,"onUserInteraction()");
- if (CategoryList.isSignedIn()==false) {
+ if (RuntimeSecrets.isSignedIn()==false) {
// startActivity(frontdoor);
}else{
if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
import java.util.ArrayList;
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
*
* @author Randy McEoin
*/
-public class PassView extends Activity implements View.OnClickListener {
+public class PassView extends FrontDooringActivity
+ implements View.OnClickListener {
private static boolean debug = false;
private static String TAG = "PassView";
private Long CategoryId;
public static boolean entryEdited=false;
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (debug) Log.d(TAG,"onCreate("+icicle+")");
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
String title = getResources().getString(R.string.app_name) + " - "
+ getResources().getString(R.string.view_entry);
setTitle(title);
outState.putLong(PassList.KEY_CATEGORY_ID, CategoryId);
}
- @Override
- protected void onPause() {
- super.onPause();
-
- if (debug) Log.d(TAG,"onResume()");
-
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
- }
-
@Override
protected void onResume() {
super.onResume();
if (debug) Log.d(TAG,"onResume()");
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
-
Passwords.Initialize(this);
populateFields();
ClipboardManager cb = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
cb.setText(value);
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
if (ch==null) {
ch = new CryptoHelper();
}
- if ((cryptoInitialized==false) &&
- (CategoryList.getSalt()!=null) &&
- (CategoryList.getMasterKey()!=null))
+ if ((cryptoInitialized==false) && RuntimeSecrets.isSignedIn())
{
try {
Passwords.InitCrypto(CryptoHelper.EncryptionMedium,
- CategoryList.getSalt(), CategoryList.getMasterKey());
+ RuntimeSecrets.getSalt(),
+ RuntimeSecrets.getMasterKey());
cryptoInitialized=true;
} catch (Exception e) {
e.printStackTrace();
protected void onResume() {
super.onResume();
- if (CategoryList.isSignedIn()==false) {
+ if (RuntimeSecrets.isSignedIn()==false) {
startActivity(frontdoor);
return;
}
if (debug) Log.d(TAG,"onUserInteraction()");
- if (CategoryList.isSignedIn()==false) {
+ if (RuntimeSecrets.isSignedIn()==false) {
// startActivity(frontdoor);
}else{
if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
import java.io.FileReader;
import java.io.IOException;
+import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringActivity;
+
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.openintents.intents.CryptoIntents;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import android.widget.TextView;
import android.widget.Toast;
-public class Restore extends Activity {
+public class Restore extends FrontDooringActivity {
private static boolean debug = false;
private static final String TAG = "Restore";
public static final String KEY_FIRST_TIME = "first_time"; // Intent keys
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
firstTime = extras != null ? extras.getBoolean(Restore.KEY_FIRST_TIME) : false;
}
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
Passwords.Initialize(this);
setContentView(R.layout.restore);
setTitle(title);
if (filename==null) {
- filename=CategoryList.BACKUP_FILENAME;
+ filename=Constants.BACKUP_FILENAME;
}
TextView filenameText;
filenameText = (TextView) findViewById(R.id.restore_filename);
});
}
- @Override
- protected void onPause() {
- super.onPause();
-
- try {
- unregisterReceiver(mIntentReceiver);
- } catch (IllegalArgumentException e) {
- //if (debug) Log.d(TAG,"IllegalArgumentException");
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- if (debug) Log.d(TAG,"onResume()");
-
- if ((!firstTime) && (CategoryList.isSignedIn()==false)) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
- }
-
private boolean backupFileExists(String filename) {
FileReader fr;
try {
dbHelper.storeSalt(restoreDataSet.getSalt());
dbHelper.storeMasterKey(restoreDataSet.getMasterKeyEncrypted());
- CategoryList.setSalt(restoreDataSet.getSalt());
- PassList.setSalt(restoreDataSet.getSalt());
- CategoryList.setMasterKey(masterKey);
- PassList.setMasterKey(masterKey);
+ RuntimeSecrets.setSalt(restoreDataSet.getSalt());
+ RuntimeSecrets.setMasterKey(masterKey);
for (CategoryEntry category : restoreDataSet.getCategories()) {
if (debug) Log.d(TAG,"category="+category.name);
dbHelper.addCategory(category);
setResult(RESULT_OK);
finish();
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
--- /dev/null
+/* A new central holding place for runtime secrets of the safe */
+
+package org.openintents.safe;
+
+import android.util.Log;
+
+public class RuntimeSecrets {
+
+ private static final boolean debug = false;
+ private static final String TAG = "RuntimeSecrets";
+
+ private static String salt;
+ static void setSalt(String saltIn) {
+ salt = saltIn;
+ }
+ static String getSalt() {
+ return salt;
+ }
+
+ private static String masterKey;
+ static void setMasterKey(String key) {
+ masterKey = key;
+ }
+
+ static String getMasterKey() {
+ return masterKey;
+ }
+
+ /**
+ * Returns the current status of signedIn.
+ *
+ * @return True if signed in
+ */
+ public static boolean isSignedIn() {
+ if ((salt != null) && (masterKey != null)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Sets signedIn status to false.
+ *
+ * @see org.openintents.safe.CategoryList#isSignedIn
+ */
+ public static void setSignedOut() {
+ if (debug) Log.d(TAG,"setSignedOut()");
+ masterKey=null;
+ }
+}
import java.util.List;
import org.openintents.intents.CryptoIntents;
+import org.openintents.util.FrontDooringListActivity;
import android.app.Dialog;
-import android.app.ListActivity;
import android.app.ProgressDialog;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.widget.TextView;
import android.widget.Toast;
-public class Search extends ListActivity {
+public class Search extends FrontDooringListActivity {
private static final String TAG = "Search";
private static boolean debug = false;
private List<PassEntry> results=null;
private ArrayAdapter<String> entries=null;
- Intent frontdoor;
- private Intent restartTimerIntent=null;
-
public Handler myViewUpdateHandler = new Handler(){
// @Override
public void handleMessage(Message msg) {
}
};
- BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
- if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
- startActivity(frontdoor);
- }
- }
- };
-
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getResources().getString(R.string.search);
setTitle(title);
- frontdoor = new Intent(this, Safe.class);
- frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
- restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
-
etSearchCriteria = (EditText) findViewById(R.id.search_criteria);
results=new ArrayList<PassEntry>();
if (debug) Log.d(TAG,"onResume()");
- if (CategoryList.isSignedIn()==false) {
- startActivity(frontdoor);
- return;
- }
- IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
- registerReceiver(mIntentReceiver, filter);
-
Passwords.Initialize(this);
}
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
passDescriptions);
}
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
-
- if (debug) Log.d(TAG,"onUserInteraction()");
-
- if (CategoryList.isSignedIn()==false) {
-// startActivity(frontdoor);
- }else{
- if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
- }
- }
}
// if there are still clients attached. Should be fixed.
import org.openintents.intents.CryptoIntents;
-import org.openintents.safe.CategoryList;
import org.openintents.safe.CryptoHelper;
import org.openintents.safe.CryptoHelperException;
+import org.openintents.safe.RuntimeSecrets;
import android.app.Service;
ch = null;
ServiceNotification.clearNotification(ServiceDispatchImpl.this);
- CategoryList.setSignedOut();
+ RuntimeSecrets.setSignedOut();
Intent intent = new Intent(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
sendBroadcast(intent);
}
--- /dev/null
+/* Since just about everybody does this dance, we move it out to its own place */
+package org.openintents.util;
+
+import org.openintents.intents.CryptoIntents;
+import org.openintents.safe.RuntimeSecrets;
+import org.openintents.safe.Safe;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.util.Log;
+
+public class FrontDooringActivity extends Activity {
+
+ private static boolean debug = false; // nonfinal for inheritance
+ private static String TAG = "FrontDooringActivity"; // ditto
+
+ private Intent frontdoor;
+ protected Intent restartTimerIntent=null;
+
+ protected BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ if (RuntimeSecrets.isSignedIn()==false) {
+ startActivity(frontdoor);
+ return;
+ }
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
+ }
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (!RuntimeSecrets.isSignedIn()==false) {
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
+
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ frontdoor = new Intent(this, Safe.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+
+ sendBroadcast (restartTimerIntent);
+ }
+}
--- /dev/null
+/* Since just about everybody does this dance, we move it out to its own place */
+package org.openintents.util;
+
+import org.openintents.intents.CryptoIntents;
+import org.openintents.safe.RuntimeSecrets;
+import org.openintents.safe.Safe;
+
+import android.app.ListActivity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.util.Log;
+
+public class FrontDooringListActivity extends ListActivity {
+
+ private static boolean debug = false; // nonfinal for inheritance
+ private static String TAG = "FrontDooringActivity"; // ditto
+
+ private Intent frontdoor;
+ protected Intent restartTimerIntent=null;
+
+ protected BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT)) {
+ if (debug) Log.d(TAG,"caught ACTION_CRYPTO_LOGGED_OUT");
+ startActivity(frontdoor);
+ }
+ }
+ };
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ if (RuntimeSecrets.isSignedIn()==false) {
+ startActivity(frontdoor);
+ return;
+ }
+ IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
+ registerReceiver(mIntentReceiver, filter);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ try {
+ unregisterReceiver(mIntentReceiver);
+ } catch (IllegalArgumentException e) {
+ if (debug) Log.d(TAG,"IllegalArgumentException");
+ }
+ }
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ if (debug) Log.d(TAG,"onUserInteraction()");
+
+ if (!RuntimeSecrets.isSignedIn()==false) {
+ if (restartTimerIntent!=null) sendBroadcast (restartTimerIntent);
+ }
+ }
+
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ frontdoor = new Intent(this, Safe.class);
+ frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK);
+ restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
+
+ sendBroadcast (restartTimerIntent);
+ }
+}