Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ffabb003
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看板
提交
ffabb003
编写于
12月 11, 2012
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8004488: wrong permissions checked in krb5
Reviewed-by: xuelei
上级
86fad0e0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
71 addition
and
67 deletion
+71
-67
src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
...classes/com/sun/security/auth/module/Krb5LoginModule.java
+0
-4
src/share/classes/sun/security/jgss/krb5/Krb5Util.java
src/share/classes/sun/security/jgss/krb5/Krb5Util.java
+12
-48
test/sun/security/krb5/auto/KeyPermissions.java
test/sun/security/krb5/auto/KeyPermissions.java
+56
-0
test/sun/security/krb5/auto/KeyTabCompat.java
test/sun/security/krb5/auto/KeyTabCompat.java
+3
-15
未找到文件。
src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
浏览文件 @
ffabb003
...
...
@@ -1067,10 +1067,6 @@ public class Krb5LoginModule implements LoginModule {
if
(
ktab
!=
null
)
{
if
(!
privCredSet
.
contains
(
ktab
))
{
privCredSet
.
add
(
ktab
);
// Compatibility; also add keys to privCredSet
for
(
KerberosKey
key:
ktab
.
getKeys
(
kerbClientPrinc
))
{
privCredSet
.
add
(
new
Krb5Util
.
KeysFromKeyTab
(
key
));
}
}
}
else
{
succeeded
=
false
;
...
...
src/share/classes/sun/security/jgss/krb5/Krb5Util.java
浏览文件 @
ffabb003
...
...
@@ -40,10 +40,7 @@ import sun.security.krb5.EncryptionKey;
import
sun.security.krb5.KrbException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
sun.security.krb5.KerberosSecrets
;
import
sun.security.krb5.PrincipalName
;
/**
...
...
@@ -189,18 +186,6 @@ public class Krb5Util {
return
subject
;
}
// A special KerberosKey, used as keys read from a KeyTab object.
// Each time new keys are read from KeyTab objects in the private
// credentials set, old ones are removed and new ones added.
public
static
class
KeysFromKeyTab
extends
KerberosKey
{
private
static
final
long
serialVersionUID
=
8238092170252746927L
;
public
KeysFromKeyTab
(
KerberosKey
key
)
{
super
(
key
.
getPrincipal
(),
key
.
getEncoded
(),
key
.
getKeyType
(),
key
.
getVersionNumber
());
}
}
/**
* Credentials of a service, the private secret to authenticate its
* identity, which can be:
...
...
@@ -239,7 +224,7 @@ public class Krb5Util {
// Compatibility with old behavior: even when there is no
// KerberosPrincipal, we can find one from KerberosKeys
List
<
KerberosKey
>
keys
=
SubjectComber
.
findMany
(
subj
,
nul
l
,
null
,
KerberosKey
.
class
);
subj
,
serverPrincipa
l
,
null
,
KerberosKey
.
class
);
if
(!
keys
.
isEmpty
())
{
sc
.
kp
=
keys
.
get
(
0
).
getPrincipal
();
serverPrincipal
=
sc
.
kp
.
getName
();
...
...
@@ -255,9 +240,9 @@ public class Krb5Util {
subj
,
null
,
null
,
KeyTab
.
class
);
sc
.
kk
=
SubjectComber
.
findMany
(
subj
,
serverPrincipal
,
null
,
KerberosKey
.
class
);
sc
.
tgt
=
SubjectComber
.
find
(
subj
,
null
,
null
,
KerberosTicket
.
class
);
if
(
sc
.
ktabs
.
isEmpty
()
&&
sc
.
kk
.
isEmpty
())
{
sc
.
tgt
=
SubjectComber
.
find
(
subj
,
null
,
serverPrincipal
,
KerberosTicket
.
class
);
if
(
sc
.
ktabs
.
isEmpty
()
&&
sc
.
kk
.
isEmpty
()
&&
sc
.
tgt
==
null
)
{
return
null
;
}
return
sc
;
...
...
@@ -268,37 +253,16 @@ public class Krb5Util {
}
public
KerberosKey
[]
getKKeys
()
{
if
(
ktabs
.
isEmpty
())
{
return
kk
.
toArray
(
new
KerberosKey
[
kk
.
size
()]);
}
else
{
List
<
KerberosKey
>
keys
=
new
ArrayList
<>();
for
(
KeyTab
ktab:
ktabs
)
{
for
(
KerberosKey
k:
ktab
.
getKeys
(
kp
))
{
keys
.
add
(
k
);
}
}
// Compatibility: also add keys to privCredSet. Remove old
// ones first, only remove those from keytab.
if
(!
subj
.
isReadOnly
())
{
Set
<
Object
>
pcs
=
subj
.
getPrivateCredentials
();
synchronized
(
pcs
)
{
Iterator
<
Object
>
iterator
=
pcs
.
iterator
();
while
(
iterator
.
hasNext
())
{
Object
obj
=
iterator
.
next
();
if
(
obj
instanceof
KeysFromKeyTab
)
{
KerberosKey
key
=
(
KerberosKey
)
obj
;
if
(
Objects
.
equals
(
key
.
getPrincipal
(),
kp
))
{
iterator
.
remove
();
}
}
}
}
for
(
KerberosKey
key:
keys
)
{
subj
.
getPrivateCredentials
().
add
(
new
KeysFromKeyTab
(
key
));
}
List
<
KerberosKey
>
keys
=
new
ArrayList
<>();
for
(
KerberosKey
k:
kk
)
{
keys
.
add
(
k
);
}
for
(
KeyTab
ktab:
ktabs
)
{
for
(
KerberosKey
k:
ktab
.
getKeys
(
kp
))
{
keys
.
add
(
k
);
}
return
keys
.
toArray
(
new
KerberosKey
[
keys
.
size
()]);
}
return
keys
.
toArray
(
new
KerberosKey
[
keys
.
size
()]);
}
public
EncryptionKey
[]
getEKeys
()
{
...
...
test/sun/security/krb5/auto/KeyPermissions.java
0 → 100644
浏览文件 @
ffabb003
/*
* 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 8004488
* @summary wrong permissions checked in krb5
* @compile -XDignore.symbol.file KeyPermissions.java
* @run main/othervm KeyPermissions
*/
import
java.security.AccessControlException
;
import
java.security.Permission
;
import
javax.security.auth.PrivateCredentialPermission
;
import
sun.security.jgss.GSSUtil
;
public
class
KeyPermissions
extends
SecurityManager
{
@Override
public
void
checkPermission
(
Permission
perm
)
{
if
(
perm
instanceof
PrivateCredentialPermission
)
{
if
(!
perm
.
getName
().
startsWith
(
"javax.security.auth.kerberos."
))
{
throw
new
AccessControlException
(
"I don't like this"
,
perm
);
}
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setSecurityManager
(
new
KeyPermissions
());
new
OneKDC
(
null
).
writeJAASConf
();
Context
s
=
Context
.
fromJAAS
(
"server"
);
s
.
startAsServer
(
GSSUtil
.
GSS_KRB5_MECH_OID
);
}
}
test/sun/security/krb5/auto/KeyTabCompat.java
浏览文件 @
ffabb003
...
...
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6894072
* @bug 8004488
* @compile -XDignore.symbol.file KeyTabCompat.java
* @run main/othervm KeyTabCompat
* @summary always refresh keytab
...
...
@@ -70,21 +71,8 @@ public class KeyTabCompat {
s
.
startAsServer
(
GSSUtil
.
GSS_KRB5_MECH_OID
);
s
.
status
();
if
(
s
.
s
().
getPrivateCredentials
(
KerberosKey
.
class
).
size
()
!=
1
)
{
throw
new
Exception
(
"There should be
one
KerberosKey"
);
if
(
s
.
s
().
getPrivateCredentials
(
KerberosKey
.
class
).
size
()
!=
0
)
{
throw
new
Exception
(
"There should be
no
KerberosKey"
);
}
Thread
.
sleep
(
2000
);
// make sure ktab timestamp is different
kdc
.
addPrincipal
(
OneKDC
.
SERVER
,
"pass2"
.
toCharArray
());
kdc
.
writeKtab
(
OneKDC
.
KTAB
);
Context
.
handshake
(
c
,
s
);
s
.
status
();
if
(
s
.
s
().
getPrivateCredentials
(
KerberosKey
.
class
).
size
()
!=
1
)
{
throw
new
Exception
(
"There should be only one KerberosKey"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录