Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0bde254d
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0bde254d
编写于
3月 25, 2010
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6813340: X509Factory should not depend on is.available()==0
Reviewed-by: xuelei
上级
d876c863
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
410 addition
and
354 deletion
+410
-354
src/share/classes/sun/security/provider/X509Factory.java
src/share/classes/sun/security/provider/X509Factory.java
+222
-309
src/share/classes/sun/security/tools/KeyTool.java
src/share/classes/sun/security/tools/KeyTool.java
+23
-45
test/java/security/cert/CertificateFactory/ReturnStream.java
test/java/security/cert/CertificateFactory/ReturnStream.java
+64
-0
test/java/security/cert/CertificateFactory/SlowStream.java
test/java/security/cert/CertificateFactory/SlowStream.java
+51
-0
test/java/security/cert/CertificateFactory/slowstream.sh
test/java/security/cert/CertificateFactory/slowstream.sh
+50
-0
未找到文件。
src/share/classes/sun/security/provider/X509Factory.java
浏览文件 @
0bde254d
此差异已折叠。
点击以展开。
src/share/classes/sun/security/tools/KeyTool.java
浏览文件 @
0bde254d
...
...
@@ -977,26 +977,10 @@ public final class KeyTool {
if
(
filename
!=
null
)
{
inStream
=
new
FileInputStream
(
filename
);
}
// Read the full stream before feeding to X509Factory,
// otherwise, keytool -gencert | keytool -importcert
// might not work properly, since -gencert is slow
// and there's no data in the pipe at the beginning.
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
try
{
byte
[]
b
=
new
byte
[
4096
];
while
(
true
)
{
int
len
=
inStream
.
read
(
b
);
if
(
len
<
0
)
break
;
bout
.
write
(
b
,
0
,
len
);
}
}
finally
{
if
(
inStream
!=
System
.
in
)
{
inStream
.
close
();
}
}
inStream
=
new
ByteArrayInputStream
(
bout
.
toByteArray
());
String
importAlias
=
(
alias
!=
null
)?
alias:
keyAlias
;
if
(
keyStore
.
entryInstanceOf
(
importAlias
,
KeyStore
.
PrivateKeyEntry
.
class
))
{
try
{
if
(
keyStore
.
entryInstanceOf
(
importAlias
,
KeyStore
.
PrivateKeyEntry
.
class
))
{
kssave
=
installReply
(
importAlias
,
inStream
);
if
(
kssave
)
{
System
.
err
.
println
(
rb
.
getString
...
...
@@ -1017,6 +1001,11 @@ public final class KeyTool {
(
"Certificate was not added to keystore"
));
}
}
}
finally
{
if
(
inStream
!=
System
.
in
)
{
inStream
.
close
();
}
}
}
else
if
(
command
==
IMPORTKEYSTORE
)
{
doImportKeyStore
();
kssave
=
true
;
...
...
@@ -2149,18 +2138,7 @@ public final class KeyTool {
inStream
=
new
FileInputStream
(
filename
);
}
try
{
// Read the full stream before feeding to X509Factory,
// otherwise, keytool -gencert | keytool -printcert
// might not work properly, since -gencert is slow
// and there's no data in the pipe at the beginning.
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
byte
[]
b
=
new
byte
[
4096
];
while
(
true
)
{
int
len
=
inStream
.
read
(
b
);
if
(
len
<
0
)
break
;
bout
.
write
(
b
,
0
,
len
);
}
printCertFromStream
(
new
ByteArrayInputStream
(
bout
.
toByteArray
()),
out
);
printCertFromStream
(
inStream
,
out
);
}
finally
{
if
(
inStream
!=
System
.
in
)
{
inStream
.
close
();
...
...
test/java/security/cert/CertificateFactory/ReturnStream.java
0 → 100644
浏览文件 @
0bde254d
/*
* Copyright 2010 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 6813340
* @summary X509Factory should not depend on is.available()==0
*/
import
java.io.*
;
import
java.security.cert.*
;
/**
* Tests ol'Mac style file, end witha single '\r'
*/
public
class
ReturnStream
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
FileInputStream
fin
=
new
FileInputStream
(
new
File
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"openssl"
),
"pem"
));
byte
[]
buffer
=
new
byte
[
4096
];
int
size
=
0
;
while
(
true
)
{
int
len
=
fin
.
read
(
buffer
,
size
,
4096
-
size
);
if
(
len
<
0
)
break
;
size
+=
len
;
}
fin
.
close
();
// Make a copy
System
.
arraycopy
(
buffer
,
0
,
buffer
,
size
,
size
);
size
+=
size
;
// Create a ol'Mac style file.
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
buffer
[
i
]
==
'\n'
)
buffer
[
i
]
=
'\r'
;
}
CertificateFactory
factory
=
CertificateFactory
.
getInstance
(
"X.509"
);
if
(
factory
.
generateCertificates
(
new
ByteArrayInputStream
(
buffer
,
0
,
size
)).
size
()
!=
2
)
{
throw
new
Exception
(
"Cert not OK"
);
}
}
}
test/java/security/cert/CertificateFactory/SlowStream.java
0 → 100644
浏览文件 @
0bde254d
/*
* Copyright 2010 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.
*/
import
java.io.*
;
import
java.security.cert.*
;
class
SlowStreamReader
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
CertificateFactory
factory
=
CertificateFactory
.
getInstance
(
"X.509"
);
if
(
factory
.
generateCertificates
(
System
.
in
).
size
()
!=
5
)
{
throw
new
Exception
(
"Not all certs read"
);
}
}
}
class
SlowStreamWriter
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
FileInputStream
fin
=
new
FileInputStream
(
new
File
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"openssl"
),
"pem"
));
byte
[]
buffer
=
new
byte
[
4096
];
while
(
true
)
{
int
len
=
fin
.
read
(
buffer
);
if
(
len
<
0
)
break
;
System
.
out
.
write
(
buffer
,
0
,
len
);
}
Thread
.
sleep
(
2000
);
}
}
}
test/java/security/cert/CertificateFactory/slowstream.sh
0 → 100644
浏览文件 @
0bde254d
#
# Copyright 2010 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 6813340
# @summary X509Factory should not depend on is.available()==0
if
[
"
${
TESTSRC
}
"
=
""
]
;
then
TESTSRC
=
"."
fi
if
[
"
${
TESTJAVA
}
"
=
""
]
;
then
echo
"TESTJAVA not set. Test cannot execute."
echo
"FAILED!!!"
exit
1
fi
# set platform-dependent variables
OS
=
`
uname
-s
`
case
"
$OS
"
in
Windows_
*
)
FS
=
"
\\
"
;;
*
)
FS
=
"/"
;;
esac
${
TESTJAVA
}${
FS
}
bin
${
FS
}
javac
-d
.
${
TESTSRC
}${
FS
}
SlowStream.java
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java
-Dtest
.src
=
${
TESTSRC
}
SlowStreamWriter |
\
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java SlowStreamReader
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录