Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a5ed7dbb
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看板
提交
a5ed7dbb
编写于
2月 04, 2013
作者:
V
vinnie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006994: Cleanup PKCS12 tests to ensure streams get closed
Reviewed-by: mullan
上级
ea1bd613
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
114 addition
and
116 deletion
+114
-116
test/java/security/KeyStore/PBETest.java
test/java/security/KeyStore/PBETest.java
+29
-28
test/sun/security/pkcs12/StorePasswordTest.java
test/sun/security/pkcs12/StorePasswordTest.java
+25
-25
test/sun/security/pkcs12/StoreSecretKeyTest.java
test/sun/security/pkcs12/StoreSecretKeyTest.java
+21
-22
test/sun/security/pkcs12/StoreTrustedCertTest.java
test/sun/security/pkcs12/StoreTrustedCertTest.java
+39
-41
未找到文件。
test/java/security/KeyStore/PBETest.java
浏览文件 @
a5ed7dbb
...
...
@@ -58,7 +58,6 @@ public class PBETest {
new
File
(
NEW_KEYSTORE
).
delete
();
try
{
KeyStore
keystore
=
load
(
KEYSTORE_TYPE
,
KEYSTORE
,
PASSWORD
);
KeyStore
.
Entry
entry
=
keystore
.
getEntry
(
ALIAS
,
...
...
@@ -73,30 +72,32 @@ public class PBETest {
new
IvParameterSpec
(
IV
))));
System
.
out
.
println
(
"Encrypted entry using: "
+
PBE_ALGO
);
try
(
FileOutputStream
outStream
=
new
FileOutputStream
(
NEW_KEYSTORE
))
{
System
.
out
.
println
(
"Storing keystore to: "
+
NEW_KEYSTORE
);
keystore2
.
store
(
new
FileOutputStream
(
NEW_KEYSTORE
),
PASSWORD
);
keystore2
.
store
(
outStream
,
PASSWORD
);
}
keystore2
=
load
(
NEW_KEYSTORE_TYPE
,
NEW_KEYSTORE
,
PASSWORD
);
entry
=
keystore2
.
getEntry
(
ALIAS
,
new
KeyStore
.
PasswordProtection
(
PASSWORD
));
System
.
out
.
println
(
"Retrieved entry named '"
+
ALIAS
+
"'"
);
}
finally
{
new
File
(
NEW_KEYSTORE
).
delete
();
System
.
out
.
println
(
"Deleted keystore: "
+
NEW_KEYSTORE
);
}
}
private
static
KeyStore
load
(
String
type
,
String
path
,
char
[]
password
)
throws
Exception
{
KeyStore
keystore
=
KeyStore
.
getInstance
(
type
);
FileInputStream
stream
=
null
;
if
(
path
!=
null
)
{
stream
=
new
FileInputStream
(
path
);
}
KeyStore
keystore
=
KeyStore
.
getInstance
(
type
);
try
(
FileInputStream
inStream
=
new
FileInputStream
(
path
))
{
System
.
out
.
println
(
"Loading keystore from: "
+
path
);
keystore
.
load
(
stream
,
password
);
keystore
.
load
(
inStream
,
password
);
System
.
out
.
println
(
"Loaded keystore with "
+
keystore
.
size
()
+
" entries"
);
}
}
else
{
keystore
.
load
(
null
,
null
);
}
return
keystore
;
}
...
...
test/sun/security/pkcs12/StorePasswordTest.java
浏览文件 @
a5ed7dbb
...
...
@@ -47,8 +47,6 @@ public class StorePasswordTest {
new
File
(
KEYSTORE
).
delete
();
try
{
KeyStore
keystore
=
KeyStore
.
getInstance
(
"PKCS12"
);
keystore
.
load
(
null
,
null
);
...
...
@@ -57,13 +55,18 @@ public class StorePasswordTest {
new
KeyStore
.
SecretKeyEntry
(
convertPassword
(
USER_PASSWORD
)),
new
KeyStore
.
PasswordProtection
(
PASSWORD
));
try
(
FileOutputStream
outStream
=
new
FileOutputStream
(
KEYSTORE
))
{
System
.
out
.
println
(
"Storing keystore to: "
+
KEYSTORE
);
keystore
.
store
(
new
FileOutputStream
(
KEYSTORE
),
PASSWORD
);
keystore
.
store
(
outStream
,
PASSWORD
);
}
try
(
FileInputStream
inStream
=
new
FileInputStream
(
KEYSTORE
))
{
System
.
out
.
println
(
"Loading keystore from: "
+
KEYSTORE
);
keystore
.
load
(
new
FileInputStream
(
KEYSTORE
)
,
PASSWORD
);
keystore
.
load
(
inStream
,
PASSWORD
);
System
.
out
.
println
(
"Loaded keystore with "
+
keystore
.
size
()
+
" entries"
);
}
KeyStore
.
Entry
entry
=
keystore
.
getEntry
(
ALIAS
,
new
KeyStore
.
PasswordProtection
(
PASSWORD
));
System
.
out
.
println
(
"Retrieved entry: "
+
entry
);
...
...
@@ -79,9 +82,6 @@ public class StorePasswordTest {
if
(!
Arrays
.
equals
(
USER_PASSWORD
.
toCharArray
(),
pwd
))
{
throw
new
Exception
(
"Failed to recover the stored password"
);
}
}
finally
{
new
File
(
KEYSTORE
).
delete
();
}
}
private
static
SecretKey
convertPassword
(
String
password
)
...
...
test/sun/security/pkcs12/StoreSecretKeyTest.java
浏览文件 @
a5ed7dbb
...
...
@@ -53,8 +53,6 @@ public class StoreSecretKeyTest {
new
File
(
KEYSTORE
).
delete
();
try
{
KeyStore
keystore
=
KeyStore
.
getInstance
(
"PKCS12"
);
keystore
.
load
(
null
,
null
);
...
...
@@ -63,26 +61,27 @@ public class StoreSecretKeyTest {
new
KeyStore
.
SecretKeyEntry
(
generateSecretKey
(
"AES"
,
128
)),
new
KeyStore
.
PasswordProtection
(
PASSWORD
));
try
(
FileOutputStream
outStream
=
new
FileOutputStream
(
KEYSTORE
))
{
System
.
out
.
println
(
"Storing keystore to: "
+
KEYSTORE
);
keystore
.
store
(
new
FileOutputStream
(
KEYSTORE
),
PASSWORD
);
keystore
.
store
(
outStream
,
PASSWORD
);
}
try
(
FileInputStream
inStream
=
new
FileInputStream
(
KEYSTORE
))
{
System
.
out
.
println
(
"Loading keystore from: "
+
KEYSTORE
);
keystore
.
load
(
new
FileInputStream
(
KEYSTORE
)
,
PASSWORD
);
keystore
.
load
(
inStream
,
PASSWORD
);
System
.
out
.
println
(
"Loaded keystore with "
+
keystore
.
size
()
+
" entries"
);
}
KeyStore
.
Entry
entry
=
keystore
.
getEntry
(
ALIAS
,
new
KeyStore
.
PasswordProtection
(
PASSWORD
));
System
.
out
.
println
(
"Retrieved entry: "
+
entry
);
if
(
entry
instanceof
KeyStore
.
SecretKeyEntry
)
{
System
.
out
.
println
(
"Retrieved secret key entry: "
+
entry
);
System
.
out
.
println
(
"Retrieved secret key entry: "
+
entry
);
}
else
{
throw
new
Exception
(
"Not a secret key entry"
);
}
}
finally
{
new
File
(
KEYSTORE
).
delete
();
}
}
private
static
SecretKey
generateSecretKey
(
String
algorithm
,
int
size
)
...
...
test/sun/security/pkcs12/StoreTrustedCertTest.java
浏览文件 @
a5ed7dbb
...
...
@@ -49,7 +49,6 @@ public class StoreTrustedCertTest {
new
File
(
KEYSTORE
).
delete
();
try
{
KeyStore
keystore
=
KeyStore
.
getInstance
(
"PKCS12"
);
keystore
.
load
(
null
,
null
);
...
...
@@ -66,18 +65,21 @@ public class StoreTrustedCertTest {
keystore
.
setEntry
(
ALIAS2
,
new
KeyStore
.
TrustedCertificateEntry
(
cert
,
attributes
),
null
);
try
(
FileOutputStream
outStream
=
new
FileOutputStream
(
KEYSTORE
))
{
System
.
out
.
println
(
"Storing keystore to: "
+
KEYSTORE
);
keystore
.
store
(
new
FileOutputStream
(
KEYSTORE
),
PASSWORD
);
keystore
.
store
(
outStream
,
PASSWORD
);
}
try
(
FileInputStream
inStream
=
new
FileInputStream
(
KEYSTORE
))
{
System
.
out
.
println
(
"Loading keystore from: "
+
KEYSTORE
);
keystore
.
load
(
new
FileInputStream
(
KEYSTORE
)
,
PASSWORD
);
keystore
.
load
(
inStream
,
PASSWORD
);
System
.
out
.
println
(
"Loaded keystore with "
+
keystore
.
size
()
+
" entries"
);
}
KeyStore
.
Entry
entry
=
keystore
.
getEntry
(
ALIAS
,
null
);
if
(
entry
instanceof
KeyStore
.
TrustedCertificateEntry
)
{
System
.
out
.
println
(
"Retrieved trusted certificate entry: "
+
entry
);
System
.
out
.
println
(
"Retrieved trusted certificate entry: "
+
entry
);
}
else
{
throw
new
Exception
(
"Not a trusted certificate entry"
);
}
...
...
@@ -99,10 +101,6 @@ public class StoreTrustedCertTest {
}
else
{
throw
new
Exception
(
"Not a trusted certificate entry"
);
}
}
finally
{
new
File
(
KEYSTORE
).
delete
();
}
}
private
static
Certificate
loadCertificate
(
String
certFile
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录