Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9f36164a
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看板
提交
9f36164a
编写于
8月 04, 2011
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7061379: [Kerberos] Cross-realm authentication fails, due to nameType problem
Reviewed-by: valeriep
上级
e58cd544
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
86 addition
and
18 deletion
+86
-18
src/share/classes/sun/security/krb5/PrincipalName.java
src/share/classes/sun/security/krb5/PrincipalName.java
+0
-6
test/sun/security/krb5/auto/KDC.java
test/sun/security/krb5/auto/KDC.java
+28
-12
test/sun/security/krb5/auto/PrincipalNameEquals.java
test/sun/security/krb5/auto/PrincipalNameEquals.java
+58
-0
未找到文件。
src/share/classes/sun/security/krb5/PrincipalName.java
浏览文件 @
9f36164a
...
@@ -173,12 +173,6 @@ public class PrincipalName
...
@@ -173,12 +173,6 @@ public class PrincipalName
boolean
equalsWithoutRealm
(
PrincipalName
other
)
{
boolean
equalsWithoutRealm
(
PrincipalName
other
)
{
if
(
nameType
!=
KRB_NT_UNKNOWN
&&
other
.
nameType
!=
KRB_NT_UNKNOWN
&&
nameType
!=
other
.
nameType
)
return
false
;
if
((
nameStrings
!=
null
&&
other
.
nameStrings
==
null
)
||
if
((
nameStrings
!=
null
&&
other
.
nameStrings
==
null
)
||
(
nameStrings
==
null
&&
other
.
nameStrings
!=
null
))
(
nameStrings
==
null
&&
other
.
nameStrings
!=
null
))
return
false
;
return
false
;
...
...
test/sun/security/krb5/auto/KDC.java
浏览文件 @
9f36164a
...
@@ -170,6 +170,10 @@ public class KDC {
...
@@ -170,6 +170,10 @@ public class KDC {
* Use only one preauth, so that some keys are not easy to generate
* Use only one preauth, so that some keys are not easy to generate
*/
*/
ONLY_ONE_PREAUTH
,
ONLY_ONE_PREAUTH
,
/**
* Set all name-type to a value in response
*/
RESP_NT
,
};
};
static
{
static
{
...
@@ -637,10 +641,16 @@ public class KDC {
...
@@ -637,10 +641,16 @@ public class KDC {
*/
*/
private
byte
[]
processTgsReq
(
byte
[]
in
)
throws
Exception
{
private
byte
[]
processTgsReq
(
byte
[]
in
)
throws
Exception
{
TGSReq
tgsReq
=
new
TGSReq
(
in
);
TGSReq
tgsReq
=
new
TGSReq
(
in
);
PrincipalName
service
=
tgsReq
.
reqBody
.
sname
;
if
(
options
.
containsKey
(
KDC
.
Option
.
RESP_NT
))
{
service
=
new
PrincipalName
(
service
.
getNameStrings
(),
(
int
)
options
.
get
(
KDC
.
Option
.
RESP_NT
));
service
.
setRealm
(
service
.
getRealm
());
}
try
{
try
{
System
.
out
.
println
(
realm
+
"> "
+
tgsReq
.
reqBody
.
cname
+
System
.
out
.
println
(
realm
+
"> "
+
tgsReq
.
reqBody
.
cname
+
" sends TGS-REQ for "
+
" sends TGS-REQ for "
+
tgsReq
.
reqBody
.
snam
e
);
servic
e
);
KDCReqBody
body
=
tgsReq
.
reqBody
;
KDCReqBody
body
=
tgsReq
.
reqBody
;
int
[]
eTypes
=
KDCReqBodyDotEType
(
body
);
int
[]
eTypes
=
KDCReqBodyDotEType
(
body
);
int
e2
=
eTypes
[
0
];
// etype for outgoing session key
int
e2
=
eTypes
[
0
];
// etype for outgoing session key
...
@@ -708,7 +718,7 @@ public class KDC {
...
@@ -708,7 +718,7 @@ public class KDC {
bFlags
[
Krb5
.
TKT_OPTS_MAY_POSTDATE
]
=
true
;
bFlags
[
Krb5
.
TKT_OPTS_MAY_POSTDATE
]
=
true
;
}
}
if
(
configMatch
(
""
,
body
.
snam
e
.
getNameString
(),
"ok-as-delegate"
))
{
if
(
configMatch
(
""
,
servic
e
.
getNameString
(),
"ok-as-delegate"
))
{
bFlags
[
Krb5
.
TKT_OPTS_DELEGATE
]
=
true
;
bFlags
[
Krb5
.
TKT_OPTS_DELEGATE
]
=
true
;
}
}
bFlags
[
Krb5
.
TKT_OPTS_INITIAL
]
=
true
;
bFlags
[
Krb5
.
TKT_OPTS_INITIAL
]
=
true
;
...
@@ -728,13 +738,13 @@ public class KDC {
...
@@ -728,13 +738,13 @@ public class KDC {
:
new
HostAddresses
(
:
new
HostAddresses
(
new
InetAddress
[]{
InetAddress
.
getLocalHost
()}),
new
InetAddress
[]{
InetAddress
.
getLocalHost
()}),
null
);
null
);
EncryptionKey
skey
=
keyForUser
(
body
.
snam
e
,
e3
,
true
);
EncryptionKey
skey
=
keyForUser
(
servic
e
,
e3
,
true
);
if
(
skey
==
null
)
{
if
(
skey
==
null
)
{
throw
new
KrbException
(
Krb5
.
KDC_ERR_SUMTYPE_NOSUPP
);
// TODO
throw
new
KrbException
(
Krb5
.
KDC_ERR_SUMTYPE_NOSUPP
);
// TODO
}
}
Ticket
t
=
new
Ticket
(
Ticket
t
=
new
Ticket
(
body
.
crealm
,
body
.
crealm
,
body
.
snam
e
,
servic
e
,
new
EncryptedData
(
skey
,
enc
.
asn1Encode
(),
KeyUsage
.
KU_TICKET
)
new
EncryptedData
(
skey
,
enc
.
asn1Encode
(),
KeyUsage
.
KU_TICKET
)
);
);
EncTGSRepPart
enc_part
=
new
EncTGSRepPart
(
EncTGSRepPart
enc_part
=
new
EncTGSRepPart
(
...
@@ -750,7 +760,7 @@ public class KDC {
...
@@ -750,7 +760,7 @@ public class KDC {
body
.
from
,
body
.
from
,
till
,
body
.
rtime
,
till
,
body
.
rtime
,
body
.
crealm
,
body
.
crealm
,
body
.
snam
e
,
servic
e
,
body
.
addresses
!=
null
// always set caddr
body
.
addresses
!=
null
// always set caddr
?
body
.
addresses
?
body
.
addresses
:
new
HostAddresses
(
:
new
HostAddresses
(
...
@@ -781,7 +791,7 @@ public class KDC {
...
@@ -781,7 +791,7 @@ public class KDC {
0
,
0
,
ke
.
returnCode
(),
ke
.
returnCode
(),
body
.
crealm
,
body
.
cname
,
body
.
crealm
,
body
.
cname
,
new
Realm
(
getRealm
()),
body
.
snam
e
,
new
Realm
(
getRealm
()),
servic
e
,
KrbException
.
errorMessage
(
ke
.
returnCode
()),
KrbException
.
errorMessage
(
ke
.
returnCode
()),
null
);
null
);
}
}
...
@@ -800,10 +810,16 @@ public class KDC {
...
@@ -800,10 +810,16 @@ public class KDC {
int
[]
eTypes
=
null
;
int
[]
eTypes
=
null
;
List
<
PAData
>
outPAs
=
new
ArrayList
<>();
List
<
PAData
>
outPAs
=
new
ArrayList
<>();
PrincipalName
service
=
asReq
.
reqBody
.
sname
;
if
(
options
.
containsKey
(
KDC
.
Option
.
RESP_NT
))
{
service
=
new
PrincipalName
(
service
.
getNameStrings
(),
(
int
)
options
.
get
(
KDC
.
Option
.
RESP_NT
));
service
.
setRealm
(
service
.
getRealm
());
}
try
{
try
{
System
.
out
.
println
(
realm
+
"> "
+
asReq
.
reqBody
.
cname
+
System
.
out
.
println
(
realm
+
"> "
+
asReq
.
reqBody
.
cname
+
" sends AS-REQ for "
+
" sends AS-REQ for "
+
asReq
.
reqBody
.
snam
e
);
servic
e
);
KDCReqBody
body
=
asReq
.
reqBody
;
KDCReqBody
body
=
asReq
.
reqBody
;
body
.
cname
.
setRealm
(
getRealm
());
body
.
cname
.
setRealm
(
getRealm
());
...
@@ -812,7 +828,7 @@ public class KDC {
...
@@ -812,7 +828,7 @@ public class KDC {
int
eType
=
eTypes
[
0
];
int
eType
=
eTypes
[
0
];
EncryptionKey
ckey
=
keyForUser
(
body
.
cname
,
eType
,
false
);
EncryptionKey
ckey
=
keyForUser
(
body
.
cname
,
eType
,
false
);
EncryptionKey
skey
=
keyForUser
(
body
.
snam
e
,
eType
,
true
);
EncryptionKey
skey
=
keyForUser
(
servic
e
,
eType
,
true
);
if
(
options
.
containsKey
(
KDC
.
Option
.
ONLY_RC4_TGT
))
{
if
(
options
.
containsKey
(
KDC
.
Option
.
ONLY_RC4_TGT
))
{
int
tgtEType
=
EncryptedData
.
ETYPE_ARCFOUR_HMAC
;
int
tgtEType
=
EncryptedData
.
ETYPE_ARCFOUR_HMAC
;
...
@@ -826,7 +842,7 @@ public class KDC {
...
@@ -826,7 +842,7 @@ public class KDC {
if
(!
found
)
{
if
(!
found
)
{
throw
new
KrbException
(
Krb5
.
KDC_ERR_ETYPE_NOSUPP
);
throw
new
KrbException
(
Krb5
.
KDC_ERR_ETYPE_NOSUPP
);
}
}
skey
=
keyForUser
(
body
.
snam
e
,
tgtEType
,
true
);
skey
=
keyForUser
(
servic
e
,
tgtEType
,
true
);
}
}
if
(
ckey
==
null
)
{
if
(
ckey
==
null
)
{
throw
new
KrbException
(
Krb5
.
KDC_ERR_ETYPE_NOSUPP
);
throw
new
KrbException
(
Krb5
.
KDC_ERR_ETYPE_NOSUPP
);
...
@@ -943,7 +959,7 @@ public class KDC {
...
@@ -943,7 +959,7 @@ public class KDC {
null
);
null
);
Ticket
t
=
new
Ticket
(
Ticket
t
=
new
Ticket
(
body
.
crealm
,
body
.
crealm
,
body
.
snam
e
,
servic
e
,
new
EncryptedData
(
skey
,
enc
.
asn1Encode
(),
KeyUsage
.
KU_TICKET
)
new
EncryptedData
(
skey
,
enc
.
asn1Encode
(),
KeyUsage
.
KU_TICKET
)
);
);
EncASRepPart
enc_part
=
new
EncASRepPart
(
EncASRepPart
enc_part
=
new
EncASRepPart
(
...
@@ -959,7 +975,7 @@ public class KDC {
...
@@ -959,7 +975,7 @@ public class KDC {
body
.
from
,
body
.
from
,
till
,
body
.
rtime
,
till
,
body
.
rtime
,
body
.
crealm
,
body
.
crealm
,
body
.
snam
e
,
servic
e
,
body
.
addresses
body
.
addresses
);
);
EncryptedData
edata
=
new
EncryptedData
(
ckey
,
enc_part
.
asn1Encode
(),
KeyUsage
.
KU_ENC_AS_REP_PART
);
EncryptedData
edata
=
new
EncryptedData
(
ckey
,
enc_part
.
asn1Encode
(),
KeyUsage
.
KU_ENC_AS_REP_PART
);
...
@@ -1023,7 +1039,7 @@ public class KDC {
...
@@ -1023,7 +1039,7 @@ public class KDC {
0
,
0
,
ke
.
returnCode
(),
ke
.
returnCode
(),
body
.
crealm
,
body
.
cname
,
body
.
crealm
,
body
.
cname
,
new
Realm
(
getRealm
()),
body
.
snam
e
,
new
Realm
(
getRealm
()),
servic
e
,
KrbException
.
errorMessage
(
ke
.
returnCode
()),
KrbException
.
errorMessage
(
ke
.
returnCode
()),
eData
);
eData
);
}
}
...
...
test/sun/security/krb5/auto/PrincipalNameEquals.java
0 → 100644
浏览文件 @
9f36164a
/*
* Copyright (c) 2011, 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 7061379
* @summary [Kerberos] Cross-realm authentication fails, due to nameType problem
* @compile -XDignore.symbol.file PrincipalNameEquals.java
* @run main/othervm PrincipalNameEquals
*/
import
sun.security.jgss.GSSUtil
;
import
sun.security.krb5.PrincipalName
;
public
class
PrincipalNameEquals
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
OneKDC
kdc
=
new
OneKDC
(
null
);
kdc
.
writeJAASConf
();
kdc
.
setOption
(
KDC
.
Option
.
RESP_NT
,
PrincipalName
.
KRB_NT_PRINCIPAL
);
Context
c
,
s
;
c
=
Context
.
fromJAAS
(
"client"
);
s
=
Context
.
fromJAAS
(
"server"
);
c
.
startAsClient
(
OneKDC
.
SERVER
,
GSSUtil
.
GSS_KRB5_MECH_OID
);
s
.
startAsServer
(
GSSUtil
.
GSS_KRB5_MECH_OID
);
Context
.
handshake
(
c
,
s
);
Context
.
transmit
(
"i say high --"
,
c
,
s
);
Context
.
transmit
(
" you say low"
,
s
,
c
);
s
.
dispose
();
c
.
dispose
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录