Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6d0cdba9
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看板
提交
6d0cdba9
编写于
6月 17, 2010
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6957564: Disclosure of DNS server IP address
Reviewed-by: xuelei, chegar
上级
1dc40198
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
3 deletion
+46
-3
src/share/classes/com/sun/jndi/dns/DnsContextFactory.java
src/share/classes/com/sun/jndi/dns/DnsContextFactory.java
+46
-3
未找到文件。
src/share/classes/com/sun/jndi/dns/DnsContextFactory.java
浏览文件 @
6d0cdba9
...
@@ -54,6 +54,7 @@ import sun.net.dns.ResolverConfiguration; // available since 1.4.1
...
@@ -54,6 +54,7 @@ import sun.net.dns.ResolverConfiguration; // available since 1.4.1
public
class
DnsContextFactory
implements
InitialContextFactory
{
public
class
DnsContextFactory
implements
InitialContextFactory
{
private
static
final
String
DEFAULT_URL
=
"dns:"
;
private
static
final
String
DEFAULT_URL
=
"dns:"
;
private
static
final
int
DEFAULT_PORT
=
53
;
public
Context
getInitialContext
(
Hashtable
<?,?>
env
)
throws
NamingException
{
public
Context
getInitialContext
(
Hashtable
<?,?>
env
)
throws
NamingException
{
...
@@ -89,7 +90,9 @@ public class DnsContextFactory implements InitialContextFactory {
...
@@ -89,7 +90,9 @@ public class DnsContextFactory implements InitialContextFactory {
* Public for use by product test suite.
* Public for use by product test suite.
*/
*/
public
static
boolean
platformServersAvailable
()
{
public
static
boolean
platformServersAvailable
()
{
return
!
ResolverConfiguration
.
open
().
nameservers
().
isEmpty
();
return
!
filterNameServers
(
ResolverConfiguration
.
open
().
nameservers
(),
true
).
isEmpty
();
}
}
private
static
Context
urlToContext
(
String
url
,
Hashtable
env
)
private
static
Context
urlToContext
(
String
url
,
Hashtable
env
)
...
@@ -142,8 +145,8 @@ public class DnsContextFactory implements InitialContextFactory {
...
@@ -142,8 +145,8 @@ public class DnsContextFactory implements InitialContextFactory {
// No server or port given, so look to underlying platform.
// No server or port given, so look to underlying platform.
// ResolverConfiguration does some limited caching, so the
// ResolverConfiguration does some limited caching, so the
// following is reasonably efficient even if called rapid-fire.
// following is reasonably efficient even if called rapid-fire.
List
platformServers
=
List
platformServers
=
filterNameServers
(
ResolverConfiguration
.
open
().
nameservers
();
ResolverConfiguration
.
open
().
nameservers
()
,
false
)
;
if
(!
platformServers
.
isEmpty
())
{
if
(!
platformServers
.
isEmpty
())
{
servers
.
addAll
(
platformServers
);
servers
.
addAll
(
platformServers
);
continue
;
// on to next URL (if any, which is unlikely)
continue
;
// on to next URL (if any, which is unlikely)
...
@@ -214,4 +217,44 @@ public class DnsContextFactory implements InitialContextFactory {
...
@@ -214,4 +217,44 @@ public class DnsContextFactory implements InitialContextFactory {
String
url
=
(
String
)
env
.
get
(
Context
.
PROVIDER_URL
);
String
url
=
(
String
)
env
.
get
(
Context
.
PROVIDER_URL
);
return
((
url
!=
null
)
?
url
:
DEFAULT_URL
);
return
((
url
!=
null
)
?
url
:
DEFAULT_URL
);
}
}
/**
* Removes any DNS server that's not permitted to access
* @param input the input server[:port] list, must not be null
* @param oneIsEnough return output once there exists one ok
* @return the filtered list, all non-permitted input removed
*/
private
static
List
filterNameServers
(
List
input
,
boolean
oneIsEnough
)
{
SecurityManager
security
=
System
.
getSecurityManager
();
if
(
security
==
null
||
input
==
null
||
input
.
isEmpty
())
{
return
input
;
}
else
{
List
output
=
new
ArrayList
();
for
(
Object
o:
input
)
{
if
(
o
instanceof
String
)
{
String
platformServer
=
(
String
)
o
;
int
colon
=
platformServer
.
indexOf
(
':'
,
platformServer
.
indexOf
(
']'
)
+
1
);
int
p
=
(
colon
<
0
)
?
DEFAULT_PORT
:
Integer
.
parseInt
(
platformServer
.
substring
(
colon
+
1
));
String
s
=
(
colon
<
0
)
?
platformServer
:
platformServer
.
substring
(
0
,
colon
);
try
{
security
.
checkConnect
(
s
,
p
);
output
.
add
(
platformServer
);
if
(
oneIsEnough
)
{
return
output
;
}
}
catch
(
SecurityException
se
)
{
continue
;
}
}
}
return
output
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录