Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a533f45f
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看板
提交
a533f45f
编写于
5月 06, 2016
作者:
R
robm
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
992358ff
18773732
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
764 addition
and
509 deletion
+764
-509
src/share/classes/java/lang/invoke/MethodHandles.java
src/share/classes/java/lang/invoke/MethodHandles.java
+4
-1
src/share/classes/java/security/ProtectionDomain.java
src/share/classes/java/security/ProtectionDomain.java
+124
-15
src/share/classes/sun/security/ssl/CipherBox.java
src/share/classes/sun/security/ssl/CipherBox.java
+0
-34
src/share/classes/sun/security/ssl/CipherSuite.java
src/share/classes/sun/security/ssl/CipherSuite.java
+37
-82
src/share/classes/sun/security/ssl/CipherSuiteList.java
src/share/classes/sun/security/ssl/CipherSuiteList.java
+3
-27
src/share/classes/sun/security/ssl/JsseJce.java
src/share/classes/sun/security/ssl/JsseJce.java
+25
-23
src/share/classes/sun/security/ssl/SSLContextImpl.java
src/share/classes/sun/security/ssl/SSLContextImpl.java
+334
-272
test/java/lang/invoke/ArrayConstructorTest.java
test/java/lang/invoke/ArrayConstructorTest.java
+61
-0
test/java/lang/invoke/PermuteArgsTest.java
test/java/lang/invoke/PermuteArgsTest.java
+10
-1
test/javax/xml/jaxp/stream/8153781/SkipDTDTest.java
test/javax/xml/jaxp/stream/8153781/SkipDTDTest.java
+87
-0
test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java
...rity/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java
+22
-10
test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java
...rity/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java
+44
-33
test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
...curity/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
+13
-11
未找到文件。
src/share/classes/java/lang/invoke/MethodHandles.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 2008, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
6
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -916,6 +916,9 @@ assertEquals("[x, y, z]", pb.command().toString());
...
@@ -916,6 +916,9 @@ assertEquals("[x, y, z]", pb.command().toString());
* @throws NullPointerException if any argument is null
* @throws NullPointerException if any argument is null
*/
*/
public
MethodHandle
findConstructor
(
Class
<?>
refc
,
MethodType
type
)
throws
NoSuchMethodException
,
IllegalAccessException
{
public
MethodHandle
findConstructor
(
Class
<?>
refc
,
MethodType
type
)
throws
NoSuchMethodException
,
IllegalAccessException
{
if
(
refc
.
isArray
())
{
throw
new
NoSuchMethodException
(
"no constructor for array class: "
+
refc
.
getName
());
}
String
name
=
"<init>"
;
String
name
=
"<init>"
;
MemberName
ctor
=
resolveOrFail
(
REF_newInvokeSpecial
,
refc
,
name
,
type
);
MemberName
ctor
=
resolveOrFail
(
REF_newInvokeSpecial
,
refc
,
name
,
type
);
return
getDirectConstructor
(
refc
,
ctor
);
return
getDirectConstructor
(
refc
,
ctor
);
...
...
src/share/classes/java/security/ProtectionDomain.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 1997, 201
3
, 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.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -25,12 +25,16 @@
...
@@ -25,12 +25,16 @@
package
java.security
;
package
java.security
;
import
java.lang.ref.Reference
;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.
Weak
HashMap
;
import
java.util.
concurrent.Concurrent
HashMap
;
import
sun.misc.JavaSecurityProtectionDomainAccess
;
import
sun.misc.JavaSecurityProtectionDomainAccess
;
import
static
sun
.
misc
.
JavaSecurityProtectionDomainAccess
.
ProtectionDomainCache
;
import
static
sun
.
misc
.
JavaSecurityProtectionDomainAccess
.
ProtectionDomainCache
;
import
sun.security.util.Debug
;
import
sun.security.util.Debug
;
...
@@ -456,25 +460,130 @@ public class ProtectionDomain {
...
@@ -456,25 +460,130 @@ public class ProtectionDomain {
/**
/**
* Used for storing ProtectionDomains as keys in a Map.
* Used for storing ProtectionDomains as keys in a Map.
*/
*/
final
class
Key
{}
static
final
class
Key
{}
static
{
static
{
SharedSecrets
.
setJavaSecurityProtectionDomainAccess
(
SharedSecrets
.
setJavaSecurityProtectionDomainAccess
(
new
JavaSecurityProtectionDomainAccess
()
{
new
JavaSecurityProtectionDomainAccess
()
{
@Override
public
ProtectionDomainCache
getProtectionDomainCache
()
{
public
ProtectionDomainCache
getProtectionDomainCache
()
{
return
new
ProtectionDomainCache
()
{
return
new
PDCache
();
private
final
Map
<
Key
,
PermissionCollection
>
map
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<
Key
,
PermissionCollection
>());
public
void
put
(
ProtectionDomain
pd
,
PermissionCollection
pc
)
{
map
.
put
((
pd
==
null
?
null
:
pd
.
key
),
pc
);
}
public
PermissionCollection
get
(
ProtectionDomain
pd
)
{
return
pd
==
null
?
map
.
get
(
null
)
:
map
.
get
(
pd
.
key
);
}
};
}
}
});
});
}
}
/**
* A cache of ProtectionDomains and their Permissions.
*
* This class stores ProtectionDomains as weak keys in a ConcurrentHashMap
* with additional support for checking and removing weak keys that are no
* longer in use. There can be cases where the permission collection may
* have a chain of strong references back to the ProtectionDomain, which
* ordinarily would prevent the entry from being removed from the map. To
* address that, we wrap the permission collection in a SoftReference so
* that it can be reclaimed by the garbage collector due to memory demand.
*/
private
static
class
PDCache
implements
ProtectionDomainCache
{
private
final
ConcurrentHashMap
<
WeakProtectionDomainKey
,
SoftReference
<
PermissionCollection
>>
pdMap
=
new
ConcurrentHashMap
<>();
private
final
ReferenceQueue
<
Key
>
queue
=
new
ReferenceQueue
<>();
@Override
public
void
put
(
ProtectionDomain
pd
,
PermissionCollection
pc
)
{
processQueue
(
queue
,
pdMap
);
WeakProtectionDomainKey
weakPd
=
new
WeakProtectionDomainKey
(
pd
,
queue
);
pdMap
.
put
(
weakPd
,
new
SoftReference
<>(
pc
));
}
@Override
public
PermissionCollection
get
(
ProtectionDomain
pd
)
{
processQueue
(
queue
,
pdMap
);
WeakProtectionDomainKey
weakPd
=
new
WeakProtectionDomainKey
(
pd
);
SoftReference
<
PermissionCollection
>
sr
=
pdMap
.
get
(
weakPd
);
return
(
sr
==
null
)
?
null
:
sr
.
get
();
}
/**
* Removes weak keys from the map that have been enqueued
* on the reference queue and are no longer in use.
*/
private
static
void
processQueue
(
ReferenceQueue
<
Key
>
queue
,
ConcurrentHashMap
<?
extends
WeakReference
<
Key
>,
?>
pdMap
)
{
Reference
<?
extends
Key
>
ref
;
while
((
ref
=
queue
.
poll
())
!=
null
)
{
pdMap
.
remove
(
ref
);
}
}
}
/**
* A weak key for a ProtectionDomain.
*/
private
static
class
WeakProtectionDomainKey
extends
WeakReference
<
Key
>
{
/**
* Saved value of the referent's identity hash code, to maintain
* a consistent hash code after the referent has been cleared
*/
private
final
int
hash
;
/**
* A key representing a null ProtectionDomain.
*/
private
static
final
Key
NULL_KEY
=
new
Key
();
/**
* Create a new WeakProtectionDomain with the specified domain and
* registered with a queue.
*/
WeakProtectionDomainKey
(
ProtectionDomain
pd
,
ReferenceQueue
<
Key
>
rq
)
{
this
((
pd
==
null
?
NULL_KEY
:
pd
.
key
),
rq
);
}
WeakProtectionDomainKey
(
ProtectionDomain
pd
)
{
this
(
pd
==
null
?
NULL_KEY
:
pd
.
key
);
}
private
WeakProtectionDomainKey
(
Key
key
,
ReferenceQueue
<
Key
>
rq
)
{
super
(
key
,
rq
);
hash
=
key
.
hashCode
();
}
private
WeakProtectionDomainKey
(
Key
key
)
{
super
(
key
);
hash
=
key
.
hashCode
();
}
/**
* Returns the identity hash code of the original referent.
*/
@Override
public
int
hashCode
()
{
return
hash
;
}
/**
* Returns true if the given object is an identical
* WeakProtectionDomainKey instance, or, if this object's referent
* has not been cleared and the given object is another
* WeakProtectionDomainKey instance with an identical non-null
* referent as this one.
*/
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
this
)
{
return
true
;
}
if
(
obj
instanceof
WeakProtectionDomainKey
)
{
Object
referent
=
get
();
return
(
referent
!=
null
)
&&
(
referent
==
((
WeakProtectionDomainKey
)
obj
).
get
());
}
else
{
return
false
;
}
}
}
}
}
src/share/classes/sun/security/ssl/CipherBox.java
浏览文件 @
a533f45f
...
@@ -1044,40 +1044,6 @@ final class CipherBox {
...
@@ -1044,40 +1044,6 @@ final class CipherBox {
return
nonce
;
return
nonce
;
}
}
/*
* Is this cipher available?
*
* This method can only be called by CipherSuite.BulkCipher.isAvailable()
* to test the availability of a cipher suites. Please DON'T use it in
* other places, otherwise, the behavior may be unexpected because we may
* initialize AEAD cipher improperly in the method.
*/
Boolean
isAvailable
()
{
// We won't know whether a cipher for a particular key size is
// available until the cipher is successfully initialized.
//
// We do not initialize AEAD cipher in the constructor. Need to
// initialize the cipher to ensure that the AEAD mode for a
// particular key size is supported.
if
(
cipherType
==
AEAD_CIPHER
)
{
try
{
Authenticator
authenticator
=
new
Authenticator
(
protocolVersion
);
byte
[]
nonce
=
authenticator
.
sequenceNumber
();
byte
[]
iv
=
Arrays
.
copyOf
(
fixedIv
,
fixedIv
.
length
+
nonce
.
length
);
System
.
arraycopy
(
nonce
,
0
,
iv
,
fixedIv
.
length
,
nonce
.
length
);
GCMParameterSpec
spec
=
new
GCMParameterSpec
(
tagSize
*
8
,
iv
);
cipher
.
init
(
mode
,
key
,
spec
,
random
);
}
catch
(
Exception
e
)
{
return
Boolean
.
FALSE
;
}
}
// Otherwise, we have initialized the cipher in the constructor.
return
Boolean
.
TRUE
;
}
/**
/**
* Sanity check the length of a fragment before decryption.
* Sanity check the length of a fragment before decryption.
*
*
...
...
src/share/classes/sun/security/ssl/CipherSuite.java
浏览文件 @
a533f45f
...
@@ -75,12 +75,6 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -75,12 +75,6 @@ final class CipherSuite implements Comparable<CipherSuite> {
// minimum priority for default enabled CipherSuites
// minimum priority for default enabled CipherSuites
final
static
int
DEFAULT_SUITES_PRIORITY
=
300
;
final
static
int
DEFAULT_SUITES_PRIORITY
=
300
;
// Flag indicating if CipherSuite availability can change dynamically.
// This is the case when we rely on a JCE cipher implementation that
// may not be available in the installed JCE providers.
// It is true because we might not have an ECC implementation.
final
static
boolean
DYNAMIC_AVAILABILITY
=
true
;
private
final
static
boolean
ALLOW_ECC
=
Debug
.
getBooleanProperty
private
final
static
boolean
ALLOW_ECC
=
Debug
.
getBooleanProperty
(
"com.sun.net.ssl.enableECC"
,
true
);
(
"com.sun.net.ssl.enableECC"
,
true
);
...
@@ -186,9 +180,6 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -186,9 +180,6 @@ final class CipherSuite implements Comparable<CipherSuite> {
* Return whether this CipherSuite is available for use. A
* Return whether this CipherSuite is available for use. A
* CipherSuite may be unavailable even if it is supported
* CipherSuite may be unavailable even if it is supported
* (i.e. allowed == true) if the required JCE cipher is not installed.
* (i.e. allowed == true) if the required JCE cipher is not installed.
* In some configuration, this situation may change over time, call
* CipherSuiteList.clearAvailableCache() before this method to obtain
* the most current status.
*/
*/
boolean
isAvailable
()
{
boolean
isAvailable
()
{
return
allowed
&&
keyExchange
.
isAvailable
()
&&
cipher
.
isAvailable
();
return
allowed
&&
keyExchange
.
isAvailable
()
&&
cipher
.
isAvailable
();
...
@@ -404,10 +395,6 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -404,10 +395,6 @@ final class CipherSuite implements Comparable<CipherSuite> {
*/
*/
final
static
class
BulkCipher
{
final
static
class
BulkCipher
{
// Map BulkCipher -> Boolean(available)
private
final
static
Map
<
BulkCipher
,
Boolean
>
availableCache
=
new
HashMap
<>(
8
);
// descriptive name including key size, e.g. AES/128
// descriptive name including key size, e.g. AES/128
final
String
description
;
final
String
description
;
...
@@ -451,6 +438,9 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -451,6 +438,9 @@ final class CipherSuite implements Comparable<CipherSuite> {
// The secure random used to detect the cipher availability.
// The secure random used to detect the cipher availability.
private
final
static
SecureRandom
secureRandom
;
private
final
static
SecureRandom
secureRandom
;
// runtime availability
private
final
boolean
isAvailable
;
static
{
static
{
try
{
try
{
secureRandom
=
JsseJce
.
getSecureRandom
();
secureRandom
=
JsseJce
.
getSecureRandom
();
...
@@ -475,6 +465,17 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -475,6 +465,17 @@ final class CipherSuite implements Comparable<CipherSuite> {
this
.
expandedKeySize
=
expandedKeySize
;
this
.
expandedKeySize
=
expandedKeySize
;
this
.
exportable
=
true
;
this
.
exportable
=
true
;
// availability of this bulk cipher
//
// Currently all supported ciphers except AES are always available
// via the JSSE internal implementations. We also assume AES/128 of
// CBC mode is always available since it is shipped with the SunJCE
// provider. However, AES/256 is unavailable when the default JCE
// policy jurisdiction files are installed because of key length
// restrictions.
this
.
isAvailable
=
allowed
?
isUnlimited
(
keySize
,
transformation
)
:
false
;
}
}
BulkCipher
(
String
transformation
,
CipherType
cipherType
,
int
keySize
,
BulkCipher
(
String
transformation
,
CipherType
cipherType
,
int
keySize
,
...
@@ -491,6 +492,17 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -491,6 +492,17 @@ final class CipherSuite implements Comparable<CipherSuite> {
this
.
expandedKeySize
=
keySize
;
this
.
expandedKeySize
=
keySize
;
this
.
exportable
=
false
;
this
.
exportable
=
false
;
// availability of this bulk cipher
//
// Currently all supported ciphers except AES are always available
// via the JSSE internal implementations. We also assume AES/128 of
// CBC mode is always available since it is shipped with the SunJCE
// provider. However, AES/256 is unavailable when the default JCE
// policy jurisdiction files are installed because of key length
// restrictions.
this
.
isAvailable
=
allowed
?
isUnlimited
(
keySize
,
transformation
)
:
false
;
}
}
/**
/**
...
@@ -508,84 +520,27 @@ final class CipherSuite implements Comparable<CipherSuite> {
...
@@ -508,84 +520,27 @@ final class CipherSuite implements Comparable<CipherSuite> {
/**
/**
* Test if this bulk cipher is available. For use by CipherSuite.
* Test if this bulk cipher is available. For use by CipherSuite.
*
* Currently all supported ciphers except AES are always available
* via the JSSE internal implementations. We also assume AES/128 of
* CBC mode is always available since it is shipped with the SunJCE
* provider. However, AES/256 is unavailable when the default JCE
* policy jurisdiction files are installed because of key length
* restrictions, and AEAD is unavailable when the underlying providers
* do not support AEAD/GCM mode.
*/
*/
boolean
isAvailable
()
{
boolean
isAvailable
()
{
if
(
allowed
==
false
)
{
return
this
.
isAvailable
;
return
false
;
}
if
((
this
==
B_AES_256
)
||
(
this
.
cipherType
==
CipherType
.
AEAD_CIPHER
))
{
return
isAvailable
(
this
);
}
// always available
return
true
;
}
}
// for use by CipherSuiteList.clearAvailableCache();
private
static
boolean
isUnlimited
(
int
keySize
,
String
transformation
)
{
static
synchronized
void
clearAvailableCache
()
{
int
keySizeInBits
=
keySize
*
8
;
if
(
DYNAMIC_AVAILABILITY
)
{
if
(
keySizeInBits
>
128
)
{
// need the JCE unlimited
availableCache
.
clear
();
// strength jurisdiction policy
}
try
{
}
if
(
Cipher
.
getMaxAllowedKeyLength
(
transformation
)
<
keySizeInBits
)
{
private
static
synchronized
boolean
isAvailable
(
BulkCipher
cipher
)
{
return
false
;
Boolean
b
=
availableCache
.
get
(
cipher
);
if
(
b
==
null
)
{
int
keySizeInBits
=
cipher
.
keySize
*
8
;
if
(
keySizeInBits
>
128
)
{
// need the JCE unlimited
// strength jurisdiction policy
try
{
if
(
Cipher
.
getMaxAllowedKeyLength
(
cipher
.
transformation
)
<
keySizeInBits
)
{
b
=
Boolean
.
FALSE
;
}
}
catch
(
Exception
e
)
{
b
=
Boolean
.
FALSE
;
}
}
}
catch
(
Exception
e
)
{
return
false
;
}
}
if
(
b
==
null
)
{
b
=
Boolean
.
FALSE
;
// may be reset to TRUE if
// the cipher is available
CipherBox
temporary
=
null
;
try
{
SecretKey
key
=
new
SecretKeySpec
(
new
byte
[
cipher
.
expandedKeySize
],
cipher
.
algorithm
);
IvParameterSpec
iv
;
if
(
cipher
.
cipherType
==
CipherType
.
AEAD_CIPHER
)
{
iv
=
new
IvParameterSpec
(
new
byte
[
cipher
.
fixedIvSize
]);
}
else
{
iv
=
new
IvParameterSpec
(
new
byte
[
cipher
.
ivSize
]);
}
temporary
=
cipher
.
newCipher
(
ProtocolVersion
.
DEFAULT
,
key
,
iv
,
secureRandom
,
true
);
b
=
temporary
.
isAvailable
();
}
catch
(
NoSuchAlgorithmException
e
)
{
// not available
}
finally
{
if
(
temporary
!=
null
)
{
temporary
.
dispose
();
}
}
}
availableCache
.
put
(
cipher
,
b
);
}
}
return
b
.
booleanValue
()
;
return
true
;
}
}
@Override
@Override
...
...
src/share/classes/sun/security/ssl/CipherSuiteList.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 2002, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
5
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -74,24 +74,12 @@ final class CipherSuiteList {
...
@@ -74,24 +74,12 @@ final class CipherSuiteList {
throw
new
IllegalArgumentException
(
"CipherSuites may not be null"
);
throw
new
IllegalArgumentException
(
"CipherSuites may not be null"
);
}
}
cipherSuites
=
new
ArrayList
<
CipherSuite
>(
names
.
length
);
cipherSuites
=
new
ArrayList
<
CipherSuite
>(
names
.
length
);
// refresh available cache once if a CipherSuite is not available
// (maybe new JCE providers have been installed)
boolean
refreshed
=
false
;
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
String
suiteName
=
names
[
i
];
String
suiteName
=
names
[
i
];
CipherSuite
suite
=
CipherSuite
.
valueOf
(
suiteName
);
CipherSuite
suite
=
CipherSuite
.
valueOf
(
suiteName
);
if
(
suite
.
isAvailable
()
==
false
)
{
if
(
suite
.
isAvailable
()
==
false
)
{
if
(
refreshed
==
false
)
{
throw
new
IllegalArgumentException
(
"Cannot support "
// clear the cache so that the isAvailable() call below
+
suiteName
+
" with currently installed providers"
);
// does a full check
clearAvailableCache
();
refreshed
=
true
;
}
// still missing?
if
(
suite
.
isAvailable
()
==
false
)
{
throw
new
IllegalArgumentException
(
"Cannot support "
+
suiteName
+
" with currently installed providers"
);
}
}
}
cipherSuites
.
add
(
suite
);
cipherSuites
.
add
(
suite
);
}
}
...
@@ -195,16 +183,4 @@ final class CipherSuiteList {
...
@@ -195,16 +183,4 @@ final class CipherSuiteList {
}
}
s
.
putBytes16
(
suiteBytes
);
s
.
putBytes16
(
suiteBytes
);
}
}
/**
* Clear cache of available ciphersuites. If we support all ciphers
* internally, there is no need to clear the cache and calling this
* method has no effect.
*/
static
synchronized
void
clearAvailableCache
()
{
if
(
CipherSuite
.
DYNAMIC_AVAILABILITY
)
{
CipherSuite
.
BulkCipher
.
clearAvailableCache
();
JsseJce
.
clearEcAvailable
();
}
}
}
}
src/share/classes/sun/security/ssl/JsseJce.java
浏览文件 @
a533f45f
...
@@ -55,11 +55,6 @@ final class JsseJce {
...
@@ -55,11 +55,6 @@ final class JsseJce {
private
final
static
ProviderList
fipsProviderList
;
private
final
static
ProviderList
fipsProviderList
;
// Flag indicating whether EC crypto is available.
// If null, then we have not checked yet.
// If yes, then all the EC based crypto we need is available.
private
static
Boolean
ecAvailable
;
// Flag indicating whether Kerberos crypto is available.
// Flag indicating whether Kerberos crypto is available.
// If true, then all the Kerberos-based crypto we need is available.
// If true, then all the Kerberos-based crypto we need is available.
private
final
static
boolean
kerberosAvailable
;
private
final
static
boolean
kerberosAvailable
;
...
@@ -195,24 +190,8 @@ final class JsseJce {
...
@@ -195,24 +190,8 @@ final class JsseJce {
// no instantiation of this class
// no instantiation of this class
}
}
synchronized
static
boolean
isEcAvailable
()
{
static
boolean
isEcAvailable
()
{
if
(
ecAvailable
==
null
)
{
return
EcAvailability
.
isAvailable
;
try
{
JsseJce
.
getSignature
(
SIGNATURE_ECDSA
);
JsseJce
.
getSignature
(
SIGNATURE_RAWECDSA
);
JsseJce
.
getKeyAgreement
(
"ECDH"
);
JsseJce
.
getKeyFactory
(
"EC"
);
JsseJce
.
getKeyPairGenerator
(
"EC"
);
ecAvailable
=
true
;
}
catch
(
Exception
e
)
{
ecAvailable
=
false
;
}
}
return
ecAvailable
;
}
synchronized
static
void
clearEcAvailable
()
{
ecAvailable
=
null
;
}
}
static
boolean
isKerberosAvailable
()
{
static
boolean
isKerberosAvailable
()
{
...
@@ -414,4 +393,27 @@ final class JsseJce {
...
@@ -414,4 +393,27 @@ final class JsseJce {
}
}
}
}
// lazy initialization holder class idiom for static default parameters
//
// See Effective Java Second Edition: Item 71.
private
static
class
EcAvailability
{
// Is EC crypto available?
private
final
static
boolean
isAvailable
;
static
{
boolean
mediator
=
true
;
try
{
JsseJce
.
getSignature
(
SIGNATURE_ECDSA
);
JsseJce
.
getSignature
(
SIGNATURE_RAWECDSA
);
JsseJce
.
getKeyAgreement
(
"ECDH"
);
JsseJce
.
getKeyFactory
(
"EC"
);
JsseJce
.
getKeyPairGenerator
(
"EC"
);
}
catch
(
Exception
e
)
{
mediator
=
false
;
}
isAvailable
=
mediator
;
}
}
}
}
src/share/classes/sun/security/ssl/SSLContextImpl.java
浏览文件 @
a533f45f
此差异已折叠。
点击以展开。
test/java/lang/invoke/ArrayConstructorTest.java
0 → 100644
浏览文件 @
a533f45f
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8155106
* @run testng/othervm -ea -esa test.java.lang.invoke.ArrayConstructorTest
*/
package
test.java.lang.invoke
;
import
java.lang.invoke.MethodHandle
;
import
java.lang.invoke.MethodHandles
;
import
static
java
.
lang
.
invoke
.
MethodType
.
methodType
;
import
static
org
.
testng
.
AssertJUnit
.*;
import
org.testng.annotations.*
;
public
class
ArrayConstructorTest
{
static
final
MethodHandles
.
Lookup
LOOKUP
=
MethodHandles
.
lookup
();
@Test
public
static
void
testFindConstructorArray
()
{
boolean
caught
=
false
;
try
{
MethodHandle
h
=
LOOKUP
.
findConstructor
(
Object
[].
class
,
methodType
(
void
.
class
));
}
catch
(
NoSuchMethodException
nsme
)
{
assertEquals
(
"no constructor for array class: [Ljava.lang.Object;"
,
nsme
.
getMessage
());
caught
=
true
;
}
catch
(
Exception
e
)
{
throw
new
AssertionError
(
"unexpected exception: "
+
e
);
}
assertTrue
(
caught
);
}
}
test/java/lang/invoke/PermuteArgsTest.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 2011, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 201
6
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
/* @test
/* @test
* @summary unit tests for method handles which permute their arguments
* @summary unit tests for method handles which permute their arguments
* @library /lib/testlibrary/jsr292 /lib/testlibrary
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
*/
*/
/* Examples of manual runs:
/* Examples of manual runs:
...
@@ -36,6 +37,8 @@ package test.java.lang.invoke;
...
@@ -36,6 +37,8 @@ package test.java.lang.invoke;
import
org.testng.*
;
import
org.testng.*
;
import
org.testng.annotations.*
;
import
org.testng.annotations.*
;
import
com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor
;
import
java.util.*
;
import
java.util.*
;
import
java.lang.reflect.*
;
import
java.lang.reflect.*
;
...
@@ -122,9 +125,15 @@ public class PermuteArgsTest {
...
@@ -122,9 +125,15 @@ public class PermuteArgsTest {
}
}
new
PermuteArgsTest
().
test
();
new
PermuteArgsTest
().
test
();
}
}
static
int
testCases
;
static
int
testCases
;
@Test
@Test
public
void
test
()
throws
Throwable
{
public
void
test
()
throws
Throwable
{
CodeCacheOverflowProcessor
.
runMHTest
(
this
::
test0
);
}
public
void
test0
()
throws
Throwable
{
testCases
=
0
;
testCases
=
0
;
Lookup
lookup
=
lookup
();
Lookup
lookup
=
lookup
();
for
(
Method
m
:
lookup
.
lookupClass
().
getDeclaredMethods
())
{
for
(
Method
m
:
lookup
.
lookupClass
().
getDeclaredMethods
())
{
...
...
test/javax/xml/jaxp/stream/8153781/SkipDTDTest.java
0 → 100644
浏览文件 @
a533f45f
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
com.sun.org.apache.xerces.internal.impl.XMLEntityManager
;
import
java.io.StringReader
;
import
javax.xml.stream.XMLEventReader
;
import
javax.xml.stream.XMLInputFactory
;
import
javax.xml.stream.XMLStreamException
;
import
javax.xml.stream.events.XMLEvent
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/*
* @test
* @bug 8153781
* @run testng/othervm SkipDTDTest
* @summary Test if method skipDTD of class XMLDTDScannerImpl will correctly skip the DTD section,
* even if a call to XMLEntityScanner.scanData for skipping to the closing ']' returns true.
*/
public
class
SkipDTDTest
{
public
static
int
DOCTYPE_SECTION_LENGTH
=
XMLEntityManager
.
DEFAULT_BUFFER_SIZE
*
2
;
public
static
int
DOCUMENT_LENGTH
=
DOCTYPE_SECTION_LENGTH
+
4096
;
public
String
createXMLDocument
(
int
doctypeoffset
)
{
StringBuilder
xmlcontentbuilder
=
new
StringBuilder
(
DOCUMENT_LENGTH
);
xmlcontentbuilder
.
append
(
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
);
xmlcontentbuilder
.
append
(
"<!DOCTYPE dummy [\r\n"
);
xmlcontentbuilder
.
append
(
" <!ELEMENT dummy EMPTY>\r\n"
);
xmlcontentbuilder
.
append
(
" <!--\r\n"
);
int
doctypelines
=
DOCTYPE_SECTION_LENGTH
/
3
;
for
(
int
i
=
0
;
i
<
doctypeoffset
;
i
++)
xmlcontentbuilder
.
append
(
'a'
);
for
(
int
i
=
0
;
i
<
doctypelines
;
i
++)
xmlcontentbuilder
.
append
(
"a\r\n"
);
xmlcontentbuilder
.
append
(
" -->\r\n"
);
xmlcontentbuilder
.
append
(
" ]\r\n"
);
xmlcontentbuilder
.
append
(
">\r\n"
);
xmlcontentbuilder
.
append
(
"<dummy>\r\n"
);
xmlcontentbuilder
.
append
(
"</dummy>\r\n"
);
System
.
out
.
println
(
"Document length:"
+
xmlcontentbuilder
.
length
());
return
xmlcontentbuilder
.
toString
();
}
public
void
runReader
(
XMLInputFactory
factory
,
int
offset
)
throws
XMLStreamException
{
StringReader
stringReader
=
new
StringReader
(
createXMLDocument
(
offset
));
XMLEventReader
reader
=
factory
.
createXMLEventReader
(
stringReader
);
while
(
reader
.
hasNext
())
{
XMLEvent
event
=
reader
.
nextEvent
();
System
.
out
.
println
(
"Event Type: "
+
event
.
getEventType
());
}
}
@Test
public
void
test
()
{
try
{
XMLInputFactory
factory
=
XMLInputFactory
.
newInstance
();
factory
.
setProperty
(
XMLInputFactory
.
SUPPORT_DTD
,
false
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
runReader
(
factory
,
i
);
}
}
catch
(
XMLStreamException
xe
)
{
xe
.
printStackTrace
();
Assert
.
fail
(
xe
.
getMessage
());
}
}
}
test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 2001, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
6
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -35,6 +35,7 @@ import java.io.*;
...
@@ -35,6 +35,7 @@ import java.io.*;
import
java.net.*
;
import
java.net.*
;
import
javax.net.ssl.*
;
import
javax.net.ssl.*
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.security.KeyStore
;
import
java.security.KeyStore
;
public
class
SSLCtxAccessToSessCtx
{
public
class
SSLCtxAccessToSessCtx
{
...
@@ -63,7 +64,7 @@ public class SSLCtxAccessToSessCtx {
...
@@ -63,7 +64,7 @@ public class SSLCtxAccessToSessCtx {
/*
/*
* Is the server ready to serve?
* Is the server ready to serve?
*/
*/
volatile
static
boolean
serverReady
=
false
;
AtomicInteger
serverReady
=
new
AtomicInteger
(
1
);
// only one port now
/*
/*
* Turn on SSL debugging?
* Turn on SSL debugging?
...
@@ -89,12 +90,13 @@ public class SSLCtxAccessToSessCtx {
...
@@ -89,12 +90,13 @@ public class SSLCtxAccessToSessCtx {
SSLServerSocket
sslServerSocket
=
SSLServerSocket
sslServerSocket
=
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
);
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
);
serverPorts
[
createdPorts
++]
=
sslServerSocket
.
getLocalPort
();
int
slot
=
createdPorts
.
getAndIncrement
();
serverPorts
[
slot
]
=
sslServerSocket
.
getLocalPort
();
/*
/*
* Signal Client, we're ready for his connect.
* Signal Client, we're ready for his connect.
*/
*/
serverReady
=
true
;
serverReady
.
getAndDecrement
()
;
int
read
=
0
;
int
read
=
0
;
SSLSocket
sslSocket
=
(
SSLSocket
)
sslServerSocket
.
accept
();
SSLSocket
sslSocket
=
(
SSLSocket
)
sslServerSocket
.
accept
();
InputStream
sslIS
=
sslSocket
.
getInputStream
();
InputStream
sslIS
=
sslSocket
.
getInputStream
();
...
@@ -121,7 +123,7 @@ public class SSLCtxAccessToSessCtx {
...
@@ -121,7 +123,7 @@ public class SSLCtxAccessToSessCtx {
/*
/*
* Wait for server to get started.
* Wait for server to get started.
*/
*/
while
(
!
serverReady
)
{
while
(
serverReady
.
get
()
>
0
)
{
Thread
.
sleep
(
50
);
Thread
.
sleep
(
50
);
}
}
/*
/*
...
@@ -151,8 +153,8 @@ public class SSLCtxAccessToSessCtx {
...
@@ -151,8 +153,8 @@ public class SSLCtxAccessToSessCtx {
* The remainder is just support stuff
* The remainder is just support stuff
*/
*/
volatile
int
serverPorts
[]
=
new
int
[]{
0
};
int
serverPorts
[]
=
new
int
[]{
0
};
// only one port at present
volatile
int
createdPorts
=
0
;
AtomicInteger
createdPorts
=
new
AtomicInteger
(
0
)
;
static
SSLServerSocketFactory
sslssf
;
static
SSLServerSocketFactory
sslssf
;
static
SSLSocketFactory
sslsf
;
static
SSLSocketFactory
sslsf
;
static
SSLContext
sslctx
;
static
SSLContext
sslctx
;
...
@@ -255,14 +257,20 @@ public class SSLCtxAccessToSessCtx {
...
@@ -255,14 +257,20 @@ public class SSLCtxAccessToSessCtx {
*/
*/
System
.
err
.
println
(
"Server died..."
);
System
.
err
.
println
(
"Server died..."
);
e
.
printStackTrace
();
e
.
printStackTrace
();
serverReady
=
true
;
serverReady
.
set
(
0
)
;
serverException
=
e
;
serverException
=
e
;
}
}
}
}
};
};
serverThread
.
start
();
serverThread
.
start
();
}
else
{
}
else
{
doServerSide
(
port
);
try
{
doServerSide
(
port
);
}
catch
(
Exception
e
)
{
serverException
=
e
;
}
finally
{
serverReady
.
set
(
0
);
}
}
}
}
}
...
@@ -284,7 +292,11 @@ public class SSLCtxAccessToSessCtx {
...
@@ -284,7 +292,11 @@ public class SSLCtxAccessToSessCtx {
};
};
clientThread
.
start
();
clientThread
.
start
();
}
else
{
}
else
{
doClientSide
();
try
{
doClientSide
();
}
catch
(
Exception
e
)
{
clientException
=
e
;
}
}
}
}
}
}
}
test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 2001, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
6
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
/*
/*
* @test
* @test
* @bug
4366807
* @bug 4366807
* @summary Need new APIs to get/set session timeout and session cache size.
* @summary Need new APIs to get/set session timeout and session cache size.
* @run main/othervm SessionCacheSizeTests
* @run main/othervm SessionCacheSizeTests
*/
*/
...
@@ -108,36 +108,47 @@ public class SessionCacheSizeTests {
...
@@ -108,36 +108,47 @@ public class SessionCacheSizeTests {
void
doServerSide
(
int
serverPort
,
int
serverConns
)
throws
Exception
{
void
doServerSide
(
int
serverPort
,
int
serverConns
)
throws
Exception
{
SSLServerSocket
sslServerSocket
=
try
(
SSLServerSocket
sslServerSocket
=
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
);
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
))
{
serverPorts
[
createdPorts
++]
=
sslServerSocket
.
getLocalPort
();
/*
// timeout to accept a connection
* Signal Client, we're ready for his connect.
sslServerSocket
.
setSoTimeout
(
45000
);
*/
if
(
createdPorts
==
serverPorts
.
length
)
{
// make sure createdPorts++ is atomic
serverReady
=
true
;
synchronized
(
serverPorts
)
{
}
serverPorts
[
createdPorts
++]
=
sslServerSocket
.
getLocalPort
();
int
read
=
0
;
int
nConnections
=
0
;
/*
/*
* Signal Client, we're ready for his connect.
* Divide the max connections among the available server ports.
*/
* The use of more than one server port ensures creation of more
if
(
createdPorts
==
serverPorts
.
length
)
{
* than one session.
serverReady
=
true
;
*/
}
SSLSession
sessions
[]
=
new
SSLSession
[
serverConns
];
}
SSLSessionContext
sessCtx
=
sslctx
.
getServerSessionContext
();
int
read
=
0
;
int
nConnections
=
0
;
while
(
nConnections
<
serverConns
)
{
SSLSocket
sslSocket
=
(
SSLSocket
)
sslServerSocket
.
accept
();
/*
InputStream
sslIS
=
sslSocket
.
getInputStream
();
* Divide the max connections among the available server ports.
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
* The use of more than one server port ensures creation of more
read
=
sslIS
.
read
();
* than one session.
sessions
[
nConnections
]
=
sslSocket
.
getSession
();
*/
sslOS
.
write
(
85
);
SSLSession
sessions
[]
=
new
SSLSession
[
serverConns
];
sslOS
.
flush
();
SSLSessionContext
sessCtx
=
sslctx
.
getServerSessionContext
();
sslSocket
.
close
();
nConnections
++;
while
(
nConnections
<
serverConns
)
{
try
(
SSLSocket
sslSocket
=
(
SSLSocket
)
sslServerSocket
.
accept
())
{
sslSocket
.
setSoTimeout
(
90000
);
// timeout to read
InputStream
sslIS
=
sslSocket
.
getInputStream
();
OutputStream
sslOS
=
sslSocket
.
getOutputStream
();
read
=
sslIS
.
read
();
sessions
[
nConnections
]
=
sslSocket
.
getSession
();
sslOS
.
write
(
85
);
sslOS
.
flush
();
nConnections
++;
}
}
}
}
}
}
...
@@ -263,8 +274,8 @@ public class SessionCacheSizeTests {
...
@@ -263,8 +274,8 @@ public class SessionCacheSizeTests {
* Using four ports (one per each connection), we are able to create
* Using four ports (one per each connection), we are able to create
* alteast four sessions.
* alteast four sessions.
*/
*/
volatile
int
serverPorts
[]
=
new
int
[]{
0
,
0
,
0
,
0
};
int
serverPorts
[]
=
new
int
[]{
0
,
0
,
0
,
0
};
// MAX_ACTIVE_CONNECTIONS: 4
volatile
int
createdPorts
=
0
;
int
createdPorts
=
0
;
static
SSLServerSocketFactory
sslssf
;
static
SSLServerSocketFactory
sslssf
;
static
SSLSocketFactory
sslsf
;
static
SSLSocketFactory
sslsf
;
static
SSLContext
sslctx
;
static
SSLContext
sslctx
;
...
...
test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
浏览文件 @
a533f45f
/*
/*
* Copyright (c) 2001, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
6
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -36,6 +36,7 @@ import java.net.*;
...
@@ -36,6 +36,7 @@ import java.net.*;
import
javax.net.ssl.*
;
import
javax.net.ssl.*
;
import
java.util.*
;
import
java.util.*
;
import
java.security.*
;
import
java.security.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
/**
* Session reuse time-out tests cover the cases below:
* Session reuse time-out tests cover the cases below:
...
@@ -79,7 +80,7 @@ public class SessionTimeOutTests {
...
@@ -79,7 +80,7 @@ public class SessionTimeOutTests {
/*
/*
* Is the server ready to serve?
* Is the server ready to serve?
*/
*/
volatile
static
int
serverReady
=
PORTS
;
AtomicInteger
serverReady
=
new
AtomicInteger
(
PORTS
)
;
/*
/*
* Turn on SSL debugging?
* Turn on SSL debugging?
...
@@ -98,7 +99,7 @@ public class SessionTimeOutTests {
...
@@ -98,7 +99,7 @@ public class SessionTimeOutTests {
/*
/*
* Define the server side of the test.
* Define the server side of the test.
*
*
* If the server prematurely exits, serverReady will be set to
true
* If the server prematurely exits, serverReady will be set to
zero
* to avoid infinite hangs.
* to avoid infinite hangs.
*/
*/
...
@@ -111,12 +112,13 @@ public class SessionTimeOutTests {
...
@@ -111,12 +112,13 @@ public class SessionTimeOutTests {
SSLServerSocket
sslServerSocket
=
SSLServerSocket
sslServerSocket
=
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
);
(
SSLServerSocket
)
sslssf
.
createServerSocket
(
serverPort
);
serverPorts
[
createdPorts
++]
=
sslServerSocket
.
getLocalPort
();
int
slot
=
createdPorts
.
getAndIncrement
();
serverPorts
[
slot
]
=
sslServerSocket
.
getLocalPort
();
/*
/*
* Signal Client, we're ready for his connect.
* Signal Client, we're ready for his connect.
*/
*/
serverReady
--
;
serverReady
.
getAndDecrement
()
;
int
read
=
0
;
int
read
=
0
;
int
nConnections
=
0
;
int
nConnections
=
0
;
SSLSession
sessions
[]
=
new
SSLSession
[
serverConns
];
SSLSession
sessions
[]
=
new
SSLSession
[
serverConns
];
...
@@ -137,7 +139,7 @@ public class SessionTimeOutTests {
...
@@ -137,7 +139,7 @@ public class SessionTimeOutTests {
/*
/*
* Define the client side of the test.
* Define the client side of the test.
*
*
* If the server prematurely exits, serverReady will be set to
true
* If the server prematurely exits, serverReady will be set to
zero
* to avoid infinite hangs.
* to avoid infinite hangs.
*/
*/
void
doClientSide
()
throws
Exception
{
void
doClientSide
()
throws
Exception
{
...
@@ -145,7 +147,7 @@ public class SessionTimeOutTests {
...
@@ -145,7 +147,7 @@ public class SessionTimeOutTests {
/*
/*
* Wait for server to get started.
* Wait for server to get started.
*/
*/
while
(
serverReady
>
0
)
{
while
(
serverReady
.
get
()
>
0
)
{
Thread
.
sleep
(
50
);
Thread
.
sleep
(
50
);
}
}
...
@@ -287,8 +289,8 @@ public class SessionTimeOutTests {
...
@@ -287,8 +289,8 @@ public class SessionTimeOutTests {
* The remainder is just support stuff
* The remainder is just support stuff
*/
*/
volatile
int
serverPorts
[]
=
new
int
[
PORTS
];
int
serverPorts
[]
=
new
int
[
PORTS
];
volatile
int
createdPorts
=
0
;
AtomicInteger
createdPorts
=
new
AtomicInteger
(
0
)
;
static
SSLServerSocketFactory
sslssf
;
static
SSLServerSocketFactory
sslssf
;
static
SSLSocketFactory
sslsf
;
static
SSLSocketFactory
sslsf
;
static
SSLContext
sslctx
;
static
SSLContext
sslctx
;
...
@@ -447,7 +449,7 @@ public class SessionTimeOutTests {
...
@@ -447,7 +449,7 @@ public class SessionTimeOutTests {
*/
*/
System
.
err
.
println
(
"Server died..."
);
System
.
err
.
println
(
"Server died..."
);
e
.
printStackTrace
();
e
.
printStackTrace
();
serverReady
=
0
;
serverReady
.
set
(
0
)
;
serverException
=
e
;
serverException
=
e
;
}
}
}
}
...
@@ -459,7 +461,7 @@ public class SessionTimeOutTests {
...
@@ -459,7 +461,7 @@ public class SessionTimeOutTests {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
serverException
=
e
;
serverException
=
e
;
}
finally
{
}
finally
{
serverReady
=
0
;
serverReady
.
set
(
0
)
;
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录