Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
c853c471
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c853c471
编写于
10月 28, 2013
作者:
S
ssogabe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-20191] Add Test button to check proxy connection
上级
ad935811
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
16 deletion
+72
-16
core/src/main/java/hudson/ProxyConfiguration.java
core/src/main/java/hudson/ProxyConfiguration.java
+52
-13
core/src/main/resources/hudson/Messages.properties
core/src/main/resources/hudson/Messages.properties
+4
-0
core/src/main/resources/hudson/Messages_ja.properties
core/src/main/resources/hudson/Messages_ja.properties
+5
-1
core/src/main/resources/hudson/ProxyConfiguration/config.groovy
...rc/main/resources/hudson/ProxyConfiguration/config.groovy
+7
-0
core/src/main/resources/hudson/ProxyConfiguration/config_ja.properties
.../resources/hudson/ProxyConfiguration/config_ja.properties
+4
-2
未找到文件。
core/src/main/java/hudson/ProxyConfiguration.java
浏览文件 @
c853c471
...
...
@@ -24,18 +24,19 @@
package
hudson
;
import
com.google.common.collect.Lists
;
import
com.thoughtworks.xstream.XStream
;
import
hudson.model.AbstractDescribableImpl
;
import
hudson.model.Descriptor
;
import
hudson.util.FormValidation
;
import
jenkins.model.Jenkins
;
import
hudson.model.Saveable
;
import
hudson.model.listeners.SaveableListener
;
import
hudson.util.FormValidation
;
import
hudson.util.IOUtils
;
import
hudson.util.Scrambler
;
import
hudson.util.Secret
;
import
hudson.util.XStream2
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.Serializable
;
import
java.net.Authenticator
;
import
java.net.InetSocketAddress
;
...
...
@@ -43,13 +44,10 @@ import java.net.PasswordAuthentication;
import
java.net.Proxy
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
com.thoughtworks.xstream.XStream
;
import
java.io.InputStream
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.regex.Pattern
;
import
jenkins.model.Jenkins
;
import
org.jvnet.robust_http_client.RetryableHttpStream
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.QueryParameter
;
...
...
@@ -65,7 +63,7 @@ import org.kohsuke.stapler.QueryParameter;
* (as described in the Java 6 tech note
* <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html">
* Http Authentication</a>).
*
*
* @see jenkins.model.Jenkins#proxy
*/
public
final
class
ProxyConfiguration
extends
AbstractDescribableImpl
<
ProxyConfiguration
>
implements
Saveable
,
Serializable
{
...
...
@@ -80,7 +78,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
/**
* List of host names that shouldn't use proxy, as typed by users.
*
* @see #getNoProxyHostPatterns()
* @see #getNoProxyHostPatterns()
*/
public
final
String
noProxyHost
;
...
...
@@ -91,6 +89,8 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
* encrypted password
*/
private
Secret
secretPassword
;
private
String
testUrl
;
public
ProxyConfiguration
(
String
name
,
int
port
)
{
this
(
name
,
port
,
null
,
null
);
...
...
@@ -100,13 +100,18 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
this
(
name
,
port
,
userName
,
password
,
null
);
}
@DataBoundConstructor
public
ProxyConfiguration
(
String
name
,
int
port
,
String
userName
,
String
password
,
String
noProxyHost
)
{
this
(
name
,
port
,
userName
,
password
,
noProxyHost
,
null
);
}
@DataBoundConstructor
public
ProxyConfiguration
(
String
name
,
int
port
,
String
userName
,
String
password
,
String
noProxyHost
,
String
testUrl
)
{
this
.
name
=
Util
.
fixEmptyAndTrim
(
name
);
this
.
port
=
port
;
this
.
userName
=
Util
.
fixEmptyAndTrim
(
userName
);
this
.
secretPassword
=
Secret
.
fromString
(
password
);
this
.
noProxyHost
=
Util
.
fixEmptyAndTrim
(
noProxyHost
);
this
.
testUrl
=
Util
.
fixEmptyAndTrim
(
testUrl
);
}
public
String
getUserName
()
{
...
...
@@ -126,6 +131,10 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
return
(
secretPassword
==
null
)
?
null
:
secretPassword
.
getEncryptedValue
();
}
public
String
getTestUrl
()
{
return
testUrl
;
}
/**
* Returns the list of properly formatted no proxy host names.
*/
...
...
@@ -207,7 +216,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
URLConnection
con
=
url
.
openConnection
(
p
.
createProxy
(
url
.
getHost
()));
if
(
p
.
getUserName
()!=
null
)
{
// Add an authenticator which provides the credentials for proxy authentication
// Add an authenticator which provides the credentials for proxy authentication
Authenticator
.
setDefault
(
new
Authenticator
()
{
@Override
public
PasswordAuthentication
getPasswordAuthentication
()
{
...
...
@@ -224,10 +233,14 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
return
con
;
}
public
static
InputStream
getInputStream
(
URL
url
)
throws
IOException
{
Jenkins
h
=
Jenkins
.
getInstance
();
// this code might run on slaves
final
ProxyConfiguration
p
=
(
h
!=
null
)
?
h
.
proxy
:
null
;
return
getInputStream
(
url
,
p
);
}
public
static
InputStream
getInputStream
(
URL
url
,
final
ProxyConfiguration
p
)
throws
IOException
{
if
(
p
==
null
)
return
new
RetryableHttpStream
(
url
);
...
...
@@ -245,7 +258,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
}
});
}
return
is
;
}
...
...
@@ -280,5 +293,31 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
}
return
FormValidation
.
ok
();
}
public
FormValidation
doValidateProxy
(
@QueryParameter
(
"testUrl"
)
String
testUrl
,
@QueryParameter
(
"name"
)
String
name
,
@QueryParameter
(
"port"
)
int
port
,
@QueryParameter
(
"userName"
)
String
userName
,
@QueryParameter
(
"password"
)
String
password
,
@QueryParameter
(
"noProxyHost"
)
String
noProxyHost
)
{
if
(
Util
.
fixEmptyAndTrim
(
testUrl
)
==
null
)
{
return
FormValidation
.
error
(
Messages
.
ProxyConfiguration_TestUrlRequired
());
}
ProxyConfiguration
pc
=
null
;
if
(
Util
.
fixEmptyAndTrim
(
name
)
!=
null
)
{
pc
=
new
ProxyConfiguration
(
name
,
port
,
userName
,
password
,
noProxyHost
);
}
InputStream
is
=
null
;
try
{
is
=
ProxyConfiguration
.
getInputStream
(
new
URL
(
testUrl
),
pc
);
}
catch
(
IOException
e
)
{
return
FormValidation
.
error
(
e
,
Messages
.
ProxyConfiguration_FailedToConnectViaProxy
(
testUrl
));
}
finally
{
IOUtils
.
closeQuietly
(
is
);
}
return
FormValidation
.
ok
(
Messages
.
ProxyConfiguration_Success
());
}
}
}
core/src/main/resources/hudson/Messages.properties
浏览文件 @
c853c471
...
...
@@ -63,3 +63,7 @@ PluginManager.ConfigureUpdateCenterPermission.Description=\
AboutJenkins.DisplayName
=
About Jenkins
AboutJenkins.Description
=
See the version and license information.
ProxyConfiguration.TestUrlRequired
=
Test URL is required.
ProxyConfiguration.FailedToConnectViaProxy
=
Failed to connect to {0}.
ProxyConfiguration.Success
=
Success
\ No newline at end of file
core/src/main/resources/hudson/Messages_ja.properties
浏览文件 @
c853c471
...
...
@@ -62,4 +62,8 @@ PluginManager.UploadPluginsPermission.Description=\
PluginManager.ConfigureUpdateCenterPermission.Description
=
\
\u
6a29
\u9650
"
\u
30a2
\u
30c3
\u
30d7
\u
30c7
\u
30fc
\u
30c8
\u
30bb
\u
30f3
\u
30bf
\u
30fc
\u
306e
\u
66f4
\u
65b0"
\u
304c
\u3001\u
30a2
\u
30c3
\u
30d7
\u
30c7
\u
30fc
\u
30c8
\u
30b5
\u
30a4
\u
30c8
\u3084\u
30d7
\u
30ed
\u
30ad
\u
30b7
\u
30fc
\u
306e
\u
8a2d
\u
5b9a
\u3092\u
8a31
\u
53ef
\u3059\u
308b
\u3088\u3046\u
306b
\u
8a2d
\u
5b9a
\u3055\u
308c
\u3066\u3044\u
307e
\u
305b
\u3093\u3002
AboutJenkins.DisplayName
=
Jenkins
\u
306b
\u3064\u3044\u3066
AboutJenkins.Description
=
\u
30d0
\u
30fc
\u
30b8
\u
30e7
\u
30f3
\u3068\u
30e9
\u
30a4
\u
30bb
\u
30f3
\u
30b9
\u
60c5
\u5831\u3092\u8868\u
793a
\u3057\u
307e
\u3059\u3002
\ No newline at end of file
AboutJenkins.Description
=
\u
30d0
\u
30fc
\u
30b8
\u
30e7
\u
30f3
\u3068\u
30e9
\u
30a4
\u
30bb
\u
30f3
\u
30b9
\u
60c5
\u5831\u3092\u8868\u
793a
\u3057\u
307e
\u3059\u3002
ProxyConfiguration.TestUrlRequired
=
\u
30c6
\u
30b9
\u
30c8URL
\u
306f
\u
5fc5
\u9808\u3067\u3059\u3002
ProxyConfiguration.FailedToConnectViaProxy
=
{0}
\u
306b
\u
63a5
\u
7d9a
\u3067\u
304d
\u
307e
\u
305b
\u3093\u3067\u3057\u
305f
\u3002
ProxyConfiguration.Success
=
\u6210\u
529f
\ No newline at end of file
core/src/main/resources/hudson/ProxyConfiguration/config.groovy
浏览文件 @
c853c471
...
...
@@ -17,3 +17,10 @@ f.entry(title:_("Password"),field:"password") {
f
.
entry
(
title:
_
(
"No Proxy Host"
),
field:
"noProxyHost"
)
{
f
.
textarea
()
}
f
.
advanced
(){
f
.
entry
(
title:
_
(
"Test URL"
),
field:
"testUrl"
)
{
f
.
textbox
()
}
f
.
validateButton
(
title:
_
(
"Validate Proxy"
),
method:
"validateProxy"
,
with:
"testUrl,name,port,userName,passwrod,noProxyHost"
)
}
core/src/main/resources/hudson/ProxyConfiguration/config_ja.properties
浏览文件 @
c853c471
# The MIT License
#
# Copyright (c) 2004-201
2
, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe
# Copyright (c) 2004-201
3
, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
...
...
@@ -24,4 +24,6 @@ Server=\u30b5\u30fc\u30d0\u30fc
Port
=
\u
30dd
\u
30fc
\u
30c8
\u
756a
\u
53f7
User\
name
=
\u
30e6
\u
30fc
\u
30b6
\u
30fc
\u
540d
Password
=
\u
30d1
\u
30b9
\u
30ef
\u
30fc
\u
30c9
No\
Proxy\
Host
=
\u
5bfe
\u
8c61
\u5916\u
30db
\u
30b9
\u
30c8
\ No newline at end of file
No\
Proxy\
Host
=
\u
5bfe
\u
8c61
\u5916\u
30db
\u
30b9
\u
30c8
Test\
URL
=
\u
30c6
\u
30b9
\u
30c8URL
Validate\
Proxy
=
Proxy
\u
306e
\u
63a5
\u
7d9a
\u
78ba
\u
8a8d
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录