Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
8504c8ad
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8504c8ad
编写于
10月 29, 2012
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7184246: Simplify Config.get() of krb5
Reviewed-by: xuelei
上级
2e656f02
变更
19
展开全部
隐藏空白更改
内联
并排
Showing
19 changed file
with
589 addition
and
524 deletion
+589
-524
src/share/classes/sun/security/krb5/Checksum.java
src/share/classes/sun/security/krb5/Checksum.java
+8
-4
src/share/classes/sun/security/krb5/Config.java
src/share/classes/sun/security/krb5/Config.java
+250
-451
src/share/classes/sun/security/krb5/KdcComm.java
src/share/classes/sun/security/krb5/KdcComm.java
+4
-4
src/share/classes/sun/security/krb5/PrincipalName.java
src/share/classes/sun/security/krb5/PrincipalName.java
+3
-3
src/share/classes/sun/security/krb5/Realm.java
src/share/classes/sun/security/krb5/Realm.java
+2
-2
src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java
...share/classes/sun/security/krb5/SCDynamicStoreConfig.java
+50
-18
src/share/classes/sun/security/krb5/internal/KDCOptions.java
src/share/classes/sun/security/krb5/internal/KDCOptions.java
+7
-9
src/share/classes/sun/security/krb5/internal/KerberosTime.java
...hare/classes/sun/security/krb5/internal/KerberosTime.java
+3
-3
src/share/classes/sun/security/krb5/internal/crypto/CksumType.java
.../classes/sun/security/krb5/internal/crypto/CksumType.java
+4
-4
src/share/classes/sun/security/krb5/internal/crypto/EType.java
...hare/classes/sun/security/krb5/internal/crypto/EType.java
+8
-4
src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
...share/classes/sun/security/krb5/internal/ktab/KeyTab.java
+2
-2
test/sun/security/krb5/ConfPlusProp.java
test/sun/security/krb5/ConfPlusProp.java
+5
-4
test/sun/security/krb5/DnsFallback.java
test/sun/security/krb5/DnsFallback.java
+24
-13
test/sun/security/krb5/ParseConfig.java
test/sun/security/krb5/ParseConfig.java
+2
-1
test/sun/security/krb5/auto/BasicKrb5Test.java
test/sun/security/krb5/auto/BasicKrb5Test.java
+2
-1
test/sun/security/krb5/auto/MaxRetries.java
test/sun/security/krb5/auto/MaxRetries.java
+1
-1
test/sun/security/krb5/config/Duplicates.java
test/sun/security/krb5/config/Duplicates.java
+72
-0
test/sun/security/krb5/config/SCDynamicConfigTest.java
test/sun/security/krb5/config/SCDynamicConfigTest.java
+102
-0
test/sun/security/krb5/config/k1.conf
test/sun/security/krb5/config/k1.conf
+40
-0
未找到文件。
src/share/classes/sun/security/krb5/Checksum.java
浏览文件 @
8504c8ad
...
...
@@ -74,14 +74,18 @@ public class Checksum {
private
static
boolean
DEBUG
=
Krb5
.
DEBUG
;
static
{
initStatic
();
}
public
static
void
initStatic
()
{
String
temp
=
null
;
Config
cfg
=
null
;
try
{
cfg
=
Config
.
getInstance
();
temp
=
cfg
.
get
Default
(
"default_checksum"
,
"libdefaults
"
);
temp
=
cfg
.
get
(
"libdefaults"
,
"default_checksum
"
);
if
(
temp
!=
null
)
{
CKSUMTYPE_DEFAULT
=
cf
g
.
getType
(
temp
);
CKSUMTYPE_DEFAULT
=
Confi
g
.
getType
(
temp
);
}
else
{
/*
* If the default checksum is not
...
...
@@ -103,10 +107,10 @@ public class Checksum {
try
{
temp
=
cfg
.
get
Default
(
"safe_checksum_type"
,
"libdefaults
"
);
temp
=
cfg
.
get
(
"libdefaults"
,
"safe_checksum_type
"
);
if
(
temp
!=
null
)
{
SAFECKSUMTYPE_DEFAULT
=
cf
g
.
getType
(
temp
);
SAFECKSUMTYPE_DEFAULT
=
Confi
g
.
getType
(
temp
);
}
else
{
SAFECKSUMTYPE_DEFAULT
=
CKSUMTYPE_RSA_MD5_DES
;
}
...
...
src/share/classes/sun/security/krb5/Config.java
浏览文件 @
8504c8ad
此差异已折叠。
点击以展开。
src/share/classes/sun/security/krb5/KdcComm.java
浏览文件 @
8504c8ad
...
...
@@ -142,11 +142,11 @@ public final class KdcComm {
try
{
Config
cfg
=
Config
.
getInstance
();
String
temp
=
cfg
.
get
Default
(
"kdc_timeout"
,
"libdefaults
"
);
String
temp
=
cfg
.
get
(
"libdefaults"
,
"kdc_timeout
"
);
timeout
=
parsePositiveIntString
(
temp
);
temp
=
cfg
.
get
Default
(
"max_retries"
,
"libdefault
s"
);
temp
=
cfg
.
get
(
"libdefaults"
,
"max_retrie
s"
);
max_retries
=
parsePositiveIntString
(
temp
);
temp
=
cfg
.
get
Default
(
"udp_preference_limit"
,
"libdefaults
"
);
temp
=
cfg
.
get
(
"libdefaults"
,
"udp_preference_limit
"
);
udf_pref_limit
=
parsePositiveIntString
(
temp
);
}
catch
(
Exception
exc
)
{
// ignore any exceptions; use default values
...
...
@@ -421,7 +421,7 @@ public final class KdcComm {
int
temp
=
-
1
;
try
{
String
value
=
Config
.
getInstance
().
get
Default
(
key
,
realm
);
Config
.
getInstance
().
get
(
"realms"
,
realm
,
key
);
temp
=
parsePositiveIntString
(
value
);
}
catch
(
Exception
exc
)
{
// Ignored, defValue will be picked up
...
...
src/share/classes/sun/security/krb5/PrincipalName.java
浏览文件 @
8504c8ad
...
...
@@ -655,19 +655,19 @@ public class PrincipalName implements Cloneable {
try
{
String
subname
=
null
;
Config
c
=
Config
.
getInstance
();
if
((
result
=
c
.
get
Default
(
name
,
"domain_realm"
))
!=
null
)
if
((
result
=
c
.
get
(
"domain_realm"
,
name
))
!=
null
)
return
result
;
else
{
for
(
int
i
=
1
;
i
<
name
.
length
();
i
++)
{
if
((
name
.
charAt
(
i
)
==
'.'
)
&&
(
i
!=
name
.
length
()
-
1
))
{
//mapping could be .ibm.com = AUSTIN.IBM.COM
subname
=
name
.
substring
(
i
);
result
=
c
.
get
Default
(
subname
,
"domain_realm"
);
result
=
c
.
get
(
"domain_realm"
,
subname
);
if
(
result
!=
null
)
{
break
;
}
else
{
subname
=
name
.
substring
(
i
+
1
);
//or mapping could be ibm.com = AUSTIN.IBM.COM
result
=
c
.
get
Default
(
subname
,
"domain_realm"
);
result
=
c
.
get
(
"domain_realm"
,
subname
);
if
(
result
!=
null
)
{
break
;
}
...
...
src/share/classes/sun/security/krb5/Realm.java
浏览文件 @
8504c8ad
...
...
@@ -350,7 +350,7 @@ public class Realm implements Cloneable {
return
null
;
}
String
intermediaries
=
cfg
.
get
Default
(
sRealm
,
c
Realm
);
String
intermediaries
=
cfg
.
get
All
(
"capaths"
,
cRealm
,
s
Realm
);
if
(
intermediaries
==
null
)
{
if
(
DEBUG
)
{
...
...
@@ -459,7 +459,7 @@ public class Realm implements Cloneable {
tempTarget
);
}
intermediaries
=
cfg
.
get
Default
(
tempTarget
,
cRealm
);
intermediaries
=
cfg
.
get
All
(
"capaths"
,
cRealm
,
tempTarget
);
}
while
(
true
);
...
...
src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java
浏览文件 @
8504c8ad
...
...
@@ -34,19 +34,25 @@ import java.util.Vector;
public
class
SCDynamicStoreConfig
{
private
static
native
void
installNotificationCallback
();
private
static
native
Hashtable
<
String
,
Object
>
getKerberosConfig
();
private
static
boolean
DEBUG
=
sun
.
security
.
krb5
.
internal
.
Krb5
.
DEBUG
;
static
{
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
System
.
loadLibrary
(
"osx"
);
return
null
;
boolean
isMac
=
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
Boolean
>()
{
public
Boolean
run
()
{
String
osname
=
System
.
getProperty
(
"os.name"
);
if
(
osname
.
contains
(
"OS X"
))
{
System
.
loadLibrary
(
"osx"
);
return
true
;
}
return
false
;
}
});
installNotificationCallback
();
i
f
(
isMac
)
i
nstallNotificationCallback
();
}
private
static
Vector
<
String
>
unwrapHost
(
Collection
<
Hashtable
<
String
,
String
>>
c
)
{
private
static
Vector
<
String
>
unwrapHost
(
Collection
<
Hashtable
<
String
,
String
>>
c
)
{
Vector
<
String
>
vector
=
new
Vector
<
String
>();
for
(
Hashtable
<
String
,
String
>
m
:
c
)
{
vector
.
add
(
m
.
get
(
"host"
));
...
...
@@ -60,20 +66,25 @@ public class SCDynamicStoreConfig {
* are wrapped inside Hashtables
*/
@SuppressWarnings
(
"unchecked"
)
private
static
Hashtable
<
String
,
Object
>
convertRealmConfigs
(
Hashtable
<
String
,
?>
configs
)
{
private
static
Hashtable
<
String
,
Object
>
convertRealmConfigs
(
Hashtable
<
String
,
?>
configs
)
{
Hashtable
<
String
,
Object
>
realmsTable
=
new
Hashtable
<
String
,
Object
>();
for
(
String
realm
:
configs
.
keySet
())
{
// get the kdc
Hashtable
<
String
,
Collection
<?>>
map
=
(
Hashtable
<
String
,
Collection
<?>>)
configs
.
get
(
realm
);
Collection
<
Hashtable
<
String
,
String
>>
kdc
=
(
Collection
<
Hashtable
<
String
,
String
>>)
map
.
get
(
"kdc"
);
Hashtable
<
String
,
Collection
<?>>
map
=
(
Hashtable
<
String
,
Collection
<?>>)
configs
.
get
(
realm
);
Hashtable
<
String
,
Vector
<
String
>>
realmMap
=
new
Hashtable
<
String
,
Vector
<
String
>>();
// put the kdc into the realmMap
Hashtable
<
String
,
Vector
<
String
>>
realmMap
=
new
Hashtable
<
String
,
Vector
<
String
>>();
Collection
<
Hashtable
<
String
,
String
>>
kdc
=
(
Collection
<
Hashtable
<
String
,
String
>>)
map
.
get
(
"kdc"
);
if
(
kdc
!=
null
)
realmMap
.
put
(
"kdc"
,
unwrapHost
(
kdc
));
// put the admin server into the realmMap
Collection
<
Hashtable
<
String
,
String
>>
kadmin
=
(
Collection
<
Hashtable
<
String
,
String
>>)
map
.
get
(
"kadmin"
);
Collection
<
Hashtable
<
String
,
String
>>
kadmin
=
(
Collection
<
Hashtable
<
String
,
String
>>)
map
.
get
(
"kadmin"
);
if
(
kadmin
!=
null
)
realmMap
.
put
(
"admin_server"
,
unwrapHost
(
kadmin
));
// add the full entry to the realmTable
...
...
@@ -90,23 +101,44 @@ public class SCDynamicStoreConfig {
* @return
* @throws IOException
*/
@SuppressWarnings
(
"unchecked"
)
public
static
Hashtable
<
String
,
Object
>
getConfig
()
throws
IOException
{
Hashtable
<
String
,
Object
>
stanzaTable
=
getKerberosConfig
();
if
(
stanzaTable
==
null
)
{
throw
new
IOException
(
"Could not load configuration from SCDynamicStore"
);
throw
new
IOException
(
"Could not load configuration from SCDynamicStore"
);
}
//System.out.println("Raw map from JNI: " + stanzaTable);
if
(
DEBUG
)
System
.
out
.
println
(
"Raw map from JNI: "
+
stanzaTable
);
return
convertNativeConfig
(
stanzaTable
);
}
@SuppressWarnings
(
"unchecked"
)
private
static
Hashtable
<
String
,
Object
>
convertNativeConfig
(
Hashtable
<
String
,
Object
>
stanzaTable
)
{
// convert SCDynamicStore realm structure to Java realm structure
Hashtable
<
String
,
?>
realms
=
(
Hashtable
<
String
,
?>)
stanzaTable
.
get
(
"realms"
);
Hashtable
<
String
,
?>
realms
=
(
Hashtable
<
String
,
?>)
stanzaTable
.
get
(
"realms"
);
if
(
realms
!=
null
)
{
stanzaTable
.
remove
(
"realms"
);
Hashtable
<
String
,
Object
>
realmsTable
=
convertRealmConfigs
(
realms
);
stanzaTable
.
put
(
"realms"
,
realmsTable
);
}
//
System.out.println("stanzaTable : " + stanzaTable);
WrapAllStringInVector
(
stanzaTable
);
if
(
DEBUG
)
System
.
out
.
println
(
"stanzaTable : "
+
stanzaTable
);
return
stanzaTable
;
}
@SuppressWarnings
(
"unchecked"
)
private
static
void
WrapAllStringInVector
(
Hashtable
<
String
,
Object
>
stanzaTable
)
{
for
(
String
s:
stanzaTable
.
keySet
())
{
Object
v
=
stanzaTable
.
get
(
s
);
if
(
v
instanceof
Hashtable
)
{
WrapAllStringInVector
((
Hashtable
<
String
,
Object
>)
v
);
}
else
if
(
v
instanceof
String
)
{
Vector
<
String
>
vec
=
new
Vector
<>();
vec
.
add
((
String
)
v
);
stanzaTable
.
put
(
s
,
vec
);
}
}
}
}
src/share/classes/sun/security/krb5/internal/KDCOptions.java
浏览文件 @
8504c8ad
...
...
@@ -244,25 +244,23 @@ public class KDCOptions extends KerberosFlags {
Config
config
=
Config
.
getInstance
();
/*
* First see if the IBM hex format is being used.
* If not, try the Sun's string (boolean) format.
*/
// If key not present, returns Integer.MIN_VALUE, which is
// almost all zero.
int
options
=
config
.
getDefaultIntValue
(
"kdc_default_option
s"
,
"
libdefault
s"
);
int
options
=
config
.
getIntValue
(
"libdefault
s"
,
"
kdc_default_option
s"
);
if
((
options
&
RENEWABLE_OK
)
==
RENEWABLE_OK
)
{
set
(
RENEWABLE_OK
,
true
);
}
else
{
if
(
config
.
get
DefaultBooleanValue
(
"renewable"
,
"libdefaults
"
))
{
if
(
config
.
get
BooleanValue
(
"libdefaults"
,
"renewable
"
))
{
set
(
RENEWABLE_OK
,
true
);
}
}
if
((
options
&
PROXIABLE
)
==
PROXIABLE
)
{
set
(
PROXIABLE
,
true
);
}
else
{
if
(
config
.
get
DefaultBooleanValue
(
"proxiable"
,
"libdefaults
"
))
{
if
(
config
.
get
BooleanValue
(
"libdefaults"
,
"proxiable
"
))
{
set
(
PROXIABLE
,
true
);
}
}
...
...
@@ -270,7 +268,7 @@ public class KDCOptions extends KerberosFlags {
if
((
options
&
FORWARDABLE
)
==
FORWARDABLE
)
{
set
(
FORWARDABLE
,
true
);
}
else
{
if
(
config
.
get
DefaultBooleanValue
(
"forwardable"
,
"libdefaults
"
))
{
if
(
config
.
get
BooleanValue
(
"libdefaults"
,
"forwardable
"
))
{
set
(
FORWARDABLE
,
true
);
}
}
...
...
src/share/classes/sun/security/krb5/internal/KerberosTime.java
浏览文件 @
8504c8ad
...
...
@@ -350,9 +350,9 @@ public class KerberosTime implements Cloneable {
public
static
int
getDefaultSkew
()
{
int
tdiff
=
Krb5
.
DEFAULT_ALLOWABLE_CLOCKSKEW
;
try
{
Config
c
=
Config
.
getInstance
();
if
((
tdiff
=
c
.
getDefaultIntValue
(
"clockskew"
,
"libdefaults"
))
==
Integer
.
MIN_VALUE
)
{
//value is not defined
if
((
tdiff
=
Config
.
getInstance
().
getIntValue
(
"libdefaults"
,
"clockskew"
))
==
Integer
.
MIN_VALUE
)
{
//value is not defined
tdiff
=
Krb5
.
DEFAULT_ALLOWABLE_CLOCKSKEW
;
}
}
catch
(
KrbException
e
)
{
...
...
src/share/classes/sun/security/krb5/internal/crypto/CksumType.java
浏览文件 @
8504c8ad
...
...
@@ -126,10 +126,10 @@ public abstract class CksumType {
int
cksumType
=
Checksum
.
CKSUMTYPE_RSA_MD5
;
// default
try
{
Config
c
=
Config
.
getInstance
();
if
((
cksumType
=
(
c
.
getType
(
c
.
getDefault
(
"ap_req_checksum_type
"
,
"libdefaults
"
))))
==
-
1
)
{
if
((
cksumType
=
c
.
getType
(
c
.
getDefault
(
"checksum_type
"
,
"libdefaults
"
)))
==
-
1
)
{
if
((
cksumType
=
(
Config
.
getType
(
c
.
get
(
"libdefaults
"
,
"ap_req_checksum_type
"
))))
==
-
1
)
{
if
((
cksumType
=
Config
.
getType
(
c
.
get
(
"libdefaults
"
,
"checksum_type
"
)))
==
-
1
)
{
cksumType
=
Checksum
.
CKSUMTYPE_RSA_MD5
;
// default
}
}
...
...
src/share/classes/sun/security/krb5/internal/crypto/EType.java
浏览文件 @
8504c8ad
...
...
@@ -48,13 +48,17 @@ import java.util.ArrayList;
public
abstract
class
EType
{
private
static
final
boolean
DEBUG
=
Krb5
.
DEBUG
;
private
static
final
boolean
ALLOW_WEAK_CRYPTO
;
private
static
boolean
allowWeakCrypto
;
static
{
initStatic
();
}
public
static
void
initStatic
()
{
boolean
allowed
=
true
;
try
{
Config
cfg
=
Config
.
getInstance
();
String
temp
=
cfg
.
get
Default
(
"allow_weak_crypto"
,
"libdefaults
"
);
String
temp
=
cfg
.
get
(
"libdefaults"
,
"allow_weak_crypto
"
);
if
(
temp
!=
null
&&
temp
.
equals
(
"false"
))
allowed
=
false
;
}
catch
(
Exception
exc
)
{
if
(
DEBUG
)
{
...
...
@@ -63,7 +67,7 @@ public abstract class EType {
exc
.
getMessage
());
}
}
ALLOW_WEAK_CRYPTO
=
allowed
;
allowWeakCrypto
=
allowed
;
}
public
static
EType
getInstance
(
int
eTypeConst
)
...
...
@@ -216,7 +220,7 @@ public abstract class EType {
}
else
{
result
=
BUILTIN_ETYPES
;
}
if
(!
ALLOW_WEAK_CRYPTO
)
{
if
(!
allowWeakCrypto
)
{
// The last 2 etypes are now weak ones
return
Arrays
.
copyOfRange
(
result
,
0
,
result
.
length
-
2
);
}
...
...
src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
浏览文件 @
8504c8ad
...
...
@@ -186,8 +186,8 @@ public class KeyTab implements KeyTabConstants {
}
else
{
String
kname
=
null
;
try
{
String
keytab_names
=
Config
.
getInstance
().
get
Default
(
"default_keytab_name"
,
"libdefaults
"
);
String
keytab_names
=
Config
.
getInstance
().
get
(
"libdefaults"
,
"default_keytab_name
"
);
if
(
keytab_names
!=
null
)
{
StringTokenizer
st
=
new
StringTokenizer
(
keytab_names
,
" "
);
while
(
st
.
hasMoreTokens
())
{
...
...
test/sun/security/krb5/ConfPlusProp.java
浏览文件 @
8504c8ad
...
...
@@ -25,6 +25,7 @@
* @bug 6857795
* @bug 6858589
* @bug 6972005
* @compile -XDignore.symbol.file ConfPlusProp.java
* @run main/othervm ConfPlusProp
* @summary krb5.conf ignored if system properties on realm and kdc are provided
*/
...
...
@@ -75,7 +76,7 @@ public class ConfPlusProp {
check
(
"R1"
,
"k1"
);
check
(
"R2"
,
"old"
);
check
(
"R3"
,
null
);
if
(!
config
.
get
Default
(
"forwardable"
,
"libdefaults
"
).
equals
(
"well"
))
{
if
(!
config
.
get
(
"libdefaults"
,
"forwardable
"
).
equals
(
"well"
))
{
throw
new
Exception
(
"Extra config error"
);
}
...
...
@@ -103,7 +104,7 @@ public class ConfPlusProp {
check
(
"R1"
,
null
);
check
(
"R2"
,
null
);
check
(
"R3"
,
null
);
if
(
config
.
get
Default
(
"forwardable"
,
"libdefaults
"
)
!=
null
)
{
if
(
config
.
get
(
"libdefaults"
,
"forwardable
"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
}
...
...
@@ -121,7 +122,7 @@ public class ConfPlusProp {
check
(
"R1"
,
"k1"
);
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
if
(!
config
.
get
Default
(
"forwardable"
,
"libdefaults
"
).
equals
(
"well"
))
{
if
(!
config
.
get
(
"libdefaults"
,
"forwardable
"
).
equals
(
"well"
))
{
throw
new
Exception
(
"Extra config error"
);
}
...
...
@@ -143,7 +144,7 @@ public class ConfPlusProp {
check
(
"R1"
,
"k2"
);
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
if
(
config
.
get
Default
(
"forwardable"
,
"libdefaults
"
)
!=
null
)
{
if
(
config
.
get
(
"libdefaults"
,
"forwardable
"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
}
...
...
test/sun/security/krb5/DnsFallback.java
浏览文件 @
8504c8ad
...
...
@@ -28,12 +28,20 @@
* @summary fix dns_fallback parse error, and use dns by default
*/
import
sun.security.krb5.*
;
import
java.io.*
;
import
java.lang.reflect.Method
;
import
sun.security.krb5.Config
;
public
class
DnsFallback
{
static
Method
useDNS_Realm
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
useDNS_Realm
=
Config
.
class
.
getDeclaredMethod
(
"useDNS_Realm"
);
useDNS_Realm
.
setAccessible
(
true
);
// for 6673164
check
(
"true"
,
"true"
,
true
);
check
(
"false"
,
"true"
,
false
);
...
...
@@ -48,22 +56,25 @@ public class DnsFallback {
check
(
null
,
null
,
true
);
}
static
void
check
(
String
realm
,
String
fallback
,
boolean
output
)
throws
Exception
{
FileOutputStream
fo
=
new
FileOutputStream
(
"dnsfallback.conf"
);
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"[libdefaults]\n"
);
if
(
realm
!=
null
)
{
sb
.
append
(
"dns_lookup_realm="
+
realm
+
"\n"
);
}
if
(
fallback
!=
null
)
{
sb
.
append
(
"dns_fallback="
+
fallback
+
"\n"
);
static
void
check
(
String
realm
,
String
fallback
,
boolean
output
)
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
(
fallback
!=
null
)
{
ps
.
println
(
"dns_fallback="
+
fallback
);
}
}
fo
.
write
(
sb
.
toString
().
getBytes
());
fo
.
close
();
System
.
setProperty
(
"java.security.krb5.conf"
,
"dnsfallback.conf"
);
Config
.
refresh
();
System
.
out
.
println
(
"Testing "
+
realm
+
", "
+
fallback
+
", "
+
output
);
if
(
Config
.
getInstance
().
useDNS_Realm
()
!=
output
)
{
if
(!
useDNS_Realm
.
invoke
(
Config
.
getInstance
()).
equals
(
output
))
{
throw
new
Exception
(
"Fail"
);
}
}
...
...
test/sun/security/krb5/ParseConfig.java
浏览文件 @
8504c8ad
...
...
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6319046
* @compile -XDignore.symbol.file ParseConfig.java
* @run main/othervm ParseConfig
* @summary Problem with parsing krb5.conf
*/
...
...
@@ -37,7 +38,7 @@ public class ParseConfig {
String
sample
=
"kdc.example.com kdc2.example.com"
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
String
expected
=
config
.
get
Default
(
"kdc"
,
"EXAMPLE_"
+
i
+
".COM
"
);
String
expected
=
config
.
get
All
(
"realms"
,
"EXAMPLE_"
+
i
+
".COM"
,
"kdc
"
);
if
(!
sample
.
equals
(
expected
))
{
throw
new
Exception
(
"krb5.conf: unexpected kdc value \""
+
expected
+
"\""
);
...
...
test/sun/security/krb5/auto/BasicKrb5Test.java
浏览文件 @
8504c8ad
...
...
@@ -25,6 +25,7 @@
* @test
* @bug 6706974
* @summary Add krb5 test infrastructure
* @compile -XDignore.symbol.file BasicKrb5Test.java
* @run main/othervm BasicKrb5Test
* @run main/othervm BasicKrb5Test des-cbc-crc
* @run main/othervm BasicKrb5Test des-cbc-md5
...
...
@@ -86,7 +87,7 @@ public class BasicKrb5Test {
new
OneKDC
(
etype
).
writeJAASConf
();
System
.
out
.
println
(
"Testing etype "
+
etype
);
if
(
etype
!=
null
&&
!
EType
.
isSupported
(
Config
.
get
Instance
().
get
Type
(
etype
)))
{
if
(
etype
!=
null
&&
!
EType
.
isSupported
(
Config
.
getType
(
etype
)))
{
// aes256 is not enabled on all systems
System
.
out
.
println
(
"Not supported."
);
return
;
...
...
test/sun/security/krb5/auto/MaxRetries.java
浏览文件 @
8504c8ad
...
...
@@ -108,7 +108,7 @@ public class MaxRetries {
if
(
line
.
startsWith
(
">>> KDCCommunication"
))
{
System
.
out
.
println
(
line
);
if
(
line
.
indexOf
(
timeoutTag
)
<
0
)
{
throw
new
Exception
(
"Wrong timeout value"
);
throw
new
Exception
(
"Wrong timeout value"
+
timeoutTag
);
}
count
--;
}
...
...
test/sun/security/krb5/config/Duplicates.java
0 → 100644
浏览文件 @
8504c8ad
/*
* Copyright (c) 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7184246
* @compile -XDignore.symbol.file Duplicates.java
* @run main/othervm Duplicates
* @summary Simplify Config.get() of krb5
*/
import
sun.security.krb5.Config
;
public
class
Duplicates
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"java.security.krb5.conf"
,
System
.
getProperty
(
"test.src"
,
"."
)
+
"/k1.conf"
);
Config
config
=
Config
.
getInstance
();
config
.
listTable
();
String
s
;
// Latter overwrites former for root section
s
=
config
.
get
(
"libdefaults"
,
"default_realm"
);
if
(
s
!=
null
)
{
throw
new
Exception
();
}
// Latter overwrites former for strings
s
=
config
.
get
(
"libdefaults"
,
"default_tkt_enctypes"
);
if
(!
s
.
equals
(
"aes256-cts"
))
{
throw
new
Exception
();
}
// Latter overwrites former for sub-section
s
=
config
.
get
(
"realms"
,
"R1"
,
"kdc"
);
if
(!
s
.
equals
(
"k2"
))
{
throw
new
Exception
(
s
);
}
// Duplicate keys in [realms] are merged
s
=
config
.
getAll
(
"realms"
,
"R2"
,
"kdc"
);
if
(!
s
.
equals
(
"k1 k2 k3 k4"
))
{
throw
new
Exception
(
s
);
}
// Duplicate keys in [capaths] are merged
s
=
config
.
getAll
(
"capaths"
,
"R1"
,
"R2"
);
if
(!
s
.
equals
(
"R3 R4 R5 R6"
))
{
throw
new
Exception
(
s
);
}
// We can be very deep now
s
=
config
.
get
(
"new"
,
"x"
,
"y"
,
"z"
,
"a"
,
"b"
,
"c"
);
if
(!
s
.
equals
(
"d"
))
{
throw
new
Exception
(
s
);
}
}
}
test/sun/security/krb5/config/SCDynamicConfigTest.java
0 → 100644
浏览文件 @
8504c8ad
/*
* Copyright (c) 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7184246
* @summary Simplify Config.get() of krb5
*/
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.util.Hashtable
;
import
java.util.Vector
;
import
sun.security.krb5.Config
;
import
sun.security.krb5.SCDynamicStoreConfig
;
public
class
SCDynamicConfigTest
{
static
Vector
<
Hashtable
<
String
,
String
>>
hosts
()
{
Vector
<
Hashtable
<
String
,
String
>>
result
=
new
Vector
<>();
Hashtable
<
String
,
String
>
pair
=
new
Hashtable
<>();
pair
.
put
(
"host"
,
"127.0.0.1"
);
result
.
add
(
pair
);
pair
=
new
Hashtable
<>();
pair
.
put
(
"host"
,
"127.0.0.2"
);
result
.
add
(
pair
);
return
result
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Reconstruct a typical SCDynamicConfig.getKerberosConfig() output
Hashtable
<
String
,
Object
>
conf
=
new
Hashtable
<>();
Hashtable
<
String
,
Object
>
libdefaults
=
new
Hashtable
<>();
libdefaults
.
put
(
"default_realm"
,
"REALM.COM"
);
conf
.
put
(
"libdefaults"
,
libdefaults
);
Hashtable
<
String
,
Object
>
realms
=
new
Hashtable
<>();
Hashtable
<
String
,
Object
>
thisRealm
=
new
Hashtable
<>();
realms
.
put
(
"REALM.COM"
,
thisRealm
);
thisRealm
.
put
(
"kpasswd"
,
hosts
());
thisRealm
.
put
(
"kadmin"
,
hosts
());
thisRealm
.
put
(
"kdc"
,
hosts
());
conf
.
put
(
"realms"
,
realms
);
Hashtable
<
String
,
Object
>
domain_realm
=
new
Hashtable
<>();
domain_realm
.
put
(
".realm.com"
,
"REALM.COM"
);
domain_realm
.
put
(
"realm.com"
,
"REALM.COM"
);
conf
.
put
(
"domain_realm"
,
domain_realm
);
System
.
out
.
println
(
"SCDynamicConfig:\n"
);
System
.
out
.
println
(
conf
);
// Simulate SCDynamicConfig.getConfig() output
Method
m
=
SCDynamicStoreConfig
.
class
.
getDeclaredMethod
(
"convertNativeConfig"
,
Hashtable
.
class
);
m
.
setAccessible
(
true
);
conf
=
(
Hashtable
)
m
.
invoke
(
null
,
conf
);
System
.
out
.
println
(
"\nkrb5.conf:\n"
);
System
.
out
.
println
(
conf
);
// Feed it into a Config object
System
.
setProperty
(
"java.security.krb5.conf"
,
"not-a-file"
);
Config
cf
=
Config
.
getInstance
();
Field
f
=
Config
.
class
.
getDeclaredField
(
"stanzaTable"
);
f
.
setAccessible
(
true
);
f
.
set
(
cf
,
conf
);
System
.
out
.
println
(
"\nConfig:\n"
);
System
.
out
.
println
(
cf
);
if
(!
cf
.
getDefaultRealm
().
equals
(
"REALM.COM"
))
{
throw
new
Exception
();
}
if
(!
cf
.
getKDCList
(
"REALM.COM"
).
equals
(
"127.0.0.1 127.0.0.2"
))
{
throw
new
Exception
();
}
if
(!
cf
.
get
(
"domain_realm"
,
".realm.com"
).
equals
(
"REALM.COM"
))
{
throw
new
Exception
();
}
}
}
test/sun/security/krb5/config/k1.conf
0 → 100644
浏览文件 @
8504c8ad
[
libdefaults
]
default_realm
=
R1
[
libdefaults
]
default_tkt_enctypes
=
aes128
-
cts
default_tkt_enctypes
=
aes256
-
cts
[
realms
]
R1
= {
kdc
=
k1
}
R1
= {
kdc
=
k2
}
R2
= {
kdc
=
k1
kdc
=
k2
k3
admin_server
=
a1
kdc
=
k4
}
[
capaths
]
R1
= {
R2
=
R3
R2
=
R4
R5
R2
=
R6
}
[
new
]
x
= {
y
= {
z
= {
a
= {
b
= {
c
=
d
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录