mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-01-11 05:28:34 -05:00
challenge secret can be entered (using OTP UI)
message when Yubichallenge is not installed
This commit is contained in:
parent
5cf8b8450d
commit
ba82a0a216
@ -62,7 +62,7 @@ namespace keepass2android
|
|||||||
KeyFile = 1,
|
KeyFile = 1,
|
||||||
Otp = 2,
|
Otp = 2,
|
||||||
OtpRecovery = 3,
|
OtpRecovery = 3,
|
||||||
Chal = 4,
|
Challenge = 4,
|
||||||
ChalRecovery = 5
|
ChalRecovery = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ namespace keepass2android
|
|||||||
if (_keyFileOrProvider == KeyProviderIdOtpRecovery)
|
if (_keyFileOrProvider == KeyProviderIdOtpRecovery)
|
||||||
return KeyProviders.OtpRecovery;
|
return KeyProviders.OtpRecovery;
|
||||||
if (_keyFileOrProvider == KeyProviderIdChallenge)
|
if (_keyFileOrProvider == KeyProviderIdChallenge)
|
||||||
return KeyProviders.Chal;
|
return KeyProviders.Challenge;
|
||||||
if (_keyFileOrProvider == KeyProviderIdChallengeRecovery)
|
if (_keyFileOrProvider == KeyProviderIdChallengeRecovery)
|
||||||
return KeyProviders.ChalRecovery;
|
return KeyProviders.ChalRecovery;
|
||||||
return KeyProviders.KeyFile;
|
return KeyProviders.KeyFile;
|
||||||
@ -299,6 +299,8 @@ namespace keepass2android
|
|||||||
byte[] challengeResponse = data.GetByteArrayExtra("response");
|
byte[] challengeResponse = data.GetByteArrayExtra("response");
|
||||||
_challengeSecret = KeeChallengeProv.GetSecret(_chalInfo, challengeResponse);
|
_challengeSecret = KeeChallengeProv.GetSecret(_chalInfo, challengeResponse);
|
||||||
UpdateOkButtonState();
|
UpdateOkButtonState();
|
||||||
|
FindViewById(Resource.Id.otpInitView).Visibility = ViewStates.Gone;
|
||||||
|
|
||||||
if (_challengeSecret != null)
|
if (_challengeSecret != null)
|
||||||
{
|
{
|
||||||
new LoadingDialog<object, object, object>(this, true,
|
new LoadingDialog<object, object, object>(this, true,
|
||||||
@ -425,7 +427,13 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO message no plugin!
|
AlertDialog.Builder b = new AlertDialog.Builder(this);
|
||||||
|
b.SetMessage(Resource.String.YubiChallengeNotInstalled);
|
||||||
|
b.SetPositiveButton(Resource.String.ok, delegate {
|
||||||
|
Util.GotoUrl(this, GetString(Resource.String.MarketURL) + "com.yubichallenge");
|
||||||
|
});
|
||||||
|
b.SetNegativeButton(Resource.String.cancel, delegate { });
|
||||||
|
b.Create().Show();
|
||||||
}
|
}
|
||||||
}).Execute();
|
}).Execute();
|
||||||
|
|
||||||
@ -814,14 +822,12 @@ namespace keepass2android
|
|||||||
FindViewById(Resource.Id.pass_ok).Enabled = enabled;
|
FindViewById(Resource.Id.pass_ok).Enabled = enabled;
|
||||||
break;
|
break;
|
||||||
case KeyProviders.OtpRecovery:
|
case KeyProviders.OtpRecovery:
|
||||||
FindViewById(Resource.Id.pass_ok).Enabled = FindViewById<EditText>(Resource.Id.pass_otpsecret).Text != "" && _password != "";
|
case KeyProviders.ChalRecovery:
|
||||||
|
FindViewById(Resource.Id.pass_ok).Enabled = FindViewById<EditText>(Resource.Id.pass_otpsecret).Text != "";
|
||||||
break;
|
break;
|
||||||
case KeyProviders.Chal:
|
case KeyProviders.Challenge:
|
||||||
FindViewById(Resource.Id.pass_ok).Enabled = _challengeSecret != null;
|
FindViewById(Resource.Id.pass_ok).Enabled = _challengeSecret != null;
|
||||||
break;
|
break;
|
||||||
case KeyProviders.ChalRecovery:
|
|
||||||
FindViewById(Resource.Id.pass_ok).Enabled = true;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
@ -836,7 +842,7 @@ namespace keepass2android
|
|||||||
? ViewStates.Visible
|
? ViewStates.Visible
|
||||||
: ViewStates.Gone;
|
: ViewStates.Gone;
|
||||||
|
|
||||||
FindViewById(Resource.Id.otpSecretLine).Visibility = KeyProviderType == KeyProviders.OtpRecovery
|
FindViewById(Resource.Id.otpSecretLine).Visibility = (KeyProviderType == KeyProviders.OtpRecovery || KeyProviderType == KeyProviders.ChalRecovery)
|
||||||
? ViewStates.Visible
|
? ViewStates.Visible
|
||||||
: ViewStates.Gone;
|
: ViewStates.Gone;
|
||||||
if (KeyProviderType == KeyProviders.Otp)
|
if (KeyProviderType == KeyProviders.Otp)
|
||||||
@ -844,7 +850,7 @@ namespace keepass2android
|
|||||||
FindViewById(Resource.Id.otps_pending).Visibility = _pendingOtps.Count > 0 ? ViewStates.Visible : ViewStates.Gone;
|
FindViewById(Resource.Id.otps_pending).Visibility = _pendingOtps.Count > 0 ? ViewStates.Visible : ViewStates.Gone;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyProviderType == KeyProviders.Chal)
|
if (KeyProviderType == KeyProviders.Challenge)
|
||||||
{
|
{
|
||||||
FindViewById (Resource.Id.otpView).Visibility = ViewStates.Visible;
|
FindViewById (Resource.Id.otpView).Visibility = ViewStates.Visible;
|
||||||
FindViewById(Resource.Id.otps_pending).Visibility = ViewStates.Gone;
|
FindViewById(Resource.Id.otps_pending).Visibility = ViewStates.Gone;
|
||||||
@ -888,7 +894,7 @@ namespace keepass2android
|
|||||||
}
|
}
|
||||||
compositeKey.AddUserKey(new KcpCustomKey(OathHotpKeyProv.Name, _otpInfo.Secret, true));
|
compositeKey.AddUserKey(new KcpCustomKey(OathHotpKeyProv.Name, _otpInfo.Secret, true));
|
||||||
}
|
}
|
||||||
else if (KeyProviderType == KeyProviders.OtpRecovery)
|
else if ((KeyProviderType == KeyProviders.OtpRecovery) || (KeyProviderType == KeyProviders.ChalRecovery))
|
||||||
{
|
{
|
||||||
Spinner stpDataFmtSpinner = FindViewById<Spinner>(Resource.Id.otpsecret_format_spinner);
|
Spinner stpDataFmtSpinner = FindViewById<Spinner>(Resource.Id.otpsecret_format_spinner);
|
||||||
EditText secretEdit = FindViewById<EditText>(Resource.Id.pass_otpsecret);
|
EditText secretEdit = FindViewById<EditText>(Resource.Id.pass_otpsecret);
|
||||||
@ -904,7 +910,7 @@ namespace keepass2android
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (KeyProviderType == KeyProviders.Chal)
|
else if (KeyProviderType == KeyProviders.Challenge)
|
||||||
{
|
{
|
||||||
compositeKey.AddUserKey(new KcpCustomKey(KeeChallengeProv.Name, _challengeSecret, true));
|
compositeKey.AddUserKey(new KcpCustomKey(KeeChallengeProv.Name, _challengeSecret, true));
|
||||||
|
|
||||||
@ -1142,6 +1148,11 @@ namespace keepass2android
|
|||||||
|
|
||||||
UpdateOkButtonState();
|
UpdateOkButtonState();
|
||||||
|
|
||||||
|
if (KeyProviderType == KeyProviders.Challenge)
|
||||||
|
{
|
||||||
|
FindViewById(Resource.Id.otpInitView).Visibility = _challengeSecret == null ? ViewStates.Visible : ViewStates.Gone;
|
||||||
|
}
|
||||||
|
|
||||||
// OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must
|
// OnResume is run every time the activity comes to the foreground. This code should only run when the activity is started (OnStart), but must
|
||||||
// be run in OnResume rather than OnStart so that it always occurrs after OnActivityResult (when re-creating a killed activity, OnStart occurs before OnActivityResult)
|
// be run in OnResume rather than OnStart so that it always occurrs after OnActivityResult (when re-creating a killed activity, OnStart occurs before OnActivityResult)
|
||||||
//use !IsFinishing to make sure we're not starting another activity when we're already finishing (e.g. due to TaskComplete in OnActivityResult)
|
//use !IsFinishing to make sure we're not starting another activity when we're already finishing (e.g. due to TaskComplete in OnActivityResult)
|
||||||
@ -1300,8 +1311,12 @@ namespace keepass2android
|
|||||||
{
|
{
|
||||||
SetEditText(otpId, "");
|
SetEditText(otpId, "");
|
||||||
}
|
}
|
||||||
Array.Clear(_challengeSecret, 0, _challengeSecret.Length);
|
if (_challengeSecret != null)
|
||||||
_challengeSecret = null;
|
{
|
||||||
|
Array.Clear(_challengeSecret, 0, _challengeSecret.Length);
|
||||||
|
_challengeSecret = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveOtpAuxFileAndLoadDb : LoadDb
|
class SaveOtpAuxFileAndLoadDb : LoadDb
|
||||||
|
Loading…
Reference in New Issue
Block a user