Skip to content

Commit

Permalink
Only decrypt if security file exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jan 5, 2024
1 parent 3abfbb6 commit 2cc2bc6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/IKVM.Maven.Sdk.Tasks/MavenEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,20 @@ Settings ReadSettings()
var settings = settingsResult.getEffectiveSettings();

// use settings-security.xml to decrypt loaded settings
var secDispatcher = new SecDispatcher(Path.Combine(userHome, SettingsSecurityXml));
var secDecrypter = new DefaultSettingsDecrypter(secDispatcher);
var secResult = secDecrypter.decrypt(new DefaultSettingsDecryptionRequest(settings));
if (secResult.getProblems() is List secProblems)
foreach (var i in secProblems.AsEnumerable<SettingsProblem>())
HandleSettingsProblem(i);

// apply decrypted settings
settings.setServers(secResult.getServers());
settings.setProxies(secResult.getProxies());
var securityFile = Path.Combine(userHome, SettingsSecurityXml);
if (System.IO.File.Exists(securityFile))
{
var secDispatcher = new SecDispatcher(securityFile);
var secDecrypter = new DefaultSettingsDecrypter(secDispatcher);
var secResult = secDecrypter.decrypt(new DefaultSettingsDecryptionRequest(settings));
if (secResult.getProblems() is List secProblems)
foreach (var i in secProblems.AsEnumerable<SettingsProblem>())
HandleSettingsProblem(i);

// apply decrypted settings
settings.setServers(secResult.getServers());
settings.setProxies(secResult.getProxies());
}

return settings;
}
Expand Down

0 comments on commit 2cc2bc6

Please sign in to comment.