Skip to content
Permalink
Browse files

Save password scrambled [JENKINS-13706]

  • Loading branch information
kutzi committed Jun 3, 2012
1 parent 045b28e commit d1515ae837d00be74e97882e10dfcbd6077f1b83
Showing with 21 additions and 7 deletions.
  1. +1 −1 pom.xml
  2. +20 −6 src/main/java/hudson/plugins/jabber/im/transport/JabberPublisherDescriptor.java
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>instant-messaging-parent</artifactId>
<version>1.19</version>
<version>1.20-SNAPSHOT</version>
<relativePath>../instant-messaging-parent-plugin/pom.xml</relativePath>
</parent>

@@ -19,6 +19,7 @@
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import hudson.util.FormValidation;
import hudson.util.Scrambler;

import java.io.IOException;
import java.net.InetAddress;
@@ -108,6 +109,12 @@
private boolean exposePresence = true;
private boolean enableSASL = true;

/**
* Marks if passwords are scrambled as they are since 1.23.
* Needed to migrate old, unscrambled passwords.
*/
private boolean scrambledPasswords = false;

/**
* @deprecated replaced by {@link #defaultTargets}
* Still needed to deserialize old descriptors
@@ -205,13 +212,15 @@ private void applyNickname(final HttpServletRequest req, boolean check) throws F

private void applyPassword(final HttpServletRequest req, boolean check) throws FormException
{
this.hudsonPassword = req.getParameter(PARAMETERNAME_PASSWORD);
this.scrambledPasswords = true;
String password = req.getParameter(PARAMETERNAME_PASSWORD);
if (check) {
if (((this.hostname != null) && (this.hudsonPassword == null))
|| (this.hudsonPassword.trim().length() == 0)) {
if ((this.hostname != null)
&& ((password == null) || (password.trim().length() == 0))) {
throw new FormException("Password cannot be empty.", PARAMETERNAME_PASSWORD);
}
}
this.hudsonPassword = Scrambler.scramble(password);
}

private void applyGroupChatNickname(final HttpServletRequest req) throws FormException
@@ -411,9 +420,8 @@ public String getJabberId()
}

@Override
public String getPassword()
{
return this.hudsonPassword;
public String getPassword() {
return Scrambler.descramble(this.hudsonPassword);
}

public String getGroupChatNickname()
@@ -793,6 +801,12 @@ private Object readResolve() {
save();
}

if (!this.scrambledPasswords) {
this.hudsonPassword = Scrambler.scramble(this.hudsonPassword);
this.scrambledPasswords = true;
save();
}

return this;
}

0 comments on commit d1515ae

Please sign in to comment.