Class ProxyConfiguration
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<ProxyConfiguration>
-
- hudson.ProxyConfiguration
-
- All Implemented Interfaces:
Describable<ProxyConfiguration>
,Saveable
,Serializable
@StaplerAccessibleType public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfiguration> implements Saveable, Serializable
HTTP proxy configuration.Use
open(URL)
to open a connection with the proxy setting.Proxy authentication (including NTLM) is implemented by setting a default
Authenticator
which provides aPasswordAuthentication
(as described in the Java 8 tech note Http Authentication).- See Also:
Jenkins.proxy
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProxyConfiguration.DescriptorImpl
-
Constructor Summary
Constructors Constructor Description ProxyConfiguration(String name, int port)
ProxyConfiguration(String name, int port, String userName, String password)
ProxyConfiguration(String name, int port, String userName, String password, String noProxyHost)
ProxyConfiguration(String name, int port, String userName, String password, String noProxyHost, String testUrl)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Proxy
createProxy()
Deprecated.Proxy
createProxy(String host)
static Proxy
createProxy(String host, String name, int port, String noProxyHost)
String
getEncryptedPassword()
Deprecated.static InputStream
getInputStream(URL url)
Deprecated.String
getName()
String
getNoProxyHost()
List<Pattern>
getNoProxyHostPatterns()
Returns the list of properly formatted no proxy host names.static List<Pattern>
getNoProxyHostPatterns(String noProxyHost)
Returns the list of properly formatted no proxy host names.String
getPassword()
Deprecated.int
getPort()
Secret
getSecretPassword()
String
getTestUrl()
String
getUserName()
static XmlFile
getXmlFile()
static ProxyConfiguration
load()
static HttpClient
newHttpClient()
Return a newHttpClient
with Jenkins-specific default settings.static HttpClient.Builder
newHttpClientBuilder()
Create a newHttpClient.Builder
preconfigured with Jenkins-specific default settings.static HttpRequest.Builder
newHttpRequestBuilder(URI uri)
Create a newHttpRequest.Builder
builder with the given URI preconfigured with Jenkins-specific default settings.static URLConnection
open(URL url)
Deprecated.void
save()
Persists the state of this object into XML.void
setNoProxyHost(String noProxyHost)
void
setSecretPassword(Secret secretPassword)
void
setTestUrl(String testUrl)
void
setUserName(String userName)
-
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
-
-
-
Field Detail
-
name
public final String name
-
port
public final int port
-
noProxyHost
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public String noProxyHost
List of host names that shouldn't use proxy, as typed by users.- See Also:
getNoProxyHostPatterns()
-
-
Constructor Detail
-
ProxyConfiguration
@DataBoundConstructor public ProxyConfiguration(String name, int port)
-
ProxyConfiguration
public ProxyConfiguration(String name, int port, String userName, String password)
-
ProxyConfiguration
public ProxyConfiguration(String name, int port, String userName, String password, String noProxyHost)
-
-
Method Detail
-
getUserName
public String getUserName()
-
getSecretPassword
public Secret getSecretPassword()
-
getPassword
@Deprecated public String getPassword()
Deprecated.
-
getEncryptedPassword
@Deprecated public String getEncryptedPassword()
Deprecated.- Returns:
- the encrypted proxy password
-
getTestUrl
public String getTestUrl()
-
getPort
public int getPort()
-
getName
public String getName()
-
getNoProxyHostPatterns
public List<Pattern> getNoProxyHostPatterns()
Returns the list of properly formatted no proxy host names.
-
getNoProxyHost
public String getNoProxyHost()
-
getNoProxyHostPatterns
public static List<Pattern> getNoProxyHostPatterns(String noProxyHost)
Returns the list of properly formatted no proxy host names.
-
setSecretPassword
@DataBoundSetter public void setSecretPassword(Secret secretPassword)
-
setTestUrl
@DataBoundSetter public void setTestUrl(String testUrl)
-
setUserName
@DataBoundSetter public void setUserName(String userName)
-
setNoProxyHost
@DataBoundSetter public void setNoProxyHost(String noProxyHost)
-
createProxy
@Deprecated public Proxy createProxy()
Deprecated.
-
createProxy
public static Proxy createProxy(String host, String name, int port, String noProxyHost)
-
save
public void save() throws IOException
Description copied from interface:Saveable
Persists the state of this object into XML.For making a bulk change efficiently, see
BulkChange
.To support listeners monitoring changes to this object, call
SaveableListener.fireOnChange(hudson.model.Saveable, hudson.XmlFile)
- Specified by:
save
in interfaceSaveable
- Throws:
IOException
- if the persistence failed.
-
getXmlFile
public static XmlFile getXmlFile()
-
load
public static ProxyConfiguration load() throws IOException
- Throws:
IOException
-
open
@Deprecated public static URLConnection open(URL url) throws IOException
Deprecated.This method should be used whereverURL.openConnection()
to internet URLs is invoked directly.- Throws:
IOException
-
getInputStream
@Deprecated public static InputStream getInputStream(URL url) throws IOException
Deprecated.- Throws:
IOException
-
newHttpClient
public static HttpClient newHttpClient()
Return a newHttpClient
with Jenkins-specific default settings.Equivalent to
newHttpClientBuilder().followRedirects(HttpClient.Redirect.NORMAL).build()
.The Jenkins-specific default settings include a proxy server and proxy authentication (as configured by
ProxyConfiguration
) and a connection timeout (as configured byDEFAULT_CONNECT_TIMEOUT_MILLIS
).- Returns:
- a new
HttpClient
- Since:
- 2.379
-
newHttpClientBuilder
public static HttpClient.Builder newHttpClientBuilder()
Create a newHttpClient.Builder
preconfigured with Jenkins-specific default settings.The Jenkins-specific default settings include a proxy server and proxy authentication (as configured by
ProxyConfiguration
) and a connection timeout (as configured byDEFAULT_CONNECT_TIMEOUT_MILLIS
).- Returns:
- an
HttpClient.Builder
- Since:
- 2.379
-
newHttpRequestBuilder
public static HttpRequest.Builder newHttpRequestBuilder(URI uri)
Create a newHttpRequest.Builder
builder with the given URI preconfigured with Jenkins-specific default settings.The Jenkins-specific default settings include a custom user agent on the controller (unless
UserAgentURLConnectionDecorator.DISABLED
is true).- Parameters:
uri
- the request URI- Returns:
- an
HttpRequest.Builder
- Throws:
IllegalArgumentException
- if the URI scheme is not supported- Since:
- 2.379
-
-