Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4358c8c6
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看板
提交
4358c8c6
编写于
4月 18, 2018
作者:
R
robm
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
be4ac3f0
13bec080
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
1354 addition
and
184 deletion
+1354
-184
make/lib/Awt2dLibraries.gmk
make/lib/Awt2dLibraries.gmk
+6
-24
src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
+11
-17
src/share/classes/java/awt/SequencedEvent.java
src/share/classes/java/awt/SequencedEvent.java
+1
-5
src/share/classes/java/awt/image/FilteredImageSource.java
src/share/classes/java/awt/image/FilteredImageSource.java
+3
-3
src/share/classes/sun/security/krb5/internal/rcache/AuthList.java
...e/classes/sun/security/krb5/internal/rcache/AuthList.java
+25
-18
src/share/classes/sun/security/krb5/internal/rcache/MemoryCache.java
...lasses/sun/security/krb5/internal/rcache/MemoryCache.java
+8
-19
src/share/classes/sun/security/ssl/SSLContextImpl.java
src/share/classes/sun/security/ssl/SSLContextImpl.java
+120
-21
src/share/classes/sun/security/ssl/SSLEngineImpl.java
src/share/classes/sun/security/ssl/SSLEngineImpl.java
+14
-6
src/share/classes/sun/security/ssl/SSLSocketImpl.java
src/share/classes/sun/security/ssl/SSLSocketImpl.java
+14
-5
src/windows/classes/sun/awt/windows/WToolkit.java
src/windows/classes/sun/awt/windows/WToolkit.java
+1
-0
src/windows/native/sun/security/mscapi/security.cpp
src/windows/native/sun/security/mscapi/security.cpp
+114
-26
src/windows/native/sun/windows/awt_Component.cpp
src/windows/native/sun/windows/awt_Component.cpp
+1
-0
src/windows/native/sun/windows/awt_ScrollPane.cpp
src/windows/native/sun/windows/awt_ScrollPane.cpp
+9
-11
src/windows/native/sun/windows/awt_Toolkit.cpp
src/windows/native/sun/windows/awt_Toolkit.cpp
+1
-2
test/TEST.groups
test/TEST.groups
+1
-0
test/java/awt/ScrollPane/ScrollPaneValidateTest.java
test/java/awt/ScrollPane/ScrollPaneValidateTest.java
+91
-0
test/java/awt/event/SequencedEvent/SequencedEventTest.java
test/java/awt/event/SequencedEvent/SequencedEventTest.java
+171
-0
test/java/awt/image/FilteredImageSourceTest.java
test/java/awt/image/FilteredImageSourceTest.java
+212
-0
test/java/security/Signature/SignatureLength.java
test/java/security/Signature/SignatureLength.java
+68
-27
test/sun/security/ssl/HandshakeHash/DigestBase.java
test/sun/security/ssl/HandshakeHash/DigestBase.java
+71
-0
test/sun/security/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java
...urity/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java
+107
-0
test/sun/security/ssl/HandshakeHash/MyProvider.java
test/sun/security/ssl/HandshakeHash/MyProvider.java
+35
-0
test/sun/security/ssl/SSLContextImpl/CustomizedCipherSuites.java
...n/security/ssl/SSLContextImpl/CustomizedCipherSuites.java
+270
-0
未找到文件。
make/lib/Awt2dLibraries.gmk
浏览文件 @
4358c8c6
...
...
@@ -23,9 +23,6 @@
# questions.
#
# Openwin is defined on Solaris.
OPENWIN_LIB := $(OPENWIN_HOME)/lib
WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib
##########################################################################################
...
...
@@ -477,7 +474,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT, \
ASFLAGS := $(LIBAWT_ASFLAGS), \
MAPFILE := $(LIBAWT_MAPFILE), \
LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris := -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
LDFLAGS_SUFFIX_linux := -ljvm $(LIBM) $(LIBDL) -ljava, \
LDFLAGS_SUFFIX_solaris := -ljvm $(LIBM) $(LIBDL) -ljava -lc, \
LDFLAGS_SUFFIX_aix :=-ljvm $(LIBM) $(LIBDL) -ljava -lm,\
...
...
@@ -636,14 +632,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
$(X_CFLAGS), \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_xawt/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(X_LIBS) $(LIBAWT_XAWT_LDFLAGS), \
LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN) \
$(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_solaris := -L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \
-R$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \
-R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
$(X_LIBS) $(LIBAWT_XAWT_LDFLAGS) \
$(call SET_SHARED_LIBRARY_ORIGIN) \
$(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_SUFFIX := $(LIBAWT_XAWT_LDFLAGS_SUFFIX), \
...
...
@@ -839,9 +828,7 @@ ifeq ($(BUILD_HEADLESS), true)
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \
-R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
REORDER := $(LIBAWT_HEADLESS_REORDER), \
LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
...
...
@@ -1071,7 +1058,7 @@ else # OPENJDK_TARGET_OS not windows
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjawt/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris :=
-L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR
), \
LDFLAGS_solaris :=
$(X_LIBS
), \
LDFLAGS_SUFFIX_linux := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX), \
LDFLAGS_SUFFIX_aix := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX),\
LDFLAGS_SUFFIX_solaris := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX) -lXrender, \
...
...
@@ -1169,11 +1156,11 @@ ifndef OPENJDK
CFLAGS := $(CFLAGS_JDKLIB) \
-I$(JDK_TOPDIR)/src/share/javavm/export \
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \
-I$(OPENWIN_HOME)/include
, \
$(X_CFLAGS)
, \
MAPFILE := $(SUNWJDGA_MAPFILE), \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX :=
-L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR
) -ldga -lX11 $(LIBDL) -lc, \
LDFLAGS_SUFFIX :=
$(X_LIBS
) -ldga -lX11 $(LIBDL) -lc, \
OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libsunwjdga, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
...
...
@@ -1224,8 +1211,6 @@ ifndef BUILD_HEADLESS_ONLY
else ifeq ($(OPENJDK_TARGET_OS), windows)
LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32
else ifeq ($(OPENJDK_TARGET_OS), solaris)
LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
else
LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS)
endif
...
...
@@ -1245,10 +1230,7 @@ ifndef BUILD_HEADLESS_ONLY
-framework JavaNativeFoundation
else ifeq ($(OPENJDK_TARGET_OS), windows)
LIBSPLASHSCREEN_LDFLAGS_SUFFIX += kernel32.lib user32.lib gdi32.lib delayimp.lib -DELAYLOAD:user32.dll
else ifeq ($(OPENJDK_TARGET_OS), solaris)
# Solaris still uses OPENWIN_LIB ..
LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -lX11 -lXext $(LIBM) -lpthread
else # .. all other Unixes can use X_LIBS
else
LIBSPLASHSCREEN_LDFLAGS_SUFFIX += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread
endif
...
...
src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java
浏览文件 @
4358c8c6
/*
* Copyright (c) 1998, 201
5
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 201
8
, 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
...
...
@@ -674,20 +674,18 @@ class VirtualMachineImpl extends MirrorImpl
versionInfo
().
jdwpMinor
>=
6
;
}
public
boolean
canGetInstanceInfo
()
{
if
(
versionInfo
().
jdwpMajor
<
1
||
versionInfo
().
jdwpMinor
<
6
)
{
if
(
versionInfo
().
jdwpMajor
>
1
||
versionInfo
().
jdwpMinor
>=
6
)
{
validateVM
();
return
hasNewCapabilities
()
&&
capabilitiesNew
().
canGetInstanceInfo
;
}
else
{
return
false
;
}
validateVM
();
return
hasNewCapabilities
()
&&
capabilitiesNew
().
canGetInstanceInfo
;
}
public
boolean
canUseSourceNameFilters
()
{
if
(
versionInfo
().
jdwpMajor
<
1
||
versionInfo
().
jdwpMinor
<
6
)
{
return
false
;
}
return
true
;
return
versionInfo
().
jdwpMajor
>
1
||
versionInfo
().
jdwpMinor
>=
6
;
}
public
boolean
canForceEarlyReturn
()
{
validateVM
();
...
...
@@ -703,12 +701,8 @@ class VirtualMachineImpl extends MirrorImpl
capabilitiesNew
().
canGetSourceDebugExtension
;
}
public
boolean
canGetClassFileVersion
()
{
if
(
versionInfo
().
jdwpMajor
<
1
&&
versionInfo
().
jdwpMinor
<
6
)
{
return
false
;
}
else
{
return
true
;
}
return
versionInfo
().
jdwpMajor
>
1
||
versionInfo
().
jdwpMinor
>=
6
;
}
public
boolean
canGetConstantPool
()
{
validateVM
();
...
...
src/share/classes/java/awt/SequencedEvent.java
浏览文件 @
4358c8c6
...
...
@@ -104,11 +104,7 @@ class SequencedEvent extends AWTEvent implements ActiveEvent {
if
(
EventQueue
.
isDispatchThread
())
{
EventDispatchThread
edt
=
(
EventDispatchThread
)
Thread
.
currentThread
();
edt
.
pumpEvents
(
SentEvent
.
ID
,
new
Conditional
()
{
public
boolean
evaluate
()
{
return
!
SequencedEvent
.
this
.
isFirstOrDisposed
();
}
});
edt
.
pumpEvents
(
ID
,
()
->
!
SequencedEvent
.
this
.
isFirstOrDisposed
());
}
else
{
while
(!
isFirstOrDisposed
())
{
synchronized
(
SequencedEvent
.
class
)
{
...
...
src/share/classes/java/awt/image/FilteredImageSource.java
浏览文件 @
4358c8c6
/*
* Copyright (c) 1995, 20
03
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 20
18
, 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
...
...
@@ -171,7 +171,7 @@ public class FilteredImageSource implements ImageProducer {
* @param ic the consumer for the filtered image
* @see ImageConsumer
*/
public
void
startProduction
(
ImageConsumer
ic
)
{
public
synchronized
void
startProduction
(
ImageConsumer
ic
)
{
if
(
proxies
==
null
)
{
proxies
=
new
Hashtable
();
}
...
...
@@ -198,7 +198,7 @@ public class FilteredImageSource implements ImageProducer {
*
* @see ImageConsumer
*/
public
void
requestTopDownLeftRightResend
(
ImageConsumer
ic
)
{
public
synchronized
void
requestTopDownLeftRightResend
(
ImageConsumer
ic
)
{
if
(
proxies
!=
null
)
{
ImageFilter
imgf
=
(
ImageFilter
)
proxies
.
get
(
ic
);
if
(
imgf
!=
null
)
{
...
...
src/share/classes/sun/security/krb5/internal/rcache/AuthList.java
浏览文件 @
4358c8c6
/*
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
8
, 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
...
...
@@ -55,6 +55,9 @@ public class AuthList {
private
final
LinkedList
<
AuthTimeWithHash
>
entries
;
private
final
int
lifespan
;
// entries.getLast().ctime, updated after each cleanup.
private
volatile
int
oldestTime
=
Integer
.
MIN_VALUE
;
/**
* Constructs a AuthList.
*/
...
...
@@ -67,11 +70,13 @@ public class AuthList {
* Puts the authenticator timestamp into the cache in descending order,
* and throw an exception if it's already there.
*/
public
void
put
(
AuthTimeWithHash
t
,
KerberosTime
currentTime
)
public
synchronized
void
put
(
AuthTimeWithHash
t
,
KerberosTime
currentTime
)
throws
KrbApErrException
{
if
(
entries
.
isEmpty
())
{
entries
.
addFirst
(
t
);
oldestTime
=
t
.
ctime
;
return
;
}
else
{
AuthTimeWithHash
temp
=
entries
.
getFirst
();
int
cmp
=
temp
.
compareTo
(
t
);
...
...
@@ -106,24 +111,26 @@ public class AuthList {
// let us cleanup while we are here
long
timeLimit
=
currentTime
.
getSeconds
()
-
lifespan
;
ListIterator
<
AuthTimeWithHash
>
it
=
entries
.
listIterator
(
0
);
AuthTimeWithHash
temp
=
null
;
int
index
=
-
1
;
while
(
it
.
hasNext
())
{
// search expired timestamps.
temp
=
it
.
next
();
if
(
temp
.
ctime
<
timeLimit
)
{
index
=
entries
.
indexOf
(
temp
);
break
;
}
// Only trigger a cleanup when the earliest entry is
// lifespan + 5 sec ago. This ensures a cleanup is done
// at most every 5 seconds so that we don't always
// addLast(removeLast).
if
(
oldestTime
>
timeLimit
-
5
)
{
return
;
}
// It would be nice if LinkedList has a method called truncate(index).
if
(
index
>
-
1
)
{
do
{
// remove expired timestamps from the list.
entries
.
removeLast
();
}
while
(
entries
.
size
()
>
index
);
// and we remove the *enough* old ones (1 lifetime ago)
while
(!
entries
.
isEmpty
())
{
AuthTimeWithHash
removed
=
entries
.
removeLast
();
if
(
removed
.
ctime
>=
timeLimit
)
{
entries
.
addLast
(
removed
);
oldestTime
=
removed
.
ctime
;
return
;
}
}
oldestTime
=
Integer
.
MIN_VALUE
;
}
public
boolean
isEmpty
()
{
...
...
src/share/classes/sun/security/krb5/internal/rcache/MemoryCache.java
浏览文件 @
4358c8c6
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2018,
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
...
...
@@ -31,7 +31,9 @@
package
sun.security.krb5.internal.rcache
;
import
java.util.*
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
sun.security.krb5.internal.KerberosTime
;
import
sun.security.krb5.internal.KrbApErrException
;
import
sun.security.krb5.internal.ReplayCache
;
...
...
@@ -48,31 +50,18 @@ public class MemoryCache extends ReplayCache {
private
static
final
int
lifespan
=
KerberosTime
.
getDefaultSkew
();
private
static
final
boolean
DEBUG
=
sun
.
security
.
krb5
.
internal
.
Krb5
.
DEBUG
;
private
final
Map
<
String
,
AuthList
>
content
=
new
HashMap
<>();
private
final
Map
<
String
,
AuthList
>
content
=
new
Concurrent
HashMap
<>();
@Override
public
synchronized
void
checkAndStore
(
KerberosTime
currTime
,
AuthTimeWithHash
time
)
throws
KrbApErrException
{
String
key
=
time
.
client
+
"|"
+
time
.
server
;
AuthList
rc
=
content
.
get
(
key
);
content
.
computeIfAbsent
(
key
,
k
->
new
AuthList
(
lifespan
))
.
put
(
time
,
currTime
);
if
(
DEBUG
)
{
System
.
out
.
println
(
"MemoryCache: add "
+
time
+
" to "
+
key
);
}
if
(
rc
==
null
)
{
rc
=
new
AuthList
(
lifespan
);
rc
.
put
(
time
,
currTime
);
if
(!
rc
.
isEmpty
())
{
content
.
put
(
key
,
rc
);
}
}
else
{
if
(
DEBUG
)
{
System
.
out
.
println
(
"MemoryCache: Existing AuthList:\n"
+
rc
);
}
rc
.
put
(
time
,
currTime
);
if
(
rc
.
isEmpty
())
{
content
.
remove
(
key
);
}
}
// TODO: clean up AuthList entries with only expired AuthTimeWithHash objects.
}
public
String
toString
()
{
...
...
src/share/classes/sun/security/ssl/SSLContextImpl.java
浏览文件 @
4358c8c6
...
...
@@ -53,6 +53,11 @@ public abstract class SSLContextImpl extends SSLContextSpi {
private
X509TrustManager
trustManager
;
private
SecureRandom
secureRandom
;
private
final
static
Collection
<
CipherSuite
>
clientCustomizedCipherSuites
=
getCustomizedCipherSuites
(
"jdk.tls.client.cipherSuites"
);
private
final
static
Collection
<
CipherSuite
>
serverCustomizedCipherSuites
=
getCustomizedCipherSuites
(
"jdk.tls.server.cipherSuites"
);
SSLContextImpl
()
{
ephemeralKeyManager
=
new
EphemeralKeyManager
();
clientCache
=
new
SSLSessionContextImpl
();
...
...
@@ -279,19 +284,50 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}
/*
* Return the list of all available CipherSuites
with a priority of
*
minPriority or above
.
* Return the list of all available CipherSuites
that are supported
*
using currently installed providers
.
*/
private
static
CipherSuiteList
getApplicableCipherSuiteList
(
ProtocolList
protocols
,
boolean
onlyEnabled
)
{
private
static
CipherSuiteList
getApplicableSupportedCipherSuiteList
(
ProtocolList
protocols
)
{
return
getApplicableCipherSuiteList
(
CipherSuite
.
allowedCipherSuites
(),
protocols
,
CipherSuite
.
SUPPORTED_SUITES_PRIORITY
);
}
int
minPriority
=
CipherSuite
.
SUPPORTED_SUITES_PRIORITY
;
if
(
onlyEnabled
)
{
minPriority
=
CipherSuite
.
DEFAULT_SUITES_PRIORITY
;
/*
* Return the list of all available CipherSuites that are default enabled
* in client or server side.
*/
private
static
CipherSuiteList
getApplicableEnabledCipherSuiteList
(
ProtocolList
protocols
,
boolean
isClient
)
{
if
(
isClient
)
{
if
(!
clientCustomizedCipherSuites
.
isEmpty
())
{
return
getApplicableCipherSuiteList
(
clientCustomizedCipherSuites
,
protocols
,
CipherSuite
.
SUPPORTED_SUITES_PRIORITY
);
}
}
else
{
if
(!
serverCustomizedCipherSuites
.
isEmpty
())
{
return
getApplicableCipherSuiteList
(
serverCustomizedCipherSuites
,
protocols
,
CipherSuite
.
SUPPORTED_SUITES_PRIORITY
);
}
}
Collection
<
CipherSuite
>
allowedCipherSuites
=
CipherSuite
.
allowedCipherSuites
();
return
getApplicableCipherSuiteList
(
CipherSuite
.
allowedCipherSuites
(),
protocols
,
CipherSuite
.
DEFAULT_SUITES_PRIORITY
);
}
/*
* Return the list of available CipherSuites which are applicable to
* the specified protocols.
*/
private
static
CipherSuiteList
getApplicableCipherSuiteList
(
Collection
<
CipherSuite
>
allowedCipherSuites
,
ProtocolList
protocols
,
int
minPriority
)
{
TreeSet
<
CipherSuite
>
suites
=
new
TreeSet
<>();
if
(!(
protocols
.
collection
().
isEmpty
())
&&
...
...
@@ -328,6 +364,67 @@ public abstract class SSLContextImpl extends SSLContextSpi {
return
new
CipherSuiteList
(
suites
);
}
/*
* Get the customized cipher suites specified by the given system property.
*/
private
static
Collection
<
CipherSuite
>
getCustomizedCipherSuites
(
String
propertyName
)
{
String
property
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
propertyName
));
if
(
debug
!=
null
&&
Debug
.
isOn
(
"sslctx"
))
{
System
.
out
.
println
(
"System property "
+
propertyName
+
" is set to '"
+
property
+
"'"
);
}
if
(
property
!=
null
&&
property
.
length
()
!=
0
)
{
// remove double quote marks from beginning/end of the property
if
(
property
.
length
()
>
1
&&
property
.
charAt
(
0
)
==
'"'
&&
property
.
charAt
(
property
.
length
()
-
1
)
==
'"'
)
{
property
=
property
.
substring
(
1
,
property
.
length
()
-
1
);
}
}
if
(
property
!=
null
&&
property
.
length
()
!=
0
)
{
String
[]
cipherSuiteNames
=
property
.
split
(
","
);
Collection
<
CipherSuite
>
cipherSuites
=
new
ArrayList
<>(
cipherSuiteNames
.
length
);
for
(
int
i
=
0
;
i
<
cipherSuiteNames
.
length
;
i
++)
{
cipherSuiteNames
[
i
]
=
cipherSuiteNames
[
i
].
trim
();
if
(
cipherSuiteNames
[
i
].
isEmpty
())
{
continue
;
}
CipherSuite
suite
;
try
{
suite
=
CipherSuite
.
valueOf
(
cipherSuiteNames
[
i
]);
}
catch
(
IllegalArgumentException
iae
)
{
if
(
debug
!=
null
&&
Debug
.
isOn
(
"sslctx"
))
{
System
.
out
.
println
(
"Unknown or unsupported cipher suite name: "
+
cipherSuiteNames
[
i
]);
}
continue
;
}
if
(
suite
.
isAvailable
())
{
cipherSuites
.
add
(
suite
);
}
else
{
if
(
debug
!=
null
&&
Debug
.
isOn
(
"sslctx"
))
{
System
.
out
.
println
(
"The current installed providers do not "
+
"support cipher suite: "
+
cipherSuiteNames
[
i
]);
}
}
}
return
cipherSuites
;
}
return
Collections
.
emptyList
();
}
private
static
String
[]
getAvailableProtocols
(
ProtocolVersion
[]
protocolCandidates
)
{
...
...
@@ -422,10 +519,10 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
supportedCipherSuiteList
=
getApplicableCipherSuiteList
(
supportedProtocolList
,
false
);
// all supported
serverDefaultCipherSuiteList
=
getApplicableCipherSuiteList
(
serverDefaultProtocolList
,
true
);
// enabled only
supportedCipherSuiteList
=
getApplicable
Supported
CipherSuiteList
(
supportedProtocolList
);
serverDefaultCipherSuiteList
=
getApplicable
Enabled
CipherSuiteList
(
serverDefaultProtocolList
,
false
);
}
@Override
...
...
@@ -482,8 +579,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
clientDefaultCipherSuiteList
=
getApplicableCipherSuiteList
(
clientDefaultProtocolList
,
true
);
// enabled only
clientDefaultCipherSuiteList
=
getApplicable
Enabled
CipherSuiteList
(
clientDefaultProtocolList
,
true
);
}
@Override
...
...
@@ -522,8 +619,9 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
clientDefaultCipherSuiteList
=
getApplicableCipherSuiteList
(
clientDefaultProtocolList
,
true
);
// enabled only
clientDefaultCipherSuiteList
=
getApplicableEnabledCipherSuiteList
(
clientDefaultProtocolList
,
true
);
}
@Override
...
...
@@ -564,8 +662,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
}));
}
clientDefaultCipherSuiteList
=
getApplicableCipherSuiteList
(
clientDefaultProtocolList
,
true
);
// enabled only
clientDefaultCipherSuiteList
=
getApplicable
Enabled
CipherSuiteList
(
clientDefaultProtocolList
,
true
);
}
@Override
...
...
@@ -696,8 +794,9 @@ public abstract class SSLContextImpl extends SSLContextSpi {
clientDefaultProtocolList
=
new
ProtocolList
(
getAvailableProtocols
(
candidates
));
clientDefaultCipherSuiteList
=
getApplicableCipherSuiteList
(
clientDefaultProtocolList
,
true
);
// enabled only
clientDefaultCipherSuiteList
=
getApplicableEnabledCipherSuiteList
(
clientDefaultProtocolList
,
true
);
}
else
{
clientDefaultProtocolList
=
null
;
// unlikely to be used
clientDefaultCipherSuiteList
=
null
;
// unlikely to be used
...
...
src/share/classes/sun/security/ssl/SSLEngineImpl.java
浏览文件 @
4358c8c6
...
...
@@ -1946,13 +1946,21 @@ final public class SSLEngineImpl extends SSLEngine {
case
cs_START:
/*
* If we need to change the engine mode and the enabled
* protocols haven't specifically been set by the user,
* change them to the corresponding default ones.
* If we need to change the socket mode and the enabled
* protocols and cipher suites haven't specifically been
* set by the user, change them to the corresponding
* default ones.
*/
if
(
roleIsServer
!=
(!
flag
)
&&
sslContext
.
isDefaultProtocolList
(
enabledProtocols
))
{
enabledProtocols
=
sslContext
.
getDefaultProtocolList
(!
flag
);
if
(
roleIsServer
!=
(!
flag
))
{
if
(
sslContext
.
isDefaultProtocolList
(
enabledProtocols
))
{
enabledProtocols
=
sslContext
.
getDefaultProtocolList
(!
flag
);
}
if
(
sslContext
.
isDefaultCipherSuiteList
(
enabledCipherSuites
))
{
enabledCipherSuites
=
sslContext
.
getDefaultCipherSuiteList
(!
flag
);
}
}
roleIsServer
=
!
flag
;
...
...
src/share/classes/sun/security/ssl/SSLSocketImpl.java
浏览文件 @
4358c8c6
...
...
@@ -2417,13 +2417,22 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
case
cs_START:
/*
* If we need to change the socket mode and the enabled
* protocols haven't specifically been set by the user,
* change them to the corresponding default ones.
* protocols and cipher suites haven't specifically been
* set by the user, change them to the corresponding
* default ones.
*/
if
(
roleIsServer
!=
(!
flag
)
&&
sslContext
.
isDefaultProtocolList
(
enabledProtocols
))
{
enabledProtocols
=
sslContext
.
getDefaultProtocolList
(!
flag
);
if
(
roleIsServer
!=
(!
flag
))
{
if
(
sslContext
.
isDefaultProtocolList
(
enabledProtocols
))
{
enabledProtocols
=
sslContext
.
getDefaultProtocolList
(!
flag
);
}
if
(
sslContext
.
isDefaultCipherSuiteList
(
enabledCipherSuites
))
{
enabledCipherSuites
=
sslContext
.
getDefaultCipherSuiteList
(!
flag
);
}
}
roleIsServer
=
!
flag
;
break
;
...
...
src/windows/classes/sun/awt/windows/WToolkit.java
浏览文件 @
4358c8c6
...
...
@@ -1123,6 +1123,7 @@ public final class WToolkit extends SunToolkit implements Runnable {
}
if
((
e
instanceof
MouseEvent
)
&&
comp
.
isEnabled
()
&&
comp
.
isFocusable
()
&&
(((
comp
instanceof
TextComponent
)
&&
((
TextComponent
)
comp
).
isEditable
())
||
((
comp
instanceof
JTextComponent
)
&&
...
...
src/windows/native/sun/security/mscapi/security.cpp
浏览文件 @
4358c8c6
...
...
@@ -35,6 +35,7 @@
#include <BaseTsd.h>
#include <wincrypt.h>
#include <stdio.h>
#include <memory>
#define OID_EKU_ANY "2.5.29.37.0"
...
...
@@ -47,14 +48,27 @@
#define KEYSTORE_EXCEPTION "java/security/KeyStoreException"
#define PROVIDER_EXCEPTION "java/security/ProviderException"
#define SIGNATURE_EXCEPTION "java/security/SignatureException"
#define OUT_OF_MEMORY_ERROR "java/lang/OutOfMemoryError"
extern
"C"
{
/*
* Throws an arbitrary Java exception with the given message.
*/
void
ThrowExceptionWithMessage
(
JNIEnv
*
env
,
const
char
*
exceptionName
,
const
char
*
szMessage
)
{
jclass
exceptionClazz
=
env
->
FindClass
(
exceptionName
);
if
(
exceptionClazz
!=
NULL
)
{
env
->
ThrowNew
(
exceptionClazz
,
szMessage
);
}
}
/*
* Throws an arbitrary Java exception.
* The exception message is a Windows system error message.
*/
void
ThrowException
(
JNIEnv
*
env
,
char
*
exceptionName
,
DWORD
dwError
)
void
ThrowException
(
JNIEnv
*
env
,
c
onst
c
har
*
exceptionName
,
DWORD
dwError
)
{
char
szMessage
[
1024
];
szMessage
[
0
]
=
'\0'
;
...
...
@@ -65,12 +79,22 @@ void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError)
strcpy
(
szMessage
,
"Unknown error"
);
}
jclass
exceptionClazz
=
env
->
FindClass
(
exceptionName
);
if
(
exceptionClazz
!=
NULL
)
{
env
->
ThrowNew
(
exceptionClazz
,
szMessage
);
}
ThrowExceptionWithMessage
(
env
,
exceptionName
,
szMessage
);
}
/*
* Overloaded 'operator new[]' variant, which will raise Java's
* OutOfMemoryError in the case of a failure.
*/
void
*
operator
new
[](
std
::
size_t
size
,
JNIEnv
*
env
)
{
void
*
buf
=
::
operator
new
[](
size
,
std
::
nothrow
);
if
(
buf
==
NULL
)
{
ThrowExceptionWithMessage
(
env
,
OUT_OF_MEMORY_ERROR
,
"Native memory allocation failed"
);
}
return
buf
;
}
/*
* Maps the name of a hash algorithm to an algorithm identifier.
...
...
@@ -205,7 +229,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed
}
else
if
(
length
>
0
)
{
pbData
=
new
BYTE
[
length
];
pbData
=
new
(
env
)
BYTE
[
length
];
if
(
pbData
==
NULL
)
{
__leave
;
}
if
(
::
CryptGenRandom
(
hCryptProv
,
...
...
@@ -435,7 +462,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh
NULL
,
0
))
>
1
)
{
// Found friendly name
pszNameString
=
new
char
[
cchNameString
];
pszNameString
=
new
(
env
)
char
[
cchNameString
];
if
(
pszNameString
==
NULL
)
{
__leave
;
}
CertGetNameString
(
pc
,
CERT_NAME_FRIENDLY_DISPLAY_TYPE
,
0
,
NULL
,
pszNameString
,
cchNameString
);
...
...
@@ -572,7 +603,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
}
// Copy hash from Java to native buffer
pHashBuffer
=
new
jbyte
[
jHashSize
];
pHashBuffer
=
new
(
env
)
jbyte
[
jHashSize
];
if
(
pHashBuffer
==
NULL
)
{
__leave
;
}
env
->
GetByteArrayRegion
(
jHash
,
0
,
jHashSize
,
pHashBuffer
);
// Set hash value in the hash object
...
...
@@ -610,7 +644,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash
__leave
;
}
pSignedHashBuffer
=
new
jbyte
[
dwBufLen
];
pSignedHashBuffer
=
new
(
env
)
jbyte
[
dwBufLen
];
if
(
pSignedHashBuffer
==
NULL
)
{
__leave
;
}
if
(
::
CryptSignHash
(
hHash
,
dwKeySpec
,
NULL
,
dwFlags
,
(
BYTE
*
)
pSignedHashBuffer
,
&
dwBufLen
)
==
FALSE
)
{
ThrowException
(
env
,
SIGNATURE_EXCEPTION
,
GetLastError
());
...
...
@@ -698,9 +735,16 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas
}
// Copy hash and signedHash from Java to native buffer
pHashBuffer
=
new
jbyte
[
jHashSize
];
pHashBuffer
=
new
(
env
)
jbyte
[
jHashSize
];
if
(
pHashBuffer
==
NULL
)
{
__leave
;
}
env
->
GetByteArrayRegion
(
jHash
,
0
,
jHashSize
,
pHashBuffer
);
pSignedHashBuffer
=
new
jbyte
[
jSignedHashSize
];
pSignedHashBuffer
=
new
(
env
)
jbyte
[
jSignedHashSize
];
if
(
pSignedHashBuffer
==
NULL
)
{
__leave
;
}
env
->
GetByteArrayRegion
(
jSignedHash
,
0
,
jSignedHashSize
,
pSignedHashBuffer
);
...
...
@@ -913,7 +957,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
}
// Copy encoding from Java to native buffer
pbCertEncoding
=
new
jbyte
[
jCertEncodingSize
];
pbCertEncoding
=
new
(
env
)
jbyte
[
jCertEncodingSize
];
if
(
pbCertEncoding
==
NULL
)
{
__leave
;
}
env
->
GetByteArrayRegion
(
jCertEncoding
,
0
,
jCertEncodingSize
,
pbCertEncoding
);
// Create a certificate context from the encoded cert
...
...
@@ -926,7 +973,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
// Set the certificate's friendly name
int
size
=
env
->
GetStringLength
(
jCertAliasName
);
pszCertAliasName
=
new
WCHAR
[
size
+
1
];
pszCertAliasName
=
new
(
env
)
WCHAR
[
size
+
1
];
if
(
pszCertAliasName
==
NULL
)
{
__leave
;
}
jCertAliasChars
=
env
->
GetStringChars
(
jCertAliasName
,
NULL
);
memcpy
(
pszCertAliasName
,
jCertAliasChars
,
size
*
sizeof
(
WCHAR
));
...
...
@@ -964,7 +1014,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
__leave
;
}
pszContainerName
=
new
char
[
dwDataLen
];
pszContainerName
=
new
(
env
)
char
[
dwDataLen
];
if
(
pszContainerName
==
NULL
)
{
__leave
;
}
if
(
!
::
CryptGetProvParam
(
(
HCRYPTPROV
)
hCryptProv
,
...
...
@@ -978,7 +1031,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
}
// Convert to a wide char string
pwszContainerName
=
new
WCHAR
[
dwDataLen
];
pwszContainerName
=
new
(
env
)
WCHAR
[
dwDataLen
];
if
(
pwszContainerName
==
NULL
)
{
__leave
;
}
if
(
mbstowcs
(
pwszContainerName
,
pszContainerName
,
dwDataLen
)
==
0
)
{
ThrowException
(
env
,
KEYSTORE_EXCEPTION
,
GetLastError
());
...
...
@@ -1001,7 +1057,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
__leave
;
}
pszProviderName
=
new
char
[
dwDataLen
];
pszProviderName
=
new
(
env
)
char
[
dwDataLen
];
if
(
pszProviderName
==
NULL
)
{
__leave
;
}
if
(
!
::
CryptGetProvParam
(
(
HCRYPTPROV
)
hCryptProv
,
...
...
@@ -1015,7 +1074,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate
}
// Convert to a wide char string
pwszProviderName
=
new
WCHAR
[
dwDataLen
];
pwszProviderName
=
new
(
env
)
WCHAR
[
dwDataLen
];
if
(
pwszProviderName
==
NULL
)
{
__leave
;
}
if
(
mbstowcs
(
pwszProviderName
,
pszProviderName
,
dwDataLen
)
==
0
)
{
ThrowException
(
env
,
KEYSTORE_EXCEPTION
,
GetLastError
());
...
...
@@ -1155,7 +1217,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate
}
// Copy encoding from Java to native buffer
pbCertEncoding
=
new
jbyte
[
jCertEncodingSize
];
pbCertEncoding
=
new
(
env
)
jbyte
[
jCertEncodingSize
];
if
(
pbCertEncoding
==
NULL
)
{
__leave
;
}
env
->
GetByteArrayRegion
(
jCertEncoding
,
0
,
jCertEncodingSize
,
pbCertEncoding
);
// Create a certificate context from the encoded cert
...
...
@@ -1178,7 +1243,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate
if
((
cchNameString
=
::
CertGetNameString
(
pTBDCertContext
,
CERT_NAME_FRIENDLY_DISPLAY_TYPE
,
0
,
NULL
,
NULL
,
0
))
>
1
)
{
pszNameString
=
new
char
[
cchNameString
];
pszNameString
=
new
(
env
)
char
[
cchNameString
];
if
(
pszNameString
==
NULL
)
{
__leave
;
}
::
CertGetNameString
(
pTBDCertContext
,
CERT_NAME_FRIENDLY_DISPLAY_TYPE
,
0
,
NULL
,
pszNameString
,
...
...
@@ -1328,7 +1396,10 @@ JNIEXPORT jlong JNICALL Java_sun_security_mscapi_RSACipher_findCertificateUsingA
continue
;
// not found
}
pszNameString
=
new
char
[
cchNameString
];
pszNameString
=
new
(
env
)
char
[
cchNameString
];
if
(
pszNameString
==
NULL
)
{
__leave
;
}
if
(
::
CertGetNameString
(
pCertContext
,
CERT_NAME_FRIENDLY_DISPLAY_TYPE
,
0
,
NULL
,
pszNameString
,
...
...
@@ -1504,7 +1575,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt
__try
{
// Copy data from Java buffer to native buffer
pData
=
new
jbyte
[
dwBufLen
];
pData
=
new
(
env
)
jbyte
[
dwBufLen
];
if
(
pData
==
NULL
)
{
__leave
;
}
env
->
GetByteArrayRegion
(
jData
,
0
,
dwBufLen
,
pData
);
if
(
doEncrypt
==
JNI_TRUE
)
{
...
...
@@ -1578,7 +1652,10 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyB
__leave
;
}
pbKeyBlob
=
new
BYTE
[
dwBlobLen
];
pbKeyBlob
=
new
(
env
)
BYTE
[
dwBlobLen
];
if
(
pbKeyBlob
==
NULL
)
{
__leave
;
}
// Generate key blob
if
(
!
::
CryptExportKey
((
HCRYPTKEY
)
hCryptKey
,
0
,
PUBLICKEYBLOB
,
0
,
...
...
@@ -1632,8 +1709,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getExponent
RSAPUBKEY
*
pRsaPubKey
=
(
RSAPUBKEY
*
)
(
keyBlob
+
sizeof
(
PUBLICKEYSTRUC
));
int
len
=
sizeof
(
pRsaPubKey
->
pubexp
);
exponentBytes
=
new
jbyte
[
len
];
exponentBytes
=
new
(
env
)
jbyte
[
len
];
if
(
exponentBytes
==
NULL
)
{
__leave
;
}
// convert from little-endian while copying from blob
for
(
int
i
=
0
,
j
=
len
-
1
;
i
<
len
;
i
++
,
j
--
)
{
...
...
@@ -1684,9 +1765,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus
RSAPUBKEY
*
pRsaPubKey
=
(
RSAPUBKEY
*
)
(
keyBlob
+
sizeof
(
PUBLICKEYSTRUC
));
int
len
=
pRsaPubKey
->
bitlen
/
8
;
modulusBytes
=
new
jbyte
[
len
];
int
len
=
pRsaPubKey
->
bitlen
/
8
;
modulusBytes
=
new
(
env
)
jbyte
[
len
];
if
(
modulusBytes
==
NULL
)
{
__leave
;
}
BYTE
*
pbModulus
=
(
BYTE
*
)
(
keyBlob
+
sizeof
(
PUBLICKEYSTRUC
)
+
sizeof
(
RSAPUBKEY
));
...
...
@@ -1807,12 +1891,16 @@ jbyteArray generateKeyBlob(
(
jKeyBitLength
/
8
);
}
jbyte
*
jBlobBytes
=
new
jbyte
[
jBlobLength
]
;
jbyte
*
jBlobBytes
=
NULL
;
jbyte
*
jBlobElement
;
jbyteArray
jBlob
=
NULL
;
jsize
jElementLength
;
__try
{
jBlobBytes
=
new
(
env
)
jbyte
[
jBlobLength
];
if
(
jBlobBytes
==
NULL
)
{
__leave
;
}
BLOBHEADER
*
pBlobHeader
=
(
BLOBHEADER
*
)
jBlobBytes
;
if
(
bGeneratePrivateKeyBlob
)
{
...
...
src/windows/native/sun/windows/awt_Component.cpp
浏览文件 @
4358c8c6
...
...
@@ -1815,6 +1815,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
"new = 0x%08X"
,
GetHWnd
(),
GetClassName
(),
(
UINT
)
lParam
);
mr
=
WmInputLangChange
(
static_cast
<
UINT
>
(
wParam
),
reinterpret_cast
<
HKL
>
(
lParam
));
g_bUserHasChangedInputLang
=
TRUE
;
CallProxyDefWindowProc
(
message
,
wParam
,
lParam
,
retValue
,
mr
);
// should return non-zero if we process this message
retValue
=
1
;
...
...
src/windows/native/sun/windows/awt_ScrollPane.cpp
浏览文件 @
4358c8c6
...
...
@@ -196,15 +196,7 @@ void AwtScrollPane::SetScrollInfo(int orient, int max, int page,
// and the page size changes
posAfter
=
GetScrollPos
(
orient
);
if
(
posBefore
!=
posAfter
)
{
if
(
max
==
0
&&
posAfter
==
0
)
{
// Caller used nMin==nMax idiom to hide scrollbar.
// On the new themes (Windows XP, Vista) this would reset
// scroll position to zero ("just inside the range") (6404832).
//
PostScrollEvent
(
orient
,
SB_THUMBPOSITION
,
posBefore
);
}
else
{
PostScrollEvent
(
orient
,
SB_THUMBPOSITION
,
posAfter
);
}
PostScrollEvent
(
orient
,
SB_THUMBPOSITION
,
posAfter
);
}
}
...
...
@@ -263,8 +255,11 @@ void AwtScrollPane::RecalcSizes(int parentWidth, int parentHeight,
(
policy
==
java_awt_ScrollPane_SCROLLBARS_ALWAYS
));
env
->
DeleteLocalRef
(
hAdj
);
}
else
{
SetScrollInfo
(
SB_HORZ
,
0
,
0
,
/* Set scroll info to imitate the behaviour and since we don't
need to display it, explicitly don't show the bar */
SetScrollInfo
(
SB_HORZ
,
childWidth
-
1
,
parentWidth
,
(
policy
==
java_awt_ScrollPane_SCROLLBARS_ALWAYS
));
::
ShowScrollBar
(
GetHWnd
(),
SB_HORZ
,
false
);
}
if
(
needsVert
)
{
...
...
@@ -275,8 +270,11 @@ void AwtScrollPane::RecalcSizes(int parentWidth, int parentHeight,
(
policy
==
java_awt_ScrollPane_SCROLLBARS_ALWAYS
));
env
->
DeleteLocalRef
(
vAdj
);
}
else
{
SetScrollInfo
(
SB_VERT
,
0
,
0
,
/* Set scroll info to imitate the behaviour and since we don't
need to display it, explicitly don't show the bar */
SetScrollInfo
(
SB_VERT
,
childHeight
-
1
,
parentHeight
,
(
policy
==
java_awt_ScrollPane_SCROLLBARS_ALWAYS
));
::
ShowScrollBar
(
GetHWnd
(),
SB_VERT
,
false
);
}
env
->
DeleteLocalRef
(
target
);
...
...
src/windows/native/sun/windows/awt_Toolkit.cpp
浏览文件 @
4358c8c6
...
...
@@ -490,8 +490,7 @@ void AwtToolkit::InitTouchKeyboardExeFilePath() {
HWND
AwtToolkit
::
GetTouchKeyboardWindow
()
{
const
TCHAR
wndClassName
[]
=
_T
(
"IPTip_Main_Window"
);
HWND
hwnd
=
::
FindWindow
(
wndClassName
,
NULL
);
if
((
hwnd
!=
NULL
)
&&
::
IsWindow
(
hwnd
)
&&
::
IsWindowEnabled
(
hwnd
)
&&
::
IsWindowVisible
(
hwnd
))
{
if
((
hwnd
!=
NULL
)
&&
::
IsWindow
(
hwnd
)
&&
::
IsWindowEnabled
(
hwnd
))
{
return
hwnd
;
}
return
NULL
;
...
...
test/TEST.groups
浏览文件 @
4358c8c6
...
...
@@ -393,6 +393,7 @@ needs_jre = \
javax/management/mxbean/LeakTest.java \
javax/management/mxbean/MXBeanTest.java \
javax/management/mxbean/PropertyNamesTest.java \
javax/xml/bind/marshal/8036981/Test.java \
javax/xml/bind/marshal/8134111/UnmarshalTest.java \
javax/xml/ws/8043129 \
jdk/lambda/vm/InterfaceAccessFlagsTest.java \
...
...
test/java/awt/ScrollPane/ScrollPaneValidateTest.java
0 → 100644
浏览文件 @
4358c8c6
/*
* Copyright (c) 2018, 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 8195738
* @summary scroll position in ScrollPane is reset after calling validate()
* @run main ScrollPaneValidateTest
*/
import
java.awt.ScrollPane
;
import
java.awt.BorderLayout
;
import
java.awt.GridLayout
;
import
java.awt.Button
;
import
java.awt.Dimension
;
import
java.awt.Frame
;
import
java.awt.Panel
;
import
java.awt.Point
;
import
java.awt.Robot
;
import
java.awt.AWTException
;
public
class
ScrollPaneValidateTest
extends
Frame
{
ScrollPane
pane
;
public
ScrollPaneValidateTest
()
{
setBounds
(
300
,
300
,
300
,
300
);
pane
=
new
ScrollPane
(
ScrollPane
.
SCROLLBARS_NEVER
);
add
(
pane
,
BorderLayout
.
NORTH
);
pane
.
add
(
new
InnerPanel
());
}
public
static
void
main
(
String
[]
args
)
throws
AWTException
{
Robot
robot
=
new
Robot
();
final
ScrollPaneValidateTest
obj
=
new
ScrollPaneValidateTest
();
obj
.
setVisible
(
true
);
// set to some scroll position
obj
.
pane
.
setScrollPosition
(
600
,
200
);
// get the newly set position
Point
scrollPosition
=
obj
.
pane
.
getScrollPosition
();
// call validate multiple times
obj
.
pane
.
validate
();
robot
.
delay
(
1000
);
obj
.
pane
.
validate
();
robot
.
delay
(
1000
);
// compare position after calling the validate function
if
(!
scrollPosition
.
equals
(
obj
.
pane
.
getScrollPosition
()))
{
obj
.
dispose
();
throw
new
RuntimeException
(
"Scrolling position is changed in ScrollPane"
);
}
obj
.
dispose
();
return
;
}
class
InnerPanel
extends
Panel
{
public
InnerPanel
()
{
this
.
setLayout
(
new
GridLayout
(
2
,
4
));
for
(
int
i
=
1
;
i
<=
8
;
i
++)
{
this
.
add
(
new
Button
(
"Button"
+
i
));
}
}
public
Dimension
getPreferredSize
()
{
return
new
Dimension
(
980
,
200
);
}
}
}
test/java/awt/event/SequencedEvent/SequencedEventTest.java
0 → 100644
浏览文件 @
4358c8c6
/*
* Copyright (c) 2018, 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 8152974
* @summary AWT hang occurrs when sequenced events arrive out of sequence
* @run main SequencedEventTest
*/
import
sun.awt.AppContext
;
import
sun.awt.SunToolkit
;
import
java.awt.Robot
;
import
java.awt.Point
;
import
java.awt.Dimension
;
import
java.awt.FlowLayout
;
import
java.awt.AWTEvent
;
import
java.awt.Toolkit
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.InputEvent
;
import
java.lang.reflect.Constructor
;
import
java.util.concurrent.CountDownLatch
;
import
javax.swing.JFrame
;
import
javax.swing.JButton
;
import
javax.swing.SwingUtilities
;
import
javax.swing.JTextArea
;
public
class
SequencedEventTest
extends
JFrame
implements
ActionListener
{
private
JButton
spamMeButton
;
private
static
Robot
robot
;
private
static
SequencedEventTest
window
;
private
static
AppContext
context
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
window
=
new
SequencedEventTest
();
window
.
setVisible
(
true
);
});
robot
=
new
Robot
();
robot
.
waitForIdle
();
Point
pt
=
window
.
spamMeButton
.
getLocationOnScreen
();
Dimension
d
=
window
.
spamMeButton
.
getSize
();
robot
.
mouseMove
(
pt
.
x
+
d
.
width
/
2
,
pt
.
y
+
d
.
height
/
2
);
robot
.
waitForIdle
();
robot
.
mousePress
(
InputEvent
.
BUTTON1_DOWN_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_DOWN_MASK
);
/*
*Cannot have robot.waitForIdle() here since it will block the test forever,
* in the case of failure and the test will timeout.
*/
try
{
/*
* Wait for 2 seconds, and then see if all the sequenced events are dispatched.
*/
Thread
.
sleep
(
2000
);
AWTEvent
ev
=
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
peekEvent
(
java
.
awt
.
event
.
FocusEvent
.
FOCUS_LAST
+
1
);
if
(
ev
!=
null
)
throw
new
RuntimeException
(
"Test case failed!"
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test case failed."
+
e
.
getMessage
());
}
/*
* In the case of failure, the cleanup job cannot be executed, since it
* will block the test.
*/
System
.
out
.
println
(
"Test case succeeded."
);
context
.
dispose
();
SwingUtilities
.
invokeAndWait
(()
->
window
.
dispose
());
}
public
SequencedEventTest
()
{
super
(
"Test Window"
);
setLayout
(
new
FlowLayout
());
JTextArea
textBlock
=
new
JTextArea
(
"Lorem ipsum dolor sit amet..."
);
add
(
textBlock
);
spamMeButton
=
new
JButton
(
"Press me!"
);
spamMeButton
.
addActionListener
(
this
);
add
(
spamMeButton
);
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
pack
();
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
e
.
getSource
()
==
spamMeButton
)
{
AWTEvent
eventOne
=
getSequencedEvent
();
AWTEvent
eventFour
=
getSequencedEvent
();
ThreadGroup
tg
=
new
ThreadGroup
(
"TestThreadGroup"
);
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
Thread
t
=
new
Thread
(
tg
,
()
->
{
context
=
SunToolkit
.
createNewAppContext
();
AWTEvent
eventTwo
=
getSequencedEvent
();
AWTEvent
eventThree
=
getSequencedEvent
();
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
eventThree
);
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
new
ActionEvent
(
this
,
0
,
null
));
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
new
ActionEvent
(
this
,
1
,
null
));
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
eventTwo
);
latch
.
countDown
();
});
t
.
start
();
try
{
latch
.
await
();
}
catch
(
InterruptedException
ex
)
{
throw
new
RuntimeException
(
"Test case failed."
);
}
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
eventFour
);
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
new
ActionEvent
(
this
,
2
,
null
));
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
new
ActionEvent
(
this
,
3
,
null
));
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
eventOne
);
try
{
t
.
join
();
}
catch
(
InterruptedException
ex
)
{
throw
new
RuntimeException
(
"Test case failed."
);
}
}
}
private
AWTEvent
getSequencedEvent
()
{
AWTEvent
wrapMe
=
new
AWTEvent
(
this
,
AWTEvent
.
RESERVED_ID_MAX
)
{};
try
{
/*
* SequencedEvent is a package private class, which cannot be instantiated
* by importing. So use reflection to create an instance.
*/
Class
<?
extends
AWTEvent
>
seqClass
=
(
Class
<?
extends
AWTEvent
>)
Class
.
forName
(
"java.awt.SequencedEvent"
);
Constructor
<?
extends
AWTEvent
>
seqConst
=
seqClass
.
getConstructor
(
AWTEvent
.
class
);
seqConst
.
setAccessible
(
true
);;
return
seqConst
.
newInstance
(
wrapMe
);
}
catch
(
Throwable
err
)
{
throw
new
RuntimeException
(
"Unable to instantiate SequencedEvent"
,
err
);
}
}
}
test/java/awt/image/FilteredImageSourceTest.java
0 → 100644
浏览文件 @
4358c8c6
/*
* Copyright (c) 2017, 2018, 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 8188083
* @summary The test checks whether applying image filters using
* FilteredImageSource results in a NullPointerException.
* @run main FilteredImageSourceTest
*/
import
java.awt.Graphics
;
import
java.awt.Image
;
import
java.awt.image.ColorModel
;
import
java.awt.image.FilteredImageSource
;
import
java.awt.image.ImageConsumer
;
import
java.awt.image.ImageFilter
;
import
java.awt.image.ImageObserver
;
import
java.awt.image.ImageProducer
;
import
java.util.Hashtable
;
/*
* An empty image consumer that will be added to the list of consumers
* interested in image data for the filtered image.
*/
class
EmptyImageConsumer
implements
ImageConsumer
{
@Override
public
void
setDimensions
(
int
width
,
int
height
)
{
}
@Override
public
void
setProperties
(
Hashtable
<?,
?>
props
)
{
}
@Override
public
void
setColorModel
(
ColorModel
colorModel
)
{
}
@Override
public
void
setHints
(
int
hintFlags
)
{
}
@Override
public
void
setPixels
(
int
x
,
int
y
,
int
width
,
int
height
,
ColorModel
colorModel
,
byte
[]
pixels
,
int
offset
,
int
scanSize
)
{
}
@Override
public
void
setPixels
(
int
x
,
int
y
,
int
width
,
int
height
,
ColorModel
colorModel
,
int
[]
pixels
,
int
offset
,
int
scanSize
)
{
}
@Override
public
void
imageComplete
(
int
i
)
{
}
}
/*
* An empty image producer whose sole purpose is to provide stub methods
* that will be invoked while preparing filtered image.
*/
class
EmptyImageProducer
implements
ImageProducer
{
@Override
public
void
addConsumer
(
ImageConsumer
imageConsumer
)
{
}
@Override
public
boolean
isConsumer
(
ImageConsumer
imageConsumer
)
{
return
false
;
}
@Override
public
void
removeConsumer
(
ImageConsumer
imageConsumer
)
{
}
@Override
public
void
startProduction
(
ImageConsumer
imageConsumer
)
{
}
@Override
public
void
requestTopDownLeftRightResend
(
ImageConsumer
imageConsumer
)
{
}
}
/*
* Typically, an Image object will contain an ImageProducer that prepares
* image data. FilteredImageSource will be set as image producer for images
* that require image filter applied to image data.
*/
class
EmptyFilteredImage
extends
Image
{
ImageFilter
filter
=
null
;
ImageProducer
producer
=
null
;
public
EmptyFilteredImage
(
ImageProducer
imgSource
)
{
filter
=
new
ImageFilter
();
producer
=
new
FilteredImageSource
(
imgSource
,
filter
);
}
@Override
public
int
getWidth
(
ImageObserver
observer
)
{
return
100
;
}
@Override
public
int
getHeight
(
ImageObserver
observer
)
{
return
100
;
}
@Override
public
ImageProducer
getSource
()
{
return
producer
;
}
@Override
public
Graphics
getGraphics
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
Object
getProperty
(
String
name
,
ImageObserver
observer
)
{
return
null
;
}
}
public
final
class
FilteredImageSourceTest
{
// Minimum test duration in ms
private
static
final
int
TEST_MIN_DURATION
=
5000
;
/*
* A throwable object that will hold any exception generated while
* executing methods on FilteredImageSource. The test passes if the
* methods execute without any exception
*/
private
static
volatile
Throwable
fail
=
null
;
public
static
void
main
(
final
String
[]
args
)
throws
InterruptedException
{
final
ImageConsumer
ic
=
new
EmptyImageConsumer
();
final
ImageProducer
ip
=
new
EmptyImageProducer
();
final
Image
image
=
new
EmptyFilteredImage
(
ip
);
/*
* Simulate the framework's operations on FilteredImageSource by
* invoking the concerned methods in multiple threads and observe
* whether exceptions are generated.
*/
Thread
t1
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
image
.
getSource
().
addConsumer
(
ic
);
}
}
catch
(
Throwable
t
)
{
fail
=
t
;
}
});
t1
.
setDaemon
(
true
);
Thread
t2
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
image
.
getSource
().
removeConsumer
(
ic
);
}
}
catch
(
Throwable
t
)
{
fail
=
t
;
}
});
t2
.
setDaemon
(
true
);
Thread
t3
=
new
Thread
(()
->
{
try
{
while
(
true
)
{
image
.
getSource
().
startProduction
(
ic
);
}
}
catch
(
Throwable
t
)
{
fail
=
t
;
}
});
t3
.
setDaemon
(
true
);
// Start the threads
t1
.
start
();
t2
.
start
();
t3
.
start
();
// Wait on one of the threads for a specific duration.
t1
.
join
(
TEST_MIN_DURATION
);
if
(
fail
!=
null
)
{
throw
new
RuntimeException
(
"Test failed with exception: "
,
fail
);
}
}
}
test/java/security/Signature/SignatureLength.java
浏览文件 @
4358c8c6
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016,
2018,
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
...
...
@@ -21,48 +21,82 @@
* questions.
*/
import
java.security.*
;
/*
* @test
* @bug 8161571
* @bug 8161571
8178370
* @summary Reject signatures presented for verification that contain extra
* bytes.
* @modules jdk.crypto.ec
* @run main SignatureLength
*/
import
java.security.KeyPair
;
import
java.security.KeyPairGenerator
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.Provider
;
import
java.security.Security
;
import
java.security.Signature
;
import
java.security.SignatureException
;
public
class
SignatureLength
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
main0
(
"EC"
,
256
,
"SHA256withECDSA"
,
"SunEC"
);
main0
(
"RSA"
,
2048
,
"SHA256withRSA"
,
"SunRsaSign"
);
main0
(
"DSA"
,
2048
,
"SHA256withDSA"
,
"SUN"
);
for
(
Provider
p0
:
Security
.
getProviders
())
{
for
(
Provider
p1
:
Security
.
getProviders
())
{
for
(
Provider
p2
:
Security
.
getProviders
())
{
// SunMSCAPI signer can only be initialized with
// a key generated with SunMSCAPI
if
(!
p0
.
getName
().
equals
(
"SunMSCAPI"
)
&&
p1
.
getName
().
equals
(
"SunMSCAPI"
))
continue
;
// SunMSCAPI generated key can only be signed
// with SunMSCAPI signer
if
(
p0
.
getName
().
equals
(
"SunMSCAPI"
)
&&
!
p1
.
getName
().
equals
(
"SunMSCAPI"
))
continue
;
// SunMSCAPI and SunPKCS11 verifiers may return false
// instead of throwing SignatureException
boolean
mayNotThrow
=
p2
.
getName
().
equals
(
"SunMSCAPI"
)
||
p2
.
getName
().
startsWith
(
"SunPKCS11"
);
if
(
System
.
getProperty
(
"os.name"
).
equals
(
"SunOS"
))
{
main0
(
"EC"
,
256
,
"SHA256withECDSA"
,
null
);
main0
(
"RSA"
,
2048
,
"SHA256withRSA"
,
null
);
main0
(
"EC"
,
256
,
"SHA256withECDSA"
,
p0
,
p1
,
p2
,
mayNotThrow
);
main0
(
"RSA"
,
2048
,
"SHA256withRSA"
,
p0
,
p1
,
p2
,
mayNotThrow
);
main0
(
"DSA"
,
2048
,
"SHA256withDSA"
,
p0
,
p1
,
p2
,
mayNotThrow
);
}
}
}
}
private
static
void
main0
(
String
keyAlgorithm
,
int
keysize
,
String
signatureAlgorithm
,
String
provider
)
throws
Exception
{
String
signatureAlgorithm
,
Provider
generatorProvider
,
Provider
signerProvider
,
Provider
verifierProvider
,
boolean
mayNotThrow
)
throws
Exception
{
KeyPairGenerator
generator
;
Signature
signer
;
Signature
verifier
;
try
{
generator
=
KeyPairGenerator
.
getInstance
(
keyAlgorithm
,
generatorProvider
);
signer
=
Signature
.
getInstance
(
signatureAlgorithm
,
signerProvider
);
verifier
=
Signature
.
getInstance
(
signatureAlgorithm
,
verifierProvider
);
}
catch
(
NoSuchAlgorithmException
nsae
)
{
// ignore this set of providers
return
;
}
byte
[]
plaintext
=
"aaa"
.
getBytes
(
"UTF-8"
);
// Generate
KeyPairGenerator
generator
=
provider
==
null
?
(
KeyPairGenerator
)
KeyPairGenerator
.
getInstance
(
keyAlgorithm
)
:
(
KeyPairGenerator
)
KeyPairGenerator
.
getInstance
(
keyAlgorithm
,
provider
);
generator
.
initialize
(
keysize
);
System
.
out
.
println
(
"Generating "
+
keyAlgorithm
+
" keypair using "
+
generator
.
getProvider
().
getName
()
+
" JCE provider"
);
KeyPair
keypair
=
generator
.
generateKeyPair
();
// Sign
Signature
signer
=
provider
==
null
?
Signature
.
getInstance
(
signatureAlgorithm
)
:
Signature
.
getInstance
(
signatureAlgorithm
,
provider
);
signer
.
initSign
(
keypair
.
getPrivate
());
signer
.
update
(
plaintext
);
System
.
out
.
println
(
"Signing using "
+
signer
.
getProvider
().
getName
()
+
...
...
@@ -80,19 +114,26 @@ public class SignatureLength {
badSignature
[
signature
.
length
+
4
]
=
0x01
;
// Verify
Signature
verifier
=
provider
==
null
?
Signature
.
getInstance
(
signatureAlgorithm
)
:
Signature
.
getInstance
(
signatureAlgorithm
,
provider
);
verifier
.
initVerify
(
keypair
.
getPublic
());
verifier
.
update
(
plaintext
);
System
.
out
.
println
(
"Verifying using "
+
verifier
.
getProvider
().
getName
()
+
" JCE provider"
);
try
{
System
.
out
.
println
(
"Valid? "
+
verifier
.
verify
(
badSignature
));
throw
new
Exception
(
"ERROR: expected a SignatureException but none was thrown"
);
boolean
valid
=
verifier
.
verify
(
badSignature
);
System
.
out
.
println
(
"Valid? "
+
valid
);
if
(
mayNotThrow
)
{
if
(
valid
)
{
throw
new
Exception
(
"ERROR: expected a SignatureException but none was thrown"
+
" and invalid signature was verified"
);
}
else
{
System
.
out
.
println
(
"OK: verification failed as expected"
);
}
}
else
{
throw
new
Exception
(
"ERROR: expected a SignatureException but none was thrown"
);
}
}
catch
(
SignatureException
e
)
{
System
.
out
.
println
(
"OK: caught expected exception: "
+
e
);
}
...
...
test/sun/security/ssl/HandshakeHash/DigestBase.java
0 → 100644
浏览文件 @
4358c8c6
/*
* Copyright (c) 2018, 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.security.*
;
class
DigestBase
extends
MessageDigestSpi
{
private
MessageDigest
digest
=
null
;
public
DigestBase
(
String
alg
,
String
provider
)
throws
Exception
{
digest
=
MessageDigest
.
getInstance
(
alg
,
provider
);
}
@Override
protected
void
engineUpdate
(
byte
input
)
{
digest
.
update
(
input
);
}
@Override
protected
void
engineUpdate
(
byte
[]
input
,
int
offset
,
int
len
)
{
digest
.
update
(
input
,
offset
,
len
);
}
@Override
protected
byte
[]
engineDigest
()
{
return
digest
.
digest
();
}
@Override
protected
void
engineReset
()
{
digest
.
reset
();
}
public
static
final
class
MD5
extends
DigestBase
{
public
MD5
()
throws
Exception
{
super
(
"MD5"
,
"SUN"
);
}
}
public
static
final
class
SHA
extends
DigestBase
{
public
SHA
()
throws
Exception
{
super
(
"SHA"
,
"SUN"
);
}
}
public
static
final
class
SHA256
extends
DigestBase
{
public
SHA256
()
throws
Exception
{
super
(
"SHA-256"
,
"SUN"
);
}
}
}
test/sun/security/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java
0 → 100644
浏览文件 @
4358c8c6
/*
* Copyright (c) 2016, 2018, 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.
*/
//
// Please run in othervm mode. SunJSSE does not support dynamic system
// properties, no way to re-use system properties in samevm/agentvm mode.
//
/*
* @test
* @bug 8148421 8193683
* @summary Transport Layer Security (TLS) Session Hash and Extended
* Master Secret Extension
* @summary Increase the number of clones in the CloneableDigest
* @library /javax/net/ssl/templates
* @compile DigestBase.java
* @run main/othervm HandshakeHashCloneExhaustion
* TLSv1.2 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* @run main/othervm HandshakeHashCloneExhaustion
* TLSv1.1 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
*/
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.security.MessageDigest
;
import
java.security.Security
;
import
javax.net.ssl.SSLSocket
;
public
class
HandshakeHashCloneExhaustion
extends
SSLSocketTemplate
{
private
static
String
[]
protocol
;
private
static
String
[]
ciphersuite
;
private
static
String
[]
mds
=
{
"SHA"
,
"MD5"
,
"SHA-256"
};
/*
* ==================
* Run the test case.
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Add in a non-cloneable MD5/SHA1/SHA-256 implementation
Security
.
insertProviderAt
(
new
MyProvider
(),
1
);
// make sure our provider is functioning
for
(
String
s
:
mds
)
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
s
);
String
p
=
md
.
getProvider
().
getName
();
if
(!
p
.
equals
(
"MyProvider"
))
{
throw
new
RuntimeException
(
"Unexpected provider: "
+
p
);
}
}
if
(
args
.
length
!=
2
)
{
throw
new
Exception
(
"Usage: HandshakeHashCloneExhaustion protocol ciphersuite"
);
}
System
.
out
.
println
(
"Testing: "
+
args
[
0
]
+
" "
+
args
[
1
]);
protocol
=
new
String
[]
{
args
[
0
]
};
ciphersuite
=
new
String
[]
{
args
[
1
]
};
(
new
HandshakeHashCloneExhaustion
()).
run
();
}
@Override
protected
void
runServerApplication
(
SSLSocket
socket
)
throws
Exception
{
socket
.
setNeedClientAuth
(
true
);
socket
.
setEnabledProtocols
(
protocol
);
socket
.
setEnabledCipherSuites
(
ciphersuite
);
// here comes the test logic
InputStream
sslIS
=
socket
.
getInputStream
();
OutputStream
sslOS
=
socket
.
getOutputStream
();
sslIS
.
read
();
sslOS
.
write
(
85
);
sslOS
.
flush
();
}
@Override
protected
void
runClientApplication
(
SSLSocket
socket
)
throws
Exception
{
InputStream
sslIS
=
socket
.
getInputStream
();
OutputStream
sslOS
=
socket
.
getOutputStream
();
sslOS
.
write
(
280
);
sslOS
.
flush
();
sslIS
.
read
();
}
}
test/sun/security/ssl/HandshakeHash/MyProvider.java
0 → 100644
浏览文件 @
4358c8c6
/*
* Copyright (c) 2018, 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.security.*
;
public
final
class
MyProvider
extends
Provider
{
public
MyProvider
()
{
super
(
"MyProvider"
,
1.0d
,
"Test Provider: SHA1/MD5/SHA256 exhaustion testing"
);
put
(
"MessageDigest.SHA"
,
"DigestBase$SHA"
);
put
(
"MessageDigest.MD5"
,
"DigestBase$MD5"
);
put
(
"MessageDigest.SHA-256"
,
"DigestBase$SHA256"
);
}
}
test/sun/security/ssl/SSLContextImpl/CustomizedCipherSuites.java
0 → 100644
浏览文件 @
4358c8c6
/*
* 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.
*/
// SunJSSE does not support dynamic system properties, no way to re-use
// system properties in samevm/agentvm mode.
/*
* @test
* @bug 8162362
* @summary Cannot enable previously default enabled cipher suites
* @run main/othervm
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="unknown"
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites=""
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default true
* SSL_RSA_WITH_DES_CBC_SHA
* TLS_RSA_WITH_AES_128_CBC_SHA
* @run main/othervm
* -Djdk.tls.server.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default false
* SSL_RSA_WITH_DES_CBC_SHA
* TLS_RSA_WITH_AES_128_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default true
* SSL_RSA_WITH_DES_CBC_SHA
* ""
* @run main/othervm
* -Djdk.tls.server.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default false
* TLS_RSA_WITH_AES_128_CBC_SHA
* ""
* @run main/othervm
* -Djdk.tls.server.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default true
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
* @run main/othervm
* -Djdk.tls.client.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
* CustomizedCipherSuites Default false
* TLS_RSA_WITH_AES_128_CBC_SHA
* SSL_RSA_WITH_DES_CBC_SHA
*/
import
javax.net.ssl.*
;
/**
* Test the customized default cipher suites.
*
* This test is based on the behavior that SSL_RSA_WITH_DES_CBC_SHA is
* disabled by default, and TLS_RSA_WITH_AES_128_CBC_SHA is enabled by
* default in JDK. If the behavior is changed in the future, please
* update the test cases above accordingly.
*/
public
class
CustomizedCipherSuites
{
private
static
String
contextProtocol
;
private
static
boolean
isClientMode
;
private
static
String
enabledCipherSuite
;
private
static
String
disabledCipherSuite
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
contextProtocol
=
trimQuotes
(
args
[
0
]);
isClientMode
=
Boolean
.
parseBoolean
(
args
[
1
]);
enabledCipherSuite
=
trimQuotes
(
args
[
2
]);
disabledCipherSuite
=
trimQuotes
(
args
[
3
]);
//
// Create instance of SSLContext with the specified protocol.
//
SSLContext
context
=
SSLContext
.
getInstance
(
contextProtocol
);
// Default SSLContext is initialized automatically.
if
(!
contextProtocol
.
equals
(
"Default"
))
{
// Use default TK, KM and random.
context
.
init
((
KeyManager
[])
null
,
(
TrustManager
[])
null
,
null
);
}
// SSLContext default parameters is client mode in JDK.
if
(
isClientMode
)
{
//
// Check default parameters of the specified SSLContext protocol
//
SSLParameters
parameters
=
context
.
getDefaultSSLParameters
();
System
.
out
.
println
(
"Checking SSLContext default parameters ..."
);
checkEnabledCiphers
(
parameters
.
getCipherSuites
());
}
//
// Check supported parameters of the specified SSLContext protocol
//
SSLParameters
parameters
=
context
.
getSupportedSSLParameters
();
System
.
out
.
println
(
"Checking SSLContext suppport parameters ..."
);
checkSupportedCiphers
(
parameters
.
getCipherSuites
());
//
// Check the default cipher suites of SSLEngine.
//
SSLEngine
engine
=
context
.
createSSLEngine
();
engine
.
setUseClientMode
(
isClientMode
);
System
.
out
.
println
(
"Checking SSLEngine default cipher suites ..."
);
checkEnabledCiphers
(
engine
.
getEnabledCipherSuites
());
//
// Check the supported cipher suites of SSLEngine.
//
System
.
out
.
println
(
"Checking SSLEngine supported cipher suites ..."
);
checkSupportedCiphers
(
engine
.
getSupportedCipherSuites
());
if
(
isClientMode
)
{
SSLSocketFactory
factory
=
context
.
getSocketFactory
();
// Use an unconnected socket.
try
(
SSLSocket
socket
=
(
SSLSocket
)
factory
.
createSocket
())
{
//
// Check the default cipher suites of SSLSocket.
//
System
.
out
.
println
(
"Checking SSLSocket default cipher suites ..."
);
checkEnabledCiphers
(
socket
.
getEnabledCipherSuites
());
//
// Check the supported cipher suites of SSLSocket.
//
System
.
out
.
println
(
"Checking SSLSocket supported cipher suites ..."
);
checkSupportedCiphers
(
socket
.
getSupportedCipherSuites
());
}
}
else
{
SSLServerSocketFactory
factory
=
context
.
getServerSocketFactory
();
// Use an unbound server socket.
try
(
SSLServerSocket
socket
=
(
SSLServerSocket
)
factory
.
createServerSocket
())
{
//
// Check the default cipher suites of SSLServerSocket.
//
System
.
out
.
println
(
"Checking SSLServerSocket default cipher suites ..."
);
checkEnabledCiphers
(
socket
.
getEnabledCipherSuites
());
//
// Check the supported cipher suites of SSLServerSocket.
//
System
.
out
.
println
(
"Checking SSLServerSocket supported cipher suites ..."
);
checkSupportedCiphers
(
socket
.
getSupportedCipherSuites
());
}
}
System
.
out
.
println
(
"\t... Success"
);
}
private
static
void
checkEnabledCiphers
(
String
[]
ciphers
)
throws
Exception
{
if
(
ciphers
.
length
==
0
)
{
throw
new
Exception
(
"No default cipher suites"
);
}
boolean
isMatch
=
false
;
if
(
enabledCipherSuite
.
isEmpty
())
{
// Don't check if not specify the expected cipher suite.
isMatch
=
true
;
}
boolean
isBroken
=
false
;
for
(
String
cipher
:
ciphers
)
{
System
.
out
.
println
(
"\tdefault cipher suite "
+
cipher
);
if
(!
enabledCipherSuite
.
isEmpty
()
&&
cipher
.
equals
(
enabledCipherSuite
))
{
isMatch
=
true
;
}
if
(!
disabledCipherSuite
.
isEmpty
()
&&
cipher
.
equals
(
disabledCipherSuite
))
{
isBroken
=
true
;
}
}
if
(!
isMatch
)
{
throw
new
Exception
(
"Cipher suite "
+
enabledCipherSuite
+
" should be enabled"
);
}
if
(
isBroken
)
{
throw
new
Exception
(
"Cipher suite "
+
disabledCipherSuite
+
" should be disabled"
);
}
}
private
static
void
checkSupportedCiphers
(
String
[]
ciphers
)
throws
Exception
{
if
(
ciphers
.
length
==
0
)
{
throw
new
Exception
(
"No supported cipher suites"
);
}
boolean
hasEnabledCipherSuite
=
enabledCipherSuite
.
isEmpty
();
boolean
hasDisabledCipherSuite
=
disabledCipherSuite
.
isEmpty
();
for
(
String
cipher
:
ciphers
)
{
System
.
out
.
println
(
"\tsupported cipher suite "
+
cipher
);
if
(!
enabledCipherSuite
.
isEmpty
()
&&
cipher
.
equals
(
enabledCipherSuite
))
{
hasEnabledCipherSuite
=
true
;
}
if
(!
disabledCipherSuite
.
isEmpty
()
&&
cipher
.
equals
(
disabledCipherSuite
))
{
hasDisabledCipherSuite
=
true
;
}
}
if
(!
hasEnabledCipherSuite
)
{
throw
new
Exception
(
"Cipher suite "
+
enabledCipherSuite
+
" should be supported"
);
}
if
(!
hasDisabledCipherSuite
)
{
throw
new
Exception
(
"Cipher suite "
+
disabledCipherSuite
+
" should be supported"
);
}
}
private
static
String
trimQuotes
(
String
candidate
)
{
if
(
candidate
!=
null
&&
candidate
.
length
()
!=
0
)
{
// Remove double quote marks from beginning/end of the string.
if
(
candidate
.
length
()
>
1
&&
candidate
.
charAt
(
0
)
==
'"'
&&
candidate
.
charAt
(
candidate
.
length
()
-
1
)
==
'"'
)
{
return
candidate
.
substring
(
1
,
candidate
.
length
()
-
1
);
}
}
return
candidate
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录