mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
added support for proxy servers with authentication
This commit is contained in:
@@ -158,6 +158,8 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
this.enableProxy = other.enableProxy;
|
this.enableProxy = other.enableProxy;
|
||||||
this.proxyPort = other.proxyPort;
|
this.proxyPort = other.proxyPort;
|
||||||
this.proxyServer = other.proxyServer;
|
this.proxyServer = other.proxyServer;
|
||||||
|
this.proxyUser = other.proxyUser;
|
||||||
|
this.proxyPassword = other.proxyPassword;
|
||||||
this.forceBaseUrl = other.forceBaseUrl;
|
this.forceBaseUrl = other.forceBaseUrl;
|
||||||
this.baseUrl = other.baseUrl;
|
this.baseUrl = other.baseUrl;
|
||||||
|
|
||||||
@@ -259,6 +261,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
return pluginUrl;
|
return pluginUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
public String getProxyPassword()
|
||||||
|
{
|
||||||
|
return proxyPassword;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the proxy port.
|
* Returns the proxy port.
|
||||||
*
|
*
|
||||||
@@ -281,6 +295,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
return proxyServer;
|
return proxyServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
public String getProxyUser()
|
||||||
|
{
|
||||||
|
return proxyUser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the servername of the SCM-Manager host.
|
* Returns the servername of the SCM-Manager host.
|
||||||
*
|
*
|
||||||
@@ -496,6 +522,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
this.pluginUrl = pluginUrl;
|
this.pluginUrl = pluginUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param proxyPassword
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
public void setProxyPassword(String proxyPassword)
|
||||||
|
{
|
||||||
|
this.proxyPassword = proxyPassword;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -518,6 +556,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
this.proxyServer = proxyServer;
|
this.proxyServer = proxyServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param proxyUser
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
public void setProxyUser(String proxyUser)
|
||||||
|
{
|
||||||
|
this.proxyUser = proxyUser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -574,12 +624,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
@XmlElement(name = "plugin-url")
|
@XmlElement(name = "plugin-url")
|
||||||
private String pluginUrl = DEFAULT_PLUGINURL;
|
private String pluginUrl = DEFAULT_PLUGINURL;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String proxyPassword;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private int proxyPort = 8080;
|
private int proxyPort = 8080;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private String proxyServer = "proxy.mydomain.com";
|
private String proxyServer = "proxy.mydomain.com";
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String proxyUser;
|
||||||
|
|
||||||
/** @deprecated use {@link #baseUrl} */
|
/** @deprecated use {@link #baseUrl} */
|
||||||
private String servername = "localhost";
|
private String servername = "localhost";
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ import sonia.scm.util.Util;
|
|||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import com.sun.jersey.core.util.Base64;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
@@ -69,6 +71,9 @@ import java.util.Map;
|
|||||||
public class URLHttpClient implements HttpClient
|
public class URLHttpClient implements HttpClient
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
public static final String CREDENTIAL_SEPARATOR = ":";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String ENCODING = "UTF-8";
|
public static final String ENCODING = "UTF-8";
|
||||||
|
|
||||||
@@ -78,6 +83,9 @@ public class URLHttpClient implements HttpClient
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String HEADER_ACCEPT_ENCODING_VALUE = "gzip";
|
public static final String HEADER_ACCEPT_ENCODING_VALUE = "gzip";
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
public static final String HEADER_PROXY_AUTHORIZATION = "Proxy-Authorization";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String HEADER_USERAGENT = "User-Agent";
|
public static final String HEADER_USERAGENT = "User-Agent";
|
||||||
|
|
||||||
@@ -87,6 +95,9 @@ public class URLHttpClient implements HttpClient
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String METHOD_POST = "POST";
|
public static final String METHOD_POST = "POST";
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
public static final String PREFIX_BASIC_AUTHENTICATION = "Basic ";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final int TIMEOUT_CONNECTION = 30000;
|
public static final int TIMEOUT_CONNECTION = 30000;
|
||||||
|
|
||||||
@@ -353,6 +364,25 @@ public class URLHttpClient implements HttpClient
|
|||||||
connection.setRequestProperty(
|
connection.setRequestProperty(
|
||||||
HEADER_USERAGENT, HEADER_USERAGENT_VALUE.concat(context.getVersion()));
|
HEADER_USERAGENT, HEADER_USERAGENT_VALUE.concat(context.getVersion()));
|
||||||
|
|
||||||
|
String username = configuration.getProxyUser();
|
||||||
|
String password = configuration.getProxyPassword();
|
||||||
|
|
||||||
|
if (Util.isNotEmpty(username) || Util.isNotEmpty(password))
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("enable proxy authentication for user '{}'",
|
||||||
|
Util.nonNull(username));
|
||||||
|
}
|
||||||
|
|
||||||
|
String auth = Util.nonNull(username).concat(CREDENTIAL_SEPARATOR).concat(
|
||||||
|
Util.nonNull(password));
|
||||||
|
|
||||||
|
auth = PREFIX_BASIC_AUTHENTICATION.concat(
|
||||||
|
new String(Base64.encode(auth.getBytes())));
|
||||||
|
connection.setRequestProperty(HEADER_PROXY_AUTHORIZATION, auth);
|
||||||
|
}
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
check: function(){
|
check: function(){
|
||||||
Ext.getCmp('proxyServer').setDisabled( ! this.checked );
|
Ext.getCmp('proxyServer').setDisabled( ! this.checked );
|
||||||
Ext.getCmp('proxyPort').setDisabled( ! this.checked );
|
Ext.getCmp('proxyPort').setDisabled( ! this.checked );
|
||||||
|
Ext.getCmp('proxyUser').setDisabled( ! this.checked );
|
||||||
|
Ext.getCmp('proxyPassword').setDisabled( ! this.checked );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
@@ -143,6 +145,23 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
allowBlank: false,
|
allowBlank: false,
|
||||||
helpText: this.proxyPortHelpText
|
helpText: this.proxyPortHelpText
|
||||||
|
},{
|
||||||
|
id: 'proxyUser',
|
||||||
|
xtype: 'textfield',
|
||||||
|
fieldLabel: this.proxyUserText,
|
||||||
|
name: 'proxyUser',
|
||||||
|
disabled: true,
|
||||||
|
helpText: this.proxyUserHelpText,
|
||||||
|
allowBlank: true
|
||||||
|
},{
|
||||||
|
id: 'proxyPassword',
|
||||||
|
xtype: 'textfield',
|
||||||
|
inputType: 'password',
|
||||||
|
fieldLabel: this.proxyPasswordText,
|
||||||
|
name: 'proxyPassword',
|
||||||
|
disabled: true,
|
||||||
|
helpText: this.proxyPasswordHelpText,
|
||||||
|
allowBlank: true
|
||||||
},{
|
},{
|
||||||
xtype : 'textfield',
|
xtype : 'textfield',
|
||||||
fieldLabel : this.adminGroupsText,
|
fieldLabel : this.adminGroupsText,
|
||||||
|
|||||||
Reference in New Issue
Block a user