提交 c3eef5b5 编写于 作者: N Nicolas De loof

Merge pull request #130 from bap2000/master

Proxy password is encrypted in xml config file, and in the UI
......@@ -27,6 +27,7 @@ import hudson.model.Hudson;
import hudson.model.Saveable;
import hudson.model.listeners.SaveableListener;
import hudson.util.Scrambler;
import hudson.util.Secret;
import hudson.util.XStream2;
import java.io.File;
......@@ -59,10 +60,17 @@ public final class ProxyConfiguration implements Saveable {
public final int port;
/**
* Possibly null proxy user name and password.
* Password is base64 scrambled since this is persisted to disk.
* Possibly null proxy user name.
*/
private final String userName,password;
private final String userName;
/**
* null
*/
private String password;
/**
* encrypted password
*/
private Secret secretPassword;
public ProxyConfiguration(String name, int port) {
this(name,port,null,null);
......@@ -72,15 +80,24 @@ public final class ProxyConfiguration implements Saveable {
this.name = name;
this.port = port;
this.userName = userName;
this.password = Scrambler.scramble(password);
this.secretPassword = Secret.fromString(password);
}
public String getUserName() {
return userName;
}
// This method is public, if it was public only for jelly, then should make it private (or inline contents)
// Have left public, as can't tell if anyone else is using from plugins
/**
* @return the password in plain text
*/
public String getPassword() {
return Scrambler.descramble(password);
return Secret.toString(secretPassword);
}
public String getEncryptedPassword() {
return (secretPassword == null) ? null : secretPassword.getEncryptedValue();
}
public Proxy createProxy() {
......@@ -94,6 +111,13 @@ public final class ProxyConfiguration implements Saveable {
SaveableListener.fireOnChange(this, config);
}
public Object readResolve() {
if (secretPassword == null)
secretPassword = Secret.fromString(Scrambler.descramble(password));
password = null;
return this;
}
public static XmlFile getXmlFile() {
return new XmlFile(XSTREAM, new File(Hudson.getInstance().getRootDir(), "proxy.xml"));
}
......
......@@ -48,7 +48,7 @@ THE SOFTWARE.
<f:textbox name="proxy.userName" value="${app.proxy.userName}" />
</f:entry>
<f:entry title="${%Password}">
<f:password name="proxy.password" value="${app.proxy.password}" />
<f:password name="proxy.password" value="${app.proxy.encryptedPassword}" />
</f:entry>
<f:block>
<f:submit value="${%Submit}" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册