Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
023fdb9f
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看板
提交
023fdb9f
编写于
5月 21, 2015
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8077102: dns_lookup_realm should be false by default
Reviewed-by: weijun
上级
fcd4e2bd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
95 addition
and
61 deletion
+95
-61
src/share/classes/sun/security/krb5/Config.java
src/share/classes/sun/security/krb5/Config.java
+36
-13
test/sun/security/krb5/ConfPlusProp.java
test/sun/security/krb5/ConfPlusProp.java
+8
-25
test/sun/security/krb5/DnsFallback.java
test/sun/security/krb5/DnsFallback.java
+38
-20
test/sun/security/krb5/config/DNS.java
test/sun/security/krb5/config/DNS.java
+11
-1
test/sun/security/krb5/confplusprop.conf
test/sun/security/krb5/confplusprop.conf
+1
-1
test/sun/security/krb5/confplusprop2.conf
test/sun/security/krb5/confplusprop2.conf
+1
-1
未找到文件。
src/share/classes/sun/security/krb5/Config.java
浏览文件 @
023fdb9f
...
...
@@ -231,6 +231,31 @@ public class Config {
return
v
.
lastElement
();
}
/**
* Gets the boolean value for the specified keys. Returns TRUE if the
* string value is "yes", or "true", FALSE if "no", or "false", or null
* if otherwise or not defined. The comparision is case-insensitive.
*
* @param keys the keys, see {@link #get(String...)}
* @return the boolean value, or null if there is no value defined or the
* value does not look like a boolean value.
* @throws IllegalArgumentException see {@link #get(String...)}
*/
private
Boolean
getBooleanObject
(
String
...
keys
)
{
String
s
=
get
(
keys
);
if
(
s
==
null
)
{
return
null
;
}
switch
(
s
.
toLowerCase
(
Locale
.
US
))
{
case
"yes"
:
case
"true"
:
return
Boolean
.
TRUE
;
case
"no"
:
case
"false"
:
return
Boolean
.
FALSE
;
default
:
return
null
;
}
}
/**
* Gets all values for the specified keys.
* @throws IllegalArgumentException if any of the keys is illegal
...
...
@@ -942,32 +967,30 @@ public class Config {
/**
* Check if need to use DNS to locate Kerberos services
*/
private
boolean
useDNS
(
String
name
)
{
String
value
=
get
(
"libdefaults"
,
name
);
if
(
value
==
null
)
{
value
=
get
(
"libdefaults"
,
"dns_fallback"
);
if
(
"false"
.
equalsIgnoreCase
(
value
))
{
return
false
;
}
else
{
return
true
;
}
}
else
{
return
value
.
equalsIgnoreCase
(
"true"
);
private
boolean
useDNS
(
String
name
,
boolean
defaultValue
)
{
Boolean
value
=
getBooleanObject
(
"libdefaults"
,
name
);
if
(
value
!=
null
)
{
return
value
.
booleanValue
();
}
value
=
getBooleanObject
(
"libdefaults"
,
"dns_fallback"
);
if
(
value
!=
null
)
{
return
value
.
booleanValue
();
}
return
defaultValue
;
}
/**
* Check if need to use DNS to locate the KDC
*/
private
boolean
useDNS_KDC
()
{
return
useDNS
(
"dns_lookup_kdc"
);
return
useDNS
(
"dns_lookup_kdc"
,
true
);
}
/*
* Check if need to use DNS to locate the Realm
*/
private
boolean
useDNS_Realm
()
{
return
useDNS
(
"dns_lookup_realm"
);
return
useDNS
(
"dns_lookup_realm"
,
false
);
}
/**
...
...
test/sun/security/krb5/ConfPlusProp.java
浏览文件 @
023fdb9f
...
...
@@ -35,6 +35,12 @@ import sun.security.krb5.Config;
public
class
ConfPlusProp
{
Config
config
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
System
.
getenv
(
"USERDNSDOMAIN"
)
!=
null
||
System
.
getenv
(
"LOGONSERVER"
)
!=
null
)
{
System
.
out
.
println
(
"Looks like a Windows machine in a domain. Skip test."
);
return
;
}
new
ConfPlusProp
().
run
();
}
...
...
@@ -90,23 +96,8 @@ public class ConfPlusProp {
check
(
"R2"
,
"old"
);
check
(
"R3"
,
null
);
int
version
=
System
.
getProperty
(
"java.version"
).
charAt
(
2
)
-
'0'
;
System
.
out
.
println
(
"JDK version is "
+
version
);
// Zero-config is supported since 1.7
if
(
version
>=
7
)
{
// Point to a non-existing file
System
.
setProperty
(
"java.security.krb5.conf"
,
"i-am-not-a file"
);
refresh
();
// Default realm might come from DNS
//checkDefaultRealm(null);
check
(
"R1"
,
null
);
check
(
"R2"
,
null
);
check
(
"R3"
,
null
);
if
(
config
.
get
(
"libdefaults"
,
"forwardable"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
if
(
config
.
get
(
"libdefaults"
,
"forwardable"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
// Add prop
...
...
@@ -136,14 +127,6 @@ public class ConfPlusProp {
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
// Point to a non-existing file
System
.
setProperty
(
"java.security.krb5.conf"
,
"i-am-not-a file"
);
refresh
();
checkDefaultRealm
(
"R2"
);
check
(
"R1"
,
"k2"
);
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
if
(
config
.
get
(
"libdefaults"
,
"forwardable"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
...
...
test/sun/security/krb5/DnsFallback.java
浏览文件 @
023fdb9f
...
...
@@ -22,8 +22,7 @@
*/
/*
* @test
* @bug 6673164
* @bug 6552334
* @bug 6673164 6552334 8077102
* @run main/othervm DnsFallback
* @summary fix dns_fallback parse error, and use dns by default
*/
...
...
@@ -35,47 +34,66 @@ import sun.security.krb5.Config;
public
class
DnsFallback
{
static
Method
useDNS_Realm
;
static
Method
useDNS_KDC
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
useDNS_Realm
=
Config
.
class
.
getDeclaredMethod
(
"useDNS_Realm"
);
useDNS_Realm
.
setAccessible
(
true
);
useDNS_KDC
=
Config
.
class
.
getDeclaredMethod
(
"useDNS_KDC"
);
useDNS_KDC
.
setAccessible
(
true
);
// for 6673164
check
(
"true"
,
"true"
,
true
);
check
(
"false"
,
"true"
,
false
);
check
(
"true"
,
"false"
,
true
);
check
(
"false"
,
"false"
,
false
);
check
(
"true"
,
null
,
true
);
check
(
"false"
,
null
,
false
);
check
(
null
,
"true"
,
true
);
check
(
null
,
"false"
,
false
);
check
(
"true"
,
"true"
,
true
,
true
);
check
(
"false"
,
"true"
,
false
,
false
);
check
(
"true"
,
"false"
,
true
,
true
);
check
(
"false"
,
"false"
,
false
,
false
);
check
(
"true"
,
null
,
true
,
true
);
check
(
"false"
,
null
,
false
,
false
);
check
(
null
,
"true"
,
true
,
true
);
check
(
null
,
"false"
,
false
,
false
);
// for 6552334
check
(
null
,
null
,
true
);
// for 6552334, no longer true
//check(null, null, true, true);
// 8077102
check
(
null
,
null
,
false
,
true
);
}
static
void
check
(
String
realm
,
String
fallback
,
boolean
output
)
/**
* Sets and checks.
*
* @param u dns_lookup_XXX value set, none if null
* @param f dns_fallback value set, none if null
* @param r expected useDNS_Realm
* @param k expected useDNS_KDC
*/
static
void
check
(
String
u
,
String
f
,
boolean
r
,
boolean
k
)
throws
Exception
{
try
(
PrintStream
ps
=
new
PrintStream
(
new
FileOutputStream
(
"dnsfallback.conf"
)))
{
ps
.
println
(
"[libdefaults]\n"
);
if
(
realm
!=
null
)
{
ps
.
println
(
"dns_lookup_realm="
+
realm
);
if
(
u
!=
null
)
{
ps
.
println
(
"dns_lookup_realm="
+
u
);
ps
.
println
(
"dns_lookup_kdc="
+
u
);
}
if
(
f
allback
!=
null
)
{
ps
.
println
(
"dns_fallback="
+
f
allback
);
if
(
f
!=
null
)
{
ps
.
println
(
"dns_fallback="
+
f
);
}
}
System
.
setProperty
(
"java.security.krb5.conf"
,
"dnsfallback.conf"
);
Config
.
refresh
();
System
.
out
.
println
(
"Testing "
+
realm
+
", "
+
fallback
+
", "
+
output
);
System
.
out
.
println
(
"Testing "
+
u
+
", "
+
f
+
", "
+
r
+
", "
+
k
);
if
(!
useDNS_Realm
.
invoke
(
Config
.
getInstance
()).
equals
(
r
))
{
throw
new
Exception
(
"useDNS_Realm Fail"
);
}
if
(!
useDNS_
Realm
.
invoke
(
Config
.
getInstance
()).
equals
(
output
))
{
throw
new
Exception
(
"Fail"
);
if
(!
useDNS_
KDC
.
invoke
(
Config
.
getInstance
()).
equals
(
k
))
{
throw
new
Exception
(
"
useDNS_KDC
Fail"
);
}
}
}
...
...
test/sun/security/krb5/config/DNS.java
浏览文件 @
023fdb9f
...
...
@@ -23,12 +23,22 @@
// See dns.sh.
import
sun.security.krb5.Config
;
import
sun.security.krb5.KrbException
;
public
class
DNS
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"java.security.krb5.conf"
,
System
.
getProperty
(
"test.src"
,
"."
)
+
"/no
thing
.conf"
);
System
.
getProperty
(
"test.src"
,
"."
)
+
"/no
-such-file
.conf"
);
Config
config
=
Config
.
getInstance
();
try
{
String
r
=
config
.
getDefaultRealm
();
throw
new
Exception
(
"What? There is a default realm "
+
r
+
"?"
);
}
catch
(
KrbException
ke
)
{
ke
.
printStackTrace
();
if
(
ke
.
getCause
()
!=
null
)
{
throw
new
Exception
(
"There should be no cause. Won't try DNS"
);
}
}
String
kdcs
=
config
.
getKDCList
(
"X"
);
if
(!
kdcs
.
equals
(
"a.com.:88 b.com.:99"
)
&&
!
kdcs
.
equals
(
"a.com. b.com.:99"
))
{
...
...
test/sun/security/krb5/confplusprop.conf
浏览文件 @
023fdb9f
[
libdefaults
]
default_realm
=
R1
forwardable
=
well
dns_lookup_
realm
=
false
dns_lookup_
kdc
=
false
[
realms
]
R1
= {
...
...
test/sun/security/krb5/confplusprop2.conf
浏览文件 @
023fdb9f
[
libdefaults
]
dns_lookup_
realm
=
false
dns_lookup_
kdc
=
false
[
realms
]
R1
= {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录