Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
BZ 1070242 make sure to not remember if user tells us not to remember
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed Apr 5, 2014
1 parent 9559e6d commit ba82409
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ public void overlay(AgentInstall overlay) {
this.sshPort = overlay.sshPort;
}
if (overlay.sshUsername != null) {
this.sshUsername = overlay.sshUsername;
// to force usename to be nulled out, caller will pass in an empty string - that signals us to null out username
this.sshUsername = (overlay.sshUsername.length() == 0) ? null : overlay.sshUsername;
}
if (overlay.sshPassword != null) {
this.sshPassword = overlay.sshPassword;
// to force password to be nulled out, caller will pass in an empty string - that signals us to null out password
this.sshPassword = (overlay.sshPassword.length() == 0) ? null : overlay.sshPassword;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent cl
username.setValue(initialAgentInstall.getSshUsername());
password.setValue(initialAgentInstall.getSshPassword());
agentInstallPath.setValue(initialAgentInstall.getInstallLocation());
rememberMeCheckbox.setValue(initialAgentInstall.getSshPassword() != null); // if it was already saved, assume they want it to stay remembered
}

connectionForm.setFields(host, port, username, password, rememberMeCheckbox, agentInstallPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,25 @@ public AgentInstall updateAgentInstall(Subject user, AgentInstall agentInstall)

private void obfuscateAgentInstall(AgentInstall ai) {
try {
ai.setSshPassword(Obfuscator.encode(ai.getSshPassword()));
String pw = ai.getSshPassword();
if (pw != null && pw.length() > 0) {
ai.setSshPassword(Obfuscator.encode(pw));
}
} catch (Exception e) {
ai.setSshPassword(null);
LOG.debug("Failed to obfuscate password for agent [" + ai.getAgentName() + "]. Will be set to null");
ai.setSshPassword("");
LOG.debug("Failed to obfuscate password for agent [" + ai.getAgentName() + "]. Will be emptied.");
}
}

private void deobfuscateAgentInstall(AgentInstall ai) {
try {
ai.setSshPassword(Obfuscator.decode(ai.getSshPassword()));
String pw = ai.getSshPassword();
if (pw != null && pw.length() > 0) {
ai.setSshPassword(Obfuscator.decode(pw));
}
} catch (Exception e) {
ai.setSshPassword(null);
LOG.debug("Failed to deobfuscate password for agent [" + ai.getAgentName() + "]. Will be set to null");
ai.setSshPassword("");
LOG.debug("Failed to deobfuscate password for agent [" + ai.getAgentName() + "]. Will be emptied.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ private void processRememberMe(Subject subject, SSHInstallUtility sshSession) {
ai.setSshUsername(remoteAccessInfo.getUser());
ai.setSshPassword(remoteAccessInfo.getPassword());
} else {
// user doesn't want to remember the creds, null them out
ai.setSshUsername(null);
ai.setSshPassword(null);
// user doesn't want to remember the creds, set them to "" which tells our persistence layer to null them out
ai.setSshUsername("");
ai.setSshPassword("");
}

try {
Expand Down

0 comments on commit ba82409

Please sign in to comment.