Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f23a11d9
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看板
提交
f23a11d9
编写于
2月 05, 2016
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
6b324ac6
abba7081
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
1653 addition
and
183 deletion
+1653
-183
make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java
...es/build/tools/cldrconverter/ResourceBundleGenerator.java
+40
-1
src/share/classes/java/lang/Thread.java
src/share/classes/java/lang/Thread.java
+9
-5
src/share/classes/java/net/URLConnection.java
src/share/classes/java/net/URLConnection.java
+2
-6
src/share/classes/javax/swing/TimerQueue.java
src/share/classes/javax/swing/TimerQueue.java
+10
-5
src/share/classes/sun/security/pkcs/PKCS7.java
src/share/classes/sun/security/pkcs/PKCS7.java
+14
-8
src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
...e/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
+4
-0
src/share/classes/sun/security/tools/jarsigner/JarSignerParameters.java
...ses/sun/security/tools/jarsigner/JarSignerParameters.java
+152
-0
src/share/classes/sun/security/tools/jarsigner/Main.java
src/share/classes/sun/security/tools/jarsigner/Main.java
+15
-123
src/share/classes/sun/security/tools/jarsigner/Resources.java
...share/classes/sun/security/tools/jarsigner/Resources.java
+2
-0
src/share/classes/sun/security/tools/jarsigner/TimestampedSigner.java
...asses/sun/security/tools/jarsigner/TimestampedSigner.java
+6
-1
src/share/classes/sun/util/resources/TimeZoneNames.java
src/share/classes/sun/util/resources/TimeZoneNames.java
+2
-2
src/share/classes/sun/util/resources/de/TimeZoneNames_de.java
...share/classes/sun/util/resources/de/TimeZoneNames_de.java
+2
-2
src/share/classes/sun/util/resources/es/TimeZoneNames_es.java
...share/classes/sun/util/resources/es/TimeZoneNames_es.java
+2
-2
src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java
...share/classes/sun/util/resources/fr/TimeZoneNames_fr.java
+2
-2
src/share/classes/sun/util/resources/it/TimeZoneNames_it.java
...share/classes/sun/util/resources/it/TimeZoneNames_it.java
+2
-2
src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java
...share/classes/sun/util/resources/ja/TimeZoneNames_ja.java
+2
-2
src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java
...share/classes/sun/util/resources/ko/TimeZoneNames_ko.java
+2
-2
src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java
...re/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java
+2
-2
src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java
...share/classes/sun/util/resources/sv/TimeZoneNames_sv.java
+2
-2
src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java
...re/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java
+2
-2
src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java
...re/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java
+2
-2
src/solaris/classes/sun/awt/X11/XBaseWindow.java
src/solaris/classes/sun/awt/X11/XBaseWindow.java
+0
-4
test/java/awt/Paint/ComponentIsNotDrawnAfterRemoveAddTest/ComponentIsNotDrawnAfterRemoveAddTest.java
...rRemoveAddTest/ComponentIsNotDrawnAfterRemoveAddTest.java
+187
-0
test/java/text/Format/DateFormat/Bug8141243.java
test/java/text/Format/DateFormat/Bug8141243.java
+83
-0
test/javax/net/ssl/TLSv12/SignatureAlgorithms.java
test/javax/net/ssl/TLSv12/SignatureAlgorithms.java
+595
-0
test/javax/xml/jaxp/common/8144593/TestSAXDriver.java
test/javax/xml/jaxp/common/8144593/TestSAXDriver.java
+56
-0
test/javax/xml/jaxp/common/8144593/TransformationWarningsTest.java
...x/xml/jaxp/common/8144593/TransformationWarningsTest.java
+92
-0
test/javax/xml/jaxp/common/8144593/ValidationWarningsTest.java
...javax/xml/jaxp/common/8144593/ValidationWarningsTest.java
+76
-0
test/javax/xml/jaxp/common/8144593/WarningsTestBase.java
test/javax/xml/jaxp/common/8144593/WarningsTestBase.java
+134
-0
test/javax/xml/jaxp/parsers/8072081/SupplementaryChars.java
test/javax/xml/jaxp/parsers/8072081/SupplementaryChars.java
+91
-0
test/sun/security/tools/jarsigner/TimestampCheck.java
test/sun/security/tools/jarsigner/TimestampCheck.java
+54
-6
test/sun/security/tools/jarsigner/ts.sh
test/sun/security/tools/jarsigner/ts.sh
+1
-1
test/sun/tools/native2ascii/NativeErrors.java
test/sun/tools/native2ascii/NativeErrors.java
+8
-1
未找到文件。
make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -30,11 +30,37 @@ import java.io.IOException;
import
java.io.PrintWriter
;
import
java.util.Formatter
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.SortedSet
;
class
ResourceBundleGenerator
implements
BundleGenerator
{
// preferred timezones - keeping compatibility with JDK1.1 3 letter abbreviations
private
static
final
String
[]
preferredTZIDs
=
{
"America/Los_Angeles"
,
"America/Denver"
,
"America/Phoenix"
,
"America/Chicago"
,
"America/New_York"
,
"America/Indianapolis"
,
"Pacific/Honolulu"
,
"America/Anchorage"
,
"America/Halifax"
,
"America/Sitka"
,
"America/St_Johns"
,
"Europe/Paris"
,
// Although CLDR does not support abbreviated zones, handle "GMT" as a
// special case here, as it is specified in the javadoc.
"GMT"
,
"Africa/Casablanca"
,
"Asia/Jerusalem"
,
"Asia/Tokyo"
,
"Europe/Bucharest"
,
"Asia/Shanghai"
,
"UTC"
,
};
@Override
public
void
generateBundle
(
String
packageName
,
String
baseName
,
String
localeID
,
boolean
useJava
,
Map
<
String
,
?>
map
,
BundleType
type
)
throws
IOException
{
...
...
@@ -89,6 +115,19 @@ class ResourceBundleGenerator implements BundleGenerator {
for
(
String
key
:
metaKeys
)
{
map
.
remove
(
key
);
}
// Make it preferred ordered
LinkedHashMap
<
String
,
Object
>
newMap
=
new
LinkedHashMap
<>();
for
(
String
preferred
:
preferredTZIDs
)
{
if
(
map
.
containsKey
(
preferred
))
{
newMap
.
put
(
preferred
,
map
.
remove
(
preferred
));
}
else
if
((
"GMT"
.
equals
(
preferred
)
||
"UTC"
.
equals
(
preferred
))
&&
metaKeys
.
contains
(
CLDRConverter
.
METAZONE_ID_PREFIX
+
preferred
))
{
newMap
.
put
(
preferred
,
preferred
);
}
}
newMap
.
putAll
(
map
);
map
=
newMap
;
}
try
(
PrintWriter
out
=
new
PrintWriter
(
file
,
encoding
))
{
...
...
src/share/classes/java/lang/Thread.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1994, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -145,7 +145,7 @@ class Thread implements Runnable {
registerNatives
();
}
private
volatile
char
name
[]
;
private
volatile
String
name
;
private
int
priority
;
private
Thread
threadQ
;
private
long
eetop
;
...
...
@@ -366,7 +366,7 @@ class Thread implements Runnable {
throw
new
NullPointerException
(
"name cannot be null"
);
}
this
.
name
=
name
.
toCharArray
()
;
this
.
name
=
name
;
Thread
parent
=
currentThread
();
SecurityManager
security
=
System
.
getSecurityManager
();
...
...
@@ -1119,7 +1119,11 @@ class Thread implements Runnable {
*/
public
final
synchronized
void
setName
(
String
name
)
{
checkAccess
();
this
.
name
=
name
.
toCharArray
();
if
(
name
==
null
)
{
throw
new
NullPointerException
(
"name cannot be null"
);
}
this
.
name
=
name
;
if
(
threadStatus
!=
0
)
{
setNativeName
(
name
);
}
...
...
@@ -1132,7 +1136,7 @@ class Thread implements Runnable {
* @see #setName(String)
*/
public
final
String
getName
()
{
return
n
ew
String
(
name
,
true
)
;
return
n
ame
;
}
/**
...
...
src/share/classes/java/net/URLConnection.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1995, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -1515,7 +1515,7 @@ public abstract class URLConnection {
}
if
(
c1
==
0xFF
&&
c2
==
0xD8
&&
c3
==
0xFF
)
{
if
(
c4
==
0xE0
)
{
if
(
c4
==
0xE0
||
c4
==
0xEE
)
{
return
"image/jpeg"
;
}
...
...
@@ -1530,10 +1530,6 @@ public abstract class URLConnection {
c11
==
0
))
{
return
"image/jpeg"
;
}
if
(
c4
==
0xEE
)
{
return
"image/jpg"
;
}
}
if
(
c1
==
0xD0
&&
c2
==
0xCF
&&
c3
==
0x11
&&
c4
==
0xE0
&&
...
...
src/share/classes/javax/swing/TimerQueue.java
浏览文件 @
f23a11d9
...
...
@@ -93,6 +93,9 @@ class TimerQueue implements Runnable
void
startIfNeeded
()
{
if
(!
running
)
{
runningLock
.
lock
();
if
(
running
)
{
return
;
}
try
{
final
ThreadGroup
threadGroup
=
AppContext
.
getAppContext
().
getThreadGroup
();
...
...
@@ -168,15 +171,17 @@ class TimerQueue implements Runnable
try
{
while
(
running
)
{
try
{
Timer
timer
=
queue
.
take
().
getTimer
();
DelayedTimer
runningTimer
=
queue
.
take
();
Timer
timer
=
runningTimer
.
getTimer
();
timer
.
getLock
().
lock
();
try
{
DelayedTimer
delayedTimer
=
timer
.
delayedTimer
;
if
(
delayedTimer
!=
null
)
{
if
(
delayedTimer
==
runningTimer
)
{
/*
* Timer is not removed after we get it from
* the queue and before the lock on the timer is
* acquired
* Timer is not removed (delayedTimer != null)
* or not removed and added (runningTimer == delayedTimer)
* after we get it from the queue and before the
* lock on the timer is acquired
*/
timer
.
post
();
// have timer post an event
timer
.
delayedTimer
=
null
;
...
...
src/share/classes/sun/security/pkcs/PKCS7.java
浏览文件 @
f23a11d9
...
...
@@ -802,7 +802,8 @@ public class PKCS7 {
byte
[]
content
,
String
signatureAlgorithm
,
URI
tsaURI
,
String
tSAPolicyID
)
String
tSAPolicyID
,
String
tSADigestAlg
)
throws
CertificateException
,
IOException
,
NoSuchAlgorithmException
{
...
...
@@ -811,7 +812,8 @@ public class PKCS7 {
if
(
tsaURI
!=
null
)
{
// Timestamp the signature
HttpTimestamper
tsa
=
new
HttpTimestamper
(
tsaURI
);
byte
[]
tsToken
=
generateTimestampToken
(
tsa
,
tSAPolicyID
,
signature
);
byte
[]
tsToken
=
generateTimestampToken
(
tsa
,
tSAPolicyID
,
tSADigestAlg
,
signature
);
// Insert the timestamp token into the PKCS #7 signer info element
// (as an unsigned attribute)
...
...
@@ -869,6 +871,7 @@ public class PKCS7 {
*/
private
static
byte
[]
generateTimestampToken
(
Timestamper
tsa
,
String
tSAPolicyID
,
String
tSADigestAlg
,
byte
[]
toBeTimestamped
)
throws
IOException
,
CertificateException
{
...
...
@@ -876,11 +879,10 @@ public class PKCS7 {
MessageDigest
messageDigest
=
null
;
TSRequest
tsQuery
=
null
;
try
{
// SHA-1 is always used.
messageDigest
=
MessageDigest
.
getInstance
(
"SHA-1"
);
messageDigest
=
MessageDigest
.
getInstance
(
tSADigestAlg
);
tsQuery
=
new
TSRequest
(
tSAPolicyID
,
toBeTimestamped
,
messageDigest
);
}
catch
(
NoSuchAlgorithmException
e
)
{
// ignore
throw
new
IllegalArgumentException
(
e
);
}
// Generate a nonce
...
...
@@ -908,9 +910,13 @@ public class PKCS7 {
PKCS7
tsToken
=
tsReply
.
getToken
();
TimestampToken
tst
=
tsReply
.
getTimestampToken
();
if
(!
tst
.
getHashAlgorithm
().
getName
().
equals
(
"SHA-1"
))
{
throw
new
IOException
(
"Digest algorithm not SHA-1 in "
+
"timestamp token"
);
try
{
if
(!
tst
.
getHashAlgorithm
().
equals
(
AlgorithmId
.
get
(
tSADigestAlg
)))
{
throw
new
IOException
(
"Digest algorithm not "
+
tSADigestAlg
+
" in "
+
"timestamp token"
);
}
}
catch
(
NoSuchAlgorithmException
nase
)
{
throw
new
IllegalArgumentException
();
// should have been caught before
}
if
(!
MessageDigest
.
isEqual
(
tst
.
getHashedMessage
(),
tsQuery
.
getHashedMessage
()))
{
...
...
src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
浏览文件 @
f23a11d9
...
...
@@ -413,12 +413,16 @@ final class SignatureAndHashAlgorithm {
"SHA1withECDSA"
,
--
p
);
if
(
Security
.
getProvider
(
"SunMSCAPI"
)
==
null
)
{
supports
(
HashAlgorithm
.
SHA224
,
SignatureAlgorithm
.
DSA
,
"SHA224withDSA"
,
--
p
);
supports
(
HashAlgorithm
.
SHA224
,
SignatureAlgorithm
.
RSA
,
"SHA224withRSA"
,
--
p
);
supports
(
HashAlgorithm
.
SHA224
,
SignatureAlgorithm
.
ECDSA
,
"SHA224withECDSA"
,
--
p
);
}
supports
(
HashAlgorithm
.
SHA256
,
SignatureAlgorithm
.
DSA
,
"SHA256withDSA"
,
--
p
);
supports
(
HashAlgorithm
.
SHA256
,
SignatureAlgorithm
.
RSA
,
"SHA256withRSA"
,
--
p
);
supports
(
HashAlgorithm
.
SHA256
,
SignatureAlgorithm
.
ECDSA
,
...
...
src/share/classes/sun/security/tools/jarsigner/JarSignerParameters.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.security.tools.jarsigner
;
import
java.security.cert.Certificate
;
import
java.security.cert.X509Certificate
;
import
java.net.URI
;
import
java.util.zip.*
;
import
com.sun.jarsigner.ContentSignerParameters
;
class
JarSignerParameters
implements
ContentSignerParameters
{
private
String
[]
args
;
private
URI
tsa
;
private
X509Certificate
tsaCertificate
;
private
byte
[]
signature
;
private
String
signatureAlgorithm
;
private
X509Certificate
[]
signerCertificateChain
;
private
byte
[]
content
;
private
ZipFile
source
;
private
String
tSAPolicyID
;
private
String
tSADigestAlg
;
/**
* Create a new object.
*/
JarSignerParameters
(
String
[]
args
,
URI
tsa
,
X509Certificate
tsaCertificate
,
String
tSAPolicyID
,
String
tSADigestAlg
,
byte
[]
signature
,
String
signatureAlgorithm
,
X509Certificate
[]
signerCertificateChain
,
byte
[]
content
,
ZipFile
source
)
{
if
(
signature
==
null
||
signatureAlgorithm
==
null
||
signerCertificateChain
==
null
||
tSADigestAlg
==
null
)
{
throw
new
NullPointerException
();
}
this
.
args
=
args
;
this
.
tsa
=
tsa
;
this
.
tsaCertificate
=
tsaCertificate
;
this
.
tSAPolicyID
=
tSAPolicyID
;
this
.
tSADigestAlg
=
tSADigestAlg
;
this
.
signature
=
signature
;
this
.
signatureAlgorithm
=
signatureAlgorithm
;
this
.
signerCertificateChain
=
signerCertificateChain
;
this
.
content
=
content
;
this
.
source
=
source
;
}
/**
* Retrieves the command-line arguments.
*
* @return The command-line arguments. May be null.
*/
public
String
[]
getCommandLine
()
{
return
args
;
}
/**
* Retrieves the identifier for a Timestamping Authority (TSA).
*
* @return The TSA identifier. May be null.
*/
public
URI
getTimestampingAuthority
()
{
return
tsa
;
}
/**
* Retrieves the certificate for a Timestamping Authority (TSA).
*
* @return The TSA certificate. May be null.
*/
public
X509Certificate
getTimestampingAuthorityCertificate
()
{
return
tsaCertificate
;
}
public
String
getTSAPolicyID
()
{
return
tSAPolicyID
;
}
public
String
getTSADigestAlg
()
{
return
tSADigestAlg
;
}
/**
* Retrieves the signature.
*
* @return The non-null signature bytes.
*/
public
byte
[]
getSignature
()
{
return
signature
;
}
/**
* Retrieves the name of the signature algorithm.
*
* @return The non-null string name of the signature algorithm.
*/
public
String
getSignatureAlgorithm
()
{
return
signatureAlgorithm
;
}
/**
* Retrieves the signer's X.509 certificate chain.
*
* @return The non-null array of X.509 public-key certificates.
*/
public
X509Certificate
[]
getSignerCertificateChain
()
{
return
signerCertificateChain
;
}
/**
* Retrieves the content that was signed.
*
* @return The content bytes. May be null.
*/
public
byte
[]
getContent
()
{
return
content
;
}
/**
* Retrieves the original source ZIP file before it was signed.
*
* @return The original ZIP file. May be null.
*/
public
ZipFile
getSource
()
{
return
source
;
}
}
src/share/classes/sun/security/tools/jarsigner/Main.java
浏览文件 @
f23a11d9
...
...
@@ -139,6 +139,7 @@ public class Main {
String
tsaAlias
;
// alias for the Timestamping Authority's certificate
String
altCertChain
;
// file to read alternative cert chain from
String
tSAPolicyID
;
String
tSADigestAlg
=
"SHA-256"
;
boolean
verify
=
false
;
// verify the jar
String
verbose
=
null
;
// verbose output when signing/verifying
boolean
showcerts
=
false
;
// show certs when verifying
...
...
@@ -342,6 +343,9 @@ public class Main {
}
else
if
(
collator
.
compare
(
flags
,
"-tsapolicyid"
)
==
0
)
{
if
(++
n
==
args
.
length
)
usageNoArg
();
tSAPolicyID
=
args
[
n
];
}
else
if
(
collator
.
compare
(
flags
,
"-tsadigestalg"
)
==
0
)
{
if
(++
n
==
args
.
length
)
usageNoArg
();
tSADigestAlg
=
args
[
n
];
}
else
if
(
collator
.
compare
(
flags
,
"-debug"
)
==
0
)
{
debug
=
true
;
}
else
if
(
collator
.
compare
(
flags
,
"-keypass"
)
==
0
)
{
...
...
@@ -535,6 +539,9 @@ public class Main {
System
.
out
.
println
(
rb
.
getString
(
".tsapolicyid.tsapolicyid.for.Timestamping.Authority"
));
System
.
out
.
println
();
System
.
out
.
println
(
rb
.
getString
(
".tsadigestalg.algorithm.of.digest.data.in.timestamping.request"
));
System
.
out
.
println
();
System
.
out
.
println
(
rb
.
getString
(
".altsigner.class.class.name.of.an.alternative.signing.mechanism"
));
System
.
out
.
println
();
...
...
@@ -1270,8 +1277,8 @@ public class Main {
try
{
block
=
sf
.
generateBlock
(
privateKey
,
sigalg
,
certChain
,
externalSF
,
tsaUrl
,
tsaCert
,
tSAPolicyID
,
signingMechanism
,
args
,
zipFile
);
externalSF
,
tsaUrl
,
tsaCert
,
tSAPolicyID
,
tSADigestAlg
,
signingMechanism
,
args
,
zipFile
);
}
catch
(
SocketTimeoutException
e
)
{
// Provide a helpful message when TSA is beyond a firewall
error
(
rb
.
getString
(
"unable.to.sign.jar."
)
+
...
...
@@ -2268,13 +2275,14 @@ class SignatureFile {
boolean
externalSF
,
String
tsaUrl
,
X509Certificate
tsaCert
,
String
tSAPolicyID
,
String
tSADigestAlg
,
ContentSigner
signingMechanism
,
String
[]
args
,
ZipFile
zipFile
)
throws
NoSuchAlgorithmException
,
InvalidKeyException
,
IOException
,
SignatureException
,
CertificateException
{
return
new
Block
(
this
,
privateKey
,
sigalg
,
certChain
,
externalSF
,
tsaUrl
,
tsaCert
,
tSAPolicyID
,
signingMechanism
,
args
,
zipFile
);
tsaUrl
,
tsaCert
,
tSAPolicyID
,
tSADigestAlg
,
signingMechanism
,
args
,
zipFile
);
}
...
...
@@ -2288,8 +2296,8 @@ class SignatureFile {
*/
Block
(
SignatureFile
sfg
,
PrivateKey
privateKey
,
String
sigalg
,
X509Certificate
[]
certChain
,
boolean
externalSF
,
String
tsaUrl
,
X509Certificate
tsaCert
,
String
tSAPolicyID
,
ContentSigner
signingMechanism
,
String
[]
args
,
ZipFile
zipFile
)
X509Certificate
tsaCert
,
String
tSAPolicyID
,
String
tSADigestAlg
,
ContentSigner
signingMechanism
,
String
[]
args
,
ZipFile
zipFile
)
throws
NoSuchAlgorithmException
,
InvalidKeyException
,
IOException
,
SignatureException
,
CertificateException
{
...
...
@@ -2371,7 +2379,8 @@ class SignatureFile {
// Assemble parameters for the signing mechanism
ContentSignerParameters
params
=
new
JarSignerParameters
(
args
,
tsaUri
,
tsaCert
,
tSAPolicyID
,
signature
,
new
JarSignerParameters
(
args
,
tsaUri
,
tsaCert
,
tSAPolicyID
,
tSADigestAlg
,
signature
,
signatureAlgorithm
,
certChain
,
content
,
zipFile
);
// Generate the signature block
...
...
@@ -2400,120 +2409,3 @@ class SignatureFile {
}
}
}
/*
* This object encapsulates the parameters used to perform content signing.
*/
class
JarSignerParameters
implements
ContentSignerParameters
{
private
String
[]
args
;
private
URI
tsa
;
private
X509Certificate
tsaCertificate
;
private
byte
[]
signature
;
private
String
signatureAlgorithm
;
private
X509Certificate
[]
signerCertificateChain
;
private
byte
[]
content
;
private
ZipFile
source
;
private
String
tSAPolicyID
;
/**
* Create a new object.
*/
JarSignerParameters
(
String
[]
args
,
URI
tsa
,
X509Certificate
tsaCertificate
,
String
tSAPolicyID
,
byte
[]
signature
,
String
signatureAlgorithm
,
X509Certificate
[]
signerCertificateChain
,
byte
[]
content
,
ZipFile
source
)
{
if
(
signature
==
null
||
signatureAlgorithm
==
null
||
signerCertificateChain
==
null
)
{
throw
new
NullPointerException
();
}
this
.
args
=
args
;
this
.
tsa
=
tsa
;
this
.
tsaCertificate
=
tsaCertificate
;
this
.
tSAPolicyID
=
tSAPolicyID
;
this
.
signature
=
signature
;
this
.
signatureAlgorithm
=
signatureAlgorithm
;
this
.
signerCertificateChain
=
signerCertificateChain
;
this
.
content
=
content
;
this
.
source
=
source
;
}
/**
* Retrieves the command-line arguments.
*
* @return The command-line arguments. May be null.
*/
public
String
[]
getCommandLine
()
{
return
args
;
}
/**
* Retrieves the identifier for a Timestamping Authority (TSA).
*
* @return The TSA identifier. May be null.
*/
public
URI
getTimestampingAuthority
()
{
return
tsa
;
}
/**
* Retrieves the certificate for a Timestamping Authority (TSA).
*
* @return The TSA certificate. May be null.
*/
public
X509Certificate
getTimestampingAuthorityCertificate
()
{
return
tsaCertificate
;
}
public
String
getTSAPolicyID
()
{
return
tSAPolicyID
;
}
/**
* Retrieves the signature.
*
* @return The non-null signature bytes.
*/
public
byte
[]
getSignature
()
{
return
signature
;
}
/**
* Retrieves the name of the signature algorithm.
*
* @return The non-null string name of the signature algorithm.
*/
public
String
getSignatureAlgorithm
()
{
return
signatureAlgorithm
;
}
/**
* Retrieves the signer's X.509 certificate chain.
*
* @return The non-null array of X.509 public-key certificates.
*/
public
X509Certificate
[]
getSignerCertificateChain
()
{
return
signerCertificateChain
;
}
/**
* Retrieves the content that was signed.
*
* @return The content bytes. May be null.
*/
public
byte
[]
getContent
()
{
return
content
;
}
/**
* Retrieves the original source ZIP file before it was signed.
*
* @return The original ZIP file. May be null.
*/
public
ZipFile
getSource
()
{
return
source
;
}
}
src/share/classes/sun/security/tools/jarsigner/Resources.java
浏览文件 @
f23a11d9
...
...
@@ -88,6 +88,8 @@ public class Resources extends java.util.ListResourceBundle {
"[-tsacert <alias>] public key certificate for Timestamping Authority"
},
{
".tsapolicyid.tsapolicyid.for.Timestamping.Authority"
,
"[-tsapolicyid <oid>] TSAPolicyID for Timestamping Authority"
},
{
".tsadigestalg.algorithm.of.digest.data.in.timestamping.request"
,
"[-tsadigestalg <algorithm>] algorithm of digest data in timestamping request"
},
{
".altsigner.class.class.name.of.an.alternative.signing.mechanism"
,
"[-altsigner <class>] class name of an alternative signing mechanism"
},
{
".altsignerpath.pathlist.location.of.an.alternative.signing.mechanism"
,
...
...
src/share/classes/sun/security/tools/jarsigner/TimestampedSigner.java
浏览文件 @
f23a11d9
...
...
@@ -132,9 +132,14 @@ public final class TimestampedSigner extends ContentSigner {
}
}
}
String
tSADigestAlg
=
"SHA-256"
;
if
(
params
instanceof
JarSignerParameters
)
{
tSADigestAlg
=
((
JarSignerParameters
)
params
).
getTSADigestAlg
();
}
return
PKCS7
.
generateSignedData
(
signature
,
signerChain
,
content
,
params
.
getSignatureAlgorithm
(),
tsaURI
,
params
.
getTSAPolicyID
());
params
.
getTSAPolicyID
(),
tSADigestAlg
);
}
/**
...
...
src/share/classes/sun/util/resources/TimeZoneNames.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1996, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -307,6 +307,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/de/TimeZoneNames_de.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/es/TimeZoneNames_es.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/it/TimeZoneNames_it.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1034,7 +1035,6 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java
浏览文件 @
f23a11d9
/*
* Copyright (c) 1997, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. 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
...
...
@@ -308,6 +308,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
{
"Europe/Bucharest"
,
EET
},
{
"Asia/Shanghai"
,
CTT
},
{
"CTT"
,
CTT
},
{
"UTC"
,
UTC
},
/* Don't change the order of the above zones
* to keep compatibility with the previous version.
*/
...
...
@@ -1036,7 +1037,6 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
{
"US/Pacific"
,
PST
},
{
"US/Pacific-New"
,
PST
},
{
"US/Samoa"
,
SAMOA
},
{
"UTC"
,
UTC
},
{
"VST"
,
ICT
},
{
"W-SU"
,
MSK
},
{
"WET"
,
WET
},
...
...
src/solaris/classes/sun/awt/X11/XBaseWindow.java
浏览文件 @
f23a11d9
...
...
@@ -79,7 +79,6 @@ public class XBaseWindow {
static
enum
InitialiseState
{
INITIALISING
,
NOT_INITIALISED
,
INITIALISED
,
FAILED_INITIALISATION
};
...
...
@@ -122,7 +121,6 @@ public class XBaseWindow {
*/
void
instantPreInit
(
XCreateWindowParams
params
)
{
state_lock
=
new
StateLock
();
initialising
=
InitialiseState
.
NOT_INITIALISED
;
}
/**
...
...
@@ -131,7 +129,6 @@ public class XBaseWindow {
*/
void
preInit
(
XCreateWindowParams
params
)
{
state_lock
=
new
StateLock
();
initialising
=
InitialiseState
.
NOT_INITIALISED
;
embedded
=
Boolean
.
TRUE
.
equals
(
params
.
get
(
EMBEDDED
));
visible
=
Boolean
.
TRUE
.
equals
(
params
.
get
(
VISIBLE
));
...
...
@@ -223,7 +220,6 @@ public class XBaseWindow {
return
false
;
}
return
true
;
case
NOT_INITIALISED:
case
FAILED_INITIALISATION:
return
false
;
default
:
...
...
test/java/awt/Paint/ComponentIsNotDrawnAfterRemoveAddTest/ComponentIsNotDrawnAfterRemoveAddTest.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 8139581
@summary AWT components are not drawn after removal and addition to a container
@author Anton Litvinov
*/
import
java.awt.Button
;
import
java.awt.Color
;
import
java.awt.Canvas
;
import
java.awt.Frame
;
import
java.awt.Graphics
;
import
java.awt.Panel
;
import
java.util.ArrayList
;
public
class
ComponentIsNotDrawnAfterRemoveAddTest
{
private
final
Frame
frame
;
private
final
Panel
panel
;
private
final
ArrayList
<
Testable
>
compList
=
new
ArrayList
<
Testable
>();
public
ComponentIsNotDrawnAfterRemoveAddTest
()
{
frame
=
new
Frame
(
"ComponentIsNotDrawnAfterRemoveAddTest"
);
frame
.
setSize
(
500
,
500
);
frame
.
setLocation
(
200
,
200
);
frame
.
setLayout
(
null
);
frame
.
setBackground
(
Color
.
RED
);
panel
=
new
Panel
();
panel
.
setLayout
(
null
);
panel
.
setBounds
(
25
,
100
,
455
,
295
);
panel
.
setBackground
(
Color
.
GREEN
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
TestCanvas
canv1
=
new
TestCanvas
();
canv1
.
setBounds
(
i
*
45
+
5
,
15
,
30
+
i
,
30
+
i
);
panel
.
add
(
canv1
);
compList
.
add
(
canv1
);
TestButton
btn1
=
new
TestButton
();
btn1
.
setBounds
(
i
*
45
+
5
,
60
,
30
+
i
,
30
+
i
);
panel
.
add
(
btn1
);
compList
.
add
(
btn1
);
TestCanvas
canv2
=
new
TestCanvas
();
canv2
.
setBounds
(
i
*
45
+
5
,
105
,
30
+
i
,
30
+
i
);
panel
.
add
(
canv2
);
compList
.
add
(
canv2
);
TestButton
btn2
=
new
TestButton
();
btn2
.
setBounds
(
i
*
45
+
5
,
150
,
30
+
i
,
30
+
i
);
panel
.
add
(
btn2
);
compList
.
add
(
btn2
);
TestCanvas
canv3
=
new
TestCanvas
();
canv3
.
setBounds
(
i
*
45
+
5
,
195
,
30
+
i
,
30
+
i
);
panel
.
add
(
canv3
);
compList
.
add
(
canv3
);
TestButton
btn3
=
new
TestButton
();
btn3
.
setBounds
(
i
*
45
+
5
,
240
,
30
+
i
,
30
+
i
);
panel
.
add
(
btn3
);
compList
.
add
(
btn3
);
}
frame
.
add
(
panel
);
frame
.
setVisible
(
true
);
}
private
void
runTest
()
{
try
{
doSleep
(
1500
);
checkTestableComponents
();
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
System
.
err
.
println
(
String
.
format
(
"Test iteration #%d:"
,
i
));
frame
.
remove
(
panel
);
frame
.
invalidate
();
frame
.
validate
();
frame
.
add
(
panel
);
doSleep
(
1500
);
checkTestableComponents
();
}
}
finally
{
frame
.
dispose
();
}
}
private
void
doSleep
(
long
millis
)
{
try
{
Thread
.
sleep
(
millis
);
}
catch
(
InterruptedException
ie
)
{
ie
.
printStackTrace
();
}
}
private
void
checkTestableComponents
()
throws
RuntimeException
{
int
notDrawnCompsCount
=
0
;
for
(
Testable
comp
:
compList
)
{
if
(!
comp
.
wasPaintCalled
())
{
notDrawnCompsCount
++;
}
else
{
comp
.
resetPaintCalledFlag
();
}
}
if
(
notDrawnCompsCount
>
0
)
{
throw
new
RuntimeException
(
String
.
format
(
"'paint' method of %d components was not called."
,
notDrawnCompsCount
));
}
}
private
interface
Testable
{
boolean
wasPaintCalled
();
void
resetPaintCalledFlag
();
}
private
static
class
TestCanvas
extends
Canvas
implements
Testable
{
private
volatile
boolean
paintWasCalled
=
false
;
@Override
public
void
paint
(
Graphics
g
)
{
paintWasCalled
=
true
;
super
.
paint
(
g
);
g
.
setColor
(
Color
.
BLUE
);
g
.
fillRect
(
0
,
0
,
getWidth
(),
getHeight
());
}
@Override
public
boolean
wasPaintCalled
()
{
return
paintWasCalled
;
}
@Override
public
void
resetPaintCalledFlag
()
{
paintWasCalled
=
false
;
}
}
private
static
class
TestButton
extends
Button
implements
Testable
{
private
volatile
boolean
paintWasCalled
=
false
;
@Override
public
void
paint
(
Graphics
g
)
{
paintWasCalled
=
true
;
super
.
paint
(
g
);
g
.
setColor
(
Color
.
YELLOW
);
g
.
fillRect
(
0
,
0
,
15
,
15
);
}
@Override
public
boolean
wasPaintCalled
()
{
return
paintWasCalled
;
}
@Override
public
void
resetPaintCalledFlag
()
{
paintWasCalled
=
false
;
}
}
public
static
void
main
(
String
[]
args
)
{
new
ComponentIsNotDrawnAfterRemoveAddTest
().
runTest
();
}
}
test/java/text/Format/DateFormat/Bug8141243.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8141243
* @summary Make sure that SimpleDateFormat parses "UTC" as the UTC time zone.
* @run main Bug8141243
*/
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.TimeZone
;
import
static
java
.
util
.
TimeZone
.*;
public
class
Bug8141243
{
public
static
void
main
(
String
[]
args
)
{
TimeZone
UTC
=
TimeZone
.
getTimeZone
(
"UTC"
);
TimeZone
initTz
=
TimeZone
.
getDefault
();
List
<
String
>
errors
=
new
ArrayList
<>();
try
{
TimeZone
.
setDefault
(
TimeZone
.
getTimeZone
(
"America/Los_Angeles"
));
for
(
Locale
locale
:
DateFormat
.
getAvailableLocales
())
{
// exclude any locales which localize "UTC".
String
utc
=
UTC
.
getDisplayName
(
false
,
SHORT
,
locale
);
if
(!
"UTC"
.
equals
(
utc
))
{
System
.
out
.
println
(
"Skipping "
+
locale
+
" due to localized UTC name: "
+
utc
);
continue
;
}
SimpleDateFormat
fmt
=
new
SimpleDateFormat
(
"z"
,
locale
);
try
{
Date
date
=
fmt
.
parse
(
"UTC"
);
// Parsed one may not exactly be UTC. Universal, UCT, etc. are equivalents.
if
(!
fmt
.
getTimeZone
().
getID
().
matches
(
"(Etc/)?(UTC|Universal|UCT|Zulu)"
))
{
errors
.
add
(
"timezone: "
+
fmt
.
getTimeZone
().
getID
()
+
", locale: "
+
locale
);
}
}
catch
(
ParseException
e
)
{
errors
.
add
(
"parse exception: "
+
e
+
", locale: "
+
locale
);
}
}
}
finally
{
// Restore the default time zone
TimeZone
.
setDefault
(
initTz
);
}
if
(!
errors
.
isEmpty
())
{
System
.
out
.
println
(
"Got unexpected results:"
);
for
(
String
s
:
errors
)
{
System
.
out
.
println
(
" "
+
s
);
}
throw
new
RuntimeException
(
"Test failed."
);
}
else
{
System
.
out
.
println
(
"Test passed."
);
}
}
}
test/javax/net/ssl/TLSv12/SignatureAlgorithms.java
0 → 100644
浏览文件 @
f23a11d9
此差异已折叠。
点击以展开。
test/javax/xml/jaxp/common/8144593/TestSAXDriver.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
;
import
javax.xml.XMLConstants
;
import
org.xml.sax.SAXNotRecognizedException
;
import
org.xml.sax.SAXNotSupportedException
;
/*
* Test implementation of SAXParser. It is extended from JDK parser and two methods
* are overriden to disable support of specific features and properties.
* This class is used in ValidationWarningsTest and TransformationWarningsTest
* to generate multiple warnings during xml validation and transformation processes.
*/
public
class
TestSAXDriver
extends
SAXParserImpl
.
JAXPSAXParser
{
@Override
public
synchronized
void
setFeature
(
String
name
,
boolean
value
)
throws
SAXNotRecognizedException
,
SAXNotSupportedException
{
if
(
XMLConstants
.
FEATURE_SECURE_PROCESSING
.
equals
(
name
))
{
throw
new
SAXNotRecognizedException
(
name
+
" feature is not recognised by test SAX parser intentionally."
);
}
else
{
super
.
setFeature
(
name
,
value
);
}
}
@Override
public
synchronized
void
setProperty
(
String
name
,
Object
value
)
throws
SAXNotRecognizedException
,
SAXNotSupportedException
{
if
(
XMLConstants
.
ACCESS_EXTERNAL_DTD
.
equals
(
name
)
||
ENT_EXP_LIMIT_PROP
.
equals
(
name
))
{
throw
new
SAXNotRecognizedException
(
name
+
" property is not recognised by test SAX parser intentionally."
);
}
else
{
super
.
setProperty
(
name
,
value
);
}
}
private
static
final
String
ENT_EXP_LIMIT_PROP
=
"http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit"
;
}
test/javax/xml/jaxp/common/8144593/TransformationWarningsTest.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.BeforeClass
;
/*
* @test
* @bug 8144593
* @summary Check that warnings about unsupported properties from parsers
* are suppressed during the transformation process.
* @compile -XDignore.symbol.file TestSAXDriver.java
* @run testng/othervm TransformationWarningsTest
*/
public
class
TransformationWarningsTest
extends
WarningsTestBase
{
@BeforeClass
public
void
setup
()
{
//Set test SAX driver implementation.
System
.
setProperty
(
"org.xml.sax.driver"
,
"TestSAXDriver"
);
}
@Test
public
void
testTransformation
()
throws
Exception
{
startTest
();
}
//One iteration of xml transformation test case. It will be called from each
//TestWorker task defined in WarningsTestBase class.
void
doOneTestIteration
()
throws
Exception
{
// Prepare output stream
StringWriter
xmlResultString
=
new
StringWriter
();
StreamResult
xmlResultStream
=
new
StreamResult
(
xmlResultString
);
// Prepare xml source stream
Source
src
=
new
StreamSource
(
new
StringReader
(
xml
));
Transformer
t
=
createTransformer
();
//Transform the xml
t
.
transform
(
src
,
xmlResultStream
);
}
//Create transformer from xsl test string
Transformer
createTransformer
()
throws
Exception
{
// Prepare sources for transormation
Source
xslsrc
=
new
StreamSource
(
new
StringReader
(
xsl
));
// Create factory and transformer
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
Transformer
t
=
tf
.
newTransformer
(
xslsrc
);
// Set URI Resolver to return the newly constructed xml
// stream source object from xml test string
t
.
setURIResolver
((
String
href
,
String
base
)
->
new
StreamSource
(
new
StringReader
(
xml
)));
return
t
;
}
//Xsl and Xml contents used in the transformation test
private
static
final
String
xsl
=
"<xsl:stylesheet version='2.0'"
+
" xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>"
+
" <xsl:output method='xml' indent='yes' omit-xml-declaration='yes'/>"
+
" <xsl:template match='/'>"
+
" <test>Simple Transformation Result. No warnings should be printed to console</test>"
+
" </xsl:template>"
+
"</xsl:stylesheet>"
;
private
static
final
String
xml
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><root></root>"
;
}
test/javax/xml/jaxp/common/8144593/ValidationWarningsTest.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.ByteArrayInputStream
;
import
java.io.StringReader
;
import
javax.xml.XMLConstants
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.sax.SAXSource
;
import
javax.xml.transform.stream.StreamSource
;
import
javax.xml.validation.Schema
;
import
javax.xml.validation.SchemaFactory
;
import
javax.xml.validation.Validator
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.BeforeClass
;
import
org.xml.sax.InputSource
;
/*
* @test
* @bug 8144593
* @summary Check that warnings about unsupported properties from SAX
* parsers are suppressed during the xml validation process.
* @compile -XDignore.symbol.file TestSAXDriver.java
* @run testng/othervm ValidationWarningsTest
*/
public
class
ValidationWarningsTest
extends
WarningsTestBase
{
@BeforeClass
public
void
setup
()
{
//Set test SAX driver implementation.
System
.
setProperty
(
"org.xml.sax.driver"
,
"TestSAXDriver"
);
}
@Test
public
void
testValidation
()
throws
Exception
{
startTest
();
}
//One iteration of xml validation test case. It will be called from each
//TestWorker task defined in WarningsTestBase class.
void
doOneTestIteration
()
throws
Exception
{
Source
src
=
new
StreamSource
(
new
StringReader
(
xml
));
SchemaFactory
schemaFactory
=
SchemaFactory
.
newInstance
(
XMLConstants
.
W3C_XML_SCHEMA_NS_URI
);
SAXSource
xsdSource
=
new
SAXSource
(
new
InputSource
(
new
ByteArrayInputStream
(
xsd
.
getBytes
())));
Schema
schema
=
schemaFactory
.
newSchema
(
xsdSource
);
Validator
v
=
schema
.
newValidator
();
v
.
validate
(
src
);
}
//Xsd and Xml contents used in the validation test
private
static
final
String
xsd
=
"<?xml version='1.0'?>"
+
" <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>"
+
" <xs:element name='test' type='xs:string'/>\n"
+
" </xs:schema>"
;
private
static
final
String
xml
=
"<?xml version='1.0'?><test>Element</test>"
;
}
test/javax/xml/jaxp/common/8144593/WarningsTestBase.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
java.util.concurrent.CyclicBarrier
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.xml.XMLConstants
;
import
org.testng.Assert
;
/*
* This class helps to test suppression of unsupported parser properties
* messages printed to standard error output.
* It launches THREADS_COUNT tasks. Each task does ITERATIONS_PER_THREAD
* sequential calls to doOneIteration method implemented by specific test class.
*/
public
abstract
class
WarningsTestBase
{
/*
* Abstract method that should be implemented by test class.
* It is repeatedly called by each TestWorker task.
*/
abstract
void
doOneTestIteration
()
throws
Exception
;
/*
* Launches parallel test tasks and check the output for the number of
* generated warning messages. There should be no more than one message of
* each type.
*/
void
startTest
()
throws
Exception
{
//Save standard error stream
PrintStream
defStdErr
=
System
.
err
;
//Set new byte array stream as standard error stream
ByteArrayOutputStream
byteStream
=
new
ByteArrayOutputStream
(
5000
);
System
.
setErr
(
new
PrintStream
(
byteStream
));
//Execute multiple TestWorker tasks
for
(
int
id
=
0
;
id
<
THREADS_COUNT
;
id
++)
{
EXECUTOR
.
execute
(
new
TestWorker
(
id
));
}
//Initiate shutdown of previously submitted task
EXECUTOR
.
shutdown
();
//Wait for termination of submitted tasks
if
(!
EXECUTOR
.
awaitTermination
(
THREADS_COUNT
,
TimeUnit
.
SECONDS
))
{
//If not all tasks terminates during the time out force them to shutdown
EXECUTOR
.
shutdownNow
();
}
//Restore default standard error stream
System
.
setErr
(
defStdErr
);
//Print tasks stderr output
String
errContent
=
byteStream
.
toString
();
System
.
out
.
println
(
"Standard error output content:"
);
System
.
out
.
println
(
errContent
);
//Check tasks stderr output for quatity of warning messages
Assert
.
assertTrue
(
warningPrintedOnce
(
XMLConstants
.
ACCESS_EXTERNAL_DTD
,
errContent
));
Assert
.
assertTrue
(
warningPrintedOnce
(
ENT_EXP_PROPERTY
,
errContent
));
Assert
.
assertTrue
(
warningPrintedOnce
(
XMLConstants
.
FEATURE_SECURE_PROCESSING
,
errContent
));
}
// Count occurences of warning messages in standard error and check if warning is printed
// not more than once
private
boolean
warningPrintedOnce
(
String
propertyName
,
String
testOutput
)
{
//Count for property name in test output
Pattern
p
=
Pattern
.
compile
(
propertyName
);
Matcher
m
=
p
.
matcher
(
testOutput
);
int
count
=
0
;
while
(
m
.
find
())
{
count
+=
1
;
}
System
.
out
.
println
(
"'"
+
propertyName
+
"' print count: "
+
count
);
//If count is more than 1 then consider test failed
return
count
<=
1
;
}
//TestWorker task that sequentially calls test method
private
class
TestWorker
implements
Runnable
{
// Task id
private
final
int
id
;
TestWorker
(
int
id
)
{
this
.
id
=
id
;
}
@Override
public
void
run
()
{
try
{
System
.
out
.
printf
(
"%d: waiting for barrier%n"
,
id
);
//Synchronize startup of all tasks
BARRIER
.
await
();
System
.
out
.
printf
(
"%d: starting iterations%n"
,
id
);
//Call test method multiple times
for
(
int
i
=
0
;
i
<
ITERATIONS_PER_THREAD
;
i
++)
{
doOneTestIteration
();
}
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
"TestWorker id:"
+
id
+
" failed"
,
ex
);
}
}
}
//Entity expansion limit property name
private
static
final
String
ENT_EXP_PROPERTY
=
"http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit"
;
//Number of simultaneous test threads
private
static
final
int
THREADS_COUNT
=
10
;
//Number of iterations per one thread
private
static
final
int
ITERATIONS_PER_THREAD
=
4
;
//Test thread pool
private
static
final
ExecutorService
EXECUTOR
=
Executors
.
newCachedThreadPool
();
//Cyclic barrier for threads startup synchronisation
private
static
final
CyclicBarrier
BARRIER
=
new
CyclicBarrier
(
THREADS_COUNT
);
}
test/javax/xml/jaxp/parsers/8072081/SupplementaryChars.java
0 → 100644
浏览文件 @
f23a11d9
/*
* Copyright (c) 2015, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.ByteArrayInputStream
;
import
javax.xml.parsers.SAXParser
;
import
javax.xml.parsers.SAXParserFactory
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
org.xml.sax.SAXParseException
;
import
org.xml.sax.helpers.DefaultHandler
;
/**
* @test
* @bug 8072081
* @summary verifies that supplementary characters are supported as character
* data in xml 1.0, and also names in xml 1.1.
* @run testng/othervm SupplementaryChars
*/
/*
* Joe Wang (huizhe.wang@oracle.com)
*/
public
class
SupplementaryChars
{
@Test
(
dataProvider
=
"supported"
)
public
void
test
(
String
xml
)
throws
Exception
{
ByteArrayInputStream
stream
=
new
ByteArrayInputStream
(
xml
.
getBytes
(
"UTF-8"
));
getParser
().
parse
(
stream
,
new
DefaultHandler
());
stream
.
close
();
}
@Test
(
dataProvider
=
"unsupported"
,
expectedExceptions
=
SAXParseException
.
class
)
public
void
testInvalid
(
String
xml
)
throws
Exception
{
ByteArrayInputStream
stream
=
new
ByteArrayInputStream
(
xml
.
getBytes
(
"UTF-8"
));
getParser
().
parse
(
stream
,
new
DefaultHandler
());
stream
.
close
();
}
@DataProvider
(
name
=
"supported"
)
private
Object
[][]
supported
()
{
return
new
Object
[][]
{
{
"<?xml version=\"1.0\"?><tag>\uD840\uDC0B</tag>"
},
{
"<?xml version=\"1.0\"?><!-- \uD840\uDC0B --><tag/>"
},
{
"<?xml version=\"1.1\"?><tag\uD840\uDC0B>in tag name</tag\uD840\uDC0B>"
},
{
"<?xml version=\"1.1\"?><tag attr\uD840\uDC0B=\"in attribute\">in attribute name</tag>"
},
{
"<?xml version=\"1.1\"?><tag>\uD840\uDC0B</tag>"
},
{
"<?xml version=\"1.1\"?><!-- \uD840\uDC0B --><dontCare/>"
}
};
}
@DataProvider
(
name
=
"unsupported"
)
private
Object
[][]
unsupported
()
{
return
new
Object
[][]
{
{
"<?xml version=\"1.0\"?><tag\uD840\uDC0B>in tag name</tag\uD840\uDC0B>"
},
{
"<?xml version=\"1.0\"?><tag attr\uD840\uDC0B=\"in attribute\">in attribute name</tag>"
}
};
}
private
SAXParser
getParser
()
{
SAXParser
parser
=
null
;
try
{
SAXParserFactory
factory
=
SAXParserFactory
.
newInstance
();
parser
=
factory
.
newSAXParser
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
());
}
return
parser
;
}
}
test/sun/security/tools/jarsigner/TimestampCheck.java
浏览文件 @
f23a11d9
...
...
@@ -24,10 +24,9 @@
import
com.sun.net.httpserver.*
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.math.BigInteger
;
...
...
@@ -38,9 +37,15 @@ import java.security.Signature;
import
java.security.cert.Certificate
;
import
java.security.cert.X509Certificate
;
import
java.util.Calendar
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
import
sun.misc.IOUtils
;
import
sun.security.pkcs.ContentInfo
;
import
sun.security.pkcs.PKCS7
;
import
sun.security.pkcs.PKCS9Attribute
;
import
sun.security.pkcs.SignerInfo
;
import
sun.security.timestamp.TimestampToken
;
import
sun.security.util.DerOutputStream
;
import
sun.security.util.DerValue
;
import
sun.security.util.ObjectIdentifier
;
...
...
@@ -51,6 +56,8 @@ public class TimestampCheck {
static
final
String
TSKS
=
"tsks"
;
static
final
String
JAR
=
"old.jar"
;
static
final
String
defaultPolicyId
=
"2.3.4.5"
;
static
class
Handler
implements
HttpHandler
{
public
void
handle
(
HttpExchange
t
)
throws
IOException
{
int
len
=
0
;
...
...
@@ -94,6 +101,11 @@ public class TimestampCheck {
* 6: extension is missing
* 7: extension is non-critical
* 8: extension does not have timestamping
* 9: no cert in response
* 10: normal
* 11: always return default policy id
* 12: normal
* otherwise: normal
* @returns the signed
*/
byte
[]
sign
(
byte
[]
input
,
int
path
)
throws
Exception
{
...
...
@@ -106,6 +118,7 @@ public class TimestampCheck {
messageImprint
.
data
.
getDerValue
());
System
.
err
.
println
(
"AlgorithmId: "
+
aid
);
ObjectIdentifier
policyId
=
new
ObjectIdentifier
(
defaultPolicyId
);
BigInteger
nonce
=
null
;
while
(
value
.
data
.
available
()
>
0
)
{
DerValue
v
=
value
.
data
.
getDerValue
();
...
...
@@ -114,6 +127,9 @@ public class TimestampCheck {
System
.
err
.
println
(
"nonce: "
+
nonce
);
}
else
if
(
v
.
tag
==
DerValue
.
tag_Boolean
)
{
System
.
err
.
println
(
"certReq: "
+
v
.
getBoolean
());
}
else
if
(
v
.
tag
==
DerValue
.
tag_ObjectId
)
{
policyId
=
v
.
getOID
();
System
.
err
.
println
(
"PolicyID: "
+
policyId
);
}
}
...
...
@@ -127,6 +143,10 @@ public class TimestampCheck {
if
(
path
==
7
)
alias
=
"tsbad2"
;
if
(
path
==
8
)
alias
=
"tsbad3"
;
if
(
path
==
11
)
{
policyId
=
new
ObjectIdentifier
(
defaultPolicyId
);
}
DerOutputStream
statusInfo
=
new
DerOutputStream
();
statusInfo
.
putInteger
(
0
);
...
...
@@ -150,7 +170,7 @@ public class TimestampCheck {
DerOutputStream
tst
=
new
DerOutputStream
();
tst
.
putInteger
(
1
);
tst
.
putOID
(
new
ObjectIdentifier
(
"1.2.3.4"
));
// policy
tst
.
putOID
(
policyId
);
if
(
path
!=
3
&&
path
!=
4
)
{
tst
.
putDerValue
(
messageImprint
);
...
...
@@ -260,15 +280,43 @@ public class TimestampCheck {
jarsigner
(
cmd
,
7
,
false
);
// tsbad2
jarsigner
(
cmd
,
8
,
false
);
// tsbad3
jarsigner
(
cmd
,
9
,
false
);
// no cert in timestamp
jarsigner
(
cmd
+
" -tsapolicyid 1.2.3.4"
,
0
,
true
);
jarsigner
(
cmd
+
" -tsapolicyid 1.2.3.5"
,
0
,
false
);
jarsigner
(
cmd
+
" -tsapolicyid 1.2.3.4"
,
10
,
true
);
checkTimestamp
(
"new_10.jar"
,
"1.2.3.4"
,
"SHA-256"
);
jarsigner
(
cmd
+
" -tsapolicyid 1.2.3.5"
,
11
,
false
);
jarsigner
(
cmd
+
" -tsadigestalg SHA"
,
12
,
true
);
checkTimestamp
(
"new_12.jar"
,
defaultPolicyId
,
"SHA-1"
);
}
else
{
// Run as a standalone server
System
.
err
.
println
(
"Press Enter to quit server"
);
System
.
in
.
read
();
}
}
finally
{
server
.
stop
(
0
);
new
File
(
"x.jar"
).
delete
();
}
}
static
void
checkTimestamp
(
String
file
,
String
policyId
,
String
digestAlg
)
throws
Exception
{
try
(
JarFile
jf
=
new
JarFile
(
file
))
{
JarEntry
je
=
jf
.
getJarEntry
(
"META-INF/OLD.RSA"
);
try
(
InputStream
is
=
jf
.
getInputStream
(
je
))
{
byte
[]
content
=
IOUtils
.
readFully
(
is
,
-
1
,
true
);
PKCS7
p7
=
new
PKCS7
(
content
);
SignerInfo
[]
si
=
p7
.
getSignerInfos
();
if
(
si
==
null
||
si
.
length
==
0
)
{
throw
new
Exception
(
"Not signed"
);
}
PKCS9Attribute
p9
=
si
[
0
].
getUnauthenticatedAttributes
()
.
getAttribute
(
PKCS9Attribute
.
SIGNATURE_TIMESTAMP_TOKEN_OID
);
PKCS7
tsToken
=
new
PKCS7
((
byte
[])
p9
.
getValue
());
TimestampToken
tt
=
new
TimestampToken
(
tsToken
.
getContentInfo
().
getData
());
if
(!
tt
.
getHashAlgorithm
().
toString
().
equals
(
digestAlg
))
{
throw
new
Exception
(
"Digest alg different"
);
}
if
(!
tt
.
getPolicyID
().
equals
(
policyId
))
{
throw
new
Exception
(
"policyId different"
);
}
}
}
}
...
...
test/sun/security/tools/jarsigner/ts.sh
浏览文件 @
f23a11d9
...
...
@@ -86,6 +86,6 @@ $KT -alias tsbad3 -certreq | \
$KT
-alias
ca
-gencert
-ext
eku:critical
=
cs |
\
$KT
-alias
tsbad3
-importcert
$JAVAC
-d
.
${
TESTSRC
}
/TimestampCheck.java
$JAVAC
-
XDignore
.symbol.file
-
d
.
${
TESTSRC
}
/TimestampCheck.java
$JAVA
${
TESTVMOPTS
}
TimestampCheck
test/sun/tools/native2ascii/NativeErrors.java
浏览文件 @
f23a11d9
...
...
@@ -75,7 +75,14 @@ public class NativeErrors {
throw
new
Error
(
"Output file cannot be made read only: "
+
path2
);
}
f2
.
deleteOnExit
();
checkResult
(
executeCmd
(
path1
,
path2
),
"err.cannot.write"
);
if
(
f2
.
canWrite
()
)
{
String
msg
=
"Output file is still writable. "
+
"Probably because test is run as root. Read-only test skipped."
;
System
.
out
.
println
(
msg
);
}
else
{
// Test write to a read-only file.
checkResult
(
executeCmd
(
path1
,
path2
),
"err.cannot.write"
);
}
}
private
static
String
executeCmd
(
String
...
toolArgs
)
throws
Throwable
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录