-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from Yubico/release/1.0.1
Bug fix release: 1.0.1
- Loading branch information
Showing
24 changed files
with
567 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ public OathMainMenuItem RunMenuItem(OathMainMenuItem menuItem) | |
// If there are no YubiKeys, this will return false. In that | ||
// case, we don't want to exit, we just want to report the | ||
// result and run through the main menu again. | ||
_ = ChooseYubiKey.RunChooseYubiKey(true, _menuObject, Transport.SmartCard, out _yubiKeyChosen); | ||
_ = ChooseYubiKey.RunChooseYubiKey(true, _menuObject, Transport.SmartCard, ref _yubiKeyChosen); | ||
break; | ||
|
||
case OathMainMenuItem.GetOathCredentials: | ||
|
@@ -78,10 +78,7 @@ public OathMainMenuItem RunMenuItem(OathMainMenuItem menuItem) | |
|
||
case OathMainMenuItem.RenameOathCredential: | ||
_ = ChooseCredential.RunChooseAction(_menuObject, out _optionIndex, "rename"); | ||
isValid = RenameCredential.RunRenameCredential( | ||
_yubiKeyChosen, | ||
SampleKeyCollector.SampleKeyCollectorDelegate, | ||
_optionIndex != 0 ? null : _menuObject); | ||
isValid = RunRenameCredentialMenuItem(_optionIndex); | ||
break; | ||
|
||
case OathMainMenuItem.RemoveOathCredential: | ||
|
@@ -212,5 +209,72 @@ private bool RunCalculateCredentialMenuItem(int? index) | |
_credentialChosen, | ||
SampleKeyCollector.SampleKeyCollectorDelegate); | ||
} | ||
|
||
private bool RunRenameCredentialMenuItem(int? index) | ||
{ | ||
if (index != 0) | ||
{ | ||
_ = ChooseCredential.RunChooseCredential( | ||
_yubiKeyChosen, | ||
true, | ||
_menuObject, | ||
out _credentialChosen); | ||
|
||
return RenameCredential.RunRenameCredential( | ||
_yubiKeyChosen, | ||
SampleKeyCollector.SampleKeyCollectorDelegate, | ||
_credentialChosen, | ||
"Yubico", | ||
"[email protected]"); | ||
} | ||
else | ||
{ | ||
RunCollectCredential(_menuObject, | ||
out Credential credential, | ||
out string newIssuer, | ||
out string newAccount); | ||
|
||
return RenameCredential.RunRenameCredential( | ||
_yubiKeyChosen, | ||
SampleKeyCollector.SampleKeyCollectorDelegate, | ||
credential, | ||
newIssuer, | ||
newAccount); | ||
} | ||
} | ||
|
||
// Collect a credential. | ||
private static void RunCollectCredential( | ||
SampleMenu menuObject, | ||
out Credential credential, | ||
out string newIssuer, | ||
out string newAccount) | ||
{ | ||
SampleMenu.WriteMessage(MessageType.Title, 0, "Enter current issuer"); | ||
_ = SampleMenu.ReadResponse(out string currentIssuer); | ||
|
||
SampleMenu.WriteMessage(MessageType.Title, 0, "Enter current account name"); | ||
_ = SampleMenu.ReadResponse(out string currentAccount); | ||
|
||
_ = ChooseCredentialProperties.RunChooseTypeOption(menuObject, out CredentialType? type); | ||
|
||
CredentialPeriod period = CredentialPeriod.Undefined; | ||
|
||
if (type == CredentialType.Totp) | ||
{ | ||
_ = ChooseCredentialProperties.RunChoosePeriodOption(menuObject, out CredentialPeriod? credentialPeriod); | ||
period = credentialPeriod.Value; | ||
} | ||
|
||
SampleMenu.WriteMessage(MessageType.Title, 0, "Enter new issuer"); | ||
_ = SampleMenu.ReadResponse(out string issuer); | ||
|
||
SampleMenu.WriteMessage(MessageType.Title, 0, "Enter new account name"); | ||
_ = SampleMenu.ReadResponse(out string account); | ||
|
||
newIssuer = issuer; | ||
newAccount = account; | ||
credential = new Credential(currentIssuer, currentAccount, type.Value, period); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,50 +28,30 @@ public static class RenameCredential | |
public static bool RunRenameCredential( | ||
IYubiKeyDevice yubiKey, | ||
Func<KeyEntryData, bool> KeyCollectorDelegate, | ||
SampleMenu menuObject) | ||
Credential credential, | ||
string newIssuer, | ||
string newAccount) | ||
{ | ||
if (credential is null) | ||
{ | ||
throw new ArgumentNullException(nameof(credential)); | ||
} | ||
|
||
using var oathSession = new OathSession(yubiKey); | ||
{ | ||
oathSession.KeyCollector = KeyCollectorDelegate; | ||
|
||
if (menuObject is null) | ||
{ | ||
_ = ChooseCredential.RunChooseCredential( | ||
yubiKey, | ||
true, | ||
menuObject, | ||
out Credential credential); | ||
|
||
Credential renamedCredential = oathSession.RenameCredential( | ||
credential.Issuer, | ||
credential.AccountName, | ||
"Yubico", | ||
"[email protected]", | ||
credential.Type.Value, | ||
credential.Period.Value); | ||
|
||
ReportResult(renamedCredential); | ||
} | ||
else | ||
{ | ||
RunCollectCredential( | ||
menuObject, | ||
out Credential credential, | ||
out string newIssuer, | ||
out string newAccount); | ||
|
||
Credential renamedCredential = oathSession.RenameCredential( | ||
credential.Issuer, | ||
credential.AccountName, | ||
newIssuer, | ||
newAccount, | ||
credential.Type.Value, | ||
credential.Period.Value); | ||
|
||
ReportResult(renamedCredential); | ||
} | ||
} | ||
Credential renamedCredential = oathSession.RenameCredential( | ||
credential.Issuer, | ||
credential.AccountName, | ||
newIssuer, | ||
newAccount, | ||
credential.Type.Value, | ||
credential.Period.Value); | ||
|
||
ReportResult(renamedCredential); | ||
|
||
} | ||
return true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.