Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
a22d7f21
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a22d7f21
编写于
9月 22, 2009
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6877357: IPv6 address does not work
Reviewed-by: xuelei, alanb
上级
7c34f84b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
163 addition
and
5 deletion
+163
-5
jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java
jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java
+36
-5
jdk/test/sun/security/krb5/IPv6.java
jdk/test/sun/security/krb5/IPv6.java
+127
-0
未找到文件。
jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java
浏览文件 @
a22d7f21
/*
* Portions Copyright 2000-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Portions Copyright 2000-200
9
Sun Microsystems, Inc. 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
...
...
@@ -149,6 +149,11 @@ public abstract class KrbKdcReq {
send
(
realm
,
tempKdc
,
useTCP
);
break
;
}
catch
(
Exception
e
)
{
if
(
DEBUG
)
{
System
.
out
.
println
(
">>> KrbKdcReq send: error trying "
+
tempKdc
);
e
.
printStackTrace
(
System
.
out
);
}
savedException
=
e
;
}
}
...
...
@@ -179,10 +184,36 @@ public abstract class KrbKdcReq {
/*
* Get port number for this KDC.
*/
StringTokenizer
strTok
=
new
StringTokenizer
(
tempKdc
,
":"
);
String
kdc
=
strTok
.
nextToken
();
if
(
strTok
.
hasMoreTokens
())
{
String
portStr
=
strTok
.
nextToken
();
String
kdc
=
null
;
String
portStr
=
null
;
if
(
tempKdc
.
charAt
(
0
)
==
'['
)
{
// Explicit IPv6 in []
int
pos
=
tempKdc
.
indexOf
(
']'
,
1
);
if
(
pos
==
-
1
)
{
throw
new
IOException
(
"Illegal KDC: "
+
tempKdc
);
}
kdc
=
tempKdc
.
substring
(
1
,
pos
);
if
(
pos
!=
tempKdc
.
length
()
-
1
)
{
// with port number
if
(
tempKdc
.
charAt
(
pos
+
1
)
!=
':'
)
{
throw
new
IOException
(
"Illegal KDC: "
+
tempKdc
);
}
portStr
=
tempKdc
.
substring
(
pos
+
2
);
}
}
else
{
int
colon
=
tempKdc
.
indexOf
(
':'
);
if
(
colon
==
-
1
)
{
// Hostname or IPv4 host only
kdc
=
tempKdc
;
}
else
{
int
nextColon
=
tempKdc
.
indexOf
(
':'
,
colon
+
1
);
if
(
nextColon
>
0
)
{
// >=2 ":", IPv6 with no port
kdc
=
tempKdc
;
}
else
{
// 1 ":", hostname or IPv4 with port
kdc
=
tempKdc
.
substring
(
0
,
colon
);
portStr
=
tempKdc
.
substring
(
colon
+
1
);
}
}
}
if
(
portStr
!=
null
)
{
int
tempPort
=
parsePositiveIntString
(
portStr
);
if
(
tempPort
>
0
)
port
=
tempPort
;
...
...
jdk/test/sun/security/krb5/IPv6.java
0 → 100644
浏览文件 @
a22d7f21
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6877357
* @summary IPv6 address does not work
*/
import
com.sun.security.auth.module.Krb5LoginModule
;
import
java.io.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.security.auth.Subject
;
public
class
IPv6
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
[][]
kdcs
=
{
{
"simple.host"
,
null
},
// These are legal settings
{
"simple.host"
,
""
},
{
"simple.host"
,
"8080"
},
{
"0.0.0.1"
,
null
},
{
"0.0.0.1"
,
""
},
{
"0.0.0.1"
,
"8080"
},
{
"1::1"
,
null
},
{
"[1::1]"
,
null
},
{
"[1::1]"
,
""
},
{
"[1::1]"
,
"8080"
},
{
"[1::1"
,
null
},
// Two illegal settings
{
"[1::1]abc"
,
null
},
};
// Prepares a krb5.conf with every kind of KDC settings
PrintStream
out
=
new
PrintStream
(
new
FileOutputStream
(
"ipv6.conf"
));
out
.
println
(
"[libdefaults]"
);
out
.
println
(
"default_realm = V6"
);
out
.
println
(
"[realms]"
);
out
.
println
(
"V6 = {"
);
for
(
String
[]
hp:
kdcs
)
{
if
(
hp
[
1
]
!=
null
)
out
.
println
(
" kdc = "
+
hp
[
0
]+
":"
+
hp
[
1
]);
else
out
.
println
(
" kdc = "
+
hp
[
0
]);
}
out
.
println
(
"}"
);
out
.
close
();
System
.
setProperty
(
"sun.security.krb5.debug"
,
"true"
);
System
.
setProperty
(
"java.security.krb5.conf"
,
"ipv6.conf"
);
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
PrintStream
po
=
new
PrintStream
(
bo
);
PrintStream
oldout
=
System
.
out
;
System
.
setOut
(
po
);
try
{
Subject
subject
=
new
Subject
();
Krb5LoginModule
krb5
=
new
Krb5LoginModule
();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
Object
>
shared
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"debug"
,
"true"
);
map
.
put
(
"doNotPrompt"
,
"true"
);
map
.
put
(
"useTicketCache"
,
"false"
);
map
.
put
(
"useFirstPass"
,
"true"
);
shared
.
put
(
"javax.security.auth.login.name"
,
"any"
);
shared
.
put
(
"javax.security.auth.login.password"
,
"any"
.
toCharArray
());
krb5
.
initialize
(
subject
,
null
,
shared
,
map
);
krb5
.
login
();
}
catch
(
Exception
e
)
{
// Ignore
}
po
.
flush
();
System
.
setOut
(
oldout
);
String
[]
lines
=
new
String
(
bo
.
toByteArray
()).
split
(
"\n"
);
int
cc
=
0
;
Pattern
r
=
Pattern
.
compile
(
".*KrbKdcReq send: kdc=(.*) UDP:(\\d+),.*"
);
for
(
String
line:
lines
)
{
Matcher
m
=
r
.
matcher
(
line
.
subSequence
(
0
,
line
.
length
()));
if
(
m
.
matches
())
{
System
.
out
.
println
(
"------------------"
);
System
.
out
.
println
(
line
);
String
h
=
m
.
group
(
1
),
p
=
m
.
group
(
2
);
String
eh
=
kdcs
[
cc
][
0
],
ep
=
kdcs
[
cc
][
1
];
if
(
eh
.
charAt
(
0
)
==
'['
)
{
eh
=
eh
.
substring
(
1
,
eh
.
length
()-
1
);
}
System
.
out
.
println
(
"Expected: "
+
eh
+
" : "
+
ep
);
System
.
out
.
println
(
"Actual: "
+
h
+
" : "
+
p
);
if
(!
eh
.
equals
(
h
)
||
(
ep
==
null
||
ep
.
length
()
==
0
)
&&
!
p
.
equals
(
"88"
)
||
(
ep
!=
null
&&
ep
.
length
()
>
0
)
&&
!
p
.
equals
(
ep
))
{
throw
new
Exception
(
"Mismatch"
);
}
cc
++;
}
}
if
(
cc
!=
kdcs
.
length
-
2
)
{
// 2 illegal settings at the end
throw
new
Exception
(
"Not traversed"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录