Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
30f766b9
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看板
提交
30f766b9
编写于
1月 12, 2020
作者:
A
andrew
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8186884: Test native KDC, Java krb5 lib, and native krb5 lib in one test
Reviewed-by: mbalao
上级
15b81d15
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
844 addition
and
257 deletion
+844
-257
test/java/security/testlibrary/Proc.java
test/java/security/testlibrary/Proc.java
+13
-2
test/sun/security/krb5/auto/BasicProc.java
test/sun/security/krb5/auto/BasicProc.java
+293
-154
test/sun/security/krb5/auto/Context.java
test/sun/security/krb5/auto/Context.java
+74
-11
test/sun/security/krb5/auto/KDC.java
test/sun/security/krb5/auto/KDC.java
+464
-90
未找到文件。
test/java/security/testlibrary/Proc.java
浏览文件 @
30f766b9
...
@@ -235,6 +235,13 @@ public class Proc {
...
@@ -235,6 +235,13 @@ public class Proc {
br
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
br
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
return
this
;
return
this
;
}
}
String
getId
(
String
suffix
)
{
if
(
debug
!=
null
)
{
return
debug
+
"."
+
suffix
;
}
else
{
return
System
.
identityHashCode
(
this
)
+
"."
+
suffix
;
}
}
// Reads a line from stdout of proc
// Reads a line from stdout of proc
public
String
readLine
()
throws
IOException
{
public
String
readLine
()
throws
IOException
{
String
s
=
br
.
readLine
();
String
s
=
br
.
readLine
();
...
@@ -303,9 +310,13 @@ public class Proc {
...
@@ -303,9 +310,13 @@ public class Proc {
boolean
isEmpty
=
true
;
boolean
isEmpty
=
true
;
while
(
true
)
{
while
(
true
)
{
int
i
=
System
.
in
.
read
();
int
i
=
System
.
in
.
read
();
if
(
i
==
-
1
)
break
;
if
(
i
==
-
1
)
{
break
;
}
isEmpty
=
false
;
isEmpty
=
false
;
if
(
i
==
'\n'
)
break
;
if
(
i
==
'\n'
)
{
break
;
}
if
(
i
!=
13
)
{
if
(
i
!=
13
)
{
// Force it to a char, so only simple ASCII works.
// Force it to a char, so only simple ASCII works.
sb
.
append
((
char
)
i
);
sb
.
append
((
char
)
i
);
...
...
test/sun/security/krb5/auto/BasicProc.java
浏览文件 @
30f766b9
此差异已折叠。
点击以展开。
test/sun/security/krb5/auto/Context.java
浏览文件 @
30f766b9
/*
/*
* Copyright (c) 2008, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
7
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -22,14 +22,21 @@
...
@@ -22,14 +22,21 @@
*/
*/
import
com.sun.security.auth.module.Krb5LoginModule
;
import
com.sun.security.auth.module.Krb5LoginModule
;
import
java.
security.Key
;
import
java.
io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.security.PrivilegedActionException
;
import
java.security.PrivilegedActionException
;
import
java.security.PrivilegedExceptionAction
;
import
java.security.PrivilegedExceptionAction
;
import
java.security.Key
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.security.auth.Subject
;
import
javax.security.auth.Subject
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.CallbackHandler
;
import
javax.security.auth.callback.NameCallback
;
import
javax.security.auth.callback.PasswordCallback
;
import
javax.security.auth.callback.UnsupportedCallbackException
;
import
javax.security.auth.kerberos.KerberosKey
;
import
javax.security.auth.kerberos.KerberosKey
;
import
javax.security.auth.kerberos.KerberosTicket
;
import
javax.security.auth.kerberos.KerberosTicket
;
import
javax.security.auth.login.LoginContext
;
import
javax.security.auth.login.LoginContext
;
...
@@ -40,6 +47,10 @@ import org.ietf.jgss.GSSManager;
...
@@ -40,6 +47,10 @@ import org.ietf.jgss.GSSManager;
import
org.ietf.jgss.GSSName
;
import
org.ietf.jgss.GSSName
;
import
org.ietf.jgss.MessageProp
;
import
org.ietf.jgss.MessageProp
;
import
org.ietf.jgss.Oid
;
import
org.ietf.jgss.Oid
;
import
sun.security.jgss.krb5.Krb5Util
;
import
sun.security.krb5.Credentials
;
import
sun.security.krb5.internal.ccache.CredentialsCache
;
import
com.sun.security.jgss.ExtendedGSSContext
;
import
com.sun.security.jgss.ExtendedGSSContext
;
import
com.sun.security.jgss.InquireType
;
import
com.sun.security.jgss.InquireType
;
import
com.sun.security.jgss.AuthorizationDataEntry
;
import
com.sun.security.jgss.AuthorizationDataEntry
;
...
@@ -154,24 +165,36 @@ public class Context {
...
@@ -154,24 +165,36 @@ public class Context {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
shared
=
new
HashMap
<>();
Map
<
String
,
Object
>
shared
=
new
HashMap
<>();
if
(
storeKey
)
{
map
.
put
(
"storeKey"
,
"true"
);
}
if
(
pass
!=
null
)
{
if
(
pass
!=
null
)
{
map
.
put
(
"useFirstPass"
,
"true"
);
krb5
.
initialize
(
out
.
s
,
new
CallbackHandler
()
{
shared
.
put
(
"javax.security.auth.login.name"
,
user
);
@Override
shared
.
put
(
"javax.security.auth.login.password"
,
pass
);
public
void
handle
(
Callback
[]
callbacks
)
throws
IOException
,
UnsupportedCallbackException
{
for
(
Callback
cb:
callbacks
)
{
if
(
cb
instanceof
NameCallback
)
{
((
NameCallback
)
cb
).
setName
(
user
);
}
else
if
(
cb
instanceof
PasswordCallback
)
{
((
PasswordCallback
)
cb
).
setPassword
(
pass
);
}
}
}
},
shared
,
map
);
}
else
{
}
else
{
map
.
put
(
"doNotPrompt"
,
"true"
);
map
.
put
(
"doNotPrompt"
,
"true"
);
map
.
put
(
"useTicketCache"
,
"true"
);
map
.
put
(
"useTicketCache"
,
"true"
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
map
.
put
(
"principal"
,
user
);
map
.
put
(
"principal"
,
user
);
}
}
}
krb5
.
initialize
(
out
.
s
,
null
,
shared
,
map
);
if
(
storeKey
)
{
map
.
put
(
"storeKey"
,
"true"
);
}
}
krb5
.
initialize
(
out
.
s
,
null
,
shared
,
map
);
krb5
.
login
();
krb5
.
login
();
krb5
.
commit
();
krb5
.
commit
();
return
out
;
return
out
;
}
}
...
@@ -529,9 +552,23 @@ public class Context {
...
@@ -529,9 +552,23 @@ public class Context {
* @param s2 the receiver
* @param s2 the receiver
* @throws java.lang.Exception If anything goes wrong
* @throws java.lang.Exception If anything goes wrong
*/
*/
static
public
void
transmit
(
final
String
message
,
final
Context
s1
,
static
public
void
transmit
(
String
message
,
final
Context
s1
,
final
Context
s2
)
throws
Exception
{
transmit
(
message
.
getBytes
(),
s1
,
s2
);
}
/**
* Transmits a message from one Context to another. The sender wraps the
* message and sends it to the receiver. The receiver unwraps it, creates
* a MIC of the clear text and sends it back to the sender. The sender
* verifies the MIC against the message sent earlier.
* @param messageBytes the message
* @param s1 the sender
* @param s2 the receiver
* @throws java.lang.Exception If anything goes wrong
*/
static
public
void
transmit
(
byte
[]
messageBytes
,
final
Context
s1
,
final
Context
s2
)
throws
Exception
{
final
Context
s2
)
throws
Exception
{
final
byte
[]
messageBytes
=
message
.
getBytes
();
System
.
out
.
printf
(
"-------------------- TRANSMIT from %s to %s------------------------\n"
,
System
.
out
.
printf
(
"-------------------- TRANSMIT from %s to %s------------------------\n"
,
s1
.
name
,
s2
.
name
);
s1
.
name
,
s2
.
name
);
byte
[]
wrapped
=
s1
.
wrap
(
messageBytes
,
true
);
byte
[]
wrapped
=
s1
.
wrap
(
messageBytes
,
true
);
...
@@ -615,6 +652,32 @@ public class Context {
...
@@ -615,6 +652,32 @@ public class Context {
},
in
);
},
in
);
}
}
/**
* Saves the tickets to a ccache file.
*
* @param file pathname of the ccache file
* @return true if created, false otherwise.
*/
public
boolean
ccache
(
String
file
)
throws
Exception
{
Set
<
KerberosTicket
>
tickets
=
s
.
getPrivateCredentials
(
KerberosTicket
.
class
);
if
(
tickets
!=
null
&&
!
tickets
.
isEmpty
())
{
CredentialsCache
cc
=
null
;
for
(
KerberosTicket
t
:
tickets
)
{
Credentials
cred
=
Krb5Util
.
ticketToCreds
(
t
);
if
(
cc
==
null
)
{
cc
=
CredentialsCache
.
create
(
cred
.
getClient
(),
file
);
}
cc
.
update
(
cred
.
toCCacheCreds
());
}
if
(
cc
!=
null
)
{
cc
.
save
();
return
true
;
}
}
return
false
;
}
/**
/**
* Handshake (security context establishment process) between two Contexts
* Handshake (security context establishment process) between two Contexts
* @param c the initiator
* @param c the initiator
...
...
test/sun/security/krb5/auto/KDC.java
浏览文件 @
30f766b9
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录