Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
43715ec9
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看板
提交
43715ec9
编写于
10月 07, 2016
作者:
R
robm
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
893ec0fc
7d39b241
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
790 addition
and
149 deletion
+790
-149
src/share/classes/sun/management/LazyCompositeData.java
src/share/classes/sun/management/LazyCompositeData.java
+56
-21
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
test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java
...t/geom/AffineTransform/InvalidTransformParameterTest.java
+138
-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/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
未找到文件。
src/share/classes/sun/management/LazyCompositeData.java
浏览文件 @
43715ec9
...
...
@@ -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/native/sun/awt/image/jpeg/imageioJPEG.c
浏览文件 @
43715ec9
/*
* 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
浏览文件 @
43715ec9
/*
* 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
浏览文件 @
43715ec9
/*
* 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
浏览文件 @
43715ec9
/*
* 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__
test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java
0 → 100644
浏览文件 @
43715ec9
/*
* 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/sun/management/LazyCompositeDataTest.java
0 → 100644
浏览文件 @
43715ec9
/*
* 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
浏览文件 @
43715ec9
/*
* 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/security/krb5/auto/CommMatcher.java
0 → 100644
浏览文件 @
43715ec9
/*
* 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
浏览文件 @
43715ec9
...
...
@@ -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
浏览文件 @
43715ec9
...
...
@@ -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
浏览文件 @
43715ec9
/*
* 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录