Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9d2d80a9
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看板
提交
9d2d80a9
编写于
7月 03, 2015
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8098854: Do cleanup in a proper order in sunmscapi code
Reviewed-by: vinnie
上级
d93f54ca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
12 deletion
+56
-12
src/windows/native/sun/security/mscapi/security.cpp
src/windows/native/sun/security/mscapi/security.cpp
+56
-12
未找到文件。
src/windows/native/sun/security/mscapi/security.cpp
浏览文件 @
9d2d80a9
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include <jni.h>
#include <jni.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <windows.h>
#include <BaseTsd.h>
#include <BaseTsd.h>
#include <wincrypt.h>
#include <wincrypt.h>
...
@@ -58,11 +59,16 @@ void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError)
...
@@ -58,11 +59,16 @@ void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError)
char
szMessage
[
1024
];
char
szMessage
[
1024
];
szMessage
[
0
]
=
'\0'
;
szMessage
[
0
]
=
'\0'
;
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
dwError
,
NULL
,
szMessage
,
DWORD
res
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
dwError
,
1024
,
NULL
);
NULL
,
szMessage
,
sizeof
(
szMessage
),
NULL
);
if
(
res
==
0
)
{
strcpy
(
szMessage
,
"Unknown error"
);
}
jclass
exceptionClazz
=
env
->
FindClass
(
exceptionName
);
jclass
exceptionClazz
=
env
->
FindClass
(
exceptionName
);
env
->
ThrowNew
(
exceptionClazz
,
szMessage
);
if
(
exceptionClazz
!=
NULL
)
{
env
->
ThrowNew
(
exceptionClazz
,
szMessage
);
}
}
}
...
@@ -295,22 +301,42 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
...
@@ -295,22 +301,42 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
// Determine clazz and method ID to generate certificate
// Determine clazz and method ID to generate certificate
jclass
clazzArrayList
=
env
->
FindClass
(
"java/util/ArrayList"
);
jclass
clazzArrayList
=
env
->
FindClass
(
"java/util/ArrayList"
);
if
(
clazzArrayList
==
NULL
)
{
__leave
;
}
jmethodID
mNewArrayList
=
env
->
GetMethodID
(
clazzArrayList
,
"<init>"
,
"()V"
);
jmethodID
mNewArrayList
=
env
->
GetMethodID
(
clazzArrayList
,
"<init>"
,
"()V"
);
if
(
mNewArrayList
==
NULL
)
{
__leave
;
}
jmethodID
mGenCert
=
env
->
GetMethodID
(
env
->
GetObjectClass
(
obj
),
jclass
clazzOfThis
=
env
->
GetObjectClass
(
obj
);
if
(
clazzOfThis
==
NULL
)
{
__leave
;
}
jmethodID
mGenCert
=
env
->
GetMethodID
(
clazzOfThis
,
"generateCertificate"
,
"generateCertificate"
,
"([BLjava/util/Collection;)V"
);
"([BLjava/util/Collection;)V"
);
if
(
mGenCert
==
NULL
)
{
__leave
;
}
// Determine method ID to generate certificate chain
// Determine method ID to generate certificate chain
jmethodID
mGenCertChain
=
env
->
GetMethodID
(
env
->
GetObjectClass
(
obj
)
,
jmethodID
mGenCertChain
=
env
->
GetMethodID
(
clazzOfThis
,
"generateCertificateChain"
,
"generateCertificateChain"
,
"(Ljava/lang/String;Ljava/util/Collection;Ljava/util/Collection;)V"
);
"(Ljava/lang/String;Ljava/util/Collection;Ljava/util/Collection;)V"
);
if
(
mGenCertChain
==
NULL
)
{
__leave
;
}
// Determine method ID to generate RSA certificate chain
// Determine method ID to generate RSA certificate chain
jmethodID
mGenRSAKeyAndCertChain
=
env
->
GetMethodID
(
env
->
GetObjectClass
(
obj
)
,
jmethodID
mGenRSAKeyAndCertChain
=
env
->
GetMethodID
(
clazzOfThis
,
"generateRSAKeyAndCertificateChain"
,
"generateRSAKeyAndCertificateChain"
,
"(Ljava/lang/String;JJILjava/util/Collection;Ljava/util/Collection;)V"
);
"(Ljava/lang/String;JJILjava/util/Collection;Ljava/util/Collection;)V"
);
if
(
mGenRSAKeyAndCertChain
==
NULL
)
{
__leave
;
}
// Use CertEnumCertificatesInStore to get the certificates
// Use CertEnumCertificatesInStore to get the certificates
// from the open store. pCertContext must be reset to
// from the open store. pCertContext must be reset to
...
@@ -590,9 +616,6 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
...
@@ -590,9 +616,6 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
}
}
__finally
__finally
{
{
if
(
hCryptProvAlt
)
::
CryptReleaseContext
(
hCryptProvAlt
,
0
);
if
(
pSignedHashBuffer
)
if
(
pSignedHashBuffer
)
delete
[]
pSignedHashBuffer
;
delete
[]
pSignedHashBuffer
;
...
@@ -601,6 +624,9 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
...
@@ -601,6 +624,9 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
if
(
hHash
)
if
(
hHash
)
::
CryptDestroyHash
(
hHash
);
::
CryptDestroyHash
(
hHash
);
if
(
hCryptProvAlt
)
::
CryptReleaseContext
(
hCryptProvAlt
,
0
);
}
}
return
jSignedHash
;
return
jSignedHash
;
...
@@ -688,9 +714,6 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas
...
@@ -688,9 +714,6 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas
__finally
__finally
{
{
if
(
hCryptProvAlt
)
::
CryptReleaseContext
(
hCryptProvAlt
,
0
);
if
(
pSignedHashBuffer
)
if
(
pSignedHashBuffer
)
delete
[]
pSignedHashBuffer
;
delete
[]
pSignedHashBuffer
;
...
@@ -699,6 +722,9 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas
...
@@ -699,6 +722,9 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas
if
(
hHash
)
if
(
hHash
)
::
CryptDestroyHash
(
hHash
);
::
CryptDestroyHash
(
hHash
);
if
(
hCryptProvAlt
)
::
CryptReleaseContext
(
hCryptProvAlt
,
0
);
}
}
return
result
;
return
result
;
...
@@ -763,9 +789,15 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR
...
@@ -763,9 +789,15 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR
// Get the method ID for the RSAKeyPair constructor
// Get the method ID for the RSAKeyPair constructor
jclass
clazzRSAKeyPair
=
jclass
clazzRSAKeyPair
=
env
->
FindClass
(
"sun/security/mscapi/RSAKeyPair"
);
env
->
FindClass
(
"sun/security/mscapi/RSAKeyPair"
);
if
(
clazzRSAKeyPair
==
NULL
)
{
__leave
;
}
jmethodID
mNewRSAKeyPair
=
jmethodID
mNewRSAKeyPair
=
env
->
GetMethodID
(
clazzRSAKeyPair
,
"<init>"
,
"(JJI)V"
);
env
->
GetMethodID
(
clazzRSAKeyPair
,
"<init>"
,
"(JJI)V"
);
if
(
mNewRSAKeyPair
==
NULL
)
{
__leave
;
}
// Create a new RSA keypair
// Create a new RSA keypair
keypair
=
env
->
NewObject
(
clazzRSAKeyPair
,
mNewRSAKeyPair
,
keypair
=
env
->
NewObject
(
clazzRSAKeyPair
,
mNewRSAKeyPair
,
...
@@ -1948,9 +1980,15 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey
...
@@ -1948,9 +1980,15 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey
// Get the method ID for the RSAPrivateKey constructor
// Get the method ID for the RSAPrivateKey constructor
jclass
clazzRSAPrivateKey
=
jclass
clazzRSAPrivateKey
=
env
->
FindClass
(
"sun/security/mscapi/RSAPrivateKey"
);
env
->
FindClass
(
"sun/security/mscapi/RSAPrivateKey"
);
if
(
clazzRSAPrivateKey
==
NULL
)
{
__leave
;
}
jmethodID
mNewRSAPrivateKey
=
jmethodID
mNewRSAPrivateKey
=
env
->
GetMethodID
(
clazzRSAPrivateKey
,
"<init>"
,
"(JJI)V"
);
env
->
GetMethodID
(
clazzRSAPrivateKey
,
"<init>"
,
"(JJI)V"
);
if
(
mNewRSAPrivateKey
==
NULL
)
{
__leave
;
}
// Create a new RSA private key
// Create a new RSA private key
privateKey
=
env
->
NewObject
(
clazzRSAPrivateKey
,
mNewRSAPrivateKey
,
privateKey
=
env
->
NewObject
(
clazzRSAPrivateKey
,
mNewRSAPrivateKey
,
...
@@ -2035,9 +2073,15 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey
...
@@ -2035,9 +2073,15 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey
// Get the method ID for the RSAPublicKey constructor
// Get the method ID for the RSAPublicKey constructor
jclass
clazzRSAPublicKey
=
jclass
clazzRSAPublicKey
=
env
->
FindClass
(
"sun/security/mscapi/RSAPublicKey"
);
env
->
FindClass
(
"sun/security/mscapi/RSAPublicKey"
);
if
(
clazzRSAPublicKey
==
NULL
)
{
__leave
;
}
jmethodID
mNewRSAPublicKey
=
jmethodID
mNewRSAPublicKey
=
env
->
GetMethodID
(
clazzRSAPublicKey
,
"<init>"
,
"(JJI)V"
);
env
->
GetMethodID
(
clazzRSAPublicKey
,
"<init>"
,
"(JJI)V"
);
if
(
mNewRSAPublicKey
==
NULL
)
{
__leave
;
}
// Create a new RSA public key
// Create a new RSA public key
publicKey
=
env
->
NewObject
(
clazzRSAPublicKey
,
mNewRSAPublicKey
,
publicKey
=
env
->
NewObject
(
clazzRSAPublicKey
,
mNewRSAPublicKey
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录