Skip to content

Commit

Permalink
fix insecure password in configuration page
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Bogomolov authored and Konstantin Bogomolov committed Feb 17, 2018
1 parent 0a9258a commit 9055510
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private Authenticator getAuthenticator(final MailAccount acc) {

@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(acc.getSmtpUsername(), acc.getSmtpPassword());
return new PasswordAuthentication(acc.getSmtpUsername(), Secret.toString(acc.getSmtpPassword()));
}
};
}
Expand All @@ -314,29 +314,29 @@ public void setSmtpServer(String smtpServer) {
mailAccount.setSmtpHost(smtpServer);
}

public String getSmtpAuthUsername() {
public String getSmtpUsername() {
return mailAccount.getSmtpUsername();
}

@SuppressWarnings("unused")
public void setSmtpAuthUsername(String username) {
public void setSmtpUsername(String username) {
mailAccount.setSmtpUsername(username);
}

public String getSmtpAuthPassword() {
public Secret getSmtpPassword() {
return mailAccount.getSmtpPassword();
}

@SuppressWarnings("unused")
public void setSmtpAuthPassword(String password) {
public void setSmtpPassword(String password) {
mailAccount.setSmtpPassword(password);
}

// Make API match Mailer plugin
@SuppressWarnings("unused")
public void setSmtpAuth(String userName, String password) {
setSmtpAuthUsername(userName);
setSmtpAuthPassword(password);
setSmtpUsername(userName);
setSmtpPassword(password);
}

public boolean getUseSsl() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/emailext/MailAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public String getSmtpUsername(){
return smtpUsername;
}

public String getSmtpPassword(){
return Secret.toString(smtpPassword);
public Secret getSmtpPassword(){
return smtpPassword;
}

public boolean isUseSsl(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ f.section(title: _("Extended E-mail Notification")) {
}
f.advanced() {
f.optionalBlock(help: "/help/tasks/mailer/smtpAuth.html", checked: descriptor.mailAccount.smtpUsername!=null, name: "ext_mailer_use_smtp_auth", title: _("Use SMTP Authentication")) {
f.entry(title: _("User Name")) {
input(type: "text", class: "setting-input", value: descriptor.mailAccount.smtpUsername, name: "ext_mailer_smtp_username")
f.entry(field: "smtpUsername", title: _("User Name")) {
f.textbox(name: "ext_mailer_smtp_username")
}
f.entry(title: _("Password")) {
input(type: "password", class: "setting-input", value: descriptor.mailAccount.smtpPassword, name: "ext_mailer_smtp_password")
f.entry(field: "smtpPassword", title: _("Password")) {
f.password(name: "ext_mailer_smtp_password")
}
}
f.entry(title: _("Advanced Email Properties")) {
Expand Down

0 comments on commit 9055510

Please sign in to comment.