Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
318eae7f
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
318eae7f
编写于
10月 11, 2016
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
30e01d68
43715ec9
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
1853 addition
and
224 deletion
+1853
-224
.hgtags
.hgtags
+1
-0
make/profile-rtjar-includes.txt
make/profile-rtjar-includes.txt
+2
-2
src/macosx/classes/sun/lwawt/macosx/CAccessibility.java
src/macosx/classes/sun/lwawt/macosx/CAccessibility.java
+15
-6
src/macosx/native/sun/awt/JavaComponentAccessibility.m
src/macosx/native/sun/awt/JavaComponentAccessibility.m
+6
-2
src/share/classes/java/nio/Bits.java
src/share/classes/java/nio/Bits.java
+3
-2
src/share/classes/java/util/ArrayList.java
src/share/classes/java/util/ArrayList.java
+2
-0
src/share/classes/sun/management/LazyCompositeData.java
src/share/classes/sun/management/LazyCompositeData.java
+56
-21
src/share/classes/sun/security/provider/ByteArrayAccess.java
src/share/classes/sun/security/provider/ByteArrayAccess.java
+2
-2
src/share/classes/sun/security/ssl/SSLSocketImpl.java
src/share/classes/sun/security/ssl/SSLSocketImpl.java
+72
-23
src/share/native/sun/awt/image/jpeg/imageioJPEG.c
src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+61
-26
src/share/native/sun/awt/medialib/awt_ImagingLib.c
src/share/native/sun/awt/medialib/awt_ImagingLib.c
+23
-1
src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c
src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c
+17
-1
src/share/native/sun/awt/medialib/safe_math.h
src/share/native/sun/awt/medialib/safe_math.h
+6
-1
src/windows/native/java/net/Inet4AddressImpl.c
src/windows/native/java/net/Inet4AddressImpl.c
+2
-0
test/ProblemList.txt
test/ProblemList.txt
+7
-0
test/com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java
test/com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java
+210
-0
test/com/sun/jndi/ldap/LdapTimeoutTest.java
test/com/sun/jndi/ldap/LdapTimeoutTest.java
+15
-38
test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java
...t/geom/AffineTransform/InvalidTransformParameterTest.java
+138
-0
test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
+335
-0
test/sun/management/LazyCompositeDataTest.java
test/sun/management/LazyCompositeDataTest.java
+163
-0
test/sun/misc/URLClassPath/ClassnameCharTest.java
test/sun/misc/URLClassPath/ClassnameCharTest.java
+54
-10
test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
...et/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
+391
-0
test/sun/security/krb5/auto/CommMatcher.java
test/sun/security/krb5/auto/CommMatcher.java
+86
-0
test/sun/security/krb5/auto/MaxRetries.java
test/sun/security/krb5/auto/MaxRetries.java
+105
-38
test/sun/security/krb5/auto/OneKDC.java
test/sun/security/krb5/auto/OneKDC.java
+2
-1
test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java
...m/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java
+79
-50
未找到文件。
.hgtags
浏览文件 @
318eae7f
...
...
@@ -660,3 +660,4 @@ d2d8b67021a0f41e0eabd711bfd87a943dc0a8d5 jdk8u112-b14
60767ec3909b3d0cb26dd7b3f952c62053719dda jdk8u112-b15
1442bc728814af451e2dd1a6719a64485d27e3a0 jdk8u122-b00
f6030acfa5aec0e64d45adfac69b9e7e5c12bc74 jdk8u122-b01
6b072c3a6db7ab06804c91aab77431799dfb5d47 jdk8u122-b02
make/profile-rtjar-includes.txt
浏览文件 @
318eae7f
#
# Copyright (c) 2012, 201
5
, 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
...
...
@@ -119,6 +119,7 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
com/sun/tracing \
jdk/management \
jdk/internal/cmm \
jdk/internal/instrumentation \
java/lang/instrument \
java/lang/management \
java/security/acl \
...
...
@@ -207,7 +208,6 @@ FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
javax/xml/bind \
javax/xml/soap \
javax/xml/ws \
jdk/internal/instrumentation \
jdk/management/resource \
org/omg \
sun/applet \
...
...
src/macosx/classes/sun/lwawt/macosx/CAccessibility.java
浏览文件 @
318eae7f
...
...
@@ -84,6 +84,15 @@ class CAccessibility implements PropertyChangeListener {
return
null
;
}
static
<
T
>
T
invokeAndWait
(
final
Callable
<
T
>
callable
,
final
Component
c
,
final
T
defValue
)
{
T
value
=
null
;
try
{
value
=
LWCToolkit
.
invokeAndWait
(
callable
,
c
);
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
}
return
value
!=
null
?
value
:
defValue
;
}
static
void
invokeLater
(
final
Runnable
runnable
,
final
Component
c
)
{
try
{
LWCToolkit
.
invokeLater
(
runnable
,
c
);
...
...
@@ -179,7 +188,7 @@ class CAccessibility implements PropertyChangeListener {
return
new
Boolean
(
as
.
isAccessibleChildSelected
(
index
));
}
},
c
);
},
c
,
false
);
}
public
static
AccessibleStateSet
getAccessibleStateSet
(
final
AccessibleContext
ac
,
final
Component
c
)
{
...
...
@@ -201,7 +210,7 @@ class CAccessibility implements PropertyChangeListener {
if
(
ass
==
null
)
return
null
;
return
ass
.
contains
(
as
);
}
},
c
);
},
c
,
false
);
}
static
Field
getAccessibleBundleKeyFieldWithReflection
()
{
...
...
@@ -267,7 +276,7 @@ class CAccessibility implements PropertyChangeListener {
public
Integer
call
()
throws
Exception
{
return
at
.
getCharCount
();
}
},
c
);
},
c
,
0
);
}
// Accessibility Threadsafety for JavaComponentAccessibility.m
...
...
@@ -292,7 +301,7 @@ class CAccessibility implements PropertyChangeListener {
if
(
ac
==
null
)
return
null
;
return
ac
.
getAccessibleIndexInParent
();
}
},
c
);
},
c
,
-
1
);
}
public
static
AccessibleComponent
getAccessibleComponent
(
final
Accessible
a
,
final
Component
c
)
{
...
...
@@ -388,7 +397,7 @@ class CAccessibility implements PropertyChangeListener {
return
aComp
.
isFocusTraversable
();
}
},
c
);
},
c
,
false
);
}
public
static
Accessible
accessibilityHitTest
(
final
Container
parent
,
final
float
hitPointX
,
final
float
hitPointY
)
{
...
...
@@ -447,7 +456,7 @@ class CAccessibility implements PropertyChangeListener {
return
aComp
.
isEnabled
();
}
},
c
);
},
c
,
false
);
}
// KCH - can we make this a postEvent instead?
...
...
src/macosx/native/sun/awt/JavaComponentAccessibility.m
浏览文件 @
318eae7f
...
...
@@ -330,11 +330,15 @@ static NSObject *sAttributeNamesLOCK = nil;
+
(
JavaComponentAccessibility
*
)
createWithAccessible
:(
jobject
)
jaccessible
withEnv
:(
JNIEnv
*
)
env
withView
:(
NSView
*
)
view
{
JavaComponentAccessibility
*
ret
=
nil
;
jobject
jcomponent
=
[(
AWTView
*
)
view
awtComponent
:
env
];
jint
index
=
JNFCallStaticIntMethod
(
env
,
sjm_getAccessibleIndexInParent
,
jaccessible
,
jcomponent
);
NSString
*
javaRole
=
getJavaRole
(
env
,
jaccessible
,
jcomponent
);
if
(
index
>=
0
)
{
NSString
*
javaRole
=
getJavaRole
(
env
,
jaccessible
,
jcomponent
);
ret
=
[
self
createWithAccessible
:
jaccessible
role
:
javaRole
index
:
index
withEnv
:
env
withView
:
view
];
}
(
*
env
)
->
DeleteLocalRef
(
env
,
jcomponent
);
return
[
self
createWithAccessible
:
jaccessible
role
:
javaRole
index
:
index
withEnv
:
env
withView
:
view
]
;
return
ret
;
}
+
(
JavaComponentAccessibility
*
)
createWithAccessible
:(
jobject
)
jaccessible
role
:(
NSString
*
)
javaRole
index
:(
jint
)
index
withEnv
:(
JNIEnv
*
)
env
withView
:(
NSView
*
)
view
...
...
src/share/classes/java/nio/Bits.java
浏览文件 @
318eae7f
/*
* Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
...
...
@@ -614,7 +614,8 @@ class Bits { // package-private
String
arch
=
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"os.arch"
));
unaligned
=
arch
.
equals
(
"i386"
)
||
arch
.
equals
(
"x86"
)
||
arch
.
equals
(
"amd64"
)
||
arch
.
equals
(
"x86_64"
);
||
arch
.
equals
(
"amd64"
)
||
arch
.
equals
(
"x86_64"
)
||
arch
.
equals
(
"ppc64"
)
||
arch
.
equals
(
"ppc64le"
);
unalignedKnown
=
true
;
return
unaligned
;
}
...
...
src/share/classes/java/util/ArrayList.java
浏览文件 @
318eae7f
...
...
@@ -842,6 +842,8 @@ public class ArrayList<E> extends AbstractList<E>
int
lastRet
=
-
1
;
// index of last element returned; -1 if no such
int
expectedModCount
=
modCount
;
Itr
()
{}
public
boolean
hasNext
()
{
return
cursor
!=
size
;
}
...
...
src/share/classes/sun/management/LazyCompositeData.java
浏览文件 @
318eae7f
...
...
@@ -27,6 +27,7 @@ package sun.management;
import
java.io.Serializable
;
import
java.util.*
;
import
javax.management.openmbean.ArrayType
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.CompositeType
;
import
javax.management.openmbean.OpenType
;
...
...
@@ -48,39 +49,48 @@ public abstract class LazyCompositeData
private
CompositeData
compositeData
;
// Implementation of the CompositeData interface
@Override
public
boolean
containsKey
(
String
key
)
{
return
compositeData
().
containsKey
(
key
);
}
@Override
public
boolean
containsValue
(
Object
value
)
{
return
compositeData
().
containsValue
(
value
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
return
compositeData
().
equals
(
obj
);
}
@Override
public
Object
get
(
String
key
)
{
return
compositeData
().
get
(
key
);
}
@Override
public
Object
[]
getAll
(
String
[]
keys
)
{
return
compositeData
().
getAll
(
keys
);
}
@Override
public
CompositeType
getCompositeType
()
{
return
compositeData
().
getCompositeType
();
}
@Override
public
int
hashCode
()
{
return
compositeData
().
hashCode
();
}
@Override
public
String
toString
()
{
/** FIXME: What should this be?? */
return
compositeData
().
toString
();
}
@Override
public
Collection
<?>
values
()
{
return
compositeData
().
values
();
}
...
...
@@ -126,27 +136,31 @@ public abstract class LazyCompositeData
if
(
cd
==
null
)
throw
new
IllegalArgumentException
(
"Null CompositeData"
);
return
((
Boolean
)
cd
.
get
(
itemName
))
.
booleanValue
()
;
return
((
Boolean
)
cd
.
get
(
itemName
));
}
static
long
getLong
(
CompositeData
cd
,
String
itemName
)
{
if
(
cd
==
null
)
throw
new
IllegalArgumentException
(
"Null CompositeData"
);
return
((
Long
)
cd
.
get
(
itemName
))
.
longValue
()
;
return
((
Long
)
cd
.
get
(
itemName
));
}
static
int
getInt
(
CompositeData
cd
,
String
itemName
)
{
if
(
cd
==
null
)
throw
new
IllegalArgumentException
(
"Null CompositeData"
);
return
((
Integer
)
cd
.
get
(
itemName
))
.
intValue
()
;
return
((
Integer
)
cd
.
get
(
itemName
));
}
/**
* Compares two CompositeTypes and returns true if
* all items in type1 exist in type2 and their item types
* are the same.
* @param type1 the base composite type
* @param type2 the checked composite type
* @return {@code true} if all items in type1 exist in type2 and their item
* types are the same.
*/
protected
static
boolean
isTypeMatched
(
CompositeType
type1
,
CompositeType
type2
)
{
if
(
type1
==
type2
)
return
true
;
...
...
@@ -159,24 +173,9 @@ public abstract class LazyCompositeData
if
(!
type2
.
keySet
().
containsAll
(
allItems
))
return
false
;
for
(
String
item:
allItems
)
{
OpenType
<?>
ot1
=
type1
.
getType
(
item
);
OpenType
<?>
ot2
=
type2
.
getType
(
item
);
if
(
ot1
instanceof
CompositeType
)
{
if
(!
(
ot2
instanceof
CompositeType
))
return
false
;
if
(!
isTypeMatched
((
CompositeType
)
ot1
,
(
CompositeType
)
ot2
))
return
false
;
}
else
if
(
ot1
instanceof
TabularType
)
{
if
(!
(
ot2
instanceof
TabularType
))
return
false
;
if
(!
isTypeMatched
((
TabularType
)
ot1
,
(
TabularType
)
ot2
))
return
false
;
}
else
if
(!
ot1
.
equals
(
ot2
))
{
return
false
;
}
}
return
true
;
return
allItems
.
stream
().
allMatch
(
item
->
isTypeMatched
(
type1
.
getType
(
item
),
type2
.
getType
(
item
))
);
}
protected
static
boolean
isTypeMatched
(
TabularType
type1
,
TabularType
type2
)
{
...
...
@@ -192,5 +191,41 @@ public abstract class LazyCompositeData
return
isTypeMatched
(
type1
.
getRowType
(),
type2
.
getRowType
());
}
protected
static
boolean
isTypeMatched
(
ArrayType
<?>
type1
,
ArrayType
<?>
type2
)
{
if
(
type1
==
type2
)
return
true
;
int
dim1
=
type1
.
getDimension
();
int
dim2
=
type2
.
getDimension
();
// check if the array dimensions are the same
if
(
dim1
!=
dim2
)
return
false
;
return
isTypeMatched
(
type1
.
getElementOpenType
(),
type2
.
getElementOpenType
());
}
private
static
boolean
isTypeMatched
(
OpenType
<?>
ot1
,
OpenType
<?>
ot2
)
{
if
(
ot1
instanceof
CompositeType
)
{
if
(!
(
ot2
instanceof
CompositeType
))
return
false
;
if
(!
isTypeMatched
((
CompositeType
)
ot1
,
(
CompositeType
)
ot2
))
return
false
;
}
else
if
(
ot1
instanceof
TabularType
)
{
if
(!
(
ot2
instanceof
TabularType
))
return
false
;
if
(!
isTypeMatched
((
TabularType
)
ot1
,
(
TabularType
)
ot2
))
return
false
;
}
else
if
(
ot1
instanceof
ArrayType
)
{
if
(!
(
ot2
instanceof
ArrayType
))
return
false
;
if
(!
isTypeMatched
((
ArrayType
<?>)
ot1
,
(
ArrayType
<?>)
ot2
))
{
return
false
;
}
}
else
if
(!
ot1
.
equals
(
ot2
))
{
return
false
;
}
return
true
;
}
private
static
final
long
serialVersionUID
=
-
2190411934472666714L
;
}
src/share/classes/sun/security/provider/ByteArrayAccess.java
浏览文件 @
318eae7f
/*
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 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
...
...
@@ -94,7 +94,7 @@ final class ByteArrayAccess {
String
arch
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"os.arch"
,
""
));
return
arch
.
equals
(
"i386"
)
||
arch
.
equals
(
"x86"
)
||
arch
.
equals
(
"amd64"
)
||
arch
.
equals
(
"x86_64"
);
||
arch
.
equals
(
"x86_64"
)
||
arch
.
equals
(
"ppc64"
)
||
arch
.
equals
(
"ppc64le"
)
;
}
/**
...
...
src/share/classes/sun/security/ssl/SSLSocketImpl.java
浏览文件 @
318eae7f
/*
* 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
...
...
@@ -220,6 +220,11 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
Collections
.<
SNIServerName
>
emptyList
();
Collection
<
SNIMatcher
>
sniMatchers
=
Collections
.<
SNIMatcher
>
emptyList
();
// Is the serverNames set to empty with SSLParameters.setServerNames()?
private
boolean
noSniExtension
=
false
;
// Is the sniMatchers set to empty with SSLParameters.setSNIMatchers()?
private
boolean
noSniMatcher
=
false
;
/*
* READ ME * READ ME * READ ME * READ ME * READ ME * READ ME *
...
...
@@ -666,6 +671,11 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
}
super
.
connect
(
endpoint
,
timeout
);
if
(
host
==
null
||
host
.
length
()
==
0
)
{
useImplicitHost
(
false
);
}
doneConnect
();
}
...
...
@@ -2158,41 +2168,61 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
output
.
r
.
setVersion
(
protocolVersion
);
}
//
// ONLY used by ClientHandshaker for the server hostname during handshaking
//
synchronized
String
getHost
()
{
// Note that the host may be null or empty for localhost.
if
(
host
==
null
||
host
.
length
()
==
0
)
{
if
(!
trustNameService
)
{
// If the local name service is not trustworthy, reverse host
// name resolution should not be performed for endpoint
// identification. Use the application original specified
// hostname or IP address instead.
host
=
getOriginalHostname
(
getInetAddress
());
}
else
{
host
=
getInetAddress
().
getHostName
();
}
useImplicitHost
(
true
);
}
return
host
;
}
/*
*
Get the original application specified hostname.
*
Try to set and use the implicit specified hostname
*/
private
static
String
getOriginalHostname
(
InetAddress
inetAddress
)
{
/*
* Get the original hostname via sun.misc.SharedSecrets.
*/
private
synchronized
void
useImplicitHost
(
boolean
noSniUpdate
)
{
// Note: If the local name service is not trustworthy, reverse
// host name resolution should not be performed for endpoint
// identification. Use the application original specified
// hostname or IP address instead.
// Get the original hostname via jdk.internal.misc.SharedSecrets
InetAddress
inetAddress
=
getInetAddress
();
if
(
inetAddress
==
null
)
{
// not connected
return
;
}
JavaNetAccess
jna
=
SharedSecrets
.
getJavaNetAccess
();
String
originalHostname
=
jna
.
getOriginalHostName
(
inetAddress
);
if
((
originalHostname
!=
null
)
&&
(
originalHostname
.
length
()
!=
0
))
{
/*
* If no application specified hostname, use the IP address.
*/
if
(
originalHostname
==
null
||
originalHostname
.
length
()
==
0
)
{
originalHostname
=
inetAddress
.
getHostAddress
();
host
=
originalHostname
;
if
(!
noSniUpdate
&&
serverNames
.
isEmpty
()
&&
!
noSniExtension
)
{
serverNames
=
Utilities
.
addToSNIServerNameList
(
serverNames
,
host
);
if
(!
roleIsServer
&&
(
handshaker
!=
null
)
&&
!
handshaker
.
started
())
{
handshaker
.
setSNIServerNames
(
serverNames
);
}
}
return
;
}
return
originalHostname
;
// No explicitly specified hostname, no server name indication.
if
(!
trustNameService
)
{
// The local name service is not trustworthy, use IP address.
host
=
inetAddress
.
getHostAddress
();
}
else
{
// Use the underlying reverse host name resolution service.
host
=
getInetAddress
().
getHostName
();
}
}
...
...
@@ -2205,6 +2235,10 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
this
.
host
=
host
;
this
.
serverNames
=
Utilities
.
addToSNIServerNameList
(
this
.
serverNames
,
this
.
host
);
if
(!
roleIsServer
&&
(
handshaker
!=
null
)
&&
!
handshaker
.
started
())
{
handshaker
.
setSNIServerNames
(
serverNames
);
}
}
/**
...
...
@@ -2571,8 +2605,21 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
// the super implementation does not handle the following parameters
params
.
setEndpointIdentificationAlgorithm
(
identificationProtocol
);
params
.
setAlgorithmConstraints
(
algorithmConstraints
);
params
.
setSNIMatchers
(
sniMatchers
);
params
.
setServerNames
(
serverNames
);
if
(
sniMatchers
.
isEmpty
()
&&
!
noSniMatcher
)
{
// 'null' indicates none has been set
params
.
setSNIMatchers
(
null
);
}
else
{
params
.
setSNIMatchers
(
sniMatchers
);
}
if
(
serverNames
.
isEmpty
()
&&
!
noSniExtension
)
{
// 'null' indicates none has been set
params
.
setServerNames
(
null
);
}
else
{
params
.
setServerNames
(
serverNames
);
}
params
.
setUseCipherSuitesOrder
(
preferLocalCipherSuites
);
return
params
;
...
...
@@ -2592,11 +2639,13 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
List
<
SNIServerName
>
sniNames
=
params
.
getServerNames
();
if
(
sniNames
!=
null
)
{
noSniExtension
=
sniNames
.
isEmpty
();
serverNames
=
sniNames
;
}
Collection
<
SNIMatcher
>
matchers
=
params
.
getSNIMatchers
();
if
(
matchers
!=
null
)
{
noSniMatcher
=
matchers
.
isEmpty
();
sniMatchers
=
matchers
;
}
...
...
src/share/native/sun/awt/image/jpeg/imageioJPEG.c
浏览文件 @
318eae7f
/*
* Copyright (c) 2000, 201
4
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
...
...
@@ -553,30 +553,43 @@ sun_jpeg_error_exit (j_common_ptr cinfo)
METHODDEF
(
void
)
sun_jpeg_output_message
(
j_common_ptr
cinfo
)
{
char
buffer
[
JMSG_LENGTH_MAX
];
jstring
string
;
imageIODataPtr
data
=
(
imageIODataPtr
)
cinfo
->
client_data
;
JNIEnv
*
env
=
(
JNIEnv
*
)
JNU_GetEnv
(
jvm
,
JNI_VERSION_1_2
);
jobject
theObject
;
/* Create the message */
(
*
cinfo
->
err
->
format_message
)
(
cinfo
,
buffer
);
// Create a new java string from the message
string
=
(
*
env
)
->
NewStringUTF
(
env
,
buffer
);
CHECK_NULL
(
string
);
theObject
=
data
->
imageIOobj
;
if
(
cinfo
->
is_decompressor
)
{
(
*
env
)
->
CallVoidMethod
(
env
,
theObject
,
JPEGImageReader_warningWithMessageID
,
string
);
}
else
{
(
*
env
)
->
CallVoidMethod
(
env
,
theObject
,
JPEGImageWriter_warningWithMessageID
,
string
);
}
char
buffer
[
JMSG_LENGTH_MAX
];
jstring
string
;
imageIODataPtr
data
=
(
imageIODataPtr
)
cinfo
->
client_data
;
JNIEnv
*
env
=
(
JNIEnv
*
)
JNU_GetEnv
(
jvm
,
JNI_VERSION_1_2
);
jobject
theObject
;
/* Create the message */
(
*
cinfo
->
err
->
format_message
)
(
cinfo
,
buffer
);
// Create a new java string from the message
string
=
(
*
env
)
->
NewStringUTF
(
env
,
buffer
);
CHECK_NULL
(
string
);
theObject
=
data
->
imageIOobj
;
if
(
cinfo
->
is_decompressor
)
{
struct
jpeg_source_mgr
*
src
=
((
j_decompress_ptr
)
cinfo
)
->
src
;
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
(
*
env
)
->
CallVoidMethod
(
env
,
theObject
,
JPEGImageReader_warningWithMessageID
,
string
);
if
((
*
env
)
->
ExceptionOccurred
(
env
)
||
!
GET_ARRAYS
(
env
,
data
,
&
(
src
->
next_input_byte
)))
{
cinfo
->
err
->
error_exit
(
cinfo
);
}
}
else
{
struct
jpeg_destination_mgr
*
dest
=
((
j_compress_ptr
)
cinfo
)
->
dest
;
RELEASE_ARRAYS
(
env
,
data
,
(
const
JOCTET
*
)(
dest
->
next_output_byte
));
(
*
env
)
->
CallVoidMethod
(
env
,
theObject
,
JPEGImageWriter_warningWithMessageID
,
string
);
if
((
*
env
)
->
ExceptionOccurred
(
env
)
||
!
GET_ARRAYS
(
env
,
data
,
(
const
JOCTET
**
)(
&
dest
->
next_output_byte
)))
{
cinfo
->
err
->
error_exit
(
cinfo
);
}
}
}
/* End of verbatim copy from jpegdecoder.c */
...
...
@@ -1043,6 +1056,7 @@ imageio_fill_suspended_buffer(j_decompress_ptr cinfo)
if
(
!
GET_ARRAYS
(
env
,
data
,
&
(
src
->
next_input_byte
)))
{
cinfo
->
err
->
error_exit
((
j_common_ptr
)
cinfo
);
}
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
return
;
}
...
...
@@ -1798,9 +1812,14 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
cinfo
->
out_color_space
,
cinfo
->
num_components
,
profileData
);
if
((
*
env
)
->
ExceptionOccurred
(
env
)
||
!
GET_ARRAYS
(
env
,
data
,
&
(
src
->
next_input_byte
)))
{
cinfo
->
err
->
error_exit
((
j_common_ptr
)
cinfo
);
}
if
(
reset
)
{
jpeg_abort_decompress
(
cinfo
);
}
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
}
return
retval
;
...
...
@@ -2011,6 +2030,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
jpeg_start_decompress
(
cinfo
);
if
(
numBands
!=
cinfo
->
output_components
)
{
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
JNU_ThrowByName
(
env
,
"javax/imageio/IIOException"
,
"Invalid argument to native readImage"
);
return
data
->
abortFlag
;
...
...
@@ -2019,6 +2039,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
if
(
cinfo
->
output_components
<=
0
||
cinfo
->
image_width
>
(
0xffffffffu
/
(
unsigned
int
)
cinfo
->
output_components
))
{
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
JNU_ThrowByName
(
env
,
"javax/imageio/IIOException"
,
"Invalid number of output components"
);
return
data
->
abortFlag
;
...
...
@@ -2042,15 +2063,24 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
// the first interesting pass.
jpeg_start_output
(
cinfo
,
cinfo
->
input_scan_number
);
if
(
wantUpdates
)
{
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
(
*
env
)
->
CallVoidMethod
(
env
,
this
,
JPEGImageReader_passStartedID
,
cinfo
->
input_scan_number
-
1
);
if
((
*
env
)
->
ExceptionOccurred
(
env
)
||
!
GET_ARRAYS
(
env
,
data
,
&
(
src
->
next_input_byte
)))
{
cinfo
->
err
->
error_exit
((
j_common_ptr
)
cinfo
);
}
}
}
else
if
(
wantUpdates
)
{
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
(
*
env
)
->
CallVoidMethod
(
env
,
this
,
JPEGImageReader_passStartedID
,
0
);
if
((
*
env
)
->
ExceptionOccurred
(
env
)
||
!
GET_ARRAYS
(
env
,
data
,
&
(
src
->
next_input_byte
)))
{
cinfo
->
err
->
error_exit
((
j_common_ptr
)
cinfo
);
}
}
// Skip until the first interesting line
...
...
@@ -2138,8 +2168,13 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
done
=
TRUE
;
}
if
(
wantUpdates
)
{
RELEASE_ARRAYS
(
env
,
data
,
src
->
next_input_byte
);
(
*
env
)
->
CallVoidMethod
(
env
,
this
,
JPEGImageReader_passCompleteID
);
if
((
*
env
)
->
ExceptionOccurred
(
env
)
||
!
GET_ARRAYS
(
env
,
data
,
&
(
src
->
next_input_byte
)))
{
cinfo
->
err
->
error_exit
((
j_common_ptr
)
cinfo
);
}
}
}
...
...
src/share/native/sun/awt/medialib/awt_ImagingLib.c
浏览文件 @
318eae7f
/*
* Copyright (c) 1997, 201
4
, 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
...
...
@@ -772,6 +772,7 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this,
mlib_image
*
src
;
mlib_image
*
dst
;
int
i
;
int
j
=
0
;
int
retStatus
=
1
;
mlib_status
status
;
double
*
matrix
;
...
...
@@ -824,6 +825,15 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this,
return
0
;
}
/* Check for invalid double value in transformation matrix */
for
(
j
=
0
;
j
<
6
;
j
++
)
{
if
(
!
(
IS_FINITE
(
matrix
[
j
])))
{
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
jmatrix
,
matrix
,
JNI_ABORT
);
return
0
;
}
}
if
(
s_printIt
)
{
printf
(
"matrix is %g %g %g %g %g %g
\n
"
,
matrix
[
0
],
matrix
[
1
],
matrix
[
2
],
matrix
[
3
],
matrix
[
4
],
matrix
[
5
]);
...
...
@@ -980,6 +990,7 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this,
mlib_image
*
src
;
mlib_image
*
dst
;
int
i
;
int
j
=
0
;
int
retStatus
=
1
;
mlib_status
status
;
double
*
matrix
;
...
...
@@ -1044,6 +1055,17 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this,
return
0
;
}
/* Check for invalid double value in transformation matrix */
for
(
j
=
0
;
j
<
6
;
j
++
)
{
if
(
!
(
IS_FINITE
(
matrix
[
j
])))
{
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
jmatrix
,
matrix
,
JNI_ABORT
);
free
(
srcRasterP
);
free
(
dstRasterP
);
return
0
;
}
}
if
(
s_printIt
)
{
printf
(
"matrix is %g %g %g %g %g %g
\n
"
,
matrix
[
0
],
matrix
[
1
],
matrix
[
2
],
matrix
[
3
],
matrix
[
4
],
matrix
[
5
]);
...
...
src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c
浏览文件 @
318eae7f
/*
* Copyright (c) 1997, 20
03
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 20
16
, 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
...
...
@@ -33,6 +33,8 @@
#include "mlib_image.h"
#include "mlib_SysMath.h"
#include "mlib_ImageAffine.h"
#include "safe_math.h"
/***************************************************************/
mlib_status
mlib_AffineEdges
(
mlib_affine_param
*
param
,
...
...
@@ -83,6 +85,12 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param,
dstYStride
=
mlib_ImageGetStride
(
dst
);
paddings
=
mlib_ImageGetPaddings
(
src
);
/* All the transformation matrix parameters should be finite. if not, return failure */
if
(
!
(
IS_FINITE
(
a
)
&&
IS_FINITE
(
b
)
&&
IS_FINITE
(
c
)
&&
IS_FINITE
(
d
)
&&
IS_FINITE
(
tx
)
&&
IS_FINITE
(
ty
)))
{
return
MLIB_FAILURE
;
}
if
(
srcWidth
>=
(
1
<<
15
)
||
srcHeight
>=
(
1
<<
15
))
{
return
MLIB_FAILURE
;
}
...
...
@@ -288,6 +296,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param,
if
(
dY1
==
dY2
)
continue
;
if
(
!
(
IS_FINITE
(
slope
)))
{
continue
;
}
if
(
dY1
<
0
.
0
)
y1
=
0
;
else
{
...
...
@@ -328,6 +340,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param,
if
(
dY1
==
dY2
)
continue
;
if
(
!
(
IS_FINITE
(
slope
)))
{
continue
;
}
if
(
dY1
<
0
.
0
)
y1
=
0
;
else
{
...
...
src/share/native/sun/awt/medialib/safe_math.h
浏览文件 @
318eae7f
/*
* Copyright (c) 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 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
...
...
@@ -26,10 +26,15 @@
#ifndef __SAFE_MATH_H__
#define __SAFE_MATH_H__
#include "mlib_types.h"
#define SAFE_TO_MULT(a, b) \
(((a) > 0) && ((b) >= 0) && ((0x7fffffff / (a)) > (b)))
#define SAFE_TO_ADD(a, b) \
(((a) >= 0) && ((b) >= 0) && ((0x7fffffff - (a)) > (b)))
#define IS_FINITE(a) \
(((a) >= MLIB_D64_MIN) && ((a) <= MLIB_D64_MAX))
#endif // __SAFE_MATH_H__
src/windows/native/java/net/Inet4AddressImpl.c
浏览文件 @
318eae7f
...
...
@@ -538,6 +538,8 @@ ping4(JNIEnv *env,
case
ERROR_REQUEST_ABORTED
:
case
ERROR_INCORRECT_ADDRESS
:
case
ERROR_HOST_DOWN
:
case
ERROR_INVALID_COMPUTERNAME
:
case
ERROR_INVALID_NETNAME
:
case
WSAEHOSTUNREACH
:
/* Host Unreachable */
case
WSAENETUNREACH
:
/* Network Unreachable */
case
WSAENETDOWN
:
/* Network is down */
...
...
test/ProblemList.txt
浏览文件 @
318eae7f
...
...
@@ -289,3 +289,10 @@ sun/tools/jcmd/TestJcmdSanity.java windows-all
sun/tools/jps/TestJpsJarRelative.java generic-all
############################################################################
# jdk_other
############################################################################
# 8141370
com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java linux-i586,macosx-all
test/com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java
0 → 100644
浏览文件 @
318eae7f
/*
* Copyright (c) 2011, 2014, 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
* @run main/othervm DeadSSLLdapTimeoutTest
* @bug 8141370
* @key intermittent
*/
import
java.net.Socket
;
import
java.net.ServerSocket
;
import
java.net.SocketTimeoutException
;
import
java.io.*
;
import
javax.naming.*
;
import
javax.naming.directory.*
;
import
java.util.List
;
import
java.util.Hashtable
;
import
java.util.ArrayList
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.TimeUnit
;
import
javax.net.ssl.SSLHandshakeException
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
MILLISECONDS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
NANOSECONDS
;
class
DeadServerTimeoutSSLTest
implements
Callable
{
Hashtable
env
;
DeadSSLServer
server
;
boolean
passed
=
false
;
private
int
HANGING_TEST_TIMEOUT
=
20_000
;
public
DeadServerTimeoutSSLTest
(
Hashtable
env
)
throws
IOException
{
this
.
server
=
new
DeadSSLServer
();
this
.
env
=
env
;
}
public
void
performOp
(
InitialContext
ctx
)
throws
NamingException
{}
public
void
handleNamingException
(
NamingException
e
,
long
start
,
long
end
)
{
if
(
e
.
getCause
()
instanceof
SocketTimeoutException
)
{
// SSL connect will timeout via readReply using
// SocketTimeoutException
e
.
printStackTrace
();
pass
();
}
else
if
(
e
.
getCause
()
instanceof
SSLHandshakeException
&&
e
.
getCause
().
getCause
()
instanceof
EOFException
)
{
// test seems to be failing intermittently on some
// platforms.
pass
();
}
else
{
fail
(
e
);
}
}
public
void
pass
()
{
this
.
passed
=
true
;
}
public
void
fail
()
{
throw
new
RuntimeException
(
"Test failed"
);
}
public
void
fail
(
Exception
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
boolean
shutItDown
(
InitialContext
ctx
)
{
try
{
if
(
ctx
!=
null
)
ctx
.
close
();
return
true
;
}
catch
(
NamingException
ex
)
{
return
false
;
}
}
public
Boolean
call
()
{
InitialContext
ctx
=
null
;
ScheduledFuture
killer
=
null
;
long
start
=
System
.
nanoTime
();
try
{
while
(!
server
.
accepting
())
Thread
.
sleep
(
200
);
// allow the server to start up
Thread
.
sleep
(
200
);
// to be sure
env
.
put
(
Context
.
PROVIDER_URL
,
"ldap://localhost:"
+
server
.
getLocalPort
());
try
{
ctx
=
new
InitialDirContext
(
env
);
performOp
(
ctx
);
fail
();
}
catch
(
NamingException
e
)
{
long
end
=
System
.
nanoTime
();
System
.
out
.
println
(
this
.
getClass
().
toString
()
+
" - elapsed: "
+
NANOSECONDS
.
toMillis
(
end
-
start
));
handleNamingException
(
e
,
start
,
end
);
}
finally
{
if
(
killer
!=
null
&&
!
killer
.
isDone
())
killer
.
cancel
(
true
);
shutItDown
(
ctx
);
server
.
close
();
}
return
passed
;
}
catch
(
IOException
|
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
class
DeadSSLServer
extends
Thread
{
ServerSocket
serverSock
;
boolean
accepting
=
false
;
public
DeadSSLServer
()
throws
IOException
{
this
.
serverSock
=
new
ServerSocket
(
0
);
start
();
}
public
void
run
()
{
while
(
true
)
{
try
{
accepting
=
true
;
Socket
socket
=
serverSock
.
accept
();
}
catch
(
Exception
e
)
{
break
;
}
}
}
public
int
getLocalPort
()
{
return
serverSock
.
getLocalPort
();
}
public
boolean
accepting
()
{
return
accepting
;
}
public
void
close
()
throws
IOException
{
serverSock
.
close
();
}
}
public
class
DeadSSLLdapTimeoutTest
{
static
Hashtable
createEnv
()
{
Hashtable
env
=
new
Hashtable
(
11
);
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
return
env
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
InitialContext
ctx
=
null
;
//
// Running this test serially as it seems to tickle a problem
// on older kernels
//
// run the DeadServerTest with connect / read timeouts set
// and ssl enabled
// this should exit with a SocketTimeoutException as the root cause
// it should also use the connect timeout instead of the read timeout
System
.
out
.
println
(
"Running connect timeout test with 10ms connect timeout, 3000ms read timeout & SSL"
);
Hashtable
sslenv
=
createEnv
();
sslenv
.
put
(
"com.sun.jndi.ldap.connect.timeout"
,
"10"
);
sslenv
.
put
(
"com.sun.jndi.ldap.read.timeout"
,
"3000"
);
sslenv
.
put
(
Context
.
SECURITY_PROTOCOL
,
"ssl"
);
boolean
testFailed
=
(
new
DeadServerTimeoutSSLTest
(
sslenv
).
call
())
?
false
:
true
;
if
(
testFailed
)
{
throw
new
AssertionError
(
"some tests failed"
);
}
}
}
test/com/sun/jndi/ldap/LdapTimeoutTest.java
浏览文件 @
318eae7f
...
...
@@ -46,6 +46,7 @@ import java.util.concurrent.ScheduledExecutorService;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.TimeUnit
;
import
javax.net.ssl.SSLHandshakeException
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
MILLISECONDS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
NANOSECONDS
;
...
...
@@ -83,6 +84,10 @@ abstract class LdapTest implements Callable {
throw
new
RuntimeException
(
"Test failed"
);
}
public
void
fail
(
Exception
e
)
{
throw
new
RuntimeException
(
"Test failed"
,
e
);
}
boolean
shutItDown
(
InitialContext
ctx
)
{
try
{
if
(
ctx
!=
null
)
ctx
.
close
();
...
...
@@ -219,23 +224,6 @@ class DeadServerTimeoutTest extends DeadServerTest {
}
}
class
DeadServerTimeoutSSLTest
extends
DeadServerTest
{
public
DeadServerTimeoutSSLTest
(
Hashtable
env
)
throws
IOException
{
super
(
env
);
}
public
void
handleNamingException
(
NamingException
e
,
long
start
,
long
end
)
{
if
(
e
.
getCause
()
instanceof
SocketTimeoutException
)
{
// SSL connect will timeout via readReply using
// SocketTimeoutException
pass
();
}
else
{
fail
();
}
}
}
class
ReadServerNoTimeoutTest
extends
ReadServerTest
{
...
...
@@ -268,7 +256,8 @@ class ReadServerTimeoutTest extends ReadServerTest {
}
public
void
handleNamingException
(
NamingException
e
,
long
start
,
long
end
)
{
if
(
NANOSECONDS
.
toMillis
(
end
-
start
)
<
2_900
)
{
System
.
out
.
println
(
"ReadServerTimeoutTest: end-start="
+
NANOSECONDS
.
toMillis
(
end
-
start
));
if
(
NANOSECONDS
.
toMillis
(
end
-
start
)
<
2_500
)
{
fail
();
}
else
{
pass
();
...
...
@@ -406,11 +395,14 @@ public class LdapTimeoutTest {
// run the ReadServerTest with connect / read timeouts set
// this should exit after the connect timeout expires
System
.
out
.
println
(
"Running read timeout test with 10ms connect timeout, 3000ms read timeout"
);
Hashtable
env4
=
createEnv
();
env4
.
put
(
"com.sun.jndi.ldap.connect.timeout"
,
"10"
);
env4
.
put
(
"com.sun.jndi.ldap.read.timeout"
,
"3000"
);
results
.
add
(
testPool
.
submit
(
new
ReadServerTimeoutTest
(
env4
)));
//
// NOTE: commenting this test out as it is failing intermittently.
//
// System.out.println("Running read timeout test with 10ms connect timeout, 3000ms read timeout");
// Hashtable env4 = createEnv();
// env4.put("com.sun.jndi.ldap.connect.timeout", "10");
// env4.put("com.sun.jndi.ldap.read.timeout", "3000");
// results.add(testPool.submit(new ReadServerTimeoutTest(env4)));
// run the DeadServerTest with connect timeout set
// this should exit after the connect timeout expires
...
...
@@ -438,21 +430,6 @@ public class LdapTimeoutTest {
}
}
//
// Running this test serially as it seems to tickle a problem
// on older kernels
//
// run the DeadServerTest with connect / read timeouts set
// and ssl enabled
// this should exit with a SocketTimeoutException as the root cause
// it should also use the connect timeout instead of the read timeout
System
.
out
.
println
(
"Running connect timeout test with 10ms connect timeout, 3000ms read timeout & SSL"
);
Hashtable
sslenv
=
createEnv
();
sslenv
.
put
(
"com.sun.jndi.ldap.connect.timeout"
,
"10"
);
sslenv
.
put
(
"com.sun.jndi.ldap.read.timeout"
,
"3000"
);
sslenv
.
put
(
Context
.
SECURITY_PROTOCOL
,
"ssl"
);
testFailed
=
(
new
DeadServerTimeoutSSLTest
(
sslenv
).
call
())
?
false
:
true
;
if
(
testFailed
)
{
throw
new
AssertionError
(
"some tests failed"
);
}
...
...
test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java
0 → 100644
浏览文件 @
318eae7f
/*
* 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 8158356
* @summary Test AffineTransform transformations do not result in SIGSEGV
* if NaN or infinity parameter is passed as argument.
* @run main InvalidTransformParameterTest
*/
import
java.awt.geom.AffineTransform
;
import
java.awt.image.AffineTransformOp
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ImagingOpException
;
import
java.awt.Point
;
import
java.awt.image.DataBuffer
;
import
java.awt.image.DataBufferByte
;
import
java.awt.image.PixelInterleavedSampleModel
;
import
java.awt.image.Raster
;
import
java.awt.image.WritableRaster
;
import
java.awt.image.RasterOp
;
import
java.awt.image.SampleModel
;
public
class
InvalidTransformParameterTest
{
public
static
void
main
(
String
[]
args
)
{
int
count
=
0
;
final
int
testScenarios
=
12
;
double
NaNArg
=
0.0
/
0.0
;
double
positiveInfArg
=
1.0
/
0.0
;
double
negativeInfArg
=
-
1.0
/
0.0
;
BufferedImage
img
=
new
BufferedImage
(
5
,
5
,
BufferedImage
.
TYPE_INT_ARGB
);
AffineTransform
[]
inputTransforms
=
new
AffineTransform
[
testScenarios
];
for
(
int
i
=
0
;
i
<
inputTransforms
.
length
;
i
++)
{
inputTransforms
[
i
]
=
new
AffineTransform
();
}
inputTransforms
[
0
].
rotate
(
NaNArg
,
img
.
getWidth
()/
2
,
img
.
getHeight
()/
2
);
inputTransforms
[
1
].
translate
(
NaNArg
,
NaNArg
);
inputTransforms
[
2
].
scale
(
NaNArg
,
NaNArg
);
inputTransforms
[
3
].
shear
(
NaNArg
,
NaNArg
);
inputTransforms
[
4
].
rotate
(
positiveInfArg
,
img
.
getWidth
()/
2
,
img
.
getHeight
()/
2
);
inputTransforms
[
5
].
translate
(
positiveInfArg
,
positiveInfArg
);
inputTransforms
[
6
].
scale
(
positiveInfArg
,
positiveInfArg
);
inputTransforms
[
7
].
shear
(
positiveInfArg
,
positiveInfArg
);
inputTransforms
[
8
].
rotate
(
negativeInfArg
,
img
.
getWidth
()/
2
,
img
.
getHeight
()/
2
);
inputTransforms
[
9
].
translate
(
negativeInfArg
,
negativeInfArg
);
inputTransforms
[
10
].
scale
(
negativeInfArg
,
negativeInfArg
);
inputTransforms
[
11
].
shear
(
negativeInfArg
,
negativeInfArg
);
// Test BufferedImage AffineTransform ---------------------------------
for
(
int
i
=
0
;
i
<
inputTransforms
.
length
;
i
++)
{
try
{
testImageTransform
(
img
,
inputTransforms
[
i
]);
}
catch
(
ImagingOpException
ex
)
{
count
++;
}
}
if
(
count
!=
testScenarios
)
{
throw
new
RuntimeException
(
"Test failed. All test scenarios did not"
+
" result in exception as expected."
);
}
// Test Raster AffineTransform ---------------------------------
count
=
0
;
int
[]
bandOffsets
=
{
0
};
Point
location
=
new
Point
(
0
,
0
);
DataBuffer
db
=
new
DataBufferByte
(
10
*
10
);
SampleModel
sm
=
new
PixelInterleavedSampleModel
(
DataBuffer
.
TYPE_BYTE
,
10
,
10
,
1
,
10
,
bandOffsets
);
Raster
src
=
Raster
.
createRaster
(
sm
,
db
,
location
);
WritableRaster
dst
=
Raster
.
createWritableRaster
(
sm
,
db
,
location
);
for
(
int
i
=
0
;
i
<
inputTransforms
.
length
;
i
++)
{
try
{
testRasterTransform
(
src
,
dst
,
inputTransforms
[
i
]);
}
catch
(
ImagingOpException
ex
)
{
count
++;
}
}
if
(
count
!=
testScenarios
)
{
throw
new
RuntimeException
(
"Test failed. All test scenarios did not"
+
" result in exception as expected."
);
}
}
public
static
BufferedImage
testImageTransform
(
BufferedImage
image
,
AffineTransform
transform
)
{
AffineTransformOp
op
=
new
AffineTransformOp
(
transform
,
AffineTransformOp
.
TYPE_BILINEAR
);
BufferedImage
transformedImage
=
new
BufferedImage
(
image
.
getWidth
(),
image
.
getHeight
(),
image
.
getType
());
return
op
.
filter
(
image
,
transformedImage
);
}
public
static
Raster
testRasterTransform
(
Raster
src
,
WritableRaster
dst
,
AffineTransform
transform
)
{
AffineTransformOp
op
=
new
AffineTransformOp
(
transform
,
AffineTransformOp
.
TYPE_BILINEAR
);
return
op
.
filter
(
src
,
dst
);
}
}
test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java
0 → 100644
浏览文件 @
318eae7f
/*
* 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 8144566
* @summary Custom HostnameVerifier disables SNI extension
* @run main/othervm BestEffortOnLazyConnected
*/
import
java.io.*
;
import
java.net.*
;
import
javax.net.ssl.*
;
public
class
BestEffortOnLazyConnected
{
/*
* =============================================================
* Set the various variables needed for the tests, then
* specify what tests to run on each side.
*/
/*
* Should we run the client or server in a separate thread?
* Both sides can throw exceptions, but do you have a preference
* as to which side should be the main thread.
*/
private
static
final
boolean
separateServerThread
=
true
;
/*
* Where do we find the keystores?
*/
private
static
final
String
pathToStores
=
"../../../../sun/security/ssl/etc"
;
private
static
final
String
keyStoreFile
=
"keystore"
;
private
static
final
String
trustStoreFile
=
"truststore"
;
private
static
final
String
passwd
=
"passphrase"
;
/*
* Is the server ready to serve?
*/
private
static
volatile
boolean
serverReady
=
false
;
/*
* Turn on SSL debugging?
*/
private
static
final
boolean
debug
=
false
;
/*
* the fully qualified domain name of localhost
*/
private
static
String
hostname
=
null
;
/*
* If the client or server is doing some kind of object creation
* that the other side depends on, and that thread prematurely
* exits, you may experience a hang. The test harness will
* terminate all hung threads after its timeout has expired,
* currently 3 minutes by default, but you might try to be
* smart about it....
*/
/*
* Define the server side of the test.
*
* If the server prematurely exits, serverReady will be set to true
* to avoid infinite hangs.
*/
private
void
doServerSide
()
throws
Exception
{
SSLServerSocketFactory
sslssf
=
(
SSLServerSocketFactory
)
SSLServerSocketFactory
.
getDefault
();
try
(
SSLServerSocket
sslServerSocket
=
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
))
{
serverPort
=
sslServerSocket
.
getLocalPort
();
/*
* Signal Client, we're ready for his connect.
*/
serverReady
=
true
;
try
(
SSLSocket
sslSocket
=
(
SSLSocket
)
sslServerSocket
.
accept
())
{
InputStream
sslIS
=
sslSocket
.
getInputStream
();
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
sslIS
.
read
();
sslOS
.
write
(
85
);
sslOS
.
flush
();
ExtendedSSLSession
session
=
(
ExtendedSSLSession
)
sslSocket
.
getSession
();
if
(
session
.
getRequestedServerNames
().
isEmpty
())
{
throw
new
Exception
(
"No expected Server Name Indication"
);
}
}
}
}
/*
* Define the client side of the test.
*
* If the server prematurely exits, serverReady will be set to true
* to avoid infinite hangs.
*/
private
void
doClientSide
()
throws
Exception
{
/*
* Wait for server to get started.
*/
while
(!
serverReady
)
{
Thread
.
sleep
(
50
);
}
SSLSocketFactory
sslsf
=
(
SSLSocketFactory
)
SSLSocketFactory
.
getDefault
();
try
(
SSLSocket
sslSocket
=
(
SSLSocket
)
sslsf
.
createSocket
())
{
sslSocket
.
connect
(
new
InetSocketAddress
(
hostname
,
serverPort
),
0
);
InputStream
sslIS
=
sslSocket
.
getInputStream
();
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
sslOS
.
write
(
280
);
sslOS
.
flush
();
sslIS
.
read
();
}
}
/*
* =============================================================
* The remainder is just support stuff
*/
// use any free port by default
private
volatile
int
serverPort
=
0
;
private
volatile
Exception
serverException
=
null
;
private
volatile
Exception
clientException
=
null
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
keyFilename
=
System
.
getProperty
(
"test.src"
,
"."
)
+
"/"
+
pathToStores
+
"/"
+
keyStoreFile
;
String
trustFilename
=
System
.
getProperty
(
"test.src"
,
"."
)
+
"/"
+
pathToStores
+
"/"
+
trustStoreFile
;
System
.
setProperty
(
"javax.net.ssl.keyStore"
,
keyFilename
);
System
.
setProperty
(
"javax.net.ssl.keyStorePassword"
,
passwd
);
System
.
setProperty
(
"javax.net.ssl.trustStore"
,
trustFilename
);
System
.
setProperty
(
"javax.net.ssl.trustStorePassword"
,
passwd
);
if
(
debug
)
{
System
.
setProperty
(
"javax.net.debug"
,
"all"
);
}
try
{
hostname
=
InetAddress
.
getLocalHost
().
getCanonicalHostName
();
}
catch
(
UnknownHostException
uhe
)
{
System
.
out
.
println
(
"Ignore the test as the local hostname cannot be determined"
);
return
;
}
System
.
out
.
println
(
"The fully qualified domain name of the local host is "
+
hostname
);
// Ignore the test if the hostname does not sound like a domain name.
if
((
hostname
==
null
)
||
hostname
.
isEmpty
()
||
!
hostname
.
contains
(
"."
)
||
hostname
.
endsWith
(
"."
)
||
hostname
.
startsWith
(
"localhost"
)
||
Character
.
isDigit
(
hostname
.
charAt
(
hostname
.
length
()
-
1
)))
{
System
.
out
.
println
(
"Ignore the test as the local hostname "
+
"cannot be determined as fully qualified domain name"
);
return
;
}
/*
* Start the tests.
*/
new
BestEffortOnLazyConnected
();
}
private
Thread
clientThread
=
null
;
private
Thread
serverThread
=
null
;
/*
* Primary constructor, used to drive remainder of the test.
*
* Fork off the other side, then do your work.
*/
BestEffortOnLazyConnected
()
throws
Exception
{
try
{
if
(
separateServerThread
)
{
startServer
(
true
);
startClient
(
false
);
}
else
{
startClient
(
true
);
startServer
(
false
);
}
}
catch
(
Exception
e
)
{
// swallow for now. Show later
}
/*
* Wait for other side to close down.
*/
if
(
separateServerThread
)
{
serverThread
.
join
();
}
else
{
clientThread
.
join
();
}
/*
* When we get here, the test is pretty much over.
* Which side threw the error?
*/
Exception
local
;
Exception
remote
;
String
whichRemote
;
if
(
separateServerThread
)
{
remote
=
serverException
;
local
=
clientException
;
whichRemote
=
"server"
;
}
else
{
remote
=
clientException
;
local
=
serverException
;
whichRemote
=
"client"
;
}
/*
* If both failed, return the curthread's exception, but also
* print the remote side Exception
*/
if
((
local
!=
null
)
&&
(
remote
!=
null
))
{
System
.
out
.
println
(
whichRemote
+
" also threw:"
);
remote
.
printStackTrace
();
System
.
out
.
println
();
throw
local
;
}
if
(
remote
!=
null
)
{
throw
remote
;
}
if
(
local
!=
null
)
{
throw
local
;
}
}
private
void
startServer
(
boolean
newThread
)
throws
Exception
{
if
(
newThread
)
{
serverThread
=
new
Thread
()
{
public
void
run
()
{
try
{
doServerSide
();
}
catch
(
Exception
e
)
{
/*
* Our server thread just died.
*
* Release the client, if not active already...
*/
System
.
err
.
println
(
"Server died..."
);
serverReady
=
true
;
serverException
=
e
;
}
}
};
serverThread
.
start
();
}
else
{
try
{
doServerSide
();
}
catch
(
Exception
e
)
{
serverException
=
e
;
}
finally
{
serverReady
=
true
;
}
}
}
private
void
startClient
(
boolean
newThread
)
throws
Exception
{
if
(
newThread
)
{
clientThread
=
new
Thread
()
{
public
void
run
()
{
try
{
doClientSide
();
}
catch
(
Exception
e
)
{
/*
* Our client thread just died.
*/
System
.
err
.
println
(
"Client died..."
);
clientException
=
e
;
}
}
};
clientThread
.
start
();
}
else
{
try
{
doClientSide
();
}
catch
(
Exception
e
)
{
clientException
=
e
;
}
}
}
}
test/sun/management/LazyCompositeDataTest.java
0 → 100644
浏览文件 @
318eae7f
/*
* 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.util.HashMap
;
import
java.util.Map
;
import
javax.management.openmbean.ArrayType
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.CompositeDataSupport
;
import
javax.management.openmbean.CompositeType
;
import
javax.management.openmbean.OpenDataException
;
import
javax.management.openmbean.OpenType
;
import
javax.management.openmbean.SimpleType
;
import
sun.management.LazyCompositeData
;
/**
* @test
* @bug 8139870
* @summary sun.management.LazyCompositeData.isTypeMatched() fails for composite types with items of ArrayType
* @modules java.management/sun.management
* @author Jaroslav Bachorik
*/
public
class
LazyCompositeDataTest
{
private
final
static
CompositeData
dataV1
,
dataV2
;
static
{
try
{
// ***
// prepare the composite types
// composite type stored in an array; V1
CompositeType
subtypeV1
=
new
CompositeType
(
"Subtype1"
,
"Version 1"
,
new
String
[]{
"item1"
},
new
String
[]{
"Item 1"
},
new
OpenType
<?>[]{
SimpleType
.
STRING
}
);
// composite type stored in an array; V2
CompositeType
subtypeV2
=
new
CompositeType
(
"Subtype2"
,
"Version 2"
,
new
String
[]{
"item1"
,
"item2"
},
new
String
[]{
"Item 1"
,
"Item 2"
},
new
OpenType
<?>[]{
SimpleType
.
STRING
,
SimpleType
.
INTEGER
}
);
// main composite type; V1
// one of the items is array of 'subtypeV1' instances
CompositeType
typeV1
=
new
CompositeType
(
"MyDataV1"
,
"Version 1"
,
new
String
[]{
"item1"
,
"item2"
},
new
String
[]{
"Item 1"
,
"Item 2"
},
new
OpenType
<?>[]{
SimpleType
.
STRING
,
ArrayType
.
getArrayType
(
subtypeV1
)
}
);
// main composite type; V2
// one of the items is array of 'subtypeV2' instances
CompositeType
typeV2
=
new
CompositeType
(
"MyDataV2"
,
"Version 2"
,
new
String
[]{
"item1"
,
"item2"
},
new
String
[]{
"Item 1"
,
"Item 2"
},
new
OpenType
<?>[]{
SimpleType
.
STRING
,
ArrayType
.
getArrayType
(
subtypeV2
)
}
);
// ***
// ***
// construct the data
Map
<
String
,
Object
>
subitemsV1
=
new
HashMap
<>();
Map
<
String
,
Object
>
subitemsV2
=
new
HashMap
<>();
Map
<
String
,
Object
>
itemsV1
=
new
HashMap
<>();
Map
<
String
,
Object
>
itemsV2
=
new
HashMap
<>();
subitemsV1
.
put
(
"item1"
,
"item1"
);
subitemsV2
.
put
(
"item1"
,
"item1"
);
subitemsV2
.
put
(
"item2"
,
42
);
itemsV1
.
put
(
"item1"
,
"item1"
);
itemsV1
.
put
(
"item2"
,
new
CompositeData
[]{
new
CompositeDataSupport
(
subtypeV1
,
subitemsV1
)});
itemsV2
.
put
(
"item1"
,
"item1"
);
itemsV2
.
put
(
"item2"
,
new
CompositeData
[]{
new
CompositeDataSupport
(
subtypeV2
,
subitemsV2
)});
dataV1
=
new
CompositeDataSupport
(
typeV1
,
itemsV1
);
dataV2
=
new
CompositeDataSupport
(
typeV2
,
itemsV2
);
// ***
}
catch
(
OpenDataException
e
)
{
throw
new
Error
(
e
);
}
}
private
static
class
MyDataV1
extends
LazyCompositeData
{
@Override
protected
CompositeData
getCompositeData
()
{
return
dataV1
;
}
public
boolean
isTypeMached
(
CompositeType
type
)
{
return
isTypeMatched
(
this
.
getCompositeType
(),
type
);
}
}
private
static
class
MyDataV2
extends
LazyCompositeData
{
@Override
protected
CompositeData
getCompositeData
()
{
return
dataV2
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Checking LazyCompositeData.isTypeMatched()"
);
MyDataV1
v1
=
new
MyDataV1
();
MyDataV2
v2
=
new
MyDataV2
();
if
(!
v1
.
isTypeMached
(
v2
.
getCompositeType
()))
{
System
.
err
.
println
(
"=== FAILED"
);
System
.
err
.
println
(
"V1 should be matched by V2"
);
System
.
err
.
println
(
"\n=== V1"
);
System
.
err
.
println
(
v1
.
getCompositeType
());
System
.
err
.
println
(
"\n=== V2"
);
System
.
err
.
println
(
v2
.
getCompositeType
());
throw
new
Error
();
}
System
.
out
.
println
(
"=== PASSED"
);
}
}
\ No newline at end of file
test/sun/misc/URLClassPath/ClassnameCharTest.java
浏览文件 @
318eae7f
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
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
...
...
@@ -102,16 +102,60 @@ public class ClassnameCharTest {
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
boolean
pass
()
{
passed
++;
return
true
;}
static
boolean
fail
()
{
failed
++;
server
.
stop
(
0
);
Thread
.
dumpStack
();
return
false
;}
static
boolean
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
return
fail
();}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
server
.
stop
(
0
);
t
.
printStackTrace
();}
static
boolean
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();
return
cond
;}
static
boolean
pass
()
{
passed
++;
return
true
;
}
static
boolean
fail
()
{
failed
++;
if
(
server
!=
null
)
{
server
.
stop
(
0
);
}
Thread
.
dumpStack
();
return
false
;
}
static
boolean
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
return
fail
();
}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
if
(
server
!=
null
)
{
server
.
stop
(
0
);
}
t
.
printStackTrace
();
}
static
boolean
check
(
boolean
cond
)
{
if
(
cond
)
{
pass
();
}
else
{
fail
();
}
return
cond
;
}
static
boolean
equal
(
Object
x
,
Object
y
)
{
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
return
pass
();
else
return
fail
(
x
+
" not equal to "
+
y
);}
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
{
return
pass
();
}
else
{
return
fail
(
x
+
" not equal to "
+
y
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
try
{
realMain
(
args
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
System
.
out
.
println
(
"\nPassed = "
+
passed
+
" failed = "
+
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
if
(
failed
>
0
)
{
throw
new
AssertionError
(
"Some tests failed"
);
}
}
}
test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
0 → 100644
浏览文件 @
318eae7f
/*
* 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 8144566
* @summary Custom HostnameVerifier disables SNI extension
* @run main/othervm ImpactOnSNI
*/
import
java.io.*
;
import
java.net.*
;
import
javax.net.ssl.*
;
public
class
ImpactOnSNI
{
/*
* =============================================================
* Set the various variables needed for the tests, then
* specify what tests to run on each side.
*/
/*
* Should we run the client or server in a separate thread?
* Both sides can throw exceptions, but do you have a preference
* as to which side should be the main thread.
*/
private
static
final
boolean
separateServerThread
=
true
;
/*
* Where do we find the keystores?
*/
private
static
final
String
pathToStores
=
"../../../../../../sun/security/ssl/etc"
;
private
static
final
String
keyStoreFile
=
"keystore"
;
private
static
final
String
trustStoreFile
=
"truststore"
;
private
static
final
String
passwd
=
"passphrase"
;
/*
* Is the server ready to serve?
*/
private
static
volatile
boolean
serverReady
=
false
;
/*
* Is the connection ready to close?
*/
private
static
volatile
boolean
closeReady
=
false
;
/*
* Turn on SSL debugging?
*/
private
static
final
boolean
debug
=
false
;
/*
* Message posted
*/
private
static
final
String
postMsg
=
"HTTP post on a https server"
;
/*
* the fully qualified domain name of localhost
*/
private
static
String
hostname
=
null
;
/*
* If the client or server is doing some kind of object creation
* that the other side depends on, and that thread prematurely
* exits, you may experience a hang. The test harness will
* terminate all hung threads after its timeout has expired,
* currently 3 minutes by default, but you might try to be
* smart about it....
*/
/*
* Define the server side of the test.
*
* If the server prematurely exits, serverReady will be set to true
* to avoid infinite hangs.
*/
private
void
doServerSide
()
throws
Exception
{
SSLServerSocketFactory
sslssf
=
(
SSLServerSocketFactory
)
SSLServerSocketFactory
.
getDefault
();
try
(
SSLServerSocket
sslServerSocket
=
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
))
{
serverPort
=
sslServerSocket
.
getLocalPort
();
/*
* Signal Client, we're ready for his connect.
*/
serverReady
=
true
;
/*
* Accept connections
*/
try
(
SSLSocket
sslSocket
=
(
SSLSocket
)
sslServerSocket
.
accept
())
{
InputStream
sslIS
=
sslSocket
.
getInputStream
();
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
sslIS
));
PrintStream
ps
=
new
PrintStream
(
sslOS
);
// process HTTP POST request from client
System
.
out
.
println
(
"status line: "
+
br
.
readLine
());
String
msg
=
null
;
while
((
msg
=
br
.
readLine
())
!=
null
&&
msg
.
length
()
>
0
);
msg
=
br
.
readLine
();
if
(
msg
.
equals
(
postMsg
))
{
ps
.
println
(
"HTTP/1.1 200 OK\n\n"
);
}
else
{
ps
.
println
(
"HTTP/1.1 500 Not OK\n\n"
);
}
ps
.
flush
();
ExtendedSSLSession
session
=
(
ExtendedSSLSession
)
sslSocket
.
getSession
();
if
(
session
.
getRequestedServerNames
().
isEmpty
())
{
throw
new
Exception
(
"No expected Server Name Indication"
);
}
// close the socket
while
(!
closeReady
)
{
Thread
.
sleep
(
50
);
}
}
}
}
/*
* Define the client side of the test.
*
* If the server prematurely exits, serverReady will be set to true
* to avoid infinite hangs.
*/
private
void
doClientSide
()
throws
Exception
{
/*
* Wait for server to get started.
*/
while
(!
serverReady
)
{
Thread
.
sleep
(
50
);
}
// Send HTTP POST request to server
URL
url
=
new
URL
(
"https://"
+
hostname
+
":"
+
serverPort
);
HttpsURLConnection
.
setDefaultHostnameVerifier
(
new
NameVerifier
());
HttpsURLConnection
http
=
(
HttpsURLConnection
)
url
.
openConnection
();
http
.
setDoOutput
(
true
);
http
.
setRequestMethod
(
"POST"
);
PrintStream
ps
=
new
PrintStream
(
http
.
getOutputStream
());
try
{
ps
.
println
(
postMsg
);
ps
.
flush
();
if
(
http
.
getResponseCode
()
!=
200
)
{
throw
new
RuntimeException
(
"test Failed"
);
}
}
finally
{
ps
.
close
();
http
.
disconnect
();
closeReady
=
true
;
}
}
private
static
class
NameVerifier
implements
HostnameVerifier
{
public
boolean
verify
(
String
hostname
,
SSLSession
session
)
{
return
true
;
}
}
/*
* =============================================================
* The remainder is just support stuff
*/
// use any free port by default
private
volatile
int
serverPort
=
0
;
private
volatile
Exception
serverException
=
null
;
private
volatile
Exception
clientException
=
null
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
keyFilename
=
System
.
getProperty
(
"test.src"
,
"./"
)
+
"/"
+
pathToStores
+
"/"
+
keyStoreFile
;
String
trustFilename
=
System
.
getProperty
(
"test.src"
,
"./"
)
+
"/"
+
pathToStores
+
"/"
+
trustStoreFile
;
System
.
setProperty
(
"javax.net.ssl.keyStore"
,
keyFilename
);
System
.
setProperty
(
"javax.net.ssl.keyStorePassword"
,
passwd
);
System
.
setProperty
(
"javax.net.ssl.trustStore"
,
trustFilename
);
System
.
setProperty
(
"javax.net.ssl.trustStorePassword"
,
passwd
);
if
(
debug
)
{
System
.
setProperty
(
"javax.net.debug"
,
"all"
);
}
try
{
hostname
=
InetAddress
.
getLocalHost
().
getCanonicalHostName
();
}
catch
(
UnknownHostException
uhe
)
{
System
.
out
.
println
(
"Ignore the test as the local hostname cannot be determined"
);
return
;
}
System
.
out
.
println
(
"The fully qualified domain name of the local host is "
+
hostname
);
// Ignore the test if the hostname does not sound like a domain name.
if
((
hostname
==
null
)
||
hostname
.
isEmpty
()
||
!
hostname
.
contains
(
"."
)
||
hostname
.
endsWith
(
"."
)
||
hostname
.
startsWith
(
"localhost"
)
||
Character
.
isDigit
(
hostname
.
charAt
(
hostname
.
length
()
-
1
)))
{
System
.
out
.
println
(
"Ignore the test as the local hostname "
+
"cannot be determined as fully qualified domain name"
);
return
;
}
/*
* Start the tests.
*/
new
ImpactOnSNI
();
}
private
Thread
clientThread
=
null
;
private
Thread
serverThread
=
null
;
/*
* Primary constructor, used to drive remainder of the test.
*
* Fork off the other side, then do your work.
*/
ImpactOnSNI
()
throws
Exception
{
Exception
startException
=
null
;
try
{
if
(
separateServerThread
)
{
startServer
(
true
);
startClient
(
false
);
}
else
{
startClient
(
true
);
startServer
(
false
);
}
}
catch
(
Exception
e
)
{
startException
=
e
;
}
/*
* Wait for other side to close down.
*/
if
(
separateServerThread
)
{
if
(
serverThread
!=
null
)
{
serverThread
.
join
();
}
}
else
{
if
(
clientThread
!=
null
)
{
clientThread
.
join
();
}
}
/*
* When we get here, the test is pretty much over.
* Which side threw the error?
*/
Exception
local
;
Exception
remote
;
if
(
separateServerThread
)
{
remote
=
serverException
;
local
=
clientException
;
}
else
{
remote
=
clientException
;
local
=
serverException
;
}
Exception
exception
=
null
;
/*
* Check various exception conditions.
*/
if
((
local
!=
null
)
&&
(
remote
!=
null
))
{
// If both failed, return the curthread's exception.
local
.
initCause
(
remote
);
exception
=
local
;
}
else
if
(
local
!=
null
)
{
exception
=
local
;
}
else
if
(
remote
!=
null
)
{
exception
=
remote
;
}
else
if
(
startException
!=
null
)
{
exception
=
startException
;
}
/*
* If there was an exception *AND* a startException,
* output it.
*/
if
(
exception
!=
null
)
{
if
(
exception
!=
startException
&&
startException
!=
null
)
{
exception
.
addSuppressed
(
startException
);
}
throw
exception
;
}
// Fall-through: no exception to throw!
}
private
void
startServer
(
boolean
newThread
)
throws
Exception
{
if
(
newThread
)
{
serverThread
=
new
Thread
()
{
@Override
public
void
run
()
{
try
{
doServerSide
();
}
catch
(
Exception
e
)
{
/*
* Our server thread just died.
*
* Release the client, if not active already...
*/
System
.
err
.
println
(
"Server died..."
);
serverReady
=
true
;
serverException
=
e
;
}
}
};
serverThread
.
start
();
}
else
{
try
{
doServerSide
();
}
catch
(
Exception
e
)
{
serverException
=
e
;
}
finally
{
serverReady
=
true
;
}
}
}
private
void
startClient
(
boolean
newThread
)
throws
Exception
{
if
(
newThread
)
{
clientThread
=
new
Thread
()
{
@Override
public
void
run
()
{
try
{
doClientSide
();
}
catch
(
Exception
e
)
{
/*
* Our client thread just died.
*/
System
.
err
.
println
(
"Client died..."
);
clientException
=
e
;
}
}
};
clientThread
.
start
();
}
else
{
try
{
doClientSide
();
}
catch
(
Exception
e
)
{
clientException
=
e
;
}
}
}
}
test/sun/security/krb5/auto/CommMatcher.java
0 → 100644
浏览文件 @
318eae7f
/*
* 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.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* Matches the krb5 debug output:
* >>> KDCCommunication: kdc=host UDP:11555, timeout=100,Attempt =1, #bytes=138
*
* Example:
* CommMatcher cm = new CommMatcher();
* cm.addPort(12345).addPort(23456);
* for (String line : debugOutput) {
* if (cm.match(line)) {
* println("KDC: %c, %s, Timeout: %d\n",
* cm.kdc(), cm.protocol(), cm.timeout());
* }
* }
*/
public
class
CommMatcher
{
static
final
Pattern
re
=
Pattern
.
compile
(
">>> KDCCommunication: kdc=\\S+ (TCP|UDP):(\\d+), "
+
"timeout=(\\d+),Attempt\\s*=(\\d+)"
);
List
<
Integer
>
kdcPorts
=
new
ArrayList
<>();
Matcher
matcher
;
/**
* Add KDC ports one by one. The 1st KDC will be 'a' in {@link #kdc()},
* 2nd is 'b', etc, etc.
*/
public
CommMatcher
addPort
(
int
port
)
{
if
(
port
>
0
)
{
kdcPorts
.
add
(
port
);
}
else
{
kdcPorts
.
clear
();
}
return
this
;
}
public
boolean
match
(
String
line
)
{
matcher
=
re
.
matcher
(
line
);
return
matcher
.
find
();
}
public
String
protocol
()
{
return
matcher
.
group
(
1
);
}
public
char
kdc
()
{
int
port
=
Integer
.
parseInt
(
matcher
.
group
(
2
));
return
(
char
)(
kdcPorts
.
indexOf
(
port
)
+
'a'
);
}
public
int
timeout
()
{
return
BadKdc
.
toSymbolicSec
(
Integer
.
parseInt
(
matcher
.
group
(
3
)));
}
public
int
attempt
()
{
return
Integer
.
parseInt
(
matcher
.
group
(
4
));
}
}
test/sun/security/krb5/auto/MaxRetries.java
浏览文件 @
318eae7f
...
...
@@ -29,49 +29,94 @@
* @summary support max_retries in krb5.conf
*/
import
javax.security.auth.login.LoginException
;
import
java.io.*
;
import
java.net.DatagramSocket
;
import
java.security.Security
;
public
class
MaxRetries
{
static
int
idlePort
=
-
1
;
static
CommMatcher
cm
=
new
CommMatcher
();
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"sun.security.krb5.debug"
,
"true"
);
new
OneKDC
(
null
).
writeJAASConf
();
OneKDC
kdc
=
new
OneKDC
(
null
).
writeJAASConf
();
// An idle UDP socket to prevent PortUnreachableException
DatagramSocket
ds
=
new
DatagramSocket
();
idlePort
=
ds
.
getLocalPort
();
// An idle UDP socket to revent PortUnreachableException
DatagramSocket
ds
=
new
DatagramSocket
(
33333
);
cm
.
addPort
(
idlePort
);
cm
.
addPort
(
kdc
.
getPort
()
);
System
.
setProperty
(
"java.security.krb5.conf"
,
"alternative-krb5.conf"
);
// For tryLast
Security
.
setProperty
(
"krb5.kdc.bad.policy"
,
"trylast"
);
// We always make the real timeout to be 1 second
BadKdc
.
setRatio
(
0.25f
);
rewriteMaxRetries
(
4
);
test1
(
4000
,
6
);
// 1 1 1 1 2 2
test1
(
4000
,
2
);
// 2 2
// Explanation: In this case, max_retries=4 and timeout=4s.
// For AS-REQ without preauth, we will see 4 4s timeout on kdc#1
// ("a4" repeat 4 times), and one 4s timeout on kdc#2 ("b4"). For
// AS-REQ with preauth, one 4s timeout on kdc#2 (second "b4").
// we tolerate 4 real timeout on kdc#2, so make it "(b4){2,6}".
test1
(
"a4a4a4a4b4b4"
,
"a4a4a4a4(b4){2,6}"
);
test1
(
"b4b4"
,
"(b4){2,6}"
);
BadKdc
.
setRatio
(
1
f
);
rewriteMaxRetries
(
1
);
test1
(
1000
,
3
);
// 1 2 2
test1
(
1000
,
2
);
// 2 2
// Explanation: Since max_retries=1 only, we could fail in 1st or 2nd
// AS-REQ to kdc#2.
String
actual
=
test1
(
"a1b1b1"
,
"(a1b1b1|a1b1x|a1b1b1x)"
);
if
(
actual
.
endsWith
(
"x"
))
{
// If 1st attempt fails, all bads are back available
test1
(
"a1b1b1"
,
"(a1b1b1|a1b1x|a1b1b1x)"
);
}
else
{
test1
(
"b1b1"
,
"(b1b1|b1x|b1b1x)"
);
}
BadKdc
.
setRatio
(
0.2f
);
rewriteMaxRetries
(-
1
);
test1
(
5000
,
4
);
// 1 1 2 2
test1
(
5000
,
2
);
// 2 2
test1
(
"a5a5a5b5b5"
,
"a5a5a5(b5){2,4}"
);
test1
(
"b5b5"
,
"(b5){2,4}"
);
// For tryLess
Security
.
setProperty
(
"krb5.kdc.bad.policy"
,
"tryless:1,"
+
BadKdc
.
toReal
(
5000
));
BadKdc
.
setRatio
(
0.25f
);
Security
.
setProperty
(
"krb5.kdc.bad.policy"
,
"tryless:1,1000"
);
rewriteMaxRetries
(
4
);
test1
(
4000
,
7
);
// 1 1 1 1 2 1 2
test1
(
4000
,
4
);
// 1 2 1 2
test1
(
"a4a4a4a4b4a4b4"
,
"a4a4a4a4(b4){1,3}a4(b4){1,3}"
);
test1
(
"a4b4a4b4"
,
"a4(b4){1,3}a4(b4){1,3}"
);
BadKdc
.
setRatio
(
1
f
);
rewriteMaxRetries
(
1
);
test1
(
1000
,
4
);
// 1 2 1 2
test1
(
1000
,
4
);
// 1 2 1 2
actual
=
test1
(
"a1b1a1b1"
,
"(a1b1|a1b1x|a1b1a1b1|a1b1a1b1x)"
);
if
(
actual
.
endsWith
(
"x"
))
{
test1
(
"a1b1a1b1"
,
"(a1b1|a1b1x|a1b1a1b1|a1b1a1b1x)"
);
}
else
{
test1
(
"a1b1a1b1"
,
"(a1b1|a1b1x|a1b1a1b1|a1b1a1b1x)"
);
}
BadKdc
.
setRatio
(.
2
f
);
rewriteMaxRetries
(-
1
);
test1
(
5000
,
5
);
// 1 1 2 1 2
test1
(
5000
,
4
);
// 1 2 1 2
test1
(
"a5a5a5b5a5b5"
,
"a5a5a5(b5){1,2}a5(b5){1,2}"
);
test1
(
"a5b5a5b5"
,
"a5(b5){1,2}a5(b5){1,2}"
);
BadKdc
.
setRatio
(
1
f
);
rewriteMaxRetries
(
2
);
if
(
BadKdc
.
toReal
(
2000
)
>
1000
)
{
// Explanation: if timeout is longer than 1s in tryLess,
// we will see "a1" at 2nd kdc#1 access
test1
(
"a2a2b2a1b2"
,
"a2a2(b2){1,2}a1(b2){1,2}"
);
}
else
{
test1
(
"a2a2b2a2b2"
,
"a2a2(b2){1,2}a2(b2){1,2}"
);
}
BadKdc
.
setRatio
(
1
f
);
rewriteUdpPrefLimit
(-
1
,
-
1
);
// default, no limit
test2
(
"UDP"
);
...
...
@@ -90,32 +135,52 @@ public class MaxRetries {
/**
* One round of test for max_retries and timeout.
* @param timeout the expected timeout
* @param count the expected total try
*
* @param exact the expected exact match, where no timeout
* happens for real KDCs
* @param relaxed the expected relaxed match, where some timeout
* could happen for real KDCs
* @return the actual result
*/
private
static
void
test1
(
int
timeout
,
int
count
)
throws
Exception
{
String
timeoutTag
=
"timeout="
+
BadKdc
.
toReal
(
timeout
);
private
static
String
test1
(
String
exact
,
String
relaxed
)
throws
Exception
{
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
PrintStream
oldout
=
System
.
out
;
System
.
setOut
(
new
PrintStream
(
bo
));
Context
c
=
Context
.
fromJAAS
(
"client"
);
boolean
failed
=
false
;
long
start
=
System
.
nanoTime
();
try
{
Context
c
=
Context
.
fromJAAS
(
"client"
);
}
catch
(
LoginException
e
)
{
failed
=
true
;
}
System
.
setOut
(
oldout
);
String
[]
lines
=
new
String
(
bo
.
toByteArray
()).
split
(
"\n"
);
System
.
out
.
println
(
"----------------- TEST ("
+
timeout
+
","
+
count
+
") -----------------"
);
System
.
out
.
println
(
"----------------- TEST ("
+
exact
+
") -----------------"
);
// Result, a series of timeout + kdc#
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
line:
lines
)
{
if
(
line
.
startsWith
(
">>> KDCCommunication"
))
{
if
(
cm
.
match
(
line
))
{
System
.
out
.
println
(
line
);
if
(
line
.
indexOf
(
timeoutTag
)
<
0
)
{
throw
new
Exception
(
"Wrong timeout value"
+
timeoutTag
);
}
count
--;
sb
.
append
(
cm
.
kdc
()).
append
(
cm
.
timeout
());
}
}
if
(
count
!=
0
)
{
throw
new
Exception
(
"Retry count is "
+
count
+
" less"
);
if
(
failed
)
{
sb
.
append
(
"x"
);
}
System
.
out
.
println
(
"Time: "
+
(
System
.
nanoTime
()
-
start
)
/
1000000000
d
);
String
actual
=
sb
.
toString
();
System
.
out
.
println
(
"Actual: "
+
actual
);
if
(
actual
.
equals
(
exact
))
{
System
.
out
.
println
(
"Exact match: "
+
exact
);
}
else
if
(
actual
.
matches
(
relaxed
))
{
System
.
out
.
println
(
"!!!! Tolerant match: "
+
relaxed
);
}
else
{
throw
new
Exception
(
"Match neither "
+
exact
+
" nor "
+
relaxed
);
}
return
actual
;
}
/**
...
...
@@ -133,11 +198,11 @@ public class MaxRetries {
String
[]
lines
=
new
String
(
bo
.
toByteArray
()).
split
(
"\n"
);
System
.
out
.
println
(
"----------------- TEST -----------------"
);
for
(
String
line:
lines
)
{
if
(
line
.
startsWith
(
">>> KDCCommunication"
))
{
if
(
cm
.
match
(
line
))
{
System
.
out
.
println
(
line
);
count
--;
if
(
line
.
indexOf
(
proto
)
<
0
)
{
throw
new
Exception
(
"Wrong
timeout
value"
);
if
(
!
cm
.
protocol
().
equals
(
proto
)
)
{
throw
new
Exception
(
"Wrong
protocol
value"
);
}
}
}
...
...
@@ -160,6 +225,7 @@ public class MaxRetries {
}
if
(
s
.
startsWith
(
"[realms]"
))
{
// Reconfig global setting
fw
.
write
(
"kdc_timeout = 5000\n"
);
if
(
global
!=
-
1
)
{
fw
.
write
(
"udp_preference_limit = "
+
global
+
"\n"
);
}
...
...
@@ -178,7 +244,8 @@ public class MaxRetries {
/**
* Set max_retries and timeout value for realm. The global value is always
* 2 and 5000.
* 3 and 5000.
*
* @param value max_retries and timeout/1000 for a realm, -1 means none.
*/
private
static
void
rewriteMaxRetries
(
int
value
)
throws
Exception
{
...
...
@@ -191,7 +258,7 @@ public class MaxRetries {
}
if
(
s
.
startsWith
(
"[realms]"
))
{
// Reconfig global setting
fw
.
write
(
"max_retries =
2
\n"
);
fw
.
write
(
"max_retries =
3
\n"
);
fw
.
write
(
"kdc_timeout = "
+
BadKdc
.
toReal
(
5000
)
+
"\n"
);
}
else
if
(
s
.
trim
().
startsWith
(
"kdc = "
))
{
if
(
value
!=
-
1
)
{
...
...
@@ -200,7 +267,7 @@ public class MaxRetries {
fw
.
write
(
" kdc_timeout = "
+
BadKdc
.
toReal
(
value
*
1000
)
+
"\n"
);
}
// Add a bad KDC as the first candidate
fw
.
write
(
" kdc = localhost:
33333
\n"
);
fw
.
write
(
" kdc = localhost:
"
+
idlePort
+
"
\n"
);
}
fw
.
write
(
s
+
"\n"
);
}
...
...
test/sun/security/krb5/auto/OneKDC.java
浏览文件 @
318eae7f
...
...
@@ -95,7 +95,7 @@ public class OneKDC extends KDC {
* entries with names using existing OneKDC principals.
* @throws java.lang.Exception if anything goes wrong
*/
public
void
writeJAASConf
()
throws
IOException
{
public
OneKDC
writeJAASConf
()
throws
IOException
{
System
.
setProperty
(
"java.security.auth.login.config"
,
JAAS_CONF
);
File
f
=
new
File
(
JAAS_CONF
);
FileOutputStream
fos
=
new
FileOutputStream
(
f
);
...
...
@@ -123,6 +123,7 @@ public class OneKDC extends KDC {
" isInitiator=false;\n};\n"
).
getBytes
());
fos
.
close
();
return
this
;
}
/**
...
...
test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java
浏览文件 @
318eae7f
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
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
...
...
@@ -26,67 +26,96 @@
* @bug 4674913
* @summary Verify that EOFException are correctly handled during the handshake
* @author Andreas Sterbenz
* @run main/othervm CloseSocket
*/
import
java.io.*
;
import
java.net.*
;
import
javax.net.ssl.*
;
import
javax.net.SocketFactory
;
import
javax.net.ssl.SSLSocket
;
import
javax.net.ssl.SSLSocketFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.util.ArrayList
;
public
class
CloseSocket
{
private
static
ArrayList
<
TestCase
>
testCases
=
new
ArrayList
<>();
static
{
testCases
.
add
(
socket
->
socket
.
startHandshake
());
testCases
.
add
(
socket
->
{
InputStream
in
=
socket
.
getInputStream
();
in
.
read
();
});
testCases
.
add
(
socket
->
{
OutputStream
out
=
socket
.
getOutputStream
();
out
.
write
(
43
);
});
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
final
ServerSocket
serverSocket
=
new
ServerSocket
(
0
);
int
serverPort
=
serverSocket
.
getLocalPort
();
new
Thread
()
{
public
void
run
()
{
try
{
Socket
s
=
serverSocket
.
accept
();
System
.
out
.
println
(
"Server accepted connection"
);
// wait a bit before closing the socket to give
// the client time to send its hello message
Thread
.
currentThread
().
sleep
(
100
);
s
.
close
();
System
.
out
.
println
(
"Server closed socket, done."
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Server exception:"
);
e
.
printStackTrace
();
try
(
Server
server
=
new
Server
())
{
new
Thread
(
server
).
start
();
SocketFactory
factory
=
SSLSocketFactory
.
getDefault
();
try
(
SSLSocket
socket
=
(
SSLSocket
)
factory
.
createSocket
(
"localhost"
,
server
.
getPort
()))
{
socket
.
setSoTimeout
(
2000
);
System
.
out
.
println
(
"Client established TCP connection"
);
boolean
failed
=
false
;
for
(
TestCase
testCase
:
testCases
)
{
try
{
testCase
.
test
(
socket
);
System
.
out
.
println
(
"ERROR: no exception"
);
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
}
}
if
(
failed
)
{
throw
new
Exception
(
"One or more tests failed"
);
}
}
}.
start
();
SSLSocketFactory
factory
=
(
SSLSocketFactory
)
SSLSocketFactory
.
getDefault
();
SSLSocket
socket
=
(
SSLSocket
)
factory
.
createSocket
(
"localhost"
,
serverPort
);
System
.
out
.
println
(
"Client established TCP connection"
);
boolean
failed
=
false
;
try
{
System
.
out
.
println
(
"Starting handshake..."
);
socket
.
startHandshake
();
System
.
out
.
println
(
"ERROR: no exception"
);
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
}
try
{
System
.
out
.
println
(
"Trying read..."
);
InputStream
in
=
socket
.
getInputStream
();
int
b
=
in
.
read
();
System
.
out
.
println
(
"ERROR: no exception, read: "
+
b
)
;
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
}
static
class
Server
implements
AutoCloseable
,
Runnable
{
final
ServerSocket
serverSocket
;
Server
()
throws
IOException
{
serverSocket
=
new
ServerSocket
(
0
);
}
try
{
System
.
out
.
println
(
"Trying read..."
);
OutputStream
out
=
socket
.
getOutputStream
();
out
.
write
(
43
);
System
.
out
.
println
(
"ERROR: no exception"
);
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
public
int
getPort
()
{
return
serverSocket
.
getLocalPort
();
}
if
(
failed
)
{
throw
new
Exception
(
"One or more tests failed"
);
@Override
public
void
run
()
{
try
(
Socket
s
=
serverSocket
.
accept
())
{
System
.
out
.
println
(
"Server accepted connection"
);
// wait a bit before closing the socket to give
// the client time to send its hello message
Thread
.
currentThread
().
sleep
(
100
);
s
.
close
();
System
.
out
.
println
(
"Server closed socket, done."
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Problem in test execution"
,
e
);
}
}
@Override
public
void
close
()
throws
Exception
{
if
(!
serverSocket
.
isClosed
())
{
serverSocket
.
close
();
}
}
}
interface
TestCase
{
void
test
(
SSLSocket
socket
)
throws
IOException
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录