Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d6f9877e
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看板
提交
d6f9877e
编写于
1月 17, 2017
作者:
A
aefimov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8170814: Reuse cache entries (part II)
Reviewed-by: dfuchs
上级
08bbd5f0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
14 deletion
+60
-14
src/share/classes/sun/net/www/http/HttpClient.java
src/share/classes/sun/net/www/http/HttpClient.java
+24
-3
src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java
...es/sun/net/www/protocol/http/NegotiateAuthentication.java
+36
-11
未找到文件。
src/share/classes/sun/net/www/http/HttpClient.java
浏览文件 @
d6f9877e
/*
* Copyright (c) 1994, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 201
7
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -102,6 +102,11 @@ public class HttpClient extends NetworkClient {
if false, then NTLM connections will not be cached.
The default value is 'true'. */
private
static
final
boolean
cacheNTLMProp
;
/* Value of the system property jdk.spnego.cache;
if false, then connections authentified using the Negotiate/Kerberos
scheme will not be cached.
The default value is 'true'. */
private
static
final
boolean
cacheSPNEGOProp
;
volatile
boolean
keepingAlive
=
false
;
/* this is a keep-alive connection */
volatile
boolean
disableKeepAlive
;
/* keep-alive has been disabled for this
...
...
@@ -160,6 +165,9 @@ public class HttpClient extends NetworkClient {
String
cacheNTLM
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"jdk.ntlm.cache"
));
String
cacheSPNEGO
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"jdk.spnego.cache"
));
if
(
keepAlive
!=
null
)
{
keepAliveProp
=
Boolean
.
valueOf
(
keepAlive
).
booleanValue
();
}
else
{
...
...
@@ -177,6 +185,12 @@ public class HttpClient extends NetworkClient {
}
else
{
cacheNTLMProp
=
true
;
}
if
(
cacheSPNEGO
!=
null
)
{
cacheSPNEGOProp
=
Boolean
.
parseBoolean
(
cacheSPNEGO
);
}
else
{
cacheSPNEGOProp
=
true
;
}
}
/**
...
...
@@ -770,9 +784,16 @@ public class HttpClient extends NetworkClient {
// and cacheNTLMProp is false, than we can't keep this connection
// alive: we will switch disableKeepAlive to true.
boolean
canKeepAlive
=
!
disableKeepAlive
;
if
(
canKeepAlive
&&
cacheNTLMProp
==
false
&&
authenticate
!=
null
)
{
if
(
canKeepAlive
&&
(
cacheNTLMProp
==
false
||
cacheSPNEGOProp
==
false
)
&&
authenticate
!=
null
)
{
authenticate
=
authenticate
.
toLowerCase
(
Locale
.
US
);
canKeepAlive
=
!
authenticate
.
startsWith
(
"ntlm "
);
if
(
cacheNTLMProp
==
false
)
{
canKeepAlive
&=
!
authenticate
.
startsWith
(
"ntlm "
);
}
if
(
cacheSPNEGOProp
==
false
)
{
canKeepAlive
&=
!
authenticate
.
startsWith
(
"negotiate "
);
canKeepAlive
&=
!
authenticate
.
startsWith
(
"kerberos "
);
}
}
disableKeepAlive
|=
!
canKeepAlive
;
...
...
src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java
浏览文件 @
d6f9877e
/*
* Copyright (c) 2005, 201
4
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
7
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -34,6 +34,7 @@ import sun.net.www.HeaderParser;
import
sun.util.logging.PlatformLogger
;
import
static
sun
.
net
.
www
.
protocol
.
http
.
AuthScheme
.
NEGOTIATE
;
import
static
sun
.
net
.
www
.
protocol
.
http
.
AuthScheme
.
KERBEROS
;
import
sun.security.action.GetPropertyAction
;
/**
* NegotiateAuthentication:
...
...
@@ -52,10 +53,18 @@ class NegotiateAuthentication extends AuthenticationInfo {
// These maps are used to manage the GSS availability for diffrent
// hosts. The key for both maps is the host name.
// <code>supported</code> is set when isSupported is checked,
// if it's true, a cached Negotiator is put into <code>cache</code>.
// the cache can be used only once, so after the first use, it's cleaned.
static
HashMap
<
String
,
Boolean
>
supported
=
null
;
static
HashMap
<
String
,
Negotiator
>
cache
=
null
;
static
ThreadLocal
<
HashMap
<
String
,
Negotiator
>>
cache
=
null
;
/* Whether cache is enabled for Negotiate/Kerberos */
private
static
final
boolean
cacheSPNEGO
;
static
{
String
spnegoCacheProp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"jdk.spnego.cache"
,
"true"
));
cacheSPNEGO
=
Boolean
.
parseBoolean
(
spnegoCacheProp
);
}
// The HTTP Negotiate Helper
private
Negotiator
negotiator
=
null
;
...
...
@@ -118,8 +127,7 @@ class NegotiateAuthentication extends AuthenticationInfo {
*/
private
static
synchronized
boolean
isSupportedImpl
(
HttpCallerInfo
hci
)
{
if
(
supported
==
null
)
{
supported
=
new
HashMap
<
String
,
Boolean
>();
cache
=
new
HashMap
<
String
,
Negotiator
>();
supported
=
new
HashMap
<>();
}
String
hostname
=
hci
.
host
;
hostname
=
hostname
.
toLowerCase
();
...
...
@@ -132,7 +140,15 @@ class NegotiateAuthentication extends AuthenticationInfo {
supported
.
put
(
hostname
,
true
);
// the only place cache.put is called. here we can make sure
// the object is valid and the oneToken inside is not null
cache
.
put
(
hostname
,
neg
);
if
(
cache
==
null
)
{
cache
=
new
ThreadLocal
<
HashMap
<
String
,
Negotiator
>>()
{
@Override
protected
HashMap
<
String
,
Negotiator
>
initialValue
()
{
return
new
HashMap
<>();
}
};
}
cache
.
get
().
put
(
hostname
,
neg
);
return
true
;
}
else
{
supported
.
put
(
hostname
,
false
);
...
...
@@ -140,6 +156,16 @@ class NegotiateAuthentication extends AuthenticationInfo {
}
}
private
static
synchronized
HashMap
<
String
,
Negotiator
>
getCache
()
{
if
(
cache
==
null
)
return
null
;
return
cache
.
get
();
}
@Override
protected
boolean
useAuthCache
()
{
return
super
.
useAuthCache
()
&&
cacheSPNEGO
;
}
/**
* Not supported. Must use the setHeaders() method
*/
...
...
@@ -197,12 +223,11 @@ class NegotiateAuthentication extends AuthenticationInfo {
*/
private
byte
[]
firstToken
()
throws
IOException
{
negotiator
=
null
;
if
(
cache
!=
null
)
{
synchronized
(
cache
)
{
negotiator
=
cache
.
get
(
getHost
());
if
(
negotiator
!=
null
)
{
cache
.
remove
(
getHost
());
// so that it is only used once
}
HashMap
<
String
,
Negotiator
>
cachedMap
=
getCache
();
if
(
cachedMap
!=
null
)
{
negotiator
=
cachedMap
.
get
(
getHost
());
if
(
negotiator
!=
null
)
{
cachedMap
.
remove
(
getHost
());
// so that it is only used once
}
}
if
(
negotiator
==
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录