Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7a9bd002
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看板
提交
7a9bd002
编写于
7月 27, 2009
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
2e76bfac
56f3bea4
变更
58
隐藏空白更改
内联
并排
Showing
58 changed file
with
1472 addition
and
344 deletion
+1472
-344
make/common/shared/Defs-control.gmk
make/common/shared/Defs-control.gmk
+2
-2
make/common/shared/Defs-java.gmk
make/common/shared/Defs-java.gmk
+4
-4
make/java/dyn/Makefile
make/java/dyn/Makefile
+2
-2
src/share/classes/com/sun/jndi/ldap/Filter.java
src/share/classes/com/sun/jndi/ldap/Filter.java
+12
-6
src/share/classes/java/lang/Character.java
src/share/classes/java/lang/Character.java
+11
-5
src/share/classes/java/lang/ClassNotFoundException.java
src/share/classes/java/lang/ClassNotFoundException.java
+1
-1
src/share/classes/java/lang/Double.java
src/share/classes/java/lang/Double.java
+1
-0
src/share/classes/java/lang/Float.java
src/share/classes/java/lang/Float.java
+4
-3
src/share/classes/java/lang/IllegalAccessException.java
src/share/classes/java/lang/IllegalAccessException.java
+1
-1
src/share/classes/java/lang/InstantiationException.java
src/share/classes/java/lang/InstantiationException.java
+1
-1
src/share/classes/java/lang/NoSuchFieldException.java
src/share/classes/java/lang/NoSuchFieldException.java
+1
-1
src/share/classes/java/lang/NoSuchMethodException.java
src/share/classes/java/lang/NoSuchMethodException.java
+1
-1
src/share/classes/java/lang/ReflectiveOperationException.java
...share/classes/java/lang/ReflectiveOperationException.java
+91
-0
src/share/classes/java/lang/reflect/InvocationTargetException.java
.../classes/java/lang/reflect/InvocationTargetException.java
+1
-1
src/share/classes/java/security/cert/CertPathHelperImpl.java
src/share/classes/java/security/cert/CertPathHelperImpl.java
+6
-2
src/share/classes/java/security/cert/X509CRLSelector.java
src/share/classes/java/security/cert/X509CRLSelector.java
+26
-4
src/share/classes/java/util/logging/LogManager.java
src/share/classes/java/util/logging/LogManager.java
+1
-1
src/share/classes/sun/nio/cs/Surrogate.java
src/share/classes/sun/nio/cs/Surrogate.java
+44
-48
src/share/classes/sun/security/krb5/Config.java
src/share/classes/sun/security/krb5/Config.java
+34
-54
src/share/classes/sun/security/krb5/KrbApReq.java
src/share/classes/sun/security/krb5/KrbApReq.java
+0
-2
src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
...share/classes/sun/security/krb5/internal/ktab/KeyTab.java
+22
-5
src/share/classes/sun/security/provider/certpath/CertPathHelper.java
...lasses/sun/security/provider/certpath/CertPathHelper.java
+9
-1
src/share/classes/sun/security/provider/certpath/CrlRevocationChecker.java
.../sun/security/provider/certpath/CrlRevocationChecker.java
+6
-2
src/share/classes/sun/security/provider/certpath/OCSPResponse.java
.../classes/sun/security/provider/certpath/OCSPResponse.java
+2
-2
src/share/classes/sun/security/tools/JarSigner.java
src/share/classes/sun/security/tools/JarSigner.java
+2
-2
src/share/classes/sun/security/tools/KeyTool.java
src/share/classes/sun/security/tools/KeyTool.java
+16
-7
src/share/classes/sun/security/util/Resources.java
src/share/classes/sun/security/util/Resources.java
+2
-1
src/share/native/sun/security/pkcs11/wrapper/p11_general.c
src/share/native/sun/security/pkcs11/wrapper/p11_general.c
+2
-2
src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c
src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c
+4
-8
src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c
src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c
+5
-9
src/share/native/sun/security/pkcs11/wrapper/p11_sign.c
src/share/native/sun/security/pkcs11/wrapper/p11_sign.c
+1
-1
src/share/native/sun/security/pkcs11/wrapper/p11_util.c
src/share/native/sun/security/pkcs11/wrapper/p11_util.c
+4
-6
src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
+1
-1
src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
+12
-18
src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
+8
-4
src/solaris/native/sun/nio/ch/SctpChannelImpl.c
src/solaris/native/sun/nio/ch/SctpChannelImpl.c
+5
-4
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
+12
-4
src/windows/classes/sun/nio/fs/WindowsPath.java
src/windows/classes/sun/nio/fs/WindowsPath.java
+11
-5
src/windows/classes/sun/security/krb5/internal/tools/Klist.java
...ndows/classes/sun/security/krb5/internal/tools/Klist.java
+1
-0
src/windows/classes/sun/security/krb5/internal/tools/Ktab.java
...indows/classes/sun/security/krb5/internal/tools/Ktab.java
+88
-36
test/com/sun/jndi/ldap/BalancedParentheses.java
test/com/sun/jndi/ldap/BalancedParentheses.java
+259
-0
test/com/sun/nio/sctp/SctpChannel/CommUp.java
test/com/sun/nio/sctp/SctpChannel/CommUp.java
+364
-0
test/com/sun/nio/sctp/SctpMultiChannel/Branch.java
test/com/sun/nio/sctp/SctpMultiChannel/Branch.java
+0
-1
test/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java
.../com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java
+1
-1
test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java
...ava/nio/channels/AsynchronousChannelGroup/GroupOfOne.java
+4
-4
test/java/nio/channels/AsynchronousChannelGroup/Identity.java
.../java/nio/channels/AsynchronousChannelGroup/Identity.java
+4
-4
test/java/nio/channels/AsynchronousChannelGroup/Restart.java
test/java/nio/channels/AsynchronousChannelGroup/Restart.java
+1
-1
test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
...java/nio/channels/AsynchronousChannelGroup/Unbounded.java
+2
-2
test/java/nio/channels/AsynchronousDatagramChannel/Basic.java
.../java/nio/channels/AsynchronousDatagramChannel/Basic.java
+11
-11
test/java/nio/channels/AsynchronousFileChannel/Basic.java
test/java/nio/channels/AsynchronousFileChannel/Basic.java
+4
-4
test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java
...a/nio/channels/AsynchronousServerSocketChannel/Basic.java
+1
-1
test/java/nio/channels/AsynchronousSocketChannel/Basic.java
test/java/nio/channels/AsynchronousSocketChannel/Basic.java
+14
-14
test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java
...io/channels/AsynchronousSocketChannel/StressLoopback.java
+4
-4
test/java/nio/file/Path/Links.java
test/java/nio/file/Path/Links.java
+59
-3
test/sun/security/krb5/ConfPlusProp.java
test/sun/security/krb5/ConfPlusProp.java
+90
-37
test/sun/security/tools/jarsigner/newsize7.sh
test/sun/security/tools/jarsigner/newsize7.sh
+73
-0
test/sun/security/tools/keytool/NewSize7.java
test/sun/security/tools/keytool/NewSize7.java
+56
-0
test/sun/security/tools/keytool/emptysubject.sh
test/sun/security/tools/keytool/emptysubject.sh
+68
-0
未找到文件。
make/common/shared/Defs-control.gmk
浏览文件 @
7a9bd002
...
...
@@ -92,9 +92,9 @@ ABS_TEMP_DIR = $(ABS_OUTPUTDIR)/tmp
dummy := $(shell $(MKDIR) -p $(TEMP_DIR))
# The language version we want for this jdk build
SOURCE_LANGUAGE_VERSION=
5
SOURCE_LANGUAGE_VERSION=
7
# The class version we want for this jdk build
TARGET_CLASS_VERSION=
5
TARGET_CLASS_VERSION=
7
# The MESSAGE, WARNING and ERROR files are used to store sanity check and
# source check messages, warnings and errors.
...
...
make/common/shared/Defs-java.gmk
浏览文件 @
7a9bd002
...
...
@@ -122,13 +122,13 @@ ifeq ($(JAVAC_WARNINGS_FATAL), true)
JAVACFLAGS += -Werror
endif
# Add the source level
(currently all source is 1.5, should this be 1.6?)
SOURCE_LANGUAGE_VERSION =
5
# Add the source level
SOURCE_LANGUAGE_VERSION =
7
LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
JAVACFLAGS += $(LANGUAGE_VERSION)
# Add the class version we want
(currently this is 5, should it be 6 or even 7?)
TARGET_CLASS_VERSION =
5
# Add the class version we want
TARGET_CLASS_VERSION =
7
CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
JAVACFLAGS += $(CLASS_VERSION)
JAVACFLAGS += -encoding ascii
...
...
make/java/dyn/Makefile
浏览文件 @
7a9bd002
...
...
@@ -33,8 +33,8 @@ AUTO_FILES_JAVA_DIRS = java/dyn sun/dyn
# The sources built here use new language syntax to generate
# method handle calls. Let's be sure we are using that format.
#
LANGUAGE_VERSION = -source 7
#
CLASS_VERSION = -target 7
LANGUAGE_VERSION
=
-source
7
CLASS_VERSION
=
-target
7
# Actually, it will be less disruptive to compile with the same
# -target option as the rest of the system, and just turn on
...
...
src/share/classes/com/sun/jndi/ldap/Filter.java
浏览文件 @
7a9bd002
...
...
@@ -93,9 +93,7 @@ final class Filter {
int
filtOffset
[]
=
new
int
[
1
];
for
(
filtOffset
[
0
]
=
filterStart
;
filtOffset
[
0
]
<
filterEnd
;
filtOffset
[
0
]++)
{
for
(
filtOffset
[
0
]
=
filterStart
;
filtOffset
[
0
]
<
filterEnd
;)
{
switch
(
filter
[
filtOffset
[
0
]])
{
case
'('
:
filtOffset
[
0
]++;
...
...
@@ -104,18 +102,21 @@ final class Filter {
case
'&'
:
encodeComplexFilter
(
ber
,
filter
,
LDAP_FILTER_AND
,
filtOffset
,
filterEnd
);
// filtOffset[0] has pointed to char after right paren
parens
--;
break
;
case
'|'
:
encodeComplexFilter
(
ber
,
filter
,
LDAP_FILTER_OR
,
filtOffset
,
filterEnd
);
// filtOffset[0] has pointed to char after right paren
parens
--;
break
;
case
'!'
:
encodeComplexFilter
(
ber
,
filter
,
LDAP_FILTER_NOT
,
filtOffset
,
filterEnd
);
// filtOffset[0] has pointed to char after right paren
parens
--;
break
;
...
...
@@ -143,8 +144,8 @@ final class Filter {
encodeSimpleFilter
(
ber
,
filter
,
filtOffset
[
0
],
nextOffset
);
// points to
right parens; for loop will increment beyond parens
filtOffset
[
0
]
=
nextOffset
;
// points to
the char after right paren.
filtOffset
[
0
]
=
nextOffset
+
1
;
parens
--;
break
;
...
...
@@ -170,9 +171,14 @@ final class Filter {
filtOffset
[
0
]
=
filterEnd
;
// force break from outer
break
;
}
if
(
parens
<
0
)
{
throw
new
InvalidSearchFilterException
(
"Unbalanced parenthesis"
);
}
}
if
(
parens
>
0
)
{
if
(
parens
!=
0
)
{
throw
new
InvalidSearchFilterException
(
"Unbalanced parenthesis"
);
}
...
...
src/share/classes/java/lang/Character.java
浏览文件 @
7a9bd002
...
...
@@ -2784,8 +2784,13 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
* @since 1.5
*/
public
static
int
toCodePoint
(
char
high
,
char
low
)
{
return
((
high
-
MIN_HIGH_SURROGATE
)
<<
10
)
+
(
low
-
MIN_LOW_SURROGATE
)
+
MIN_SUPPLEMENTARY_CODE_POINT
;
// Optimized form of:
// return ((high - MIN_HIGH_SURROGATE) << 10)
// + (low - MIN_LOW_SURROGATE)
// + MIN_SUPPLEMENTARY_CODE_POINT;
return
((
high
<<
10
)
+
low
)
+
(
MIN_SUPPLEMENTARY_CODE_POINT
-
(
MIN_HIGH_SURROGATE
<<
10
)
-
MIN_LOW_SURROGATE
);
}
/**
...
...
@@ -3071,9 +3076,10 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
}
static
void
toSurrogates
(
int
codePoint
,
char
[]
dst
,
int
index
)
{
int
offset
=
codePoint
-
MIN_SUPPLEMENTARY_CODE_POINT
;
dst
[
index
+
1
]
=
(
char
)((
offset
&
0x3ff
)
+
MIN_LOW_SURROGATE
);
dst
[
index
]
=
(
char
)((
offset
>>>
10
)
+
MIN_HIGH_SURROGATE
);
// We write elements "backwards" to guarantee all-or-nothing
dst
[
index
+
1
]
=
(
char
)((
codePoint
&
0x3ff
)
+
MIN_LOW_SURROGATE
);
dst
[
index
]
=
(
char
)((
codePoint
>>>
10
)
+
(
MIN_HIGH_SURROGATE
-
(
MIN_SUPPLEMENTARY_CODE_POINT
>>>
10
)));
}
/**
...
...
src/share/classes/java/lang/ClassNotFoundException.java
浏览文件 @
7a9bd002
...
...
@@ -50,7 +50,7 @@ package java.lang;
* @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
* @since JDK1.0
*/
public
class
ClassNotFoundException
extends
Exception
{
public
class
ClassNotFoundException
extends
ReflectiveOperation
Exception
{
/**
* use serialVersionUID from JDK 1.1.X for interoperability
*/
...
...
src/share/classes/java/lang/Double.java
浏览文件 @
7a9bd002
...
...
@@ -529,6 +529,7 @@ public final class Double extends Number implements Comparable<Double> {
* @param s the string to be parsed.
* @return the {@code double} value represented by the string
* argument.
* @throws NullPointerException if the string is null
* @throws NumberFormatException if the string does not contain
* a parsable {@code double}.
* @see java.lang.Double#valueOf(String)
...
...
src/share/classes/java/lang/Float.java
浏览文件 @
7a9bd002
...
...
@@ -438,12 +438,13 @@ public final class Float extends Number implements Comparable<Float> {
* represented by the specified {@code String}, as performed
* by the {@code valueOf} method of class {@code Float}.
*
* @param
s
the string to be parsed.
* @param
s
the string to be parsed.
* @return the {@code float} value represented by the string
* argument.
* @throws NumberFormatException if the string does not contain a
* @throws NullPointerException if the string is null
* @throws NumberFormatException if the string does not contain a
* parsable {@code float}.
* @see
java.lang.Float#valueOf(String)
* @see java.lang.Float#valueOf(String)
* @since 1.2
*/
public
static
float
parseFloat
(
String
s
)
throws
NumberFormatException
{
...
...
src/share/classes/java/lang/IllegalAccessException.java
浏览文件 @
7a9bd002
...
...
@@ -56,7 +56,7 @@ package java.lang;
* @see java.lang.reflect.Constructor#newInstance(Object[])
* @since JDK1.0
*/
public
class
IllegalAccessException
extends
Exception
{
public
class
IllegalAccessException
extends
ReflectiveOperation
Exception
{
private
static
final
long
serialVersionUID
=
6616958222490762034L
;
/**
...
...
src/share/classes/java/lang/InstantiationException.java
浏览文件 @
7a9bd002
...
...
@@ -43,7 +43,7 @@ package java.lang;
* @since JDK1.0
*/
public
class
InstantiationException
extends
Exception
{
class
InstantiationException
extends
ReflectiveOperation
Exception
{
private
static
final
long
serialVersionUID
=
-
8441929162975509110L
;
/**
...
...
src/share/classes/java/lang/NoSuchFieldException.java
浏览文件 @
7a9bd002
...
...
@@ -31,7 +31,7 @@ package java.lang;
* @author unascribed
* @since JDK1.1
*/
public
class
NoSuchFieldException
extends
Exception
{
public
class
NoSuchFieldException
extends
ReflectiveOperation
Exception
{
private
static
final
long
serialVersionUID
=
-
6143714805279938260L
;
/**
...
...
src/share/classes/java/lang/NoSuchMethodException.java
浏览文件 @
7a9bd002
...
...
@@ -32,7 +32,7 @@ package java.lang;
* @since JDK1.0
*/
public
class
NoSuchMethodException
extends
Exception
{
class
NoSuchMethodException
extends
ReflectiveOperation
Exception
{
private
static
final
long
serialVersionUID
=
5034388446362600923L
;
/**
...
...
src/share/classes/java/lang/ReflectiveOperationException.java
0 → 100644
浏览文件 @
7a9bd002
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
java.lang
;
/**
* Common superclass of exceptions thrown by reflective operations in
* core reflection.
*
* @see LinkageError
* @since 1.7
*/
public
class
ReflectiveOperationException
extends
Exception
{
static
final
long
serialVersionUID
=
123456789L
;
/**
* Constructs a new exception with {@code null} as its detail
* message. The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*/
public
ReflectiveOperationException
()
{
super
();
}
/**
* Constructs a new exception with the specified detail message.
* The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public
ReflectiveOperationException
(
String
message
)
{
super
(
message
);
}
/**
* Constructs a new exception with the specified detail message
* and cause.
*
* <p>Note that the detail message associated with
* {@code cause} is <em>not</em> automatically incorporated in
* this exception's detail message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public
ReflectiveOperationException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
/**
* Constructs a new exception with the specified cause and a detail
* message of {@code (cause==null ? null : cause.toString())} (which
* typically contains the class and detail message of {@code cause}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public
ReflectiveOperationException
(
Throwable
cause
)
{
super
(
cause
);
}
}
src/share/classes/java/lang/reflect/InvocationTargetException.java
浏览文件 @
7a9bd002
...
...
@@ -39,7 +39,7 @@ package java.lang.reflect;
* @see Method
* @see Constructor
*/
public
class
InvocationTargetException
extends
Exception
{
public
class
InvocationTargetException
extends
ReflectiveOperation
Exception
{
/**
* Use serialVersionUID from JDK 1.1.X for interoperability
*/
...
...
src/share/classes/java/security/cert/CertPathHelperImpl.java
浏览文件 @
7a9bd002
/*
* Copyright 2002-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-200
9
Sun Microsystems, Inc. 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
...
...
@@ -46,7 +46,7 @@ class CertPathHelperImpl extends CertPathHelper {
/**
* Initialize the helper framework. This method must be called from
* the static initializer of each class that is the target of one of
* the methods in this class. This ensures that the helper i
f
initialized
* the methods in this class. This ensures that the helper i
s
initialized
* prior to a tunneled call from the Sun provider.
*/
synchronized
static
void
initialize
()
{
...
...
@@ -59,4 +59,8 @@ class CertPathHelperImpl extends CertPathHelper {
Set
<
GeneralNameInterface
>
names
)
{
sel
.
setPathToNamesInternal
(
names
);
}
protected
void
implSetDateAndTime
(
X509CRLSelector
sel
,
Date
date
,
long
skew
)
{
sel
.
setDateAndTime
(
date
,
skew
);
}
}
src/share/classes/java/security/cert/X509CRLSelector.java
浏览文件 @
7a9bd002
/*
* Copyright 2000-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-200
9
Sun Microsystems, Inc. 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
...
...
@@ -72,6 +72,10 @@ import sun.security.x509.X500Name;
*/
public
class
X509CRLSelector
implements
CRLSelector
{
static
{
CertPathHelperImpl
.
initialize
();
}
private
static
final
Debug
debug
=
Debug
.
getInstance
(
"certpath"
);
private
HashSet
<
Object
>
issuerNames
;
private
HashSet
<
X500Principal
>
issuerX500Principals
;
...
...
@@ -79,6 +83,7 @@ public class X509CRLSelector implements CRLSelector {
private
BigInteger
maxCRL
;
private
Date
dateAndTime
;
private
X509Certificate
certChecking
;
private
long
skew
=
0
;
/**
* Creates an <code>X509CRLSelector</code>. Initially, no criteria are set
...
...
@@ -417,7 +422,18 @@ public class X509CRLSelector implements CRLSelector {
if
(
dateAndTime
==
null
)
this
.
dateAndTime
=
null
;
else
this
.
dateAndTime
=
(
Date
)
dateAndTime
.
clone
();
this
.
dateAndTime
=
new
Date
(
dateAndTime
.
getTime
());
this
.
skew
=
0
;
}
/**
* Sets the dateAndTime criterion and allows for the specified clock skew
* (in milliseconds) when checking against the validity period of the CRL.
*/
void
setDateAndTime
(
Date
dateAndTime
,
long
skew
)
{
this
.
dateAndTime
=
(
dateAndTime
==
null
?
null
:
new
Date
(
dateAndTime
.
getTime
()));
this
.
skew
=
skew
;
}
/**
...
...
@@ -657,8 +673,14 @@ public class X509CRLSelector implements CRLSelector {
}
return
false
;
}
if
(
crlThisUpdate
.
after
(
dateAndTime
)
||
nextUpdate
.
before
(
dateAndTime
))
{
Date
nowPlusSkew
=
dateAndTime
;
Date
nowMinusSkew
=
dateAndTime
;
if
(
skew
>
0
)
{
nowPlusSkew
=
new
Date
(
dateAndTime
.
getTime
()
+
skew
);
nowMinusSkew
=
new
Date
(
dateAndTime
.
getTime
()
-
skew
);
}
if
(
nowMinusSkew
.
after
(
nextUpdate
)
||
nowPlusSkew
.
before
(
crlThisUpdate
))
{
if
(
debug
!=
null
)
{
debug
.
println
(
"X509CRLSelector.match: update out of range"
);
}
...
...
src/share/classes/java/util/logging/LogManager.java
浏览文件 @
7a9bd002
...
...
@@ -338,7 +338,7 @@ public class LogManager {
// already been created with the given name it is returned.
// Otherwise a new logger instance is created and registered
// in the LogManager global namespace.
synchronized
Logger
demandLogger
(
String
name
)
{
Logger
demandLogger
(
String
name
)
{
Logger
result
=
getLogger
(
name
);
if
(
result
==
null
)
{
result
=
new
Logger
(
name
,
null
);
...
...
src/share/classes/sun/nio/cs/Surrogate.java
浏览文件 @
7a9bd002
...
...
@@ -30,7 +30,6 @@ import java.nio.charset.CoderResult;
import
java.nio.charset.MalformedInputException
;
import
java.nio.charset.UnmappableCharacterException
;
/**
* Utility class for dealing with surrogates.
*
...
...
@@ -41,19 +40,15 @@ public class Surrogate {
private
Surrogate
()
{
}
// UTF-16 surrogate-character ranges
//
public
static
final
char
MIN_HIGH
=
'\
uD800
'
;
public
static
final
char
MAX_HIGH
=
'\
uDBFF
'
;
public
static
final
char
MIN_LOW
=
'\
uDC00
'
;
public
static
final
char
MAX_LOW
=
'\
uDFFF
'
;
public
static
final
char
MIN
=
MIN_HIGH
;
public
static
final
char
MAX
=
MAX_LOW
;
// Range of UCS-4 values that need surrogates in UTF-16
//
public
static
final
int
UCS4_MIN
=
0x10000
;
public
static
final
int
UCS4_MAX
=
(
1
<<
20
)
+
UCS4_MIN
-
1
;
// TODO: Deprecate/remove the following redundant definitions
public
static
final
char
MIN_HIGH
=
Character
.
MIN_HIGH_SURROGATE
;
public
static
final
char
MAX_HIGH
=
Character
.
MAX_HIGH_SURROGATE
;
public
static
final
char
MIN_LOW
=
Character
.
MIN_LOW_SURROGATE
;
public
static
final
char
MAX_LOW
=
Character
.
MAX_LOW_SURROGATE
;
public
static
final
char
MIN
=
Character
.
MIN_SURROGATE
;
public
static
final
char
MAX
=
Character
.
MAX_SURROGATE
;
public
static
final
int
UCS4_MIN
=
Character
.
MIN_SUPPLEMENTARY_CODE_POINT
;
public
static
final
int
UCS4_MAX
=
Character
.
MAX_CODE_POINT
;
/**
* Tells whether or not the given UTF-16 value is a high surrogate.
...
...
@@ -76,36 +71,46 @@ public class Surrogate {
return
(
MIN
<=
c
)
&&
(
c
<=
MAX
);
}
/**
* Tells whether or not the given UCS-4 character is in the Basic
* Multilingual Plane, and can be represented using a single char.
*/
public
static
boolean
isBMP
(
int
uc
)
{
return
(
int
)
(
char
)
uc
==
uc
;
}
/**
* Tells whether or not the given UCS-4 character must be represented as a
* surrogate pair in UTF-16.
*/
public
static
boolean
neededFor
(
int
uc
)
{
return
(
uc
>=
UCS4_MIN
)
&&
(
uc
<=
UCS4_MAX
);
return
Character
.
isSupplementaryCodePoint
(
uc
);
}
/**
* Returns the high UTF-16 surrogate for the given UCS-4 character.
*/
public
static
char
high
(
int
uc
)
{
assert
neededFor
(
uc
);
return
(
char
)(
0xd800
|
(((
uc
-
UCS4_MIN
)
>>
10
)
&
0x3ff
));
assert
Character
.
isSupplementaryCodePoint
(
uc
);
return
(
char
)((
uc
>>
10
)
+
(
Character
.
MIN_HIGH_SURROGATE
-
(
Character
.
MIN_SUPPLEMENTARY_CODE_POINT
>>
10
)));
}
/**
* Returns the low UTF-16 surrogate for the given UCS-4 character.
*/
public
static
char
low
(
int
uc
)
{
assert
neededFor
(
uc
);
return
(
char
)(
0xdc00
|
((
uc
-
UCS4_MIN
)
&
0x3ff
)
);
assert
Character
.
isSupplementaryCodePoint
(
uc
);
return
(
char
)(
(
uc
&
0x3ff
)
+
Character
.
MIN_LOW_SURROGATE
);
}
/**
* Converts the given surrogate pair into a 32-bit UCS-4 character.
*/
public
static
int
toUCS4
(
char
c
,
char
d
)
{
assert
isHigh
(
c
)
&&
isLow
(
d
);
return
(((
c
&
0x3ff
)
<<
10
)
|
(
d
&
0x3ff
))
+
0x10000
;
assert
Character
.
isHighSurrogate
(
c
)
&&
Character
.
isLowSurrogate
(
d
);
return
Character
.
toCodePoint
(
c
,
d
)
;
}
/**
...
...
@@ -178,14 +183,14 @@ public class Surrogate {
* object
*/
public
int
parse
(
char
c
,
CharBuffer
in
)
{
if
(
Surrogate
.
isHigh
(
c
))
{
if
(
Character
.
isHighSurrogate
(
c
))
{
if
(!
in
.
hasRemaining
())
{
error
=
CoderResult
.
UNDERFLOW
;
return
-
1
;
}
char
d
=
in
.
get
();
if
(
Surrogate
.
isLow
(
d
))
{
character
=
toUCS4
(
c
,
d
);
if
(
Character
.
isLowSurrogate
(
d
))
{
character
=
Character
.
toCodePoint
(
c
,
d
);
isPair
=
true
;
error
=
null
;
return
character
;
...
...
@@ -193,7 +198,7 @@ public class Surrogate {
error
=
CoderResult
.
malformedForLength
(
1
);
return
-
1
;
}
if
(
Surrogate
.
isLow
(
c
))
{
if
(
Character
.
isLowSurrogate
(
c
))
{
error
=
CoderResult
.
malformedForLength
(
1
);
return
-
1
;
}
...
...
@@ -220,14 +225,14 @@ public class Surrogate {
*/
public
int
parse
(
char
c
,
char
[]
ia
,
int
ip
,
int
il
)
{
assert
(
ia
[
ip
]
==
c
);
if
(
Surrogate
.
isHigh
(
c
))
{
if
(
Character
.
isHighSurrogate
(
c
))
{
if
(
il
-
ip
<
2
)
{
error
=
CoderResult
.
UNDERFLOW
;
return
-
1
;
}
char
d
=
ia
[
ip
+
1
];
if
(
Surrogate
.
isLow
(
d
))
{
character
=
toUCS4
(
c
,
d
);
if
(
Character
.
isLowSurrogate
(
d
))
{
character
=
Character
.
toCodePoint
(
c
,
d
);
isPair
=
true
;
error
=
null
;
return
character
;
...
...
@@ -235,7 +240,7 @@ public class Surrogate {
error
=
CoderResult
.
malformedForLength
(
1
);
return
-
1
;
}
if
(
Surrogate
.
isLow
(
c
))
{
if
(
Character
.
isLowSurrogate
(
c
))
{
error
=
CoderResult
.
malformedForLength
(
1
);
return
-
1
;
}
...
...
@@ -282,7 +287,7 @@ public class Surrogate {
* error() will return a descriptive result object
*/
public
int
generate
(
int
uc
,
int
len
,
CharBuffer
dst
)
{
if
(
uc
<=
0xffff
)
{
if
(
Surrogate
.
isBMP
(
uc
)
)
{
if
(
Surrogate
.
is
(
uc
))
{
error
=
CoderResult
.
malformedForLength
(
len
);
return
-
1
;
...
...
@@ -294,12 +299,7 @@ public class Surrogate {
dst
.
put
((
char
)
uc
);
error
=
null
;
return
1
;
}
if
(
uc
<
Surrogate
.
UCS4_MIN
)
{
error
=
CoderResult
.
malformedForLength
(
len
);
return
-
1
;
}
if
(
uc
<=
Surrogate
.
UCS4_MAX
)
{
}
else
if
(
Character
.
isSupplementaryCodePoint
(
uc
))
{
if
(
dst
.
remaining
()
<
2
)
{
error
=
CoderResult
.
OVERFLOW
;
return
-
1
;
...
...
@@ -308,9 +308,10 @@ public class Surrogate {
dst
.
put
(
Surrogate
.
low
(
uc
));
error
=
null
;
return
2
;
}
else
{
error
=
CoderResult
.
unmappableForLength
(
len
);
return
-
1
;
}
error
=
CoderResult
.
unmappableForLength
(
len
);
return
-
1
;
}
/**
...
...
@@ -330,7 +331,7 @@ public class Surrogate {
* error() will return a descriptive result object
*/
public
int
generate
(
int
uc
,
int
len
,
char
[]
da
,
int
dp
,
int
dl
)
{
if
(
uc
<=
0xffff
)
{
if
(
Surrogate
.
isBMP
(
uc
)
)
{
if
(
Surrogate
.
is
(
uc
))
{
error
=
CoderResult
.
malformedForLength
(
len
);
return
-
1
;
...
...
@@ -342,12 +343,7 @@ public class Surrogate {
da
[
dp
]
=
(
char
)
uc
;
error
=
null
;
return
1
;
}
if
(
uc
<
Surrogate
.
UCS4_MIN
)
{
error
=
CoderResult
.
malformedForLength
(
len
);
return
-
1
;
}
if
(
uc
<=
Surrogate
.
UCS4_MAX
)
{
}
else
if
(
Character
.
isSupplementaryCodePoint
(
uc
))
{
if
(
dl
-
dp
<
2
)
{
error
=
CoderResult
.
OVERFLOW
;
return
-
1
;
...
...
@@ -356,11 +352,11 @@ public class Surrogate {
da
[
dp
+
1
]
=
Surrogate
.
low
(
uc
);
error
=
null
;
return
2
;
}
else
{
error
=
CoderResult
.
unmappableForLength
(
len
);
return
-
1
;
}
error
=
CoderResult
.
unmappableForLength
(
len
);
return
-
1
;
}
}
}
src/share/classes/sun/security/krb5/Config.java
浏览文件 @
7a9bd002
...
...
@@ -70,7 +70,12 @@ public class Config {
private
static
final
int
BASE16_1
=
16
;
private
static
final
int
BASE16_2
=
16
*
16
;
private
static
final
int
BASE16_3
=
16
*
16
*
16
;
private
String
defaultRealm
;
// default kdc realm.
/**
* Specified by system properties. Must be both null or non-null.
*/
private
final
String
defaultRealm
;
private
final
String
defaultKDC
;
// used for native interface
private
static
native
String
getWindowsDirectory
(
boolean
isSystem
);
...
...
@@ -81,9 +86,8 @@ public class Config {
* singleton) is returned.
*
* @exception KrbException if error occurs when constructing a Config
* instance. Possible causes would be configuration file not
* found, either of java.security.krb5.realm or java.security.krb5.kdc
* not specified, error reading configuration file.
* instance. Possible causes would be either of java.security.krb5.realm or
* java.security.krb5.kdc not specified, error reading configuration file.
*/
public
static
synchronized
Config
getInstance
()
throws
KrbException
{
if
(
singleton
==
null
)
{
...
...
@@ -98,9 +102,8 @@ public class Config {
* the java.security.krb5.* system properties again.
*
* @exception KrbException if error occurs when constructing a Config
* instance. Possible causes would be configuration file not
* found, either of java.security.krb5.realm or java.security.krb5.kdc
* not specified, error reading configuration file.
* instance. Possible causes would be either of java.security.krb5.realm or
* java.security.krb5.kdc not specified, error reading configuration file.
*/
public
static
synchronized
void
refresh
()
throws
KrbException
{
...
...
@@ -114,56 +117,37 @@ public class Config {
*/
private
Config
()
throws
KrbException
{
/*
* If these two system properties are being specified by the user,
* we ignore configuration file. If either one system property is
* specified, we throw exception. If neither of them are specified,
* we load the information from configuration file.
* If either one system property is specified, we throw exception.
*/
String
kdchost
=
String
tmp
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"java.security.krb5.kdc"
));
if
(
tmp
!=
null
)
{
// The user can specify a list of kdc hosts separated by ":"
defaultKDC
=
tmp
.
replace
(
':'
,
' '
);
}
else
{
defaultKDC
=
null
;
}
defaultRealm
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"java.security.krb5.realm"
));
if
((
kdchost
==
null
&&
defaultRealm
!=
null
)
||
(
defaultRealm
==
null
&&
kdchost
!=
null
))
{
if
((
defaultKDC
==
null
&&
defaultRealm
!=
null
)
||
(
defaultRealm
==
null
&&
defaultKDC
!=
null
))
{
throw
new
KrbException
(
"System property java.security.krb5.kdc and "
+
"java.security.krb5.realm both must be set or "
+
"neither must be set."
);
}
//
R
ead the Kerberos configuration file
//
Always r
ead the Kerberos configuration file
try
{
Vector
<
String
>
configFile
;
configFile
=
loadConfigFile
();
stanzaTable
=
parseStanzaTable
(
configFile
);
}
catch
(
IOException
ioe
)
{
// No krb5.conf, no problem. We'll use DNS etc.
}
if
(
kdchost
!=
null
)
{
/*
* If configuration information is only specified by
* properties java.security.krb5.kdc and
* java.security.krb5.realm, we put both in the hashtable
* under [libdefaults].
*/
if
(
stanzaTable
==
null
)
{
stanzaTable
=
new
Hashtable
<
String
,
Object
>
();
}
Hashtable
<
String
,
String
>
kdcs
=
(
Hashtable
<
String
,
String
>)
stanzaTable
.
get
(
"libdefaults"
);
if
(
kdcs
==
null
)
{
kdcs
=
new
Hashtable
<
String
,
String
>
();
stanzaTable
.
put
(
"libdefaults"
,
kdcs
);
}
kdcs
.
put
(
"default_realm"
,
defaultRealm
);
// The user can specify a list of kdc hosts separated by ":"
kdchost
=
kdchost
.
replace
(
':'
,
' '
);
kdcs
.
put
(
"kdc"
,
kdchost
);
// No krb5.conf, no problem. We'll use DNS or system property etc.
}
}
...
...
@@ -295,19 +279,6 @@ public class Config {
String
result
=
null
;
Hashtable
subTable
;
/*
* In the situation when kdc is specified by
* java.security.krb5.kdc, we get the kdc from [libdefaults] in
* hashtable.
*/
if
(
name
.
equalsIgnoreCase
(
"kdc"
)
&&
(
section
.
equalsIgnoreCase
(
getDefault
(
"default_realm"
,
"libdefaults"
)))
&&
(
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"java.security.krb5.kdc"
))
!=
null
))
{
result
=
getDefault
(
"kdc"
,
"libdefaults"
);
return
result
;
}
if
(
stanzaTable
!=
null
)
{
for
(
Enumeration
e
=
stanzaTable
.
keys
();
e
.
hasMoreElements
();
)
{
stanzaName
=
(
String
)
e
.
nextElement
();
...
...
@@ -1035,13 +1006,13 @@ public class Config {
/**
* Resets the default kdc realm.
* We do not need to synchronize these methods since assignments are atomic
*
* This method was useless. Kept here in case some class still calls it.
*/
public
void
resetDefaultRealm
(
String
realm
)
{
defaultRealm
=
realm
;
if
(
DEBUG
)
{
System
.
out
.
println
(
">>> Config
reset default kdc "
+
defaultR
ealm
);
System
.
out
.
println
(
">>> Config
try resetting default kdc "
+
r
ealm
);
}
}
/**
...
...
@@ -1098,6 +1069,9 @@ public class Config {
* @return the default realm, always non null
*/
public
String
getDefaultRealm
()
throws
KrbException
{
if
(
defaultRealm
!=
null
)
{
return
defaultRealm
;
}
Exception
cause
=
null
;
String
realm
=
getDefault
(
"default_realm"
,
"libdefaults"
);
if
((
realm
==
null
)
&&
useDNS_Realm
())
{
...
...
@@ -1142,6 +1116,9 @@ public class Config {
if
(
realm
==
null
)
{
realm
=
getDefaultRealm
();
}
if
(
realm
.
equalsIgnoreCase
(
defaultRealm
))
{
return
defaultKDC
;
}
Exception
cause
=
null
;
String
kdcs
=
getDefault
(
"kdc"
,
realm
);
if
((
kdcs
==
null
)
&&
useDNS_KDC
())
{
...
...
@@ -1171,6 +1148,9 @@ public class Config {
});
}
if
(
kdcs
==
null
)
{
if
(
defaultKDC
!=
null
)
{
return
defaultKDC
;
}
KrbException
ke
=
new
KrbException
(
"Cannot locate KDC"
);
if
(
cause
!=
null
)
{
ke
.
initCause
(
cause
);
...
...
src/share/classes/sun/security/krb5/KrbApReq.java
浏览文件 @
7a9bd002
...
...
@@ -294,8 +294,6 @@ public class KrbApReq {
apReqMessg
.
ticket
.
sname
.
setRealm
(
apReqMessg
.
ticket
.
realm
);
enc_ticketPart
.
cname
.
setRealm
(
enc_ticketPart
.
crealm
);
Config
.
getInstance
().
resetDefaultRealm
(
apReqMessg
.
ticket
.
realm
.
toString
());
if
(!
authenticator
.
cname
.
equals
(
enc_ticketPart
.
cname
))
throw
new
KrbApErrException
(
Krb5
.
KRB_AP_ERR_BADMATCH
);
...
...
src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
浏览文件 @
7a9bd002
/*
* Portions Copyright 2000-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Portions Copyright 2000-200
9
Sun Microsystems, Inc. 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
...
...
@@ -403,11 +403,11 @@ public class KeyTab implements KeyTabConstants {
/**
* Retrieves the key table entry with the specified service name.
* @param service the service which may have an entry in the key table.
* @param keyType the etype to match, returns the 1st one if -1 provided
* @return -1 if the entry is not found, else return the entry index
* in the list.
*/
private
int
retrieveEntry
(
PrincipalName
service
,
int
keyType
)
{
int
found
=
-
1
;
KeyTabEntry
e
;
if
(
entries
!=
null
)
{
for
(
int
i
=
0
;
i
<
entries
.
size
();
i
++)
{
...
...
@@ -418,7 +418,7 @@ public class KeyTab implements KeyTabConstants {
}
}
}
return
found
;
return
-
1
;
}
/**
...
...
@@ -476,12 +476,29 @@ public class KeyTab implements KeyTabConstants {
/**
* Removes an entry from the key table.
* @param service the service <code>PrincipalName</code>.
* @param etype the etype to match, first one if -1 provided
* @return 1 if removed successfully, 0 otherwise
*/
public
void
deleteEntry
(
PrincipalName
servic
e
)
{
int
result
=
retrieveEntry
(
service
,
-
1
);
public
int
deleteEntry
(
PrincipalName
service
,
int
etyp
e
)
{
int
result
=
retrieveEntry
(
service
,
etype
);
if
(
result
!=
-
1
)
{
entries
.
removeElementAt
(
result
);
return
1
;
}
return
0
;
}
/**
* Removes an entry from the key table.
* @param service the service <code>PrincipalName</code>.
* @return number of entries removed
*/
public
int
deleteEntry
(
PrincipalName
service
)
{
int
count
=
0
;
while
(
deleteEntry
(
service
,
-
1
)
>
0
)
{
count
++;
}
return
count
;
}
/**
...
...
src/share/classes/sun/security/provider/certpath/CertPathHelper.java
浏览文件 @
7a9bd002
/*
* Copyright 2002-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-200
9
Sun Microsystems, Inc. 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
...
...
@@ -25,9 +25,11 @@
package
sun.security.provider.certpath
;
import
java.util.Date
;
import
java.util.Set
;
import
java.security.cert.X509CertSelector
;
import
java.security.cert.X509CRLSelector
;
import
sun.security.x509.GeneralNameInterface
;
...
...
@@ -55,8 +57,14 @@ public abstract class CertPathHelper {
protected
abstract
void
implSetPathToNames
(
X509CertSelector
sel
,
Set
<
GeneralNameInterface
>
names
);
protected
abstract
void
implSetDateAndTime
(
X509CRLSelector
sel
,
Date
date
,
long
skew
);
static
void
setPathToNames
(
X509CertSelector
sel
,
Set
<
GeneralNameInterface
>
names
)
{
instance
.
implSetPathToNames
(
sel
,
names
);
}
static
void
setDateAndTime
(
X509CRLSelector
sel
,
Date
date
,
long
skew
)
{
instance
.
implSetDateAndTime
(
sel
,
date
,
skew
);
}
}
src/share/classes/sun/security/provider/certpath/CrlRevocationChecker.java
浏览文件 @
7a9bd002
/*
* Copyright 2000-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-200
9
Sun Microsystems, Inc. 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
...
...
@@ -81,6 +81,10 @@ class CrlRevocationChecker extends PKIXCertPathChecker {
private
static
final
boolean
[]
ALL_REASONS
=
{
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
,
true
};
// Maximum clock skew in milliseconds (15 minutes) allowed when checking
// validity of CRLs
private
static
final
long
MAX_CLOCK_SKEW
=
900000
;
/**
* Creates a <code>CrlRevocationChecker</code>.
*
...
...
@@ -281,7 +285,7 @@ class CrlRevocationChecker extends PKIXCertPathChecker {
try
{
X509CRLSelector
sel
=
new
X509CRLSelector
();
sel
.
setCertificateChecking
(
currCert
);
sel
.
setDateAndTime
(
mCurrentTime
);
CertPathHelper
.
setDateAndTime
(
sel
,
mCurrentTime
,
MAX_CLOCK_SKEW
);
for
(
CertStore
mStore
:
mStores
)
{
for
(
java
.
security
.
cert
.
CRL
crl
:
mStore
.
getCRLs
(
sel
))
{
...
...
src/share/classes/sun/security/provider/certpath/OCSPResponse.java
浏览文件 @
7a9bd002
...
...
@@ -149,9 +149,9 @@ class OCSPResponse {
private
SingleResponse
singleResponse
;
// Maximum clock skew in milliseconds (1
0
minutes) allowed when checking
// Maximum clock skew in milliseconds (1
5
minutes) allowed when checking
// validity of OCSP responses
private
static
final
long
MAX_CLOCK_SKEW
=
6
00000
;
private
static
final
long
MAX_CLOCK_SKEW
=
9
00000
;
// an array of all of the CRLReasons (used in SingleResponse)
private
static
CRLReason
[]
values
=
CRLReason
.
values
();
...
...
src/share/classes/sun/security/tools/JarSigner.java
浏览文件 @
7a9bd002
...
...
@@ -136,7 +136,7 @@ public class JarSigner {
char
[]
keypass
;
// private key password
String
sigfile
;
// name of .SF file
String
sigalg
;
// name of signature algorithm
String
digestalg
=
"SHA
1
"
;
// name of digest algorithm
String
digestalg
=
"SHA
-256
"
;
// name of digest algorithm
String
signedjar
;
// output filename
String
tsaUrl
;
// location of the Timestamping Authority
String
tsaAlias
;
// alias for the Timestamping Authority's certificate
...
...
@@ -2205,7 +2205,7 @@ class SignatureFile {
if
(
keyAlgorithm
.
equalsIgnoreCase
(
"DSA"
))
digestAlgorithm
=
"SHA1"
;
else
if
(
keyAlgorithm
.
equalsIgnoreCase
(
"RSA"
))
digestAlgorithm
=
"SHA
1
"
;
digestAlgorithm
=
"SHA
256
"
;
else
{
throw
new
RuntimeException
(
"private key is not a DSA or "
+
"RSA key"
);
...
...
src/share/classes/sun/security/tools/KeyTool.java
浏览文件 @
7a9bd002
...
...
@@ -1052,7 +1052,7 @@ public final class KeyTool {
X509CertImpl
signerCertImpl
=
new
X509CertImpl
(
encoded
);
X509CertInfo
signerCertInfo
=
(
X509CertInfo
)
signerCertImpl
.
get
(
X509CertImpl
.
NAME
+
"."
+
X509CertImpl
.
INFO
);
X500Name
own
er
=
(
X500Name
)
signerCertInfo
.
get
(
X509CertInfo
.
SUBJECT
+
"."
+
X500Name
issu
er
=
(
X500Name
)
signerCertInfo
.
get
(
X509CertInfo
.
SUBJECT
+
"."
+
CertificateSubjectName
.
DN_NAME
);
Date
firstDate
=
getStartDate
(
startDate
);
...
...
@@ -1068,7 +1068,7 @@ public final class KeyTool {
Signature
signature
=
Signature
.
getInstance
(
sigAlgName
);
signature
.
initSign
(
privateKey
);
X500Signer
signer
=
new
X500Signer
(
signature
,
own
er
);
X500Signer
signer
=
new
X500Signer
(
signature
,
issu
er
);
X509CertInfo
info
=
new
X509CertInfo
();
info
.
set
(
X509CertInfo
.
VALIDITY
,
interval
);
...
...
@@ -1102,7 +1102,8 @@ public final class KeyTool {
PKCS10
req
=
new
PKCS10
(
rawReq
);
info
.
set
(
X509CertInfo
.
KEY
,
new
CertificateX509Key
(
req
.
getSubjectPublicKeyInfo
()));
info
.
set
(
X509CertInfo
.
SUBJECT
,
new
CertificateSubjectName
(
req
.
getSubjectName
()));
info
.
set
(
X509CertInfo
.
SUBJECT
,
new
CertificateSubjectName
(
dname
==
null
?
req
.
getSubjectName
():
new
X500Name
(
dname
)));
CertificateExtensions
reqex
=
null
;
Iterator
<
PKCS10Attribute
>
attrs
=
req
.
getAttributes
().
getAttributes
().
iterator
();
while
(
attrs
.
hasNext
())
{
...
...
@@ -1160,8 +1161,9 @@ public final class KeyTool {
Signature
signature
=
Signature
.
getInstance
(
sigAlgName
);
signature
.
initSign
(
privKey
);
X500Name
subject
=
new
X500Name
(((
X509Certificate
)
cert
).
getSubjectDN
().
toString
());
X500Name
subject
=
dname
==
null
?
new
X500Name
(((
X509Certificate
)
cert
).
getSubjectDN
().
toString
()):
new
X500Name
(
dname
);
X500Signer
signer
=
new
X500Signer
(
signature
,
subject
);
// Sign the request and base-64 encode it
...
...
@@ -1316,7 +1318,7 @@ public final class KeyTool {
if
(
"DSA"
.
equalsIgnoreCase
(
keyAlgName
))
{
return
"SHA1WithDSA"
;
}
else
if
(
"RSA"
.
equalsIgnoreCase
(
keyAlgName
))
{
return
"SHA
1
WithRSA"
;
return
"SHA
256
WithRSA"
;
}
else
if
(
"EC"
.
equalsIgnoreCase
(
keyAlgName
))
{
return
"SHA1withECDSA"
;
}
else
{
...
...
@@ -1334,6 +1336,8 @@ public final class KeyTool {
if
(
keysize
==
-
1
)
{
if
(
"EC"
.
equalsIgnoreCase
(
keyAlgName
))
{
keysize
=
256
;
}
else
if
(
"RSA"
.
equalsIgnoreCase
(
keyAlgName
))
{
keysize
=
2048
;
}
else
{
keysize
=
1024
;
}
...
...
@@ -2497,6 +2501,7 @@ public final class KeyTool {
cert
.
getNotAfter
().
toString
(),
getCertFingerPrint
(
"MD5"
,
cert
),
getCertFingerPrint
(
"SHA1"
,
cert
),
getCertFingerPrint
(
"SHA-256"
,
cert
),
cert
.
getSigAlgName
(),
cert
.
getVersion
()
};
...
...
@@ -3428,7 +3433,7 @@ public final class KeyTool {
int
colonpos
=
name
.
indexOf
(
':'
);
if
(
colonpos
>=
0
)
{
if
(
name
.
substring
(
colonpos
+
1
).
equalsIgnoreCase
(
"critical"
)
)
{
if
(
oneOf
(
name
.
substring
(
colonpos
+
1
),
"critical"
)
==
0
)
{
isCritical
=
true
;
}
name
=
name
.
substring
(
0
,
colonpos
);
...
...
@@ -3688,6 +3693,8 @@ public final class KeyTool {
(
"-certreq [-v] [-protected]"
));
System
.
err
.
println
(
rb
.
getString
(
"\t [-alias <alias>] [-sigalg <sigalg>]"
));
System
.
err
.
println
(
rb
.
getString
(
"\t [-dname <dname>]"
));
System
.
err
.
println
(
rb
.
getString
(
"\t [-file <csr_file>] [-keypass <keypass>]"
));
System
.
err
.
println
(
rb
.
getString
...
...
@@ -3770,6 +3777,8 @@ public final class KeyTool {
(
"\t [-infile <infile>] [-outfile <outfile>]"
));
System
.
err
.
println
(
rb
.
getString
(
"\t [-alias <alias>]"
));
System
.
err
.
println
(
rb
.
getString
(
"\t [-dname <dname>]"
));
System
.
err
.
println
(
rb
.
getString
(
"\t [-sigalg <sigalg>]"
));
System
.
err
.
println
(
rb
.
getString
...
...
src/share/classes/sun/security/util/Resources.java
浏览文件 @
7a9bd002
...
...
@@ -215,7 +215,7 @@ public class Resources extends java.util.ListResourceBundle {
{
"\t(RETURN if same as for <otherAlias>)"
,
"\t(RETURN if same as for <{0}>)"
},
{
"*PATTERN* printX509Cert"
,
"Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t MD5: {5}\n\t SHA1: {6}\n\t S
ignature algorithm name: {7}\n\t Version: {8
}"
},
"Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t MD5: {5}\n\t SHA1: {6}\n\t S
HA256: {7}\n\t Signature algorithm name: {8}\n\t Version: {9
}"
},
{
"What is your first and last name?"
,
"What is your first and last name?"
},
{
"What is the name of your organizational unit?"
,
...
...
@@ -301,6 +301,7 @@ public class Resources extends java.util.ListResourceBundle {
"-certreq [-v] [-protected]"
},
{
"\t [-alias <alias>] [-sigalg <sigalg>]"
,
"\t [-alias <alias>] [-sigalg <sigalg>]"
},
{
"\t [-dname <dname>]"
,
"\t [-dname <dname>]"
},
{
"\t [-file <csr_file>] [-keypass <keypass>]"
,
"\t [-file <csr_file>] [-keypass <keypass>]"
},
{
"\t [-keystore <keystore>] [-storepass <storepass>]"
,
...
...
src/share/native/sun/security/pkcs11/wrapper/p11_general.c
浏览文件 @
7a9bd002
...
...
@@ -337,7 +337,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetSlotList
CK_ULONG
ckTokenNumber
;
CK_SLOT_ID_PTR
ckpSlotList
;
CK_BBOOL
ckTokenPresent
;
jlongArray
jSlotList
;
jlongArray
jSlotList
=
NULL
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -637,7 +637,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetMechanismList
CK_SLOT_ID
ckSlotID
;
CK_ULONG
ckMechanismNumber
;
CK_MECHANISM_TYPE_PTR
ckpMechanismList
;
jlongArray
jMechanismList
;
jlongArray
jMechanismList
=
NULL
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
src/share/native/sun/security/pkcs11/wrapper/p11_keymgmt.c
浏览文件 @
7a9bd002
...
...
@@ -73,9 +73,8 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateKey
CK_MECHANISM
ckMechanism
;
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
CK_OBJECT_HANDLE
ckKeyHandle
;
CK_OBJECT_HANDLE
ckKeyHandle
=
0
;
jlong
jKeyHandle
=
0L
;
CK_ULONG
i
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -151,8 +150,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate
CK_OBJECT_HANDLE_PTR
ckpPublicKeyHandle
;
/* pointer to Public Key */
CK_OBJECT_HANDLE_PTR
ckpPrivateKeyHandle
;
/* pointer to Private Key */
CK_OBJECT_HANDLE_PTR
ckpKeyHandles
;
/* pointer to array with Public and Private Key */
jlongArray
jKeyHandles
;
CK_ULONG
i
;
jlongArray
jKeyHandles
=
NULL
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -299,9 +297,8 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1UnwrapKey
CK_ULONG
ckWrappedKeyLength
;
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
CK_OBJECT_HANDLE
ckKeyHandle
;
CK_OBJECT_HANDLE
ckKeyHandle
=
0
;
jlong
jKeyHandle
=
0L
;
CK_ULONG
i
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -478,8 +475,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DeriveKey
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
CK_OBJECT_HANDLE
ckKeyHandle
=
0
;
jlong
jKeyHandle
;
CK_ULONG
i
;
jlong
jKeyHandle
=
0L
;
CK_RV
rv
;
CK_OBJECT_HANDLE_PTR
phKey
=
&
ckKeyHandle
;
...
...
src/share/native/sun/security/pkcs11/wrapper/p11_objmgmt.c
浏览文件 @
7a9bd002
...
...
@@ -72,8 +72,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CreateObject
CK_OBJECT_HANDLE
ckObjectHandle
;
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
jlong
jObjectHandle
;
CK_ULONG
i
;
jlong
jObjectHandle
=
0L
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -114,8 +113,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CopyObject
CK_OBJECT_HANDLE
ckNewObjectHandle
;
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
jlong
jNewObjectHandle
;
CK_ULONG
i
;
jlong
jNewObjectHandle
=
0L
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -180,7 +178,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetObjectSize
CK_SESSION_HANDLE
ckSessionHandle
;
CK_OBJECT_HANDLE
ckObjectHandle
;
CK_ULONG
ckObjectSize
;
jlong
jObjectSize
;
jlong
jObjectSize
=
0L
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -217,7 +215,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetAttributeVa
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
CK_ULONG
ckBufferLength
;
CK_ULONG
i
,
j
;
CK_ULONG
i
;
jobject
jAttribute
;
CK_RV
rv
;
...
...
@@ -307,7 +305,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SetAttributeVa
CK_OBJECT_HANDLE
ckObjectHandle
;
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
CK_ULONG
i
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -342,7 +339,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObjectsIni
CK_SESSION_HANDLE
ckSessionHandle
;
CK_ATTRIBUTE_PTR
ckpAttributes
=
NULL_PTR
;
CK_ULONG
ckAttributesLength
;
CK_ULONG
i
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
@@ -385,7 +381,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1FindObje
CK_ULONG
ckMaxObjectLength
;
CK_OBJECT_HANDLE_PTR
ckpObjectHandleArray
;
CK_ULONG
ckActualObjectCount
;
jlongArray
jObjectHandleArray
;
jlongArray
jObjectHandleArray
=
NULL
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
if
(
ckpFunctions
==
NULL
)
{
return
NULL
;
}
...
...
src/share/native/sun/security/pkcs11/wrapper/p11_sign.c
浏览文件 @
7a9bd002
...
...
@@ -110,7 +110,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Sign
CK_BYTE_PTR
ckpSignature
;
CK_ULONG
ckDataLength
;
CK_ULONG
ckSignatureLength
=
0
;
jbyteArray
jSignature
;
jbyteArray
jSignature
=
NULL
;
CK_RV
rv
;
CK_FUNCTION_LIST_PTR
ckpFunctions
=
getFunctionList
(
env
,
obj
);
...
...
src/share/native/sun/security/pkcs11/wrapper/p11_util.c
浏览文件 @
7a9bd002
...
...
@@ -194,16 +194,14 @@ jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue)
jclass
jPKCS11ExceptionClass
;
jmethodID
jConstructor
;
jthrowable
jPKCS11Exception
;
jlong
jErrorCode
;
jlong
jErrorCode
=
0L
;
if
(
returnValue
==
CKR_OK
)
{
return
0L
;
}
else
{
if
(
returnValue
!=
CKR_OK
)
{
jErrorCode
=
ckULongToJLong
(
returnValue
);
jPKCS11ExceptionClass
=
(
*
env
)
->
FindClass
(
env
,
CLASS_PKCS11EXCEPTION
);
if
(
jPKCS11ExceptionClass
!=
NULL
)
{
jConstructor
=
(
*
env
)
->
GetMethodID
(
env
,
jPKCS11ExceptionClass
,
"<init>"
,
"(J)V"
);
if
(
jConstructor
!=
NULL
)
{
jErrorCode
=
ckULongToJLong
(
returnValue
);
jPKCS11Exception
=
(
jthrowable
)
(
*
env
)
->
NewObject
(
env
,
jPKCS11ExceptionClass
,
jConstructor
,
jErrorCode
);
if
(
jPKCS11Exception
!=
NULL
)
{
(
*
env
)
->
Throw
(
env
,
jPKCS11Exception
);
...
...
@@ -211,8 +209,8 @@ jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue)
}
}
(
*
env
)
->
DeleteLocalRef
(
env
,
jPKCS11ExceptionClass
);
return
jErrorCode
;
}
return
jErrorCode
;
}
/*
...
...
src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
浏览文件 @
7a9bd002
...
...
@@ -300,7 +300,7 @@ void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jAArray, CK_ATT
/* funktions to convert a CK-type array and the array length to a Java array */
j
char
Array
ckByteArrayToJByteArray
(
JNIEnv
*
env
,
const
CK_BYTE_PTR
ckpArray
,
CK_ULONG
ckLength
);
j
byte
Array
ckByteArrayToJByteArray
(
JNIEnv
*
env
,
const
CK_BYTE_PTR
ckpArray
,
CK_ULONG
ckLength
);
jlongArray
ckULongArrayToJLongArray
(
JNIEnv
*
env
,
const
CK_ULONG_PTR
ckpArray
,
CK_ULONG
ckLength
);
jcharArray
ckCharArrayToJCharArray
(
JNIEnv
*
env
,
const
CK_CHAR_PTR
ckpArray
,
CK_ULONG
length
);
jcharArray
ckUTF8CharArrayToJCharArray
(
JNIEnv
*
env
,
const
CK_UTF8CHAR_PTR
ckpArray
,
CK_ULONG
ckLength
);
...
...
src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
浏览文件 @
7a9bd002
...
...
@@ -127,8 +127,6 @@ public class SctpChannelImpl extends SctpChannel
/* -- End of fields protected by stateLock -- */
private
SctpResultContainer
commUpResultContainer
;
/* null */
/**
* Constructor for normal connecting sockets
*/
...
...
@@ -761,12 +759,6 @@ public class SctpChannelImpl extends SctpChannel
if
(!
ensureReceiveOpen
())
return
null
;
if
(
commUpResultContainer
!=
null
)
{
resultContainer
=
commUpResultContainer
;
commUpResultContainer
=
null
;
continue
;
}
int
n
=
0
;
try
{
begin
();
...
...
@@ -778,7 +770,7 @@ public class SctpChannelImpl extends SctpChannel
}
do
{
n
=
receive
(
fdVal
,
buffer
,
resultContainer
);
n
=
receive
(
fdVal
,
buffer
,
resultContainer
,
fromConnect
);
}
while
((
n
==
IOStatus
.
INTERRUPTED
)
&&
isOpen
());
}
finally
{
receiverCleanup
();
...
...
@@ -809,9 +801,9 @@ public class SctpChannelImpl extends SctpChannel
if
(
fromConnect
)
{
/* If we reach here, then it was connect that invoked
* receive an
received the COMM_UP. Save it and allow
*
the user handler to process it upon next receive. */
commUpResultContainer
=
resultContainer
;
* receive an
d received the COMM_UP. We have already
*
handled the COMM_UP with the internal notification
* handler. Simply return. */
return
null
;
}
}
/* receiveLock */
...
...
@@ -827,20 +819,21 @@ public class SctpChannelImpl extends SctpChannel
private
int
receive
(
int
fd
,
ByteBuffer
dst
,
SctpResultContainer
resultContainer
)
SctpResultContainer
resultContainer
,
boolean
peek
)
throws
IOException
{
int
pos
=
dst
.
position
();
int
lim
=
dst
.
limit
();
assert
(
pos
<=
lim
);
int
rem
=
(
pos
<=
lim
?
lim
-
pos
:
0
);
if
(
dst
instanceof
DirectBuffer
&&
rem
>
0
)
return
receiveIntoNativeBuffer
(
fd
,
resultContainer
,
dst
,
rem
,
pos
);
return
receiveIntoNativeBuffer
(
fd
,
resultContainer
,
dst
,
rem
,
pos
,
peek
);
/* Substitute a native buffer */
int
newSize
=
Math
.
max
(
rem
,
1
);
ByteBuffer
bb
=
Util
.
getTemporaryDirectBuffer
(
newSize
);
try
{
int
n
=
receiveIntoNativeBuffer
(
fd
,
resultContainer
,
bb
,
newSize
,
0
);
int
n
=
receiveIntoNativeBuffer
(
fd
,
resultContainer
,
bb
,
newSize
,
0
,
peek
);
bb
.
flip
();
if
(
n
>
0
&&
rem
>
0
)
dst
.
put
(
bb
);
...
...
@@ -854,10 +847,11 @@ public class SctpChannelImpl extends SctpChannel
SctpResultContainer
resultContainer
,
ByteBuffer
bb
,
int
rem
,
int
pos
)
int
pos
,
boolean
peek
)
throws
IOException
{
int
n
=
receive0
(
fd
,
resultContainer
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
);
int
n
=
receive0
(
fd
,
resultContainer
,
((
DirectBuffer
)
bb
).
address
()
+
pos
,
rem
,
peek
);
if
(
n
>
0
)
bb
.
position
(
pos
+
n
);
...
...
@@ -1089,7 +1083,7 @@ public class SctpChannelImpl extends SctpChannel
private
static
native
void
initIDs
();
static
native
int
receive0
(
int
fd
,
SctpResultContainer
resultContainer
,
long
address
,
int
length
)
throws
IOException
;
long
address
,
int
length
,
boolean
peek
)
throws
IOException
;
static
native
int
send0
(
int
fd
,
long
address
,
int
length
,
SocketAddress
target
,
int
assocId
,
int
streamNumber
,
...
...
src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
浏览文件 @
7a9bd002
...
...
@@ -31,6 +31,8 @@ import java.net.InetSocketAddress;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.Map.Entry
;
import
java.util.Iterator
;
import
java.util.Set
;
import
java.util.HashSet
;
import
java.util.HashMap
;
...
...
@@ -702,7 +704,7 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
int
assocId
=
association
.
associationID
();
Set
<
SocketAddress
>
addresses
=
null
;
try
{
try
{
addresses
=
SctpNet
.
getRemoteAddresses
(
fdVal
,
assocId
);
}
catch
(
IOException
unused
)
{
/* OK, determining connected addresses may not be possible
...
...
@@ -723,9 +725,11 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
/* We cannot determine the connected addresses */
Set
<
java
.
util
.
Map
.
Entry
<
SocketAddress
,
Association
>>
addrAssocs
=
addressMap
.
entrySet
();
for
(
java
.
util
.
Map
.
Entry
<
SocketAddress
,
Association
>
entry
:
addrAssocs
)
{
Iterator
<
Entry
<
SocketAddress
,
Association
>>
iterator
=
addrAssocs
.
iterator
();
while
(
iterator
.
hasNext
())
{
Entry
<
SocketAddress
,
Association
>
entry
=
iterator
.
next
();
if
(
entry
.
getValue
().
equals
(
association
))
{
addressMap
.
remove
(
entry
.
getKey
()
);
iterator
.
remove
(
);
}
}
}
...
...
@@ -957,7 +961,7 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
int
length
)
throws
IOException
{
return
SctpChannelImpl
.
receive0
(
fd
,
resultContainer
,
address
,
length
);
length
,
false
/*peek */
);
}
private
static
int
send0
(
int
fd
,
...
...
src/solaris/native/sun/nio/ch/SctpChannelImpl.c
浏览文件 @
7a9bd002
...
...
@@ -417,11 +417,11 @@ void handleMessage
/*
* Class: sun_nio_ch_SctpChannelImpl
* Method: receive0
* Signature: (ILsun/nio/ch/SctpResultContainer;JI)I
* Signature: (ILsun/nio/ch/SctpResultContainer;JI
Z
)I
*/
JNIEXPORT
jint
JNICALL
Java_sun_nio_ch_SctpChannelImpl_receive0
(
JNIEnv
*
env
,
jclass
klass
,
jint
fd
,
jobject
resultContainerObj
,
jlong
address
,
jint
length
)
{
jlong
address
,
jint
length
,
jboolean
peek
)
{
SOCKADDR
sa
;
int
sa_len
=
sizeof
(
sa
);
ssize_t
rv
=
0
;
...
...
@@ -429,6 +429,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0
struct
iovec
iov
[
1
];
struct
msghdr
msg
[
1
];
char
cbuf
[
CMSG_SPACE
(
sizeof
(
struct
sctp_sndrcvinfo
))];
int
flags
=
peek
==
JNI_TRUE
?
MSG_PEEK
:
0
;
/* Set up the msghdr structure for receiving */
memset
(
msg
,
0
,
sizeof
(
*
msg
));
...
...
@@ -443,7 +444,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0
msg
->
msg_flags
=
0
;
do
{
if
((
rv
=
recvmsg
(
fd
,
msg
,
0
))
<
0
)
{
if
((
rv
=
recvmsg
(
fd
,
msg
,
flags
))
<
0
)
{
if
(
errno
==
EWOULDBLOCK
)
{
return
IOS_UNAVAILABLE
;
}
else
if
(
errno
==
EINTR
)
{
...
...
@@ -473,7 +474,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0
memcpy
(
buf
,
addr
,
rv
);
iov
->
iov_base
=
buf
+
rv
;
iov
->
iov_len
=
NOTIFICATION_BUFFER_SIZE
-
rv
;
if
((
rv
=
recvmsg
(
fd
,
msg
,
0
))
<
0
)
{
if
((
rv
=
recvmsg
(
fd
,
msg
,
flags
))
<
0
)
{
handleSocketError
(
env
,
errno
);
return
0
;
}
...
...
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
浏览文件 @
7a9bd002
...
...
@@ -85,19 +85,21 @@ static jfieldID entry_options;
static
jfieldID
entry_dev
;
/**
* System calls that may not be available at
build
time.
* System calls that may not be available at
run
time.
*/
typedef
int
openat64_func
(
int
,
const
char
*
,
int
,
...);
typedef
int
fstatat64_func
(
int
,
const
char
*
,
struct
stat64
*
,
int
);
typedef
int
unlinkat_func
(
int
,
const
char
*
,
int
);
typedef
int
renameat_func
(
int
,
const
char
*
,
int
,
const
char
*
);
typedef
int
futimesat_func
(
int
,
const
char
*
,
const
struct
timeval
*
);
typedef
DIR
*
fdopendir_func
(
int
);
static
openat64_func
*
my_openat64_func
=
NULL
;
static
fstatat64_func
*
my_fstatat64_func
=
NULL
;
static
unlinkat_func
*
my_unlinkat_func
=
NULL
;
static
renameat_func
*
my_renameat_func
=
NULL
;
static
futimesat_func
*
my_futimesat_func
=
NULL
;
static
fdopendir_func
*
my_fdopendir_func
=
NULL
;
/**
* fstatat missing from glibc on Linux. Temporary workaround
...
...
@@ -183,7 +185,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
entry_options
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"opts"
,
"[B"
);
entry_dev
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"dev"
,
"J"
);
/* system calls that might not be available at
build
time */
/* system calls that might not be available at
run
time */
#if defined(__solaris__) && defined(_LP64)
/* Solaris 64-bit does not have openat64/fstatat64 */
...
...
@@ -196,6 +198,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
my_unlinkat_func
=
(
unlinkat_func
*
)
dlsym
(
RTLD_DEFAULT
,
"unlinkat"
);
my_renameat_func
=
(
renameat_func
*
)
dlsym
(
RTLD_DEFAULT
,
"renameat"
);
my_futimesat_func
=
(
futimesat_func
*
)
dlsym
(
RTLD_DEFAULT
,
"futimesat"
);
my_fdopendir_func
=
(
fdopendir_func
*
)
dlsym
(
RTLD_DEFAULT
,
"fdopendir"
);
#if defined(FSTATAT64_SYSCALL_AVAILABLE)
/* fstatat64 missing from glibc */
...
...
@@ -205,7 +208,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
if
(
my_openat64_func
!=
NULL
&&
my_fstatat64_func
!=
NULL
&&
my_unlinkat_func
!=
NULL
&&
my_renameat_func
!=
NULL
&&
my_futimesat_func
!=
NULL
)
my_futimesat_func
!=
NULL
&&
my_fdopendir_func
!=
NULL
)
{
flags
|=
sun_nio_fs_UnixNativeDispatcher_HAS_AT_SYSCALLS
;
}
...
...
@@ -565,8 +568,13 @@ JNIEXPORT jlong JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_fdopendir
(
JNIEnv
*
env
,
jclass
this
,
int
dfd
)
{
DIR
*
dir
;
if
(
my_fdopendir_func
==
NULL
)
{
JNU_ThrowInternalError
(
env
,
"should not reach here"
);
return
(
jlong
)
-
1
;
}
/* EINTR not listed as a possible error */
dir
=
fdopendir
((
int
)
dfd
);
dir
=
(
*
my_fdopendir_func
)
((
int
)
dfd
);
if
(
dir
==
NULL
)
{
throwUnixException
(
env
,
errno
);
}
...
...
src/windows/classes/sun/nio/fs/WindowsPath.java
浏览文件 @
7a9bd002
...
...
@@ -1177,14 +1177,20 @@ class WindowsPath extends AbstractPath {
/*
* Windows treates symbolic links to directories differently than it
* does to other file types. For that reason we
check if the exists and
*
is a directory
.
* does to other file types. For that reason we
need to check if the
*
target is a directory (or a directory junction)
.
*/
WindowsPath
resolvedTarget
;
if
(
target
.
type
==
WindowsPathType
.
RELATIVE
)
{
WindowsPath
parent
=
getParent
();
resolvedTarget
=
(
parent
==
null
)
?
target
:
parent
.
resolve
(
target
);
}
else
{
resolvedTarget
=
resolve
(
target
);
}
int
flags
=
0
;
WindowsPath
resolvedTarget
=
WindowsPath
.
createFromNormalizedPath
(
getFileSystem
(),
resolve
(
target
).
path
);
try
{
if
(
WindowsFileAttributes
.
get
(
resolvedTarget
,
true
).
isDirectory
())
WindowsFileAttributes
wattrs
=
WindowsFileAttributes
.
get
(
resolvedTarget
,
false
);
if
(
wattrs
.
isDirectory
()
||
wattrs
.
isDirectoryLink
())
flags
|=
SYMBOLIC_LINK_FLAG_DIRECTORY
;
}
catch
(
WindowsException
x
)
{
// unable to access target so assume target is not a directory
...
...
src/windows/classes/sun/security/krb5/internal/tools/Klist.java
浏览文件 @
7a9bd002
/*
* Portions Copyright 2003-2009 Sun Microsystems, Inc. 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
...
...
src/windows/classes/sun/security/krb5/internal/tools/Ktab.java
浏览文件 @
7a9bd002
/*
* Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -30,16 +31,15 @@
package
sun.security.krb5.internal.tools
;
import
sun.security.krb5.*
;
import
sun.security.krb5.internal.*
;
import
sun.security.krb5.internal.ktab.*
;
import
sun.security.krb5.KrbCryptoException
;
import
java.lang.RuntimeException
;
import
java.io.IOException
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.FileOutputStream
;
import
java.io.File
;
import
java.text.DateFormat
;
import
java.util.Arrays
;
import
java.util.Date
;
import
sun.security.krb5.internal.crypto.EType
;
/**
* This class can execute as a command-line tool to help the user manage
* entires in the key table.
...
...
@@ -55,6 +55,9 @@ public class Ktab {
char
action
;
String
name
;
// name and directory of key table
String
principal
;
boolean
showEType
;
boolean
showTime
;
int
etype
=
-
1
;
char
[]
password
=
null
;
/**
...
...
@@ -62,13 +65,14 @@ public class Ktab {
* <br>Usage: ktab <options>
* <br>available options to Ktab:
* <ul>
* <li><b>-l</b> list the keytab name and entries
* <li><b>-l [-e] [-t]</b> list the keytab name and entries, -e show
* encryption etypes, -t show timestamps.
* <li><b>-a</b> <<i>principal name</i>>
* (<<i>password</i>>) add an entry to the keytab.
* The entry is added only to the keytab. No changes are made to the
* Kerberos database.
* <li><b>-d</b> <<i>principal name</i>>
* delete an entry from the keytab
* <li><b>-d</b> <<i>principal name</i>>
[<<i>etype</i>>]
* delete an entry from the keytab
.
* The entry is deleted only from the keytab. No changes are made to the
* Kerberos database.
* <li><b>-k</b> <<i>keytab name</i> >
...
...
@@ -182,6 +186,11 @@ public class Ktab {
i
++;
if
((
i
<
args
.
length
)
&&
(!
args
[
i
].
startsWith
(
"-"
)))
{
principal
=
args
[
i
];
int
j
=
i
+
1
;
if
((
j
<
args
.
length
)
&&
(!
args
[
j
].
startsWith
(
"-"
)))
{
etype
=
Integer
.
parseInt
(
args
[
j
]);
i
=
j
;
}
}
else
{
System
.
out
.
println
(
"Please specify the principal"
+
"name of the entry you want to "
+
...
...
@@ -207,6 +216,12 @@ public class Ktab {
System
.
exit
(-
1
);
}
break
;
case
'e'
:
showEType
=
true
;
break
;
case
't'
:
showTime
=
true
;
break
;
default
:
printHelp
();
System
.
exit
(-
1
);
...
...
@@ -271,25 +286,54 @@ public class Ktab {
* Lists key table name and entries in it.
*/
void
listKt
()
{
int
version
;
String
principal
;
// System.out.println("Keytab name: " + admin.getKeyTabName());
System
.
out
.
println
(
"Keytab name: "
+
table
.
tabName
());
// KeyTabEntry[] entries = admin.getEntries();
System
.
out
.
println
(
"Keytab name: "
+
KeyTab
.
tabName
());
KeyTabEntry
[]
entries
=
table
.
getEntries
();
if
((
entries
!=
null
)
&&
(
entries
.
length
>
0
))
{
System
.
out
.
println
(
"KVNO Principal"
);
String
[][]
output
=
new
String
[
entries
.
length
+
1
][
showTime
?
3
:
2
];
int
column
=
0
;
output
[
0
][
column
++]
=
"KVNO"
;
if
(
showTime
)
output
[
0
][
column
++]
=
"Timestamp"
;
output
[
0
][
column
++]
=
"Principal"
;
for
(
int
i
=
0
;
i
<
entries
.
length
;
i
++)
{
version
=
entries
[
i
].
getKey
().
getKeyVersionNumber
().
intValue
();
principal
=
entries
[
i
].
getService
().
toString
();
if
(
i
==
0
)
{
StringBuffer
separator
=
new
StringBuffer
();
for
(
int
j
=
0
;
j
<
9
+
principal
.
length
();
j
++)
{
separator
.
append
(
"-"
);
column
=
0
;
output
[
i
+
1
][
column
++]
=
entries
[
i
].
getKey
().
getKeyVersionNumber
().
toString
();
if
(
showTime
)
output
[
i
+
1
][
column
++]
=
DateFormat
.
getDateTimeInstance
(
DateFormat
.
SHORT
,
DateFormat
.
SHORT
).
format
(
new
Date
(
entries
[
i
].
getTimeStamp
().
getTime
()));
String
princ
=
entries
[
i
].
getService
().
toString
();
if
(
showEType
)
{
int
e
=
entries
[
i
].
getKey
().
getEType
();
output
[
i
+
1
][
column
++]
=
princ
+
" ("
+
e
+
":"
+
EType
.
toString
(
e
)
+
")"
;
}
else
{
output
[
i
+
1
][
column
++]
=
princ
;
}
}
int
[]
width
=
new
int
[
column
];
for
(
int
j
=
0
;
j
<
column
;
j
++)
{
for
(
int
i
=
0
;
i
<=
entries
.
length
;
i
++)
{
if
(
output
[
i
][
j
].
length
()
>
width
[
j
])
{
width
[
j
]
=
output
[
i
][
j
].
length
();
}
System
.
out
.
println
(
separator
.
toString
());
}
System
.
out
.
println
(
" "
+
version
+
" "
+
principal
);
if
(
j
!=
0
)
width
[
j
]
=
-
width
[
j
];
}
for
(
int
j
=
0
;
j
<
column
;
j
++)
{
System
.
out
.
printf
(
"%"
+
width
[
j
]
+
"s "
,
output
[
0
][
j
]);
}
System
.
out
.
println
();
for
(
int
j
=
0
;
j
<
column
;
j
++)
{
for
(
int
k
=
0
;
k
<
Math
.
abs
(
width
[
j
]);
k
++)
System
.
out
.
print
(
"-"
);
System
.
out
.
print
(
" "
);
}
System
.
out
.
println
();
for
(
int
i
=
0
;
i
<
entries
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
column
;
j
++)
{
System
.
out
.
printf
(
"%"
+
width
[
j
]
+
"s "
,
output
[
i
+
1
][
j
]);
}
System
.
out
.
println
();
}
}
else
{
System
.
out
.
println
(
"0 entry."
);
...
...
@@ -309,9 +353,10 @@ public class Ktab {
String
answer
;
BufferedReader
cis
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
System
.
out
.
print
(
"Are you sure you want to
"
+
System
.
out
.
print
(
"Are you sure you want to"
+
" delete service key for "
+
pname
.
toString
()
+
" in "
+
table
.
tabName
()
+
"?(Y/N) :"
);
" ("
+
(
etype
==-
1
?
"all etypes"
:(
"etype = "
+
etype
))
+
") in "
+
table
.
tabName
()
+
"?(Y/N): "
);
System
.
out
.
flush
();
answer
=
cis
.
readLine
();
...
...
@@ -333,19 +378,26 @@ public class Ktab {
e
.
printStackTrace
();
System
.
exit
(-
1
);
}
// admin.deleteEntry(pname);
table
.
deleteEntry
(
pname
);
try
{
table
.
save
();
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Error occurs while saving the keytab."
+
int
count
;
if
(
etype
==
-
1
)
count
=
table
.
deleteEntry
(
pname
);
else
count
=
table
.
deleteEntry
(
pname
,
etype
);
if
(
count
==
0
)
{
System
.
err
.
println
(
"No matched entry in the keytab. "
+
"Deletion fails."
);
e
.
printStackTrace
();
System
.
exit
(-
1
);
}
else
{
try
{
table
.
save
();
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Error occurs while saving the keytab. "
+
"Deletion fails."
);
e
.
printStackTrace
();
System
.
exit
(-
1
);
}
System
.
out
.
println
(
"Done!"
);
}
System
.
out
.
println
(
"Done!"
);
}
/**
...
...
@@ -355,12 +407,12 @@ public class Ktab {
System
.
out
.
println
(
"\nUsage: ktab "
+
"<options>"
);
System
.
out
.
println
(
"available options to Ktab:"
);
System
.
out
.
println
(
"-l
\t\t\t\tlist the keytab name and entries
"
);
System
.
out
.
println
(
"-l
[-e] [-t]\t\t\tlist the keytab name and entries,\n\t\t\t\t-e with etype, -t with timestamp
"
);
System
.
out
.
println
(
"-a <principal name> (<password>)add an entry "
+
"to the keytab"
);
System
.
out
.
println
(
"-d <principal name>
\t\tdelete an entry from
"
+
"the keytab"
);
System
.
out
.
println
(
"-d <principal name>
[<etype>]\tdelete an
"
+
"
entry from
the keytab"
);
System
.
out
.
println
(
"-k <keytab name>\t\tspecify keytab name and "
+
"
path with prefix FILE:"
);
"path with prefix FILE:"
);
}
}
test/com/sun/jndi/ldap/BalancedParentheses.java
0 → 100644
浏览文件 @
7a9bd002
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 6449574
* @summary Invalid ldap filter is accepted and processed
*/
import
java.io.*
;
import
javax.naming.*
;
import
javax.naming.directory.*
;
import
java.util.Properties
;
import
java.util.Hashtable
;
import
java.net.Socket
;
import
java.net.ServerSocket
;
public
class
BalancedParentheses
{
// 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.
static
boolean
separateServerThread
=
true
;
// use any free port by default
volatile
int
serverPort
=
0
;
// Is the server ready to serve?
volatile
static
boolean
serverReady
=
false
;
// Define the server side of the test.
//
// If the server prematurely exits, serverReady will be set to true
// to avoid infinite hangs.
void
doServerSide
()
throws
Exception
{
ServerSocket
serverSock
=
new
ServerSocket
(
serverPort
);
// signal client, it's ready to accecpt connection
serverPort
=
serverSock
.
getLocalPort
();
serverReady
=
true
;
// accept a connection
Socket
socket
=
serverSock
.
accept
();
System
.
out
.
println
(
"Server: Connection accepted"
);
InputStream
is
=
socket
.
getInputStream
();
OutputStream
os
=
socket
.
getOutputStream
();
// read the bindRequest
while
(
is
.
read
()
!=
-
1
)
{
// ignore
is
.
skip
(
is
.
available
());
break
;
}
byte
[]
bindResponse
=
{
0x30
,
0x0C
,
0x02
,
0x01
,
0x01
,
0x61
,
0x07
,
0x0A
,
0x01
,
0x00
,
0x04
,
0x00
,
0x04
,
0x00
};
// write bindResponse
os
.
write
(
bindResponse
);
os
.
flush
();
// ignore any more request.
while
(
is
.
read
()
!=
-
1
)
{
// ignore
is
.
skip
(
is
.
available
());
}
is
.
close
();
os
.
close
();
socket
.
close
();
serverSock
.
close
();
}
// Define the client side of the test.
//
// If the server prematurely exits, serverReady will be set to true
// to avoid infinite hangs.
void
doClientSide
()
throws
Exception
{
// Wait for server to get started.
while
(!
serverReady
)
{
Thread
.
sleep
(
50
);
}
// set up the environment for creating the initial context
Hashtable
<
Object
,
Object
>
env
=
new
Hashtable
<
Object
,
Object
>();
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
env
.
put
(
Context
.
PROVIDER_URL
,
"ldap://localhost:"
+
serverPort
);
env
.
put
(
"com.sun.jndi.ldap.read.timeout"
,
"1000"
);
// env.put(Context.SECURITY_AUTHENTICATION, "simple");
// env.put(Context.SECURITY_PRINCIPAL,"cn=root");
// env.put(Context.SECURITY_CREDENTIALS,"root");
// create initial context
DirContext
context
=
new
InitialDirContext
(
env
);
// searching
SearchControls
scs
=
new
SearchControls
();
scs
.
setSearchScope
(
SearchControls
.
SUBTREE_SCOPE
);
try
{
NamingEnumeration
answer
=
context
.
search
(
"o=sun,c=us"
,
"(&(cn=Bob)))"
,
scs
);
}
catch
(
InvalidSearchFilterException
isfe
)
{
// ignore, it is the expected filter exception.
System
.
out
.
println
(
"Expected exception: "
+
isfe
.
getMessage
());
}
catch
(
NamingException
ne
)
{
// maybe a read timeout exception, as the server does not response.
throw
new
Exception
(
"Expect a InvalidSearchFilterException"
,
ne
);
}
try
{
NamingEnumeration
answer
=
context
.
search
(
"o=sun,c=us"
,
")(&(cn=Bob)"
,
scs
);
}
catch
(
InvalidSearchFilterException
isfe
)
{
// ignore, it is the expected filter exception.
System
.
out
.
println
(
"Expected exception: "
+
isfe
.
getMessage
());
}
catch
(
NamingException
ne
)
{
// maybe a read timeout exception, as the server does not response.
throw
new
Exception
(
"Expect a InvalidSearchFilterException"
,
ne
);
}
try
{
NamingEnumeration
answer
=
context
.
search
(
"o=sun,c=us"
,
"(&(cn=Bob))"
,
scs
);
}
catch
(
InvalidSearchFilterException
isfe
)
{
// ignore, it is the expected filter exception.
throw
new
Exception
(
"Unexpected ISFE"
,
isfe
);
}
catch
(
NamingException
ne
)
{
// maybe a read timeout exception, as the server does not response.
System
.
out
.
println
(
"Expected exception: "
+
ne
.
getMessage
());
}
context
.
close
();
}
/*
* ============================================================
* The remainder is just support stuff
*/
// client and server thread
Thread
clientThread
=
null
;
Thread
serverThread
=
null
;
// client and server exceptions
volatile
Exception
serverException
=
null
;
volatile
Exception
clientException
=
null
;
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..."
);
System
.
err
.
println
(
e
);
serverReady
=
true
;
serverException
=
e
;
}
}
};
serverThread
.
start
();
}
else
{
doServerSide
();
}
}
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
{
doClientSide
();
}
}
// Primary constructor, used to drive remainder of the test.
BalancedParentheses
()
throws
Exception
{
if
(
separateServerThread
)
{
startServer
(
true
);
startClient
(
false
);
}
else
{
startClient
(
true
);
startServer
(
false
);
}
/*
* Wait for other side to close down.
*/
if
(
separateServerThread
)
{
serverThread
.
join
();
}
else
{
clientThread
.
join
();
}
/*
* When we get here, the test is pretty much over.
*
* If the main thread excepted, that propagates back
* immediately. If the other thread threw an exception, we
* should report back.
*/
if
(
serverException
!=
null
)
{
System
.
out
.
print
(
"Server Exception:"
);
throw
serverException
;
}
if
(
clientException
!=
null
)
{
System
.
out
.
print
(
"Client Exception:"
);
throw
clientException
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// start the test
new
BalancedParentheses
();
}
}
test/com/sun/nio/sctp/SctpChannel/CommUp.java
0 → 100644
浏览文件 @
7a9bd002
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6863110
* @summary Newly connected/accepted SctpChannel should fire OP_READ if registered with a Selector
* @author chegar
*/
import
java.net.InetSocketAddress
;
import
java.net.SocketAddress
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
java.util.Set
;
import
java.util.concurrent.CountDownLatch
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.Selector
;
import
java.nio.channels.SelectionKey
;
import
com.sun.nio.sctp.AbstractNotificationHandler
;
import
com.sun.nio.sctp.AssociationChangeNotification
;
import
com.sun.nio.sctp.AssociationChangeNotification.AssocChangeEvent
;
import
com.sun.nio.sctp.HandlerResult
;
import
com.sun.nio.sctp.Notification
;
import
com.sun.nio.sctp.SctpChannel
;
import
com.sun.nio.sctp.SctpServerChannel
;
import
com.sun.nio.sctp.ShutdownNotification
;
import
static
java
.
lang
.
System
.
out
;
import
static
java
.
lang
.
System
.
err
;
import
static
java
.
nio
.
channels
.
SelectionKey
.
OP_CONNECT
;
import
static
java
.
nio
.
channels
.
SelectionKey
.
OP_READ
;
public
class
CommUp
{
static
CountDownLatch
acceptLatch
=
new
CountDownLatch
(
1
);
static
final
int
TIMEOUT
=
10000
;
CommUpNotificationHandler
clientHandler
=
new
CommUpNotificationHandler
();
CommUpNotificationHandler
serverHandler
=
new
CommUpNotificationHandler
();
CommUpServer
server
;
Thread
clientThread
;
void
test
(
String
[]
args
)
{
SocketAddress
address
=
null
;
if
(!
Util
.
isSCTPSupported
())
{
out
.
println
(
"SCTP protocol is not supported"
);
out
.
println
(
"Test cannot be run"
);
return
;
}
if
(
args
.
length
==
2
)
{
/* requested to connecct to a specific address */
try
{
int
port
=
Integer
.
valueOf
(
args
[
1
]);
address
=
new
InetSocketAddress
(
args
[
0
],
port
);
}
catch
(
NumberFormatException
nfe
)
{
err
.
println
(
nfe
);
}
}
else
{
/* start server on local machine, default */
try
{
server
=
new
CommUpServer
();
server
.
start
();
address
=
server
.
address
();
debug
(
"Server started and listening on "
+
address
);
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();
return
;
}
}
/* store the main thread so that the server can interrupt it, if necessary */
clientThread
=
Thread
.
currentThread
();
doClient
(
address
);
}
void
doClient
(
SocketAddress
peerAddress
)
{
SctpChannel
sc
=
null
;
try
{
debug
(
"connecting to "
+
peerAddress
);
sc
=
SctpChannel
.
open
();
sc
.
configureBlocking
(
false
);
check
(
sc
.
isBlocking
()
==
false
,
"Should be in non-blocking mode"
);
sc
.
connect
(
peerAddress
);
Selector
selector
=
Selector
.
open
();
SelectionKey
selectiontKey
=
sc
.
register
(
selector
,
OP_CONNECT
);
/* Expect two interest Ops */
boolean
opConnectReceived
=
false
;
boolean
opReadReceived
=
false
;
for
(
int
z
=
0
;
z
<
2
;
z
++)
{
debug
(
"select "
+
z
);
int
keysAdded
=
selector
.
select
(
TIMEOUT
);
debug
(
"returned "
+
keysAdded
+
" keys"
);
if
(
keysAdded
>
0
)
{
Set
<
SelectionKey
>
keys
=
selector
.
selectedKeys
();
Iterator
<
SelectionKey
>
i
=
keys
.
iterator
();
while
(
i
.
hasNext
())
{
SelectionKey
sk
=
i
.
next
();
i
.
remove
();
SctpChannel
readyChannel
=
(
SctpChannel
)
sk
.
channel
();
/* OP_CONNECT */
if
(
sk
.
isConnectable
())
{
/* some trivial checks */
check
(
opConnectReceived
==
false
,
"should only received one OP_CONNECT"
);
check
(
opReadReceived
==
false
,
"should not receive OP_READ before OP_CONNECT"
);
check
(
readyChannel
.
equals
(
sc
),
"channels should be equal"
);
check
(!
sk
.
isAcceptable
(),
"key should not be acceptable"
);
check
(!
sk
.
isReadable
(),
"key should not be readable"
);
check
(!
sk
.
isWritable
(),
"key should not be writable"
);
/* now process the OP_CONNECT */
opConnectReceived
=
true
;
check
((
sk
.
interestOps
()
&
OP_CONNECT
)
==
OP_CONNECT
,
"selection key interest ops should contain OP_CONNECT"
);
sk
.
interestOps
(
OP_READ
);
check
((
sk
.
interestOps
()
&
OP_CONNECT
)
!=
OP_CONNECT
,
"selection key interest ops should not contain OP_CONNECT"
);
check
(
sc
.
finishConnect
(),
"finishConnect should return true"
);
}
/* OP_READ */
else
if
(
sk
.
isReadable
())
{
/* some trivial checks */
check
(
opConnectReceived
==
true
,
"should receive one OP_CONNECT before OP_READ"
);
check
(
opReadReceived
==
false
,
"should not receive OP_READ before OP_CONNECT"
);
check
(
readyChannel
.
equals
(
sc
),
"channels should be equal"
);
check
(!
sk
.
isAcceptable
(),
"key should not be acceptable"
);
check
(
sk
.
isReadable
(),
"key should be readable"
);
check
(!
sk
.
isWritable
(),
"key should not be writable"
);
check
(!
sk
.
isConnectable
(),
"key should not be connectable"
);
/* now process the OP_READ */
opReadReceived
=
true
;
selectiontKey
.
cancel
();
/* try with small buffer to see if native
* implementation can handle this */
ByteBuffer
buffer
=
ByteBuffer
.
allocateDirect
(
1
);
readyChannel
.
receive
(
buffer
,
null
,
clientHandler
);
check
(
clientHandler
.
receivedCommUp
(),
"Client should have received COMM_UP"
);
/* dont close (or put anything on) the channel until
* we check that the server's accepted channel also
* received COMM_UP */
serverHandler
.
waitForCommUp
();
}
else
{
fail
(
"Unexpected selection key"
);
}
}
}
else
{
fail
(
"Client selector returned 0 ready keys"
);
/* stop the server */
server
.
thread
().
interrupt
();
}
}
//for
}
catch
(
IOException
ioe
)
{
unexpected
(
ioe
);
}
catch
(
InterruptedException
ie
)
{
unexpected
(
ie
);
}
}
class
CommUpServer
implements
Runnable
{
final
InetSocketAddress
serverAddr
;
private
SctpServerChannel
ssc
;
private
Thread
serverThread
;
public
CommUpServer
()
throws
IOException
{
ssc
=
SctpServerChannel
.
open
().
bind
(
null
);
java
.
util
.
Set
<
SocketAddress
>
addrs
=
ssc
.
getAllLocalAddresses
();
if
(
addrs
.
isEmpty
())
debug
(
"addrs should not be empty"
);
serverAddr
=
(
InetSocketAddress
)
addrs
.
iterator
().
next
();
}
void
start
()
{
serverThread
=
new
Thread
(
this
,
"CommUpServer-"
+
serverAddr
.
getPort
());
serverThread
.
start
();
}
InetSocketAddress
address
()
{
return
serverAddr
;
}
Thread
thread
()
{
return
serverThread
;
}
@Override
public
void
run
()
{
Selector
selector
=
null
;
SctpChannel
sc
=
null
;
SelectionKey
readKey
=
null
;
try
{
sc
=
ssc
.
accept
();
debug
(
"accepted "
+
sc
);
selector
=
Selector
.
open
();
sc
.
configureBlocking
(
false
);
check
(
sc
.
isBlocking
()
==
false
,
"Should be in non-blocking mode"
);
readKey
=
sc
.
register
(
selector
,
SelectionKey
.
OP_READ
);
debug
(
"select"
);
int
keysAdded
=
selector
.
select
(
TIMEOUT
);
debug
(
"returned "
+
keysAdded
+
" keys"
);
if
(
keysAdded
>
0
)
{
Set
<
SelectionKey
>
keys
=
selector
.
selectedKeys
();
Iterator
<
SelectionKey
>
i
=
keys
.
iterator
();
while
(
i
.
hasNext
())
{
SelectionKey
sk
=
i
.
next
();
i
.
remove
();
SctpChannel
readyChannel
=
(
SctpChannel
)
sk
.
channel
();
check
(
readyChannel
.
equals
(
sc
),
"channels should be equal"
);
check
(!
sk
.
isAcceptable
(),
"key should not be acceptable"
);
check
(
sk
.
isReadable
(),
"key should be readable"
);
check
(!
sk
.
isWritable
(),
"key should not be writable"
);
check
(!
sk
.
isConnectable
(),
"key should not be connectable"
);
/* block until we check if the client has received its COMM_UP*/
clientHandler
.
waitForCommUp
();
ByteBuffer
buffer
=
ByteBuffer
.
allocateDirect
(
1
);
sc
.
receive
(
buffer
,
null
,
serverHandler
);
check
(
serverHandler
.
receivedCommUp
(),
"Accepted channel should have received COMM_UP"
);
}
}
else
{
fail
(
"Server selector returned 0 ready keys"
);
/* stop the client */
clientThread
.
interrupt
();
}
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();
}
catch
(
InterruptedException
unused
)
{
}
finally
{
if
(
readKey
!=
null
)
readKey
.
cancel
();
try
{
if
(
selector
!=
null
)
selector
.
close
();
}
catch
(
IOException
ioe
)
{
unexpected
(
ioe
);
}
try
{
if
(
ssc
!=
null
)
ssc
.
close
();
}
catch
(
IOException
ioe
)
{
unexpected
(
ioe
);
}
try
{
if
(
sc
!=
null
)
sc
.
close
();
}
catch
(
IOException
ioe
)
{
unexpected
(
ioe
);
}
}
}
}
class
CommUpNotificationHandler
extends
AbstractNotificationHandler
<
Object
>
{
private
boolean
receivedCommUp
;
// false
public
synchronized
boolean
receivedCommUp
()
{
return
receivedCommUp
;
}
public
synchronized
boolean
waitForCommUp
()
throws
InterruptedException
{
while
(
receivedCommUp
==
false
)
{
wait
();
}
return
false
;
}
@Override
public
HandlerResult
handleNotification
(
Notification
notification
,
Object
attachment
)
{
fail
(
"Unknown notification type"
);
return
HandlerResult
.
CONTINUE
;
}
@Override
public
synchronized
HandlerResult
handleNotification
(
AssociationChangeNotification
notification
,
Object
attachment
)
{
AssocChangeEvent
event
=
notification
.
event
();
debug
(
"AssociationChangeNotification"
);
debug
(
" Association: "
+
notification
.
association
());
debug
(
" Event: "
+
event
);
if
(
event
.
equals
(
AssocChangeEvent
.
COMM_UP
))
{
receivedCommUp
=
true
;
notifyAll
();
}
return
HandlerResult
.
RETURN
;
}
@Override
public
HandlerResult
handleNotification
(
ShutdownNotification
notification
,
Object
attachment
)
{
debug
(
"ShutdownNotification"
);
debug
(
" Association: "
+
notification
.
association
());
return
HandlerResult
.
RETURN
;
}
}
//--------------------- Infrastructure ---------------------------
boolean
debug
=
true
;
volatile
int
passed
=
0
,
failed
=
0
;
void
pass
()
{
passed
++;}
void
fail
()
{
failed
++;
Thread
.
dumpStack
();}
void
fail
(
String
msg
)
{
err
.
println
(
msg
);
fail
();}
void
unexpected
(
Throwable
t
)
{
failed
++;
t
.
printStackTrace
();}
void
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();}
void
check
(
boolean
cond
,
String
failMessage
)
{
if
(
cond
)
pass
();
else
fail
(
failMessage
);}
void
debug
(
String
message
)
{
if
(
debug
)
{
out
.
println
(
Thread
.
currentThread
().
getName
()
+
": "
+
message
);
}
}
void
sleep
(
long
millis
)
{
try
{
Thread
.
currentThread
().
sleep
(
millis
);
}
catch
(
InterruptedException
ie
)
{
unexpected
(
ie
);
}}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
Class
<?>
k
=
new
Object
(){}.
getClass
().
getEnclosingClass
();
try
{
k
.
getMethod
(
"instanceMain"
,
String
[].
class
)
.
invoke
(
k
.
newInstance
(),
(
Object
)
args
);}
catch
(
Throwable
e
)
{
throw
e
.
getCause
();}}
public
void
instanceMain
(
String
[]
args
)
throws
Throwable
{
try
{
test
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
}
test/com/sun/nio/sctp/SctpMultiChannel/Branch.java
浏览文件 @
7a9bd002
...
...
@@ -115,7 +115,6 @@ public class Branch {
/* Receive the COMM_UP */
buffer
.
clear
();
BranchNotificationHandler
handler
=
new
BranchNotificationHandler
();
channel
.
configureBlocking
(
false
);
info
=
channel
.
receive
(
buffer
,
null
,
handler
);
check
(
handler
.
receivedCommUp
(),
"COMM_UP no received"
);
Set
<
Association
>
associations
=
channel
.
associations
();
...
...
test/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java
浏览文件 @
7a9bd002
...
...
@@ -181,7 +181,6 @@ public class SocketOptionTests {
/* Receive the COMM_UP */
buffer
.
clear
();
SOTNotificationHandler
handler
=
new
SOTNotificationHandler
();
smc
.
configureBlocking
(
false
);
info
=
smc
.
receive
(
buffer
,
null
,
handler
);
check
(
handler
.
receivedCommUp
(),
"COMM_UP no received"
);
Set
<
Association
>
associations
=
smc
.
associations
();
...
...
@@ -220,6 +219,7 @@ public class SocketOptionTests {
}
check
(
found
,
"SCTP_PRIMARY_ADDR returned bogus address!"
);
System
.
out
.
println
(
"Try SCTP_PRIMARY_ADDR set to: "
+
addrToSet
);
smc
.
setOption
(
SCTP_PRIMARY_ADDR
,
addrToSet
,
assoc
);
System
.
out
.
println
(
"SCTP_PRIMARY_ADDR set to: "
+
addrToSet
);
primaryAddr
=
smc
.
getOption
(
SCTP_PRIMARY_ADDR
,
assoc
);
...
...
test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java
浏览文件 @
7a9bd002
...
...
@@ -44,9 +44,9 @@ public class GroupOfOne {
final
AsynchronousServerSocketChannel
listener
=
AsynchronousServerSocketChannel
.
open
()
.
bind
(
new
InetSocketAddress
(
0
));
listener
.
accept
(
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
listener
.
accept
(
(
Void
)
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
public
void
completed
(
AsynchronousSocketChannel
ch
,
Void
att
)
{
listener
.
accept
(
null
,
this
);
listener
.
accept
(
(
Void
)
null
,
this
);
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
}
...
...
@@ -81,13 +81,13 @@ public class GroupOfOne {
// 2. the close/shutdown completes
final
CountDownLatch
latch
=
new
CountDownLatch
(
2
);
ch
.
connect
(
sa
,
null
,
new
CompletionHandler
<
Void
,
Void
>()
{
ch
.
connect
(
sa
,
(
Void
)
null
,
new
CompletionHandler
<
Void
,
Void
>()
{
public
void
completed
(
Void
result
,
Void
att
)
{
System
.
out
.
println
(
"Connected"
);
// initiate I/O operation that does not complete (successfully)
ByteBuffer
buf
=
ByteBuffer
.
allocate
(
100
);
ch
.
read
(
buf
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
buf
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesRead
,
Void
att
)
{
throw
new
RuntimeException
();
}
...
...
test/java/nio/channels/AsynchronousChannelGroup/Identity.java
浏览文件 @
7a9bd002
...
...
@@ -78,15 +78,15 @@ public class Identity {
final
AsynchronousServerSocketChannel
listener
=
AsynchronousServerSocketChannel
.
open
()
.
bind
(
new
InetSocketAddress
(
0
));
listener
.
accept
(
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
listener
.
accept
(
(
Void
)
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
public
void
completed
(
final
AsynchronousSocketChannel
ch
,
Void
att
)
{
listener
.
accept
(
null
,
this
);
listener
.
accept
(
(
Void
)
null
,
this
);
final
ByteBuffer
buf
=
ByteBuffer
.
allocate
(
100
);
ch
.
read
(
buf
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
buf
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesRead
,
Void
att
)
{
buf
.
clear
();
ch
.
read
(
buf
,
null
,
this
);
ch
.
read
(
buf
,
(
Void
)
null
,
this
);
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
}
...
...
test/java/nio/channels/AsynchronousChannelGroup/Restart.java
浏览文件 @
7a9bd002
...
...
@@ -94,7 +94,7 @@ public class Restart {
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
listener
.
accept
(
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
listener
.
accept
(
(
Void
)
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
public
void
completed
(
AsynchronousSocketChannel
ch
,
Void
att
)
{
try
{
ch
.
close
();
...
...
test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
浏览文件 @
7a9bd002
...
...
@@ -45,10 +45,10 @@ public class Unbounded {
final
AsynchronousServerSocketChannel
listener
=
AsynchronousServerSocketChannel
.
open
()
.
bind
(
new
InetSocketAddress
(
0
));
listener
.
accept
(
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
listener
.
accept
(
(
Void
)
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
public
void
completed
(
AsynchronousSocketChannel
ch
,
Void
att
)
{
queue
.
add
(
ch
);
listener
.
accept
(
null
,
this
);
listener
.
accept
(
(
Void
)
null
,
this
);
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
}
...
...
test/java/nio/channels/AsynchronousDatagramChannel/Basic.java
浏览文件 @
7a9bd002
...
...
@@ -66,7 +66,7 @@ public class Basic {
// Test: datagram packet not received immediately
dst
.
clear
();
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ch
.
receive
(
dst
,
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
ch
.
receive
(
dst
,
(
Void
)
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
public
void
completed
(
SocketAddress
source
,
Void
att
)
{
latch
.
countDown
();
}
...
...
@@ -82,7 +82,7 @@ public class Basic {
// Test: timeout
dst
.
clear
();
final
AtomicReference
<
Throwable
>
exception
=
new
AtomicReference
<
Throwable
>();
ch
.
receive
(
dst
,
2
,
TimeUnit
.
SECONDS
,
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
ch
.
receive
(
dst
,
2
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
public
void
completed
(
SocketAddress
source
,
Void
att
)
{
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -101,7 +101,7 @@ public class Basic {
// AsynchronousCloseException
dst
=
ByteBuffer
.
allocateDirect
(
100
);
exception
.
set
(
null
);
ch
.
receive
(
dst
,
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
ch
.
receive
(
dst
,
(
Void
)
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
public
void
completed
(
SocketAddress
source
,
Void
att
)
{
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -156,7 +156,7 @@ public class Basic {
// Test: datagram packet not received immediately
dst
.
clear
();
final
CountDownLatch
l1
=
new
CountDownLatch
(
1
);
ch
.
read
(
dst
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
dst
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesRead
,
Void
att
)
{
l1
.
countDown
();
}
...
...
@@ -172,7 +172,7 @@ public class Basic {
// Test: timeout
dst
.
clear
();
final
AtomicReference
<
Throwable
>
exception
=
new
AtomicReference
<
Throwable
>();
ch
.
read
(
dst
,
2
,
TimeUnit
.
SECONDS
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
dst
,
2
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesRead
,
Void
att
)
{
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -191,7 +191,7 @@ public class Basic {
// AsynchronousCloseException
dst
.
clear
();
exception
.
set
(
null
);
ch
.
read
(
dst
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
dst
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesRead
,
Void
att
)
{
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -238,7 +238,7 @@ public class Basic {
// Test: send datagram packet to reader and check completion handler
// is invoked
final
CountDownLatch
l2
=
new
CountDownLatch
(
1
);
ch
.
send
(
ByteBuffer
.
wrap
(
msg
),
sa
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
send
(
ByteBuffer
.
wrap
(
msg
),
sa
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesSent
,
Void
att
)
{
if
(
bytesSent
!=
msg
.
length
)
throw
new
RuntimeException
(
"Unexpected number of bytes received"
);
...
...
@@ -261,7 +261,7 @@ public class Basic {
// Test: check that failed method is invoked
ch
.
close
();
final
CountDownLatch
l3
=
new
CountDownLatch
(
1
);
ch
.
send
(
ByteBuffer
.
wrap
(
msg
),
sa
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
send
(
ByteBuffer
.
wrap
(
msg
),
sa
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesSent
,
Void
att
)
{
throw
new
RuntimeException
(
"completed method invoked"
);
}
...
...
@@ -315,7 +315,7 @@ public class Basic {
// Test: write datagram and check completion handler is invoked
final
CountDownLatch
l2
=
new
CountDownLatch
(
1
);
ch
.
write
(
ByteBuffer
.
wrap
(
msg
),
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
write
(
ByteBuffer
.
wrap
(
msg
),
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesSent
,
Void
att
)
{
if
(
bytesSent
!=
msg
.
length
)
throw
new
RuntimeException
(
"Unexpected number of bytes received"
);
...
...
@@ -372,7 +372,7 @@ public class Basic {
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
long
timeout
=
(
i
==
0
)
?
0L
:
60L
;
Future
<
SocketAddress
>
remote
=
ch
.
receive
(
ByteBuffer
.
allocate
(
100
),
timeout
,
TimeUnit
.
SECONDS
,
null
,
.
receive
(
ByteBuffer
.
allocate
(
100
),
timeout
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
new
CompletionHandler
<
SocketAddress
,
Void
>()
{
public
void
completed
(
SocketAddress
source
,
Void
att
)
{
}
...
...
@@ -395,7 +395,7 @@ public class Basic {
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
long
timeout
=
(
i
==
0
)
?
0L
:
60L
;
Future
<
Integer
>
result
=
ch
.
read
(
ByteBuffer
.
allocate
(
100
),
timeout
,
TimeUnit
.
SECONDS
,
null
,
.
read
(
ByteBuffer
.
allocate
(
100
),
timeout
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
bytesRead
,
Void
att
)
{
}
...
...
test/java/nio/channels/AsynchronousFileChannel/Basic.java
浏览文件 @
7a9bd002
...
...
@@ -190,7 +190,7 @@ public class Basic {
if
(
fl
==
null
)
throw
new
RuntimeException
(
"Unable to acquire lock"
);
try
{
ch
.
lock
(
null
,
new
CompletionHandler
<
FileLock
,
Void
>
()
{
ch
.
lock
(
(
Void
)
null
,
new
CompletionHandler
<
FileLock
,
Void
>
()
{
public
void
completed
(
FileLock
result
,
Void
att
)
{
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -217,7 +217,7 @@ public class Basic {
ByteBuffer
buf
=
ByteBuffer
.
allocateDirect
(
100
);
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ch
.
read
(
buf
,
0L
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
buf
,
0L
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
try
{
Thread
.
currentThread
().
interrupt
();
...
...
@@ -311,7 +311,7 @@ public class Basic {
final
AtomicReference
<
Thread
>
invoker
=
new
AtomicReference
<
Thread
>();
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ch
.
write
(
genBuffer
(),
0L
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
write
(
genBuffer
(),
0L
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
invoker
.
set
(
Thread
.
currentThread
());
latch
.
countDown
();
...
...
@@ -410,7 +410,7 @@ public class Basic {
// start write operation
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
Future
<
Integer
>
res
=
ch
.
write
(
genBuffer
(),
0L
,
null
,
Future
<
Integer
>
res
=
ch
.
write
(
genBuffer
(),
0L
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
}
...
...
test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java
浏览文件 @
7a9bd002
...
...
@@ -95,7 +95,7 @@ public class Basic {
final
AtomicReference
<
Throwable
>
exception
=
new
AtomicReference
<
Throwable
>();
// start accepting
listener
.
accept
(
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
listener
.
accept
(
(
Void
)
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
public
void
completed
(
AsynchronousSocketChannel
ch
,
Void
att
)
{
try
{
ch
.
close
();
...
...
test/java/nio/channels/AsynchronousSocketChannel/Basic.java
浏览文件 @
7a9bd002
...
...
@@ -181,7 +181,7 @@ public class Basic {
}
final
AtomicReference
<
Throwable
>
connectException
=
new
AtomicReference
<
Throwable
>();
ch
.
connect
(
server
.
address
(),
null
,
new
CompletionHandler
<
Void
,
Void
>()
{
ch
.
connect
(
server
.
address
(),
(
Void
)
null
,
new
CompletionHandler
<
Void
,
Void
>()
{
public
void
completed
(
Void
result
,
Void
att
)
{
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -332,7 +332,7 @@ public class Basic {
// start read operation
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ByteBuffer
buf
=
ByteBuffer
.
allocate
(
1
);
Future
<
Integer
>
res
=
ch
.
read
(
buf
,
null
,
Future
<
Integer
>
res
=
ch
.
read
(
buf
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
}
...
...
@@ -397,11 +397,11 @@ public class Basic {
// reads should complete immediately
final
ByteBuffer
dst
=
ByteBuffer
.
allocateDirect
(
src
.
capacity
()
+
100
);
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ch
.
read
(
dst
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
dst
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
int
n
=
result
;
if
(
n
>
0
)
{
ch
.
read
(
dst
,
null
,
this
);
ch
.
read
(
dst
,
(
Void
)
null
,
this
);
}
else
{
latch
.
countDown
();
}
...
...
@@ -450,10 +450,10 @@ public class Basic {
// read until the buffer is full
final
ByteBuffer
dst
=
ByteBuffer
.
allocateDirect
(
src
.
capacity
());
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ch
.
read
(
dst
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
read
(
dst
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
if
(
dst
.
hasRemaining
())
{
ch
.
read
(
dst
,
null
,
this
);
ch
.
read
(
dst
,
(
Void
)
null
,
this
);
}
else
{
latch
.
countDown
();
}
...
...
@@ -508,7 +508,7 @@ public class Basic {
// scattering read that completes ascynhronously
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
ch
.
read
(
dsts
,
0
,
dsts
.
length
,
0L
,
TimeUnit
.
SECONDS
,
null
,
ch
.
read
(
dsts
,
0
,
dsts
.
length
,
0L
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
new
CompletionHandler
<
Long
,
Void
>()
{
public
void
completed
(
Long
result
,
Void
att
)
{
long
n
=
result
;
...
...
@@ -536,7 +536,7 @@ public class Basic {
dsts
[
i
].
rewind
();
}
long
n
=
ch
.
read
(
dsts
,
0
,
dsts
.
length
,
0L
,
TimeUnit
.
SECONDS
,
null
,
null
).
get
();
.
read
(
dsts
,
0
,
dsts
.
length
,
0L
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
null
).
get
();
if
(
n
<=
0
)
throw
new
RuntimeException
(
"No bytes read"
);
...
...
@@ -562,10 +562,10 @@ public class Basic {
// write all bytes and close connection when done
final
ByteBuffer
src
=
genBuffer
();
ch
.
write
(
src
,
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
ch
.
write
(
src
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>()
{
public
void
completed
(
Integer
result
,
Void
att
)
{
if
(
src
.
hasRemaining
())
{
ch
.
write
(
src
,
null
,
this
);
ch
.
write
(
src
,
(
Void
)
null
,
this
);
}
else
{
try
{
ch
.
close
();
...
...
@@ -616,7 +616,7 @@ public class Basic {
// write buffers (should complete immediately)
ByteBuffer
[]
srcs
=
genBuffers
(
1
);
long
n
=
ch
.
write
(
srcs
,
0
,
srcs
.
length
,
0L
,
TimeUnit
.
SECONDS
,
null
,
null
).
get
();
.
write
(
srcs
,
0
,
srcs
.
length
,
0L
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
null
).
get
();
if
(
n
<=
0
)
throw
new
RuntimeException
(
"No bytes written"
);
...
...
@@ -629,7 +629,7 @@ public class Basic {
// write until socket buffer is full so as to create the conditions
// for when a write does not complete immediately
srcs
=
genBuffers
(
1
);
ch
.
write
(
srcs
,
0
,
srcs
.
length
,
0L
,
TimeUnit
.
SECONDS
,
null
,
ch
.
write
(
srcs
,
0
,
srcs
.
length
,
0L
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
new
CompletionHandler
<
Long
,
Void
>()
{
public
void
completed
(
Long
result
,
Void
att
)
{
long
n
=
result
;
...
...
@@ -639,7 +639,7 @@ public class Basic {
if
(
continueWriting
.
get
())
{
ByteBuffer
[]
srcs
=
genBuffers
(
8
);
ch
.
write
(
srcs
,
0
,
srcs
.
length
,
0L
,
TimeUnit
.
SECONDS
,
null
,
this
);
(
Void
)
null
,
this
);
}
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -717,7 +717,7 @@ public class Basic {
// this read should timeout
ByteBuffer
dst
=
ByteBuffer
.
allocate
(
512
);
try
{
ch
.
read
(
dst
,
3
,
TimeUnit
.
SECONDS
,
null
,
null
).
get
();
ch
.
read
(
dst
,
3
,
TimeUnit
.
SECONDS
,
(
Void
)
null
,
null
).
get
();
throw
new
RuntimeException
(
"Read did not timeout"
);
}
catch
(
ExecutionException
x
)
{
if
(!(
x
.
getCause
()
instanceof
InterruptedByTimeoutException
))
...
...
test/java/nio/channels/AsynchronousSocketChannel/StressLoopback.java
浏览文件 @
7a9bd002
...
...
@@ -99,7 +99,7 @@ public class StressLoopback {
void
start
()
{
sentBuffer
.
position
(
0
);
sentBuffer
.
limit
(
sentBuffer
.
capacity
());
channel
.
write
(
sentBuffer
,
null
,
new
CompletionHandler
<
Integer
,
Void
>
()
{
channel
.
write
(
sentBuffer
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>
()
{
public
void
completed
(
Integer
nwrote
,
Void
att
)
{
bytesSent
+=
nwrote
;
if
(
finished
)
{
...
...
@@ -107,7 +107,7 @@ public class StressLoopback {
}
else
{
sentBuffer
.
position
(
0
);
sentBuffer
.
limit
(
sentBuffer
.
capacity
());
channel
.
write
(
sentBuffer
,
null
,
this
);
channel
.
write
(
sentBuffer
,
(
Void
)
null
,
this
);
}
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
@@ -142,14 +142,14 @@ public class StressLoopback {
}
void
start
()
{
channel
.
read
(
readBuffer
,
null
,
new
CompletionHandler
<
Integer
,
Void
>
()
{
channel
.
read
(
readBuffer
,
(
Void
)
null
,
new
CompletionHandler
<
Integer
,
Void
>
()
{
public
void
completed
(
Integer
nread
,
Void
att
)
{
if
(
nread
<
0
)
{
closeUnchecked
(
channel
);
}
else
{
bytesRead
+=
nread
;
readBuffer
.
clear
();
channel
.
read
(
readBuffer
,
null
,
this
);
channel
.
read
(
readBuffer
,
(
Void
)
null
,
this
);
}
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
...
...
test/java/nio/file/Path/Links.java
浏览文件 @
7a9bd002
...
...
@@ -22,7 +22,7 @@
*/
/* @test
* @bug 4313887 6838333
* @bug 4313887 6838333
6863864
* @summary Unit test for java.nio.file.Path createSymbolicLink,
* readSymbolicLink, and createLink methods
* @library ..
...
...
@@ -31,7 +31,6 @@
import
java.nio.file.*
;
import
java.nio.file.attribute.*
;
import
java.io.*
;
import
java.util.*
;
public
class
Links
{
...
...
@@ -47,7 +46,7 @@ public class Links {
* Exercise createSymbolicLink and readLink methods
*/
static
void
testSymLinks
(
Path
dir
)
throws
IOException
{
Path
link
=
dir
.
resolve
(
"link"
);
final
Path
link
=
dir
.
resolve
(
"link"
);
// Check if sym links are supported
try
{
...
...
@@ -76,6 +75,63 @@ public class Links {
link
.
delete
();
}
}
// Test links to directory
Path
mydir
=
dir
.
resolve
(
"mydir"
);
Path
myfile
=
mydir
.
resolve
(
"myfile"
);
try
{
mydir
.
createDirectory
();
myfile
.
createFile
();
// link -> "mydir"
link
.
createSymbolicLink
(
mydir
.
getName
());
assertTrue
(
link
.
readSymbolicLink
().
equals
(
mydir
.
getName
()));
// Test access to directory via link
DirectoryStream
<
Path
>
stream
=
link
.
newDirectoryStream
();
try
{
boolean
found
=
false
;
for
(
Path
entry:
stream
)
{
if
(
entry
.
getName
().
equals
(
myfile
.
getName
()))
{
found
=
true
;
break
;
}
}
assertTrue
(
found
);
}
finally
{
stream
.
close
();
}
// Test link2 -> link -> mydir
final
Path
link2
=
dir
.
resolve
(
"link2"
);
Path
target2
=
link
.
getName
();
link2
.
createSymbolicLink
(
target2
);
try
{
assertTrue
(
link2
.
readSymbolicLink
().
equals
(
target2
));
link2
.
newDirectoryStream
().
close
();
}
finally
{
link2
.
delete
();
}
// Remove mydir and re-create link2 before re-creating mydir
// (This is a useful test on Windows to ensure that creating a
// sym link to a directory sym link creates the right type of link).
myfile
.
delete
();
mydir
.
delete
();
link2
.
createSymbolicLink
(
target2
);
try
{
assertTrue
(
link2
.
readSymbolicLink
().
equals
(
target2
));
mydir
.
createDirectory
();
link2
.
newDirectoryStream
().
close
();
}
finally
{
link2
.
delete
();
}
}
finally
{
myfile
.
deleteIfExists
();
mydir
.
deleteIfExists
();
link
.
deleteIfExists
();
}
}
/**
...
...
test/sun/security/krb5/ConfPlusProp.java
浏览文件 @
7a9bd002
...
...
@@ -23,31 +23,56 @@
/*
* @test
* @bug 6857795
* @buf 6858589
* @summary krb5.conf ignored if system properties on realm and kdc are provided
*/
import
sun.security.krb5.Config
;
import
sun.security.krb5.KrbException
;
public
class
ConfPlusProp
{
Config
config
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"java.security.krb5.realm"
,
"R2"
);
System
.
setProperty
(
"java.security.krb5.kdc"
,
"k2"
);
new
ConfPlusProp
().
run
();
}
void
refresh
()
throws
Exception
{
Config
.
refresh
();
config
=
Config
.
getInstance
();
}
void
checkDefaultRealm
(
String
r
)
throws
Exception
{
try
{
if
(!
config
.
getDefaultRealm
().
equals
(
r
))
{
throw
new
AssertionError
(
"Default realm error"
);
}
}
catch
(
Exception
e
)
{
if
(
r
!=
null
)
throw
e
;
}
}
void
check
(
String
r
,
String
k
)
throws
Exception
{
try
{
if
(!
config
.
getKDCList
(
r
).
equals
(
k
))
{
throw
new
AssertionError
(
r
+
" kdc not "
+
k
);
}
}
catch
(
Exception
e
)
{
if
(
k
!=
null
)
throw
e
;
}
}
void
run
()
throws
Exception
{
// No prop, only conf
// Point to a file with existing default_realm
System
.
setProperty
(
"java.security.krb5.conf"
,
System
.
getProperty
(
"test.src"
,
"."
)
+
"/confplusprop.conf"
);
Config
config
=
Config
.
getInstance
();
refresh
();
if
(!
config
.
getDefaultRealm
().
equals
(
"R2"
))
{
throw
new
Exception
(
"Default realm error"
);
}
if
(!
config
.
getKDCList
(
"R1"
).
equals
(
"k1"
))
{
throw
new
Exception
(
"R1 kdc error"
);
}
if
(!
config
.
getKDCList
(
"R2"
).
equals
(
"k2"
))
{
throw
new
Exception
(
"R2 kdc error"
);
}
checkDefaultRealm
(
"R1"
);
check
(
"R1"
,
"k1"
);
check
(
"R2"
,
"old"
);
check
(
"R3"
,
null
);
if
(!
config
.
getDefault
(
"forwardable"
,
"libdefaults"
).
equals
(
"well"
))
{
throw
new
Exception
(
"Extra config error"
);
}
...
...
@@ -55,38 +80,66 @@ public class ConfPlusProp {
// Point to a file with no libdefaults
System
.
setProperty
(
"java.security.krb5.conf"
,
System
.
getProperty
(
"test.src"
,
"."
)
+
"/confplusprop2.conf"
);
Config
.
refresh
();
refresh
();
config
=
Config
.
getInstance
();
checkDefaultRealm
(
null
);
check
(
"R1"
,
"k12"
);
check
(
"R2"
,
"old"
);
check
(
"R3"
,
null
);
if
(!
config
.
getDefaultRealm
().
equals
(
"R2"
))
{
throw
new
Exception
(
"Default realm error again"
);
}
if
(!
config
.
getKDCList
(
"R1"
).
equals
(
"k12"
))
{
throw
new
Exception
(
"R1 kdc error"
);
int
version
=
System
.
getProperty
(
"java.version"
).
charAt
(
2
)
-
'0'
;
System
.
out
.
println
(
"JDK version is "
+
version
);
// Zero-config is supported since 1.7
if
(
version
>=
7
)
{
// Point to a non-existing file
System
.
setProperty
(
"java.security.krb5.conf"
,
"i-am-not-a file"
);
refresh
();
checkDefaultRealm
(
null
);
check
(
"R1"
,
null
);
check
(
"R2"
,
null
);
check
(
"R3"
,
null
);
if
(
config
.
getDefault
(
"forwardable"
,
"libdefaults"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
}
if
(!
config
.
getKDCList
(
"R2"
).
equals
(
"k2"
))
{
throw
new
Exception
(
"R2 kdc error"
);
// Add prop
System
.
setProperty
(
"java.security.krb5.realm"
,
"R2"
);
System
.
setProperty
(
"java.security.krb5.kdc"
,
"k2"
);
// Point to a file with existing default_realm
System
.
setProperty
(
"java.security.krb5.conf"
,
System
.
getProperty
(
"test.src"
,
"."
)
+
"/confplusprop.conf"
);
refresh
();
checkDefaultRealm
(
"R2"
);
check
(
"R1"
,
"k1"
);
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
if
(!
config
.
getDefault
(
"forwardable"
,
"libdefaults"
).
equals
(
"well"
))
{
throw
new
Exception
(
"Extra config error"
);
}
// Point to a file with no libdefaults
System
.
setProperty
(
"java.security.krb5.conf"
,
System
.
getProperty
(
"test.src"
,
"."
)
+
"/confplusprop2.conf"
);
refresh
();
checkDefaultRealm
(
"R2"
);
check
(
"R1"
,
"k12"
);
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
// Point to a non-existing file
System
.
setProperty
(
"java.security.krb5.conf"
,
"i-am-not-a file"
);
Config
.
refresh
();
refresh
();
config
=
Config
.
getInstance
();
if
(!
config
.
getDefaultRealm
().
equals
(
"R2"
))
{
throw
new
Exception
(
"Default realm error"
);
}
try
{
config
.
getKDCList
(
"R1"
);
throw
new
Exception
(
"R1 is nowhere"
);
}
catch
(
KrbException
ke
)
{
// OK
}
if
(!
config
.
getKDCList
(
"R2"
).
equals
(
"k2"
))
{
throw
new
Exception
(
"R2 kdc error"
);
}
checkDefaultRealm
(
"R2"
);
check
(
"R1"
,
"k2"
);
check
(
"R2"
,
"k2"
);
check
(
"R3"
,
"k2"
);
if
(
config
.
getDefault
(
"forwardable"
,
"libdefaults"
)
!=
null
)
{
throw
new
Exception
(
"Extra config error"
);
}
...
...
test/sun/security/tools/jarsigner/newsize7.sh
0 → 100644
浏览文件 @
7a9bd002
#
# Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# @test
# @bug 6561126
# @summary keytool should use larger default keysize for keypairs
#
# @run shell newsize7.sh
# set a few environment variables so that the shell-script can run stand-alone
# in the source directory
if
[
"
${
TESTSRC
}
"
=
""
]
;
then
TESTSRC
=
"."
fi
if
[
"
${
TESTJAVA
}
"
=
""
]
;
then
JAVA_CMD
=
`
which java
`
TESTJAVA
=
`
dirname
$JAVA_CMD
`
/..
fi
# set platform-dependent variables
OS
=
`
uname
-s
`
case
"
$OS
"
in
Windows_
*
)
FS
=
"
\\
"
;;
*
)
FS
=
"/"
;;
esac
KSFILE
=
ns7.jks
KT
=
"
${
TESTJAVA
}${
FS
}
bin
${
FS
}
keytool -keystore ns7.jks -storepass changeit -keypass changeit"
JAR
=
"
${
TESTJAVA
}${
FS
}
bin
${
FS
}
jar"
JS
=
"
${
TESTJAVA
}${
FS
}
bin
${
FS
}
jarsigner -keystore ns7.jks -storepass changeit"
rm
ns7.
*
$KT
-genkeypair
-alias
me
-dname
CN
=
Me
touch
ns7.txt
$JAR
cvf ns7.jar ns7.txt
$JS
ns7.jar me
$JAR
xvf ns7.jar
grep
SHA-256 META-INF/MANIFEST.MF
||
exit
1
grep
SHA-256 META-INF/ME.SF
||
exit
2
#rm -rf META-INF
exit
0
test/sun/security/tools/keytool/NewSize7.java
0 → 100644
浏览文件 @
7a9bd002
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6561126
* @summary keytool should use larger default keysize for keypairs
*/
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.security.KeyStore
;
import
java.security.cert.X509Certificate
;
import
java.security.interfaces.RSAPublicKey
;
import
sun.security.tools.KeyTool
;
public
class
NewSize7
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
FILE
=
"newsize7-ks"
;
new
File
(
FILE
).
delete
();
KeyTool
.
main
((
"-debug -genkeypair -keystore "
+
FILE
+
" -alias a -dname cn=c -storepass changeit"
+
" -keypass changeit -keyalg rsa"
).
split
(
" "
));
KeyStore
ks
=
KeyStore
.
getInstance
(
"JKS"
);
ks
.
load
(
new
FileInputStream
(
FILE
),
null
);
new
File
(
FILE
).
delete
();
RSAPublicKey
r
=
(
RSAPublicKey
)
ks
.
getCertificate
(
"a"
).
getPublicKey
();
if
(
r
.
getModulus
().
bitLength
()
!=
2048
)
{
throw
new
Exception
(
"Bad keysize"
);
}
X509Certificate
x
=
(
X509Certificate
)
ks
.
getCertificate
(
"a"
);
if
(!
x
.
getSigAlgName
().
equals
(
"SHA256withRSA"
))
{
throw
new
Exception
(
"Bad sigalg"
);
}
}
}
test/sun/security/tools/keytool/emptysubject.sh
0 → 100644
浏览文件 @
7a9bd002
#
# Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# @test
# @bug 6847026
# @summary keytool should be able to generate certreq and cert without subject name
#
# @run shell emptysubject.sh
#
if
[
"
${
TESTJAVA
}
"
=
""
]
;
then
JAVAC_CMD
=
`
which javac
`
TESTJAVA
=
`
dirname
$JAVAC_CMD
`
/..
fi
# set platform-dependent variables
OS
=
`
uname
-s
`
case
"
$OS
"
in
Windows_
*
)
FS
=
"
\\
"
;;
*
)
FS
=
"/"
;;
esac
KS
=
emptysubject.jks
KT
=
"
$TESTJAVA
${
FS
}
bin
${
FS
}
keytool -storepass changeit -keypass changeit -keystore
$KS
"
rm
$KS
$KT
-alias
ca
-dname
CN
=
CA
-genkeypair
$KT
-alias
me
-dname
CN
=
Me
-genkeypair
# When -dname is recognized, SAN must be specfied, otherwise, -printcert fails.
$KT
-alias
me
-certreq
-dname
""
|
\
$KT
-alias
ca
-gencert
|
$KT
-printcert
&&
exit
1
$KT
-alias
me
-certreq
|
\
$KT
-alias
ca
-gencert
-dname
""
|
$KT
-printcert
&&
exit
2
$KT
-alias
me
-certreq
-dname
""
|
\
$KT
-alias
ca
-gencert
-ext
san:c
=
email:me@me.com |
\
$KT
-printcert
||
exit
3
$KT
-alias
me
-certreq
|
\
$KT
-alias
ca
-gencert
-dname
""
-ext
san:c
=
email:me@me.com |
\
$KT
-printcert
||
exit
4
exit
0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录