Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
15b81d15
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看板
提交
15b81d15
编写于
1月 12, 2020
作者:
A
andrew
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
Reviewed-by: mbalao
上级
633bf559
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
98 addition
and
10 deletion
+98
-10
src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
...classes/com/sun/security/auth/module/Krb5LoginModule.java
+4
-0
src/share/classes/javax/security/auth/kerberos/KerberosTicket.java
.../classes/javax/security/auth/kerberos/KerberosTicket.java
+6
-5
src/share/classes/sun/security/krb5/KrbTgsReq.java
src/share/classes/sun/security/krb5/KrbTgsReq.java
+7
-1
test/sun/security/krb5/auto/KDC.java
test/sun/security/krb5/auto/KDC.java
+14
-4
test/sun/security/krb5/auto/NullRenewUntil.java
test/sun/security/krb5/auto/NullRenewUntil.java
+67
-0
未找到文件。
src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
浏览文件 @
15b81d15
...
...
@@ -1021,6 +1021,10 @@ public class Krb5LoginModule implements LoginModule {
if
(!
creds
.
isRenewable
())
throw
new
RefreshFailedException
(
"This ticket"
+
" is not renewable"
);
if
(
creds
.
getRenewTill
()
==
null
)
{
// Renewable ticket without renew-till. Illegal and ignored.
return
creds
;
}
if
(
System
.
currentTimeMillis
()
>
cred
.
getRenewTill
().
getTime
())
throw
new
RefreshFailedException
(
"This ticket is past "
+
"its last renewal time."
);
...
...
src/share/classes/javax/security/auth/kerberos/KerberosTicket.java
浏览文件 @
15b81d15
...
...
@@ -308,11 +308,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
}
else
this
.
flags
=
new
boolean
[
NUM_FLAGS
];
if
(
this
.
flags
[
RENEWABLE_TICKET_FLAG
])
{
if
(
renewTill
==
null
)
throw
new
IllegalArgumentException
(
"The renewable period "
+
"end time cannot be null for renewable tickets."
);
if
(
this
.
flags
[
RENEWABLE_TICKET_FLAG
]
&&
renewTill
!=
null
)
{
this
.
renewTill
=
new
Date
(
renewTill
.
getTime
());
}
...
...
@@ -553,6 +549,11 @@ public class KerberosTicket implements Destroyable, Refreshable,
if
(!
isRenewable
())
throw
new
RefreshFailedException
(
"This ticket is not renewable"
);
if
(
getRenewTill
()
==
null
)
{
// Renewable ticket without renew-till. Illegal and ignored.
return
;
}
if
(
System
.
currentTimeMillis
()
>
getRenewTill
().
getTime
())
throw
new
RefreshFailedException
(
"This ticket is past "
+
"its last renewal time."
);
...
...
src/share/classes/sun/security/krb5/KrbTgsReq.java
浏览文件 @
15b81d15
...
...
@@ -35,6 +35,7 @@ import sun.security.krb5.internal.*;
import
sun.security.krb5.internal.crypto.*
;
import
java.io.IOException
;
import
java.net.UnknownHostException
;
import
java.time.Instant
;
import
java.util.Arrays
;
/**
...
...
@@ -250,7 +251,12 @@ public class KrbTgsReq {
throws
IOException
,
KrbException
,
UnknownHostException
{
KerberosTime
req_till
=
null
;
if
(
till
==
null
)
{
req_till
=
new
KerberosTime
(
0
);
String
d
=
Config
.
getInstance
().
get
(
"libdefaults"
,
"ticket_lifetime"
);
if
(
d
!=
null
)
{
req_till
=
new
KerberosTime
(
Instant
.
now
().
plusSeconds
(
Config
.
duration
(
d
)));
}
else
{
req_till
=
new
KerberosTime
(
0
);
// Choose KDC maximum allowed
}
}
else
{
req_till
=
till
;
}
...
...
test/sun/security/krb5/auto/KDC.java
浏览文件 @
15b81d15
...
...
@@ -30,8 +30,6 @@ import java.lang.reflect.Method;
import
java.security.SecureRandom
;
import
java.time.Instant
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.TemporalAmount
;
import
java.time.temporal.TemporalUnit
;
import
java.util.*
;
import
java.util.concurrent.*
;
...
...
@@ -912,6 +910,18 @@ public class KDC {
}
bFlags
[
Krb5
.
TKT_OPTS_INITIAL
]
=
true
;
KerberosTime
renewTill
=
etp
.
renewTill
;
if
(
renewTill
!=
null
&&
body
.
kdcOptions
.
get
(
KDCOptions
.
RENEW
))
{
// till should never pass renewTill
if
(
till
.
greaterThan
(
renewTill
))
{
till
=
renewTill
;
}
if
(
System
.
getProperty
(
"test.set.null.renew"
)
!=
null
)
{
// Testing 8186576, see NullRenewUntil.java.
renewTill
=
null
;
}
}
TicketFlags
tFlags
=
new
TicketFlags
(
bFlags
);
EncTicketPart
enc
=
new
EncTicketPart
(
tFlags
,
...
...
@@ -920,7 +930,7 @@ public class KDC {
new
TransitedEncoding
(
1
,
new
byte
[
0
]),
// TODO
new
KerberosTime
(
new
Date
()),
body
.
from
,
till
,
etp
.
renewTill
,
till
,
renewTill
,
body
.
addresses
!=
null
// always set caddr
?
body
.
addresses
:
new
HostAddresses
(
...
...
@@ -947,7 +957,7 @@ public class KDC {
tFlags
,
new
KerberosTime
(
new
Date
()),
body
.
from
,
till
,
etp
.
renewTill
,
till
,
renewTill
,
service
,
body
.
addresses
!=
null
// always set caddr
?
body
.
addresses
...
...
test/sun/security/krb5/auto/NullRenewUntil.java
0 → 100644
浏览文件 @
15b81d15
/*
* Copyright (c) 2017, 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 8186576
* @summary KerberosTicket does not properly handle renewable tickets
* at the end of their lifetime
* @library /lib/testlibrary/
* @compile -XDignore.symbol.file NullRenewUntil.java
* @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock -Dtest.set.null.renew NullRenewUntil
*/
import
jdk.testlibrary.Asserts
;
import
sun.security.krb5.Config
;
import
javax.security.auth.kerberos.KerberosTicket
;
public
class
NullRenewUntil
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
OneKDC
kdc
=
new
OneKDC
(
null
);
KDC
.
saveConfig
(
OneKDC
.
KRB5_CONF
,
kdc
,
"ticket_lifetime = 10s"
,
"renew_lifetime = 11s"
);
Config
.
refresh
();
KerberosTicket
ticket
=
Context
.
fromUserPass
(
OneKDC
.
USER
,
OneKDC
.
PASS
,
false
).
s
()
.
getPrivateCredentials
(
KerberosTicket
.
class
).
iterator
().
next
();
System
.
out
.
println
(
ticket
);
Asserts
.
assertTrue
(
ticket
.
getRenewTill
()
!=
null
,
ticket
.
toString
());
Thread
.
sleep
(
2000
);
ticket
.
refresh
();
System
.
out
.
println
(
ticket
);
Asserts
.
assertTrue
(
ticket
.
getRenewTill
()
==
null
,
ticket
.
toString
());
Thread
.
sleep
(
2000
);
ticket
.
refresh
();
System
.
out
.
println
(
ticket
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录