Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d1f2f618
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d1f2f618
编写于
8月 03, 2010
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6973030: NTLM proxy authentication fails with https
Reviewed-by: michaelm
上级
879f7042
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
53 deletion
+30
-53
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
.../classes/sun/net/www/protocol/http/HttpURLConnection.java
+4
-0
test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java
...n/net/www/protocol/https/HttpsURLConnection/B6226610.java
+26
-53
未找到文件。
src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
浏览文件 @
d1f2f618
...
...
@@ -1768,6 +1768,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Not really necessary for a tunnel, but can't hurt
requests
.
setIfNotSet
(
"Accept"
,
acceptString
);
if
(
http
.
getHttpKeepAliveSet
())
{
requests
.
setIfNotSet
(
"Proxy-Connection"
,
"keep-alive"
);
}
setPreemptiveProxyAuthentication
(
requests
);
/* Log the CONNECT request */
...
...
test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java
浏览文件 @
d1f2f618
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 6226610
* @bug 6226610
6973030
* @run main/othervm B6226610
* @summary HTTP tunnel connections send user headers to proxy
*/
...
...
@@ -36,45 +36,23 @@
import
java.io.*
;
import
java.net.*
;
import
javax.net.ssl.*
;
import
javax.net.ServerSocketFactory
;
import
sun.net.www.*
;
import
java.util.Enumeration
;
import
sun.net.www.MessageHeader
;
public
class
B6226610
{
static
HeaderCheckerProxyTunnelServer
proxy
;
// it seems there's no proxy ever if a url points to 'localhost',
// even if proxy related properties are set. so we need to bind
// our simple http proxy and http server to a non-loopback address
static
InetAddress
firstNonLoAddress
=
null
;
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
throws
Exception
{
try
{
proxy
=
new
HeaderCheckerProxyTunnelServer
();
proxy
.
start
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Cannot create proxy: "
+
e
);
}
try
{
firstNonLoAddress
=
getNonLoAddress
();
if
(
firstNonLoAddress
==
null
)
{
System
.
out
.
println
(
"The test needs at least one non-loopback address to run. Quit now."
);
System
.
exit
(
0
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
proxy
=
new
HeaderCheckerProxyTunnelServer
();
proxy
.
start
();
System
.
setProperty
(
"https.proxyHost"
,
firstNonLoAddress
.
getHostAddress
());
System
.
setProperty
(
"https.proxyPort"
,
(
new
Integer
(
proxy
.
getLocalPort
())).
toString
()
);
String
hostname
=
InetAddress
.
getLocalHost
().
getHostName
();
try
{
URL
u
=
new
URL
(
"https://"
+
firstNonLoAddress
.
getHostAddress
());
java
.
net
.
URLConnection
c
=
u
.
openConnection
();
URL
u
=
new
URL
(
"https://"
+
hostname
+
"/"
);
System
.
out
.
println
(
"Connecting to "
+
u
);
InetSocketAddress
proxyAddr
=
new
InetSocketAddress
(
hostname
,
proxy
.
getLocalPort
());
java
.
net
.
URLConnection
c
=
u
.
openConnection
(
new
Proxy
(
Proxy
.
Type
.
HTTP
,
proxyAddr
));
/* I want this header to go to the destination server only, protected
* by SSL
...
...
@@ -89,33 +67,15 @@ public class B6226610 {
}
else
System
.
out
.
println
(
e
);
}
finally
{
if
(
proxy
!=
null
)
proxy
.
shutdown
();
}
if
(
HeaderCheckerProxyTunnelServer
.
failed
)
throw
new
RuntimeException
(
"Test failed: Proxy should not receive user defined headers for tunneled requests"
);
}
public
static
InetAddress
getNonLoAddress
()
throws
Exception
{
NetworkInterface
loNIC
=
NetworkInterface
.
getByInetAddress
(
InetAddress
.
getByName
(
"localhost"
));
Enumeration
<
NetworkInterface
>
nics
=
NetworkInterface
.
getNetworkInterfaces
();
while
(
nics
.
hasMoreElements
())
{
NetworkInterface
nic
=
nics
.
nextElement
();
if
(!
nic
.
getName
().
equalsIgnoreCase
(
loNIC
.
getName
()))
{
Enumeration
<
InetAddress
>
addrs
=
nic
.
getInetAddresses
();
while
(
addrs
.
hasMoreElements
())
{
InetAddress
addr
=
addrs
.
nextElement
();
if
(!
addr
.
isLoopbackAddress
())
return
addr
;
}
}
}
return
null
;
throw
new
RuntimeException
(
"Test failed; see output"
);
}
}
class
HeaderCheckerProxyTunnelServer
extends
Thread
{
public
static
boolean
failed
=
false
;
...
...
@@ -139,6 +99,10 @@ class HeaderCheckerProxyTunnelServer extends Thread
}
}
void
shutdown
()
{
try
{
ss
.
close
();
}
catch
(
IOException
e
)
{}
}
public
void
run
()
{
try
{
...
...
@@ -178,6 +142,15 @@ class HeaderCheckerProxyTunnelServer extends Thread
retrieveConnectInfo
(
statusLine
);
if
(
mheader
.
findValue
(
"X-TestHeader"
)
!=
null
)
{
System
.
out
.
println
(
"Proxy should not receive user defined headers for tunneled requests"
);
failed
=
true
;
}
// 6973030
String
value
;
if
((
value
=
mheader
.
findValue
(
"Proxy-Connection"
))
==
null
||
!
value
.
equals
(
"keep-alive"
))
{
System
.
out
.
println
(
"Proxy-Connection:keep-alive not being sent"
);
failed
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录