// Path: app/src/main/java/ca/alexland/renewpass/exceptions/DecryptionFailedException.java
// public class DecryptionFailedException extends Exception {
//     Exception originalException;
// 
//     public DecryptionFailedException(Exception originalException) {
//         this.originalException = originalException;
//     }
// 
//     public Exception getOriginalException() {
//         return originalException;
//     }
// }
// 
// Path: app/src/main/java/ca/alexland/renewpass/exceptions/EncryptionFailedException.java
// public class EncryptionFailedException extends Exception {
//     Exception originalException;
// 
//     public EncryptionFailedException(Exception originalException) {
//         this.originalException = originalException;
//     }
// 
//     public Exception getOriginalException() {
//         return originalException;
//     }
// }


import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.util.Calendar;
import ca.alexland.renewpass.exceptions.DecryptionFailedException;
import ca.alexland.renewpass.exceptions.EncryptionFailedException;
import ca.alexland.renewpass.R;
        return settings.getString(context.getString(R.string.preference_key_username), DEFAULT_VALUE_STRING);
    }

    public String getPassword() {
        String password = settings.getString(context.getString(R.string.preference_key_password), DEFAULT_VALUE_STRING);
        if (getKeysExist() && getPasswordExcrypted()) {
            try {
                password = keyStoreUtil.decryptPassword(password);
            } catch (DecryptionFailedException e) {
                // TODO: Deal with failure, possibly ask for credentials and fall back to unencrypted?
                LoggerUtil.appendLogWithStacktrace(context, "Password decryption failed: ", e.getOriginalException());
            }
        }
        return password;
    }

    public String getSchool() {
        return settings.getString(context.getString(R.string.preference_key_School), DEFAULT_VALUE_STRING);
    }

    public void setUsername(String username) {
        editor.putString(context.getString(R.string.preference_key_username), username);
        editor.commit();
    }

    public void setPassword(String password) {
        if (getKeysExist()) {
            try {
                password = keyStoreUtil.encryptPassword(password);
                setPasswordEncrypted(true);
// Path: app/src/main/java/ca/alexland/renewpass/exceptions/DecryptionFailedException.java
// public class DecryptionFailedException extends Exception {
//     Exception originalException;
// 
//     public DecryptionFailedException(Exception originalException) {
//         this.originalException = originalException;
//     }
// 
//     public Exception getOriginalException() {
//         return originalException;
//     }
// }
// 
// Path: app/src/main/java/ca/alexland/renewpass/exceptions/EncryptionFailedException.java
// public class EncryptionFailedException extends Exception {
//     Exception originalException;
// 
//     public EncryptionFailedException(Exception originalException) {
//         this.originalException = originalException;
//     }
// 
//     public Exception getOriginalException() {
//         return originalException;
//     }
// }


// Path: app/src/main/java/ca/alexland/renewpass/utils/PreferenceHelper.java
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.util.Calendar;
import ca.alexland.renewpass.exceptions.DecryptionFailedException;
import ca.alexland.renewpass.exceptions.EncryptionFailedException;
import ca.alexland.renewpass.R;

        return settings.getString(context.getString(R.string.preference_key_username), DEFAULT_VALUE_STRING);
    }

    public String getPassword() {
        String password = settings.getString(context.getString(R.string.preference_key_password), DEFAULT_VALUE_STRING);
        if (getKeysExist() && getPasswordExcrypted()) {
            try {
                password = keyStoreUtil.decryptPassword(password);
            } catch (DecryptionFailedException e) {
                // TODO: Deal with failure, possibly ask for credentials and fall back to unencrypted?
                LoggerUtil.appendLogWithStacktrace(context, "Password decryption failed: ", e.getOriginalException());
            }
        }
        return password;
    }

    public String getSchool() {
        return settings.getString(context.getString(R.string.preference_key_School), DEFAULT_VALUE_STRING);
    }

    public void setUsername(String username) {
        editor.putString(context.getString(R.string.preference_key_username), username);
        editor.commit();
    }

    public void setPassword(String password) {
        if (getKeysExist()) {
            try {
                password = keyStoreUtil.encryptPassword(password);
                setPasswordEncrypted(true);
            } catch (EncryptionFailedException e) {