提交 15fddd82 编写于 作者: L lana

Merge

...@@ -82,3 +82,7 @@ d58354a69011f3d3354765fa3167567c4c4a9612 jdk7-b101 ...@@ -82,3 +82,7 @@ d58354a69011f3d3354765fa3167567c4c4a9612 jdk7-b101
3b0abcb512807bb6f6d27755bc50103211bde6ee jdk7-b105 3b0abcb512807bb6f6d27755bc50103211bde6ee jdk7-b105
b91ef6b60f4e19bf4592c6dd594c9bac62487519 jdk7-b106 b91ef6b60f4e19bf4592c6dd594c9bac62487519 jdk7-b106
882103f334bb23745d3fd70fb7928c347478b0f4 jdk7-b107 882103f334bb23745d3fd70fb7928c347478b0f4 jdk7-b107
17a5d84b75610255a3527e8ede1da19c91ba7a7e jdk7-b108
ab0d3f54a63f2aadfcdd2e14b81f79362ce454e2 jdk7-b109
176586cd040e4dd17a5ff6e91f72df10d7442453 jdk7-b110
fb63a2688db807a73e2a3de7d9bab298f1bff0e8 jdk7-b111
...@@ -31,7 +31,7 @@ BUILDDIR = .. ...@@ -31,7 +31,7 @@ BUILDDIR = ..
PRODUCT = com PRODUCT = com
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = sun SUBDIRS = sun oracle
include $(BUILDDIR)/common/Subdirs.gmk include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber:: all build clean clobber::
......
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
BUILDDIR = ../..
PRODUCT = oracle
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = net
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
$(SUBDIRS-loop)
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
BUILDDIR = ../../..
PRODUCT = oracle
include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = com/oracle/net
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
...@@ -573,13 +573,13 @@ $(NOT_RT_JAR_LIST): FRC ...@@ -573,13 +573,13 @@ $(NOT_RT_JAR_LIST): FRC
$(ECHO) "sun/jvmstat/" >> $@ $(ECHO) "sun/jvmstat/" >> $@
$(ECHO) "sun/nio/cs/ext/" >> $@ $(ECHO) "sun/nio/cs/ext/" >> $@
$(ECHO) "sun/awt/HKSCS.class" >> $@ $(ECHO) "sun/awt/HKSCS.class" >> $@
$(ECHO) "sun/awt/motif/X11GB2312$Decoder.class" >> $@ $(ECHO) "sun/awt/motif/X11GB2312\$$Decoder.class" >> $@
$(ECHO) "sun/awt/motif/X11GB2312$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11GB2312\$$Encoder.class" >> $@
$(ECHO) "sun/awt/motif/X11GB2312.class" >> $@ $(ECHO) "sun/awt/motif/X11GB2312.class" >> $@
$(ECHO) "sun/awt/motif/X11GBK$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11GBK\$$Encoder.class" >> $@
$(ECHO) "sun/awt/motif/X11GBK.class" >> $@ $(ECHO) "sun/awt/motif/X11GBK.class" >> $@
$(ECHO) "sun/awt/motif/X11KSC5601$Decoder.class" >> $@ $(ECHO) "sun/awt/motif/X11KSC5601\$$Decoder.class" >> $@
$(ECHO) "sun/awt/motif/X11KSC5601$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11KSC5601\$$Encoder.class" >> $@
$(ECHO) "sun/awt/motif/X11KSC5601.class" >> $@ $(ECHO) "sun/awt/motif/X11KSC5601.class" >> $@
$(ECHO) "sun/rmi/rmic/" >> $@ $(ECHO) "sun/rmi/rmic/" >> $@
$(ECHO) "sun/tools/asm/" >> $@ $(ECHO) "sun/tools/asm/" >> $@
......
...@@ -61,6 +61,7 @@ endif ...@@ -61,6 +61,7 @@ endif
# Get compiler version # Get compiler version
_CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1) _CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1)
CC_VER :=$(call GetVersion,"$(_CC_VER)") CC_VER :=$(call GetVersion,"$(_CC_VER)")
CC_MINORVER :=$(call MinorVersion,$(CC_VER))
# Name of compilers being used # Name of compilers being used
COMPILER_VERSION-5.7 = SS10 COMPILER_VERSION-5.7 = SS10
...@@ -69,8 +70,10 @@ COMPILER_VERSION-5.8 = SS11 ...@@ -69,8 +70,10 @@ COMPILER_VERSION-5.8 = SS11
COMPILER_NAME-5.8 = Sun Studio 11 COMPILER_NAME-5.8 = Sun Studio 11
COMPILER_VERSION-5.9 = SS12 COMPILER_VERSION-5.9 = SS12
COMPILER_NAME-5.9 = Sun Studio 12 COMPILER_NAME-5.9 = Sun Studio 12
COMPILER_VERSION-5.10 = SS13 COMPILER_VERSION-5.10 = SS12u1
COMPILER_NAME-5.10 = Sun Studio 13 COMPILER_NAME-5.10 = Sun Studio 12 Update 1
COMPILER_VERSION-5.11 = OSS12u2
COMPILER_NAME-5.11 = Oracle Solaris Studio 12 Update 2
COMPILER_VERSION = $(COMPILER_VERSION-$(CC_VER)) COMPILER_VERSION = $(COMPILER_VERSION-$(CC_VER))
COMPILER_NAME = $(COMPILER_NAME-$(CC_VER)) COMPILER_NAME = $(COMPILER_NAME-$(CC_VER))
...@@ -112,8 +115,8 @@ ifeq ($(ARCH_FAMILY), i586) ...@@ -112,8 +115,8 @@ ifeq ($(ARCH_FAMILY), i586)
XARCH_OPTION_OLD/64 += -xarch=amd64 XARCH_OPTION_OLD/64 += -xarch=amd64
LINT_XARCH_OPTION_OLD/64 += -Xarch=amd64 LINT_XARCH_OPTION_OLD/64 += -Xarch=amd64
endif endif
# Pick the options we want based on the compiler being used. # Pick the options we want based on the compiler being used. (5.9 or newer)
ifeq ($(shell expr $(CC_VER) \>= 5.9), 1) ifeq ($(shell expr $(CC_MINORVER) \>= 9), 1)
XARCH_OPTION/32 = $(XARCH_OPTION_NEW/32) XARCH_OPTION/32 = $(XARCH_OPTION_NEW/32)
XARCH_OPTION/64 = $(XARCH_OPTION_NEW/64) XARCH_OPTION/64 = $(XARCH_OPTION_NEW/64)
LINT_XARCH_OPTION/32 = $(LINT_XARCH_OPTION_NEW/32) LINT_XARCH_OPTION/32 = $(LINT_XARCH_OPTION_NEW/32)
......
...@@ -120,10 +120,10 @@ ifeq ($(PLATFORM), solaris) ...@@ -120,10 +120,10 @@ ifeq ($(PLATFORM), solaris)
else else
REQUIRED_FREE_SPACE = 1040000 REQUIRED_FREE_SPACE = 1040000
endif endif
REQUIRED_COMPILER_NAME = Sun Studio 12 REQUIRED_COMPILER_NAME = Sun Studio 12 Update 1
REQUIRED_COMPILER_VERSION = SS12 REQUIRED_COMPILER_VERSION = SS12u1
ifeq ($(CC_VERSION),sun) ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.9 REQUIRED_CC_VER = 5.10
endif endif
ifeq ($(CC_VERSION),gcc) ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 3.4.3 REQUIRED_CC_VER = 3.4.3
...@@ -145,7 +145,7 @@ ifeq ($(PLATFORM), linux) ...@@ -145,7 +145,7 @@ ifeq ($(PLATFORM), linux)
REQUIRED_CC_VER = 4.3.0 REQUIRED_CC_VER = 4.3.0
endif endif
ifeq ($(CC_VERSION),sun) ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.9 REQUIRED_CC_VER = 5.10
endif endif
endif endif
......
...@@ -91,6 +91,8 @@ SCTPAPI_PKGS = com.sun.nio.sctp ...@@ -91,6 +91,8 @@ SCTPAPI_PKGS = com.sun.nio.sctp
TRACING_PKGS = com.sun.tracing \ TRACING_PKGS = com.sun.tracing \
com.sun.tracing.dtrace com.sun.tracing.dtrace
ORACLENET_PKGS = com.oracle.net
# non-core packages in rt.jar # non-core packages in rt.jar
NON_CORE_PKGS = $(DOMAPI_PKGS) \ NON_CORE_PKGS = $(DOMAPI_PKGS) \
$(MGMT_PKGS) \ $(MGMT_PKGS) \
...@@ -101,5 +103,6 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \ ...@@ -101,5 +103,6 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \
$(HTTPSERVER_PKGS) \ $(HTTPSERVER_PKGS) \
$(SMARTCARDIO_PKGS) \ $(SMARTCARDIO_PKGS) \
$(TRACING_PKGS) \ $(TRACING_PKGS) \
$(SCTPAPI_PKGS) $(SCTPAPI_PKGS) \
$(ORACLENET_PKGS)
...@@ -39,10 +39,6 @@ FILES_c = \ ...@@ -39,10 +39,6 @@ FILES_c = \
ResolverConfigurationImpl.c \ ResolverConfigurationImpl.c \
DefaultProxySelector.c DefaultProxySelector.c
ifeq ($(PLATFORM), solaris)
FILES_c += SdpProvider.c
endif
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
FILES_c += linux_close.c FILES_c += linux_close.c
endif endif
......
...@@ -44,6 +44,8 @@ ifeq ($(PLATFORM), windows) ...@@ -44,6 +44,8 @@ ifeq ($(PLATFORM), windows)
endif endif
FILES_c += NTLMAuthSequence.c FILES_c += NTLMAuthSequence.c
FILES_c += NetworkInterface_winXP.c FILES_c += NetworkInterface_winXP.c
else
FILES_c += SdpSupport.c
endif endif
FILES_export = \ FILES_export = \
...@@ -84,7 +86,8 @@ endif ...@@ -84,7 +86,8 @@ endif
# #
# Find platform specific native code # Find platform specific native code
# #
vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http/ntlm $(PLATFORM_SRC)/native/sun/net/spi vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http/ntlm \
$(PLATFORM_SRC)/native/sun/net/sdp $(PLATFORM_SRC)/native/sun/net/spi
# #
# Include rules # Include rules
......
...@@ -88,9 +88,10 @@ SUNWprivate_1.1 { ...@@ -88,9 +88,10 @@ SUNWprivate_1.1 {
Java_java_net_PlainDatagramSocketImpl_setTimeToLive; Java_java_net_PlainDatagramSocketImpl_setTimeToLive;
Java_sun_net_dns_ResolverConfigurationImpl_localDomain0; Java_sun_net_dns_ResolverConfigurationImpl_localDomain0;
Java_sun_net_dns_ResolverConfigurationImpl_fallbackDomain0; Java_sun_net_dns_ResolverConfigurationImpl_fallbackDomain0;
Java_sun_net_sdp_SdpSupport_convert0;
Java_sun_net_sdp_SdpSupport_create0;
Java_sun_net_spi_DefaultProxySelector_init; Java_sun_net_spi_DefaultProxySelector_init;
Java_sun_net_spi_DefaultProxySelector_getSystemProxy; Java_sun_net_spi_DefaultProxySelector_getSystemProxy;
Java_sun_net_spi_SdpProvider_convert;
NET_AllocSockaddr; NET_AllocSockaddr;
NET_SockaddrToInetAddress; NET_SockaddrToInetAddress;
NET_SockaddrEqualsInetAddress; NET_SockaddrEqualsInetAddress;
......
...@@ -83,6 +83,7 @@ FILES_src = \ ...@@ -83,6 +83,7 @@ FILES_src = \
java/nio/file/ClosedFileSystemException.java \ java/nio/file/ClosedFileSystemException.java \
java/nio/file/ClosedWatchServiceException.java \ java/nio/file/ClosedWatchServiceException.java \
java/nio/file/CopyOption.java \ java/nio/file/CopyOption.java \
java/nio/file/DirectoryIteratorException.java \
java/nio/file/DirectoryNotEmptyException.java \ java/nio/file/DirectoryNotEmptyException.java \
java/nio/file/DirectoryStream.java \ java/nio/file/DirectoryStream.java \
java/nio/file/FileAlreadyExistsException.java \ java/nio/file/FileAlreadyExistsException.java \
...@@ -199,6 +200,7 @@ FILES_src = \ ...@@ -199,6 +200,7 @@ FILES_src = \
sun/nio/ch/PipeImpl.java \ sun/nio/ch/PipeImpl.java \
sun/nio/ch/PollArrayWrapper.java \ sun/nio/ch/PollArrayWrapper.java \
sun/nio/ch/Reflect.java \ sun/nio/ch/Reflect.java \
sun/nio/ch/Secrets.java \
sun/nio/ch/SelectionKeyImpl.java \ sun/nio/ch/SelectionKeyImpl.java \
sun/nio/ch/SelectorImpl.java \ sun/nio/ch/SelectorImpl.java \
sun/nio/ch/SelectorProviderImpl.java \ sun/nio/ch/SelectorProviderImpl.java \
......
...@@ -89,7 +89,7 @@ SUNWprivate_1.1 { ...@@ -89,7 +89,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_IOUtil_drain; Java_sun_nio_ch_IOUtil_drain;
Java_sun_nio_ch_IOUtil_fdVal; Java_sun_nio_ch_IOUtil_fdVal;
Java_sun_nio_ch_IOUtil_initIDs; Java_sun_nio_ch_IOUtil_initIDs;
Java_sun_nio_ch_IOUtil_initPipe; Java_sun_nio_ch_IOUtil_makePipe;
Java_sun_nio_ch_IOUtil_randomBytes; Java_sun_nio_ch_IOUtil_randomBytes;
Java_sun_nio_ch_IOUtil_setfdVal; Java_sun_nio_ch_IOUtil_setfdVal;
Java_sun_nio_ch_NativeThread_current; Java_sun_nio_ch_NativeThread_current;
......
...@@ -76,7 +76,7 @@ SUNWprivate_1.1 { ...@@ -76,7 +76,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_IOUtil_drain; Java_sun_nio_ch_IOUtil_drain;
Java_sun_nio_ch_IOUtil_fdVal; Java_sun_nio_ch_IOUtil_fdVal;
Java_sun_nio_ch_IOUtil_initIDs; Java_sun_nio_ch_IOUtil_initIDs;
Java_sun_nio_ch_IOUtil_initPipe; Java_sun_nio_ch_IOUtil_makePipe;
Java_sun_nio_ch_IOUtil_randomBytes; Java_sun_nio_ch_IOUtil_randomBytes;
Java_sun_nio_ch_IOUtil_setfdVal; Java_sun_nio_ch_IOUtil_setfdVal;
Java_sun_nio_ch_NativeThread_current; Java_sun_nio_ch_NativeThread_current;
......
...@@ -43,6 +43,7 @@ SERVER_LOCATION = server ...@@ -43,6 +43,7 @@ SERVER_LOCATION = server
CLIENT_LOCATION = client CLIENT_LOCATION = client
DB_SUFFIX = _db DB_SUFFIX = _db
DTRACE_SUFFIX = _dtrace
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
LIB_LOCATION = $(BINDIR) LIB_LOCATION = $(BINDIR)
...@@ -56,6 +57,7 @@ JVMMAP_NAME = $(LIB_PREFIX)jvm.map ...@@ -56,6 +57,7 @@ JVMMAP_NAME = $(LIB_PREFIX)jvm.map
JVMPDB_NAME = $(LIB_PREFIX)jvm.pdb JVMPDB_NAME = $(LIB_PREFIX)jvm.pdb
LIBJSIG_NAME = $(LIB_PREFIX)jsig.$(LIBRARY_SUFFIX) LIBJSIG_NAME = $(LIB_PREFIX)jsig.$(LIBRARY_SUFFIX)
JVMDB_NAME = $(LIB_PREFIX)jvm$(DB_SUFFIX).$(LIBRARY_SUFFIX) JVMDB_NAME = $(LIB_PREFIX)jvm$(DB_SUFFIX).$(LIBRARY_SUFFIX)
JVMDTRACE_NAME = $(LIB_PREFIX)jvm$(DTRACE_SUFFIX).$(LIBRARY_SUFFIX)
CLASSSHARINGDATA_DIR = $(BUILDDIR)/tools/sharing CLASSSHARINGDATA_DIR = $(BUILDDIR)/tools/sharing
...@@ -161,6 +163,12 @@ IMPORT_LIST += \ ...@@ -161,6 +163,12 @@ IMPORT_LIST += \
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME) IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME)
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME) not found!)
endif
endif endif
ifneq ($(ZERO_BUILD), true) ifneq ($(ZERO_BUILD), true)
...@@ -171,14 +179,29 @@ IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) ...@@ -171,14 +179,29 @@ IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME)
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
# solaris vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv solaris # solaris vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv solaris
ifeq ($(ARCH), sparc)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
endif
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME) IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME)
ifeq ($(ARCH), sparc) # The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME) IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME) not found!)
endif
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) not found!)
endif
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME) not found!)
endif endif
# For backwards compatability, make a link of the 32-bit client JVM to $(LIBDIR) # For backwards compatability, make a link of the 32-bit client JVM to $(LIBDIR)
...@@ -224,6 +247,18 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB ...@@ -224,6 +247,18 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)
$(install-import-file) $(install-import-file)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAME) $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAME)
$(install-import-file) $(install-import-file)
......
...@@ -24,32 +24,12 @@ ...@@ -24,32 +24,12 @@
# #
# Properties for jprt # Properties for jprt
jprt.tools.default.release=jdk1.7.0
# Specific platform list # Use whatever release that the submitted job requests
jprt.build.platforms=\ jprt.tools.default.release=${jprt.submit.release}
solaris_sparc_5.10,\
solaris_sparcv9_5.10,\
solaris_i586_5.10,\
solaris_x64_5.10,\
linux_i586_2.6,\
linux_x64_2.6,\
windows_i586_5.0,\
windows_x64_5.2
# The different build flavors we want # The different build flavors we want, we override here so we just get these 2
jprt.build.flavors=product,fastdebug jprt.build.flavors=product,fastdebug
jprt.run.flavors=c1,c2
jprt.solaris_sparcv9.run.flavors=c2
jprt.solaris_x64.run.flavors=c2
jprt.windows_x64.run.flavors=c2
jprt.linux_x64.run.flavors=c2
jprt.run.flavor.c1.option=-client
jprt.run.flavor.c2.option=-server
# Explicitly designate what the 32bit match is for the 64bit build
jprt.solaris_sparcv9.build.platform.match32=solaris_sparc_5.10
jprt.solaris_x64.build.platform.match32=solaris_i586_5.10
# Standard test target for everybody # Standard test target for everybody
jprt.test.targets=*-*-*-jvm98 jprt.test.targets=*-*-*-jvm98
...@@ -83,6 +63,6 @@ jprt2.make.rule.test.targets= \ ...@@ -83,6 +63,6 @@ jprt2.make.rule.test.targets= \
*-product-*-jdk_rmi, \ *-product-*-jdk_rmi, \
*-product-*-jdk_swing, \ *-product-*-jdk_swing, \
# Directories needed to build # Directories to be excluded from the source bundles
jprt.bundle.exclude.src.dirs=build jprt.bundle.exclude.src.dirs=build dist webrev
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
FILES_c = \ FILES_c = \
cmscam02.c \ cmscam02.c \
cmscam97.c \
cmscgats.c \ cmscgats.c \
cmscnvrt.c \ cmscnvrt.c \
cmserr.c \ cmserr.c \
...@@ -35,13 +34,17 @@ FILES_c = \ ...@@ -35,13 +34,17 @@ FILES_c = \
cmsio0.c \ cmsio0.c \
cmsio1.c \ cmsio1.c \
cmslut.c \ cmslut.c \
cmsmatsh.c \ cmsmd5.c \
cmsmtrx.c \ cmsmtrx.c \
cmsnamed.c \ cmsnamed.c \
cmsopt.c \
cmspack.c \ cmspack.c \
cmspcs.c \ cmspcs.c \
cmsplugin.c \
cmsps2.c \ cmsps2.c \
cmssamp.c \ cmssamp.c \
cmssm.c \
cmstypes.c \
cmsvirt.c \ cmsvirt.c \
cmswtpnt.c \ cmswtpnt.c \
cmsxform.c \ cmsxform.c \
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
FILES_c = \ FILES_c = \
cmscam02.c \ cmscam02.c \
cmscam97.c \
cmscgats.c \ cmscgats.c \
cmscnvrt.c \ cmscnvrt.c \
cmserr.c \ cmserr.c \
...@@ -35,13 +34,17 @@ FILES_c = \ ...@@ -35,13 +34,17 @@ FILES_c = \
cmsio0.c \ cmsio0.c \
cmsio1.c \ cmsio1.c \
cmslut.c \ cmslut.c \
cmsmatsh.c \ cmsmd5.c \
cmsmtrx.c \ cmsmtrx.c \
cmsnamed.c \ cmsnamed.c \
cmsopt.c \
cmspack.c \ cmspack.c \
cmspcs.c \ cmspcs.c \
cmsplugin.c \
cmsps2.c \ cmsps2.c \
cmssamp.c \ cmssamp.c \
cmssm.c \
cmstypes.c \
cmsvirt.c \ cmsvirt.c \
cmswtpnt.c \ cmswtpnt.c \
cmsxform.c \ cmsxform.c \
......
...@@ -80,8 +80,8 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR) ...@@ -80,8 +80,8 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR)
vpath %.c $(SHARE_SRC)/native/sun/java2d vpath %.c $(SHARE_SRC)/native/sun/java2d
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
OTHER_CFLAGS += -DCMS_IS_WINDOWS_ -Dsqrtf=sqrt
OTHER_LDLIBS = user32.lib version.lib $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib
OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \ OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \
-I$(SHARE_SRC)/native/sun/awt/debug -I$(SHARE_SRC)/native/sun/awt/debug
......
...@@ -53,6 +53,7 @@ FILES_java = \ ...@@ -53,6 +53,7 @@ FILES_java = \
sun/net/ftp/FtpProtocolException.java \ sun/net/ftp/FtpProtocolException.java \
sun/net/ftp/impl/FtpClient.java \ sun/net/ftp/impl/FtpClient.java \
sun/net/ftp/impl/DefaultFtpClientProvider.java \ sun/net/ftp/impl/DefaultFtpClientProvider.java \
sun/net/sdp/SdpSupport.java \
sun/net/spi/DefaultProxySelector.java \ sun/net/spi/DefaultProxySelector.java \
sun/net/spi/nameservice/NameServiceDescriptor.java \ sun/net/spi/nameservice/NameServiceDescriptor.java \
sun/net/spi/nameservice/NameService.java \ sun/net/spi/nameservice/NameService.java \
...@@ -136,8 +137,6 @@ FILES_java = \ ...@@ -136,8 +137,6 @@ FILES_java = \
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
FILES_java += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java FILES_java += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java
endif else
FILES_java += sun/net/sdp/SdpProvider.java
ifeq ($(PLATFORM), solaris)
FILES_java += sun/net/spi/SdpProvider.java
endif endif
...@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public License version ...@@ -17,6 +17,6 @@ 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, 2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
CA 95054 USA or visit www.sun.com if you need additional information or or visit www.oracle.com if you need additional information or have any
have any questions. questions.
...@@ -15,6 +15,6 @@ You should have received a copy of the GNU General Public License version ...@@ -15,6 +15,6 @@ 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, 2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
CA 95054 USA or visit www.sun.com if you need additional information or or visit www.oracle.com if you need additional information or have any
have any questions. questions.
...@@ -712,19 +712,19 @@ SetModulesBootClassPath(const char *jrepath) ...@@ -712,19 +712,19 @@ SetModulesBootClassPath(const char *jrepath)
struct stat statbuf; struct stat statbuf;
/* return if jre/lib/rt.jar exists */ /* return if jre/lib/rt.jar exists */
sprintf(pathname, "%s%slib%srt.jar", jrepath, separator, separator); JLI_Snprintf(pathname, sizeof(pathname), "%s%slib%srt.jar", jrepath, separator, separator);
if (stat(pathname, &statbuf) == 0) { if (stat(pathname, &statbuf) == 0) {
return; return;
} }
/* return if jre/classes exists */ /* return if jre/classes exists */
sprintf(pathname, "%s%sclasses", jrepath, separator); JLI_Snprintf(pathname, sizeof(pathname), "%s%sclasses", jrepath, separator);
if (stat(pathname, &statbuf) == 0) { if (stat(pathname, &statbuf) == 0) {
return; return;
} }
/* modularized jre */ /* modularized jre */
sprintf(pathname, "%s%slib%s*", jrepath, separator, separator); JLI_Snprintf(pathname, sizeof(pathname), "%s%slib%s*", jrepath, separator, separator);
s = (char *) JLI_WildcardExpandClasspath(pathname); s = (char *) JLI_WildcardExpandClasspath(pathname);
def = JLI_MemAlloc(sizeof(format) def = JLI_MemAlloc(sizeof(format)
- 2 /* strlen("%s") */ - 2 /* strlen("%s") */
...@@ -1624,11 +1624,8 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) ...@@ -1624,11 +1624,8 @@ ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative)
if (JLI_IsTraceLauncher()) { if (JLI_IsTraceLauncher()) {
start = CounterGet(); start = CounterGet();
} }
JLI_Snprintf(jvmCfgName, sizeof(jvmCfgName), "%s%slib%s%s%sjvm.cfg",
JLI_StrCpy(jvmCfgName, jrepath); jrepath, FILESEP, FILESEP, arch, FILESEP);
JLI_StrCat(jvmCfgName, FILESEP "lib" FILESEP);
JLI_StrCat(jvmCfgName, arch);
JLI_StrCat(jvmCfgName, FILESEP "jvm.cfg");
jvmCfg = fopen(jvmCfgName, "r"); jvmCfg = fopen(jvmCfgName, "r");
if (jvmCfg == NULL) { if (jvmCfg == NULL) {
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.net;
import java.net.Socket;
import java.net.ServerSocket;
import java.net.SocketImpl;
import java.net.SocketImplFactory;
import java.net.SocketException;
import java.nio.channels.SocketChannel;
import java.nio.channels.ServerSocketChannel;
import java.io.IOException;
import java.io.FileDescriptor;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.lang.reflect.Constructor;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.InvocationTargetException;
import sun.net.sdp.SdpSupport;
/**
* This class consists exclusively of static methods that Sockets or Channels to
* sockets that support the InfiniBand Sockets Direct Protocol (SDP).
*/
public final class Sdp {
private Sdp() { }
/**
* The package-privage ServerSocket(SocketImpl) constructor
*/
private static final Constructor<ServerSocket> serverSocketCtor;
static {
try {
serverSocketCtor = (Constructor<ServerSocket>)
ServerSocket.class.getDeclaredConstructor(SocketImpl.class);
setAccessible(serverSocketCtor);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
/**
* The package-private SdpSocketImpl() constructor
*/
private static final Constructor<SocketImpl> socketImplCtor;
static {
try {
Class<?> cl = Class.forName("java.net.SdpSocketImpl", true, null);
socketImplCtor = (Constructor<SocketImpl>)cl.getDeclaredConstructor();
setAccessible(socketImplCtor);
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
private static void setAccessible(final AccessibleObject o) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
o.setAccessible(true);
return null;
}
});
}
/**
* SDP enabled Socket.
*/
private static class SdpSocket extends Socket {
SdpSocket(SocketImpl impl) throws SocketException {
super(impl);
}
}
/**
* Creates a SDP enabled SocketImpl
*/
private static SocketImpl createSocketImpl() {
try {
return socketImplCtor.newInstance();
} catch (InstantiationException x) {
throw new AssertionError(x);
} catch (IllegalAccessException x) {
throw new AssertionError(x);
} catch (InvocationTargetException x) {
throw new AssertionError(x);
}
}
/**
* Creates an unconnected and unbound SDP socket. The {@code Socket} is
* associated with a {@link java.net.SocketImpl} of the system-default type.
*
* @return a new Socket
*
* @throws UnsupportedOperationException
* If SDP is not supported
* @throws IOException
* If an I/O error occurs
*/
public static Socket openSocket() throws IOException {
SocketImpl impl = createSocketImpl();
return new SdpSocket(impl);
}
/**
* Creates an unbound SDP server socket. The {@code ServerSocket} is
* associated with a {@link java.net.SocketImpl} of the system-default type.
*
* @return a new ServerSocket
*
* @throws UnsupportedOperationException
* If SDP is not supported
* @throws IOException
* If an I/O error occurs
*/
public static ServerSocket openServerSocket() throws IOException {
// create ServerSocket via package-private constructor
SocketImpl impl = createSocketImpl();
try {
return serverSocketCtor.newInstance(impl);
} catch (IllegalAccessException x) {
throw new AssertionError(x);
} catch (InstantiationException x) {
throw new AssertionError(x);
} catch (InvocationTargetException x) {
Throwable cause = x.getCause();
if (cause instanceof IOException)
throw (IOException)cause;
if (cause instanceof RuntimeException)
throw (RuntimeException)cause;
throw new RuntimeException(x);
}
}
/**
* Opens a socket channel to a SDP socket.
*
* <p> The channel will be associated with the system-wide default
* {@link java.nio.channels.spi.SelectorProvider SelectorProvider}.
*
* @return a new SocketChannel
*
* @throws UnsupportedOperationException
* If SDP is not supported or not supported by the default selector
* provider
* @throws IOException
* If an I/O error occurs.
*/
public static SocketChannel openSocketChannel() throws IOException {
FileDescriptor fd = SdpSupport.createSocket();
return sun.nio.ch.Secrets.newSocketChannel(fd);
}
/**
* Opens a socket channel to a SDP socket.
*
* <p> The channel will be associated with the system-wide default
* {@link java.nio.channels.spi.SelectorProvider SelectorProvider}.
*
* @return a new ServerSocketChannel
*
* @throws UnsupportedOperationException
* If SDP is not supported or not supported by the default selector
* provider
* @throws IOException
* If an I/O error occurs
*/
public static ServerSocketChannel openServerSocketChannel()
throws IOException
{
FileDescriptor fd = SdpSupport.createSocket();
return sun.nio.ch.Secrets.newServerSocketChannel(fd);
}
}
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -518,7 +518,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern ...@@ -518,7 +518,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
setReadOnly(true); setReadOnly(true);
setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
setEscapeProcessing(true); setEscapeProcessing(true);
setTypeMap(null); //setTypeMap(null);
checkTransactionalWriter(); checkTransactionalWriter();
//Instantiating the vector for MatchColumns //Instantiating the vector for MatchColumns
...@@ -679,7 +679,10 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern ...@@ -679,7 +679,10 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
} else if (obj instanceof Clob) { } else if (obj instanceof Clob) {
obj = new SerialClob((Clob)obj); obj = new SerialClob((Clob)obj);
} else if (obj instanceof java.sql.Array) { } else if (obj instanceof java.sql.Array) {
obj = new SerialArray((java.sql.Array)obj, map); if(map != null)
obj = new SerialArray((java.sql.Array)obj, map);
else
obj = new SerialArray((java.sql.Array)obj);
} }
((Row)currentRow).initColumnObject(i, obj); ((Row)currentRow).initColumnObject(i, obj);
...@@ -762,7 +765,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern ...@@ -762,7 +765,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
if( conn != null){ if( conn != null){
// JDBC 4.0 mandates as does the Java EE spec that all DataBaseMetaData methods // JDBC 4.0 mandates as does the Java EE spec that all DataBaseMetaData methods
// must be implemented, therefore, the previous fix for 5055528 is being backed out // must be implemented, therefore, the previous fix for 5055528 is being backed out
dbmslocatorsUpdateCopy = conn.getMetaData().locatorsUpdateCopy(); dbmslocatorsUpdateCopy = conn.getMetaData().locatorsUpdateCopy();
} }
} }
...@@ -6322,6 +6325,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern ...@@ -6322,6 +6325,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
crs.RowSetMD = RowSetMD; crs.RowSetMD = RowSetMD;
crs.numRows = 1; crs.numRows = 1;
crs.cursorPos = 0; crs.cursorPos = 0;
crs.setTypeMap(this.getTypeMap());
// make sure we don't get someone playing with these // make sure we don't get someone playing with these
// %%% is this now necessary ??? // %%% is this now necessary ???
...@@ -10114,7 +10118,7 @@ a ...@@ -10114,7 +10118,7 @@ a
* during the deserialization process * during the deserialization process
* *
*/ */
protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here // Default state initialization happens here
ois.defaultReadObject(); ois.defaultReadObject();
// Initialization of transient Res Bundle happens here . // Initialization of transient Res Bundle happens here .
...@@ -10125,5 +10129,15 @@ a ...@@ -10125,5 +10129,15 @@ a
} }
} }
static final long serialVersionUID =1884577171200622428L;
//------------------------- JDBC 4.1 -----------------------------------
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
throw new SQLFeatureNotSupportedException("Not supported yet.");
}
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
throw new SQLFeatureNotSupportedException("Not supported yet.");
}
static final long serialVersionUID =1884577171200622428L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1746,5 +1746,23 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C ...@@ -1746,5 +1746,23 @@ public class FilteredRowSetImpl extends WebRowSetImpl implements Serializable, C
onInsertRow = false; onInsertRow = false;
super.insertRow(); super.insertRow();
} }
static final long serialVersionUID = 6178454588413509360L;
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = 6178454588413509360L;
} // end FilteredRowSetImpl class } // end FilteredRowSetImpl class
/* /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -153,4 +153,5 @@ public class JdbcRowSetResourceBundle implements Serializable { ...@@ -153,4 +153,5 @@ public class JdbcRowSetResourceBundle implements Serializable {
return propResBundle.handleGetObject(key); return propResBundle.handleGetObject(key);
} }
static final long serialVersionUID = 436199386225359954L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -127,6 +127,11 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet { ...@@ -127,6 +127,11 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
strMatchKey = null; strMatchKey = null;
supportedJOINs = supportedJOINs =
new boolean[] {false, true, false, false, false}; new boolean[] {false, true, false, false, false};
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
} }
...@@ -4306,5 +4311,22 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet { ...@@ -4306,5 +4311,22 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet {
return crsInternal.createCopySchema(); return crsInternal.createCopySchema();
} }
static final long serialVersionUID = -5590501621560008453L; /**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = -5590501621560008453L;
} }
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.rowset;
import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.FilteredRowSet;
import javax.sql.rowset.JdbcRowSet;
import javax.sql.rowset.JoinRowSet;
import javax.sql.rowset.WebRowSet;
import javax.sql.rowset.RowSetFactory;
/**
* This is the implementation specific class for the
* <code>javax.sql.rowset.spi.RowSetFactory</code>. This is the platform
* default implementation for the Java SE platform.
*
* @author Lance Andersen
*
*
* @version 1.7
*/
public final class RowSetFactoryImpl implements RowSetFactory {
public CachedRowSet createCachedRowSet() throws SQLException {
return new com.sun.rowset.CachedRowSetImpl();
}
public FilteredRowSet createFilteredRowSet() throws SQLException {
return new com.sun.rowset.FilteredRowSetImpl();
}
public JdbcRowSet createJdbcRowSet() throws SQLException {
return new com.sun.rowset.JdbcRowSetImpl();
}
public JoinRowSet createJoinRowSet() throws SQLException {
return new com.sun.rowset.JoinRowSetImpl();
}
public WebRowSet createWebRowSet() throws SQLException {
return new com.sun.rowset.WebRowSetImpl();
}
}
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -103,6 +103,12 @@ public class WebRowSetImpl extends CachedRowSetImpl implements WebRowSet { ...@@ -103,6 +103,12 @@ public class WebRowSetImpl extends CachedRowSetImpl implements WebRowSet {
*/ */
public WebRowSetImpl(Hashtable env) throws SQLException { public WebRowSetImpl(Hashtable env) throws SQLException {
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
if ( env == null) { if ( env == null) {
throw new SQLException(resBundle.handleGetObject("webrowsetimpl.nullhash").toString()); throw new SQLException(resBundle.handleGetObject("webrowsetimpl.nullhash").toString());
} }
...@@ -263,5 +269,23 @@ public class WebRowSetImpl extends CachedRowSetImpl implements WebRowSet { ...@@ -263,5 +269,23 @@ public class WebRowSetImpl extends CachedRowSetImpl implements WebRowSet {
this.writeXml(oStream); this.writeXml(oStream);
} }
static final long serialVersionUID = -8771775154092422943L;
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = -8771775154092422943L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -490,4 +490,17 @@ public class CachedRowSetReader implements RowSetReader, Serializable { ...@@ -490,4 +490,17 @@ public class CachedRowSetReader implements RowSetReader, Serializable {
startPosition = pos; startPosition = pos;
} }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID =5049738185801363801L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,7 +31,13 @@ import java.util.*; ...@@ -31,7 +31,13 @@ import java.util.*;
import java.io.*; import java.io.*;
import com.sun.rowset.*; import com.sun.rowset.*;
import java.text.MessageFormat;
import javax.sql.rowset.*; import javax.sql.rowset.*;
import javax.sql.rowset.serial.SQLInputImpl;
import javax.sql.rowset.serial.SerialArray;
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialStruct;
import javax.sql.rowset.spi.*; import javax.sql.rowset.spi.*;
...@@ -53,6 +59,7 @@ import javax.sql.rowset.spi.*; ...@@ -53,6 +59,7 @@ import javax.sql.rowset.spi.*;
* Standard JDBC RowSet implementations provide an object instance of this * Standard JDBC RowSet implementations provide an object instance of this
* writer by invoking the <code>SyncProvider.getRowSetWriter()</code> method. * writer by invoking the <code>SyncProvider.getRowSetWriter()</code> method.
* *
* @version 0.2
* @author Jonathan Bruce * @author Jonathan Bruce
* @see javax.sql.rowset.spi.SyncProvider * @see javax.sql.rowset.spi.SyncProvider
* @see javax.sql.rowset.spi.SyncFactory * @see javax.sql.rowset.spi.SyncFactory
...@@ -508,10 +515,11 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -508,10 +515,11 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
ResultSet rs = null; ResultSet rs = null;
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next() == true) { ResultSetMetaData rsmd = rs.getMetaData();
if (rs.next()) {
if (rs.next()) { if (rs.next()) {
/** More than one row conflict. /** More than one row conflict.
* If rs has only one row we are able to * If rs has only one row we are able to
* uniquely identify the row where update * uniquely identify the row where update
* have to happen else if more than one * have to happen else if more than one
...@@ -528,7 +536,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -528,7 +536,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// we require the record in rs to be used. // we require the record in rs to be used.
// rs.close(); // rs.close();
// pstmt.close(); // pstmt.close();
rs.first(); rs.first();
// how many fields need to be updated // how many fields need to be updated
int colsNotChanged = 0; int colsNotChanged = 0;
...@@ -552,6 +560,49 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -552,6 +560,49 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
orig = origVals.getObject(i); orig = origVals.getObject(i);
curr = crs.getObject(i); curr = crs.getObject(i);
rsval = rs.getObject(i); rsval = rs.getObject(i);
/*
* the following block creates equivalent objects
* that would have been created if this rs is populated
* into a CachedRowSet so that comparison of the column values
* from the ResultSet and CachedRowSet are possible
*/
Map map = (crs.getTypeMap() == null)?con.getTypeMap():crs.getTypeMap();
if (rsval instanceof Struct) {
Struct s = (Struct)rsval;
// look up the class in the map
Class c = null;
c = (Class)map.get(s.getSQLTypeName());
if (c != null) {
// create new instance of the class
SQLData obj = null;
try {
obj = (SQLData)c.newInstance();
} catch (java.lang.InstantiationException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
} catch (java.lang.IllegalAccessException ex) {
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
ex.getMessage()));
}
// get the attributes from the struct
Object attribs[] = s.getAttributes(map);
// create the SQLInput "stream"
SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);
// read the values...
obj.readSQL(sqlInput, s.getSQLTypeName());
rsval = obj;
}
} else if (rsval instanceof SQLData) {
rsval = new SerialStruct((SQLData)rsval, map);
} else if (rsval instanceof Blob) {
rsval = new SerialBlob((Blob)rsval);
} else if (rsval instanceof Clob) {
rsval = new SerialClob((Clob)rsval);
} else if (rsval instanceof java.sql.Array) {
rsval = new SerialArray((java.sql.Array)rsval, map);
}
// reset boolNull if it had been set // reset boolNull if it had been set
boolNull = true; boolNull = true;
...@@ -669,6 +720,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -669,6 +720,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
} }
} //end for } //end for
rs.close();
pstmt.close();
this.crsResolve.insertRow(); this.crsResolve.insertRow();
this.crsResolve.moveToCurrentRow(); this.crsResolve.moveToCurrentRow();
...@@ -1179,11 +1233,22 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -1179,11 +1233,22 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
private void buildKeyDesc(CachedRowSet crs) throws SQLException { private void buildKeyDesc(CachedRowSet crs) throws SQLException {
keyCols = crs.getKeyColumns(); keyCols = crs.getKeyColumns();
ResultSetMetaData resultsetmd = crs.getMetaData();
if (keyCols == null || keyCols.length == 0) { if (keyCols == null || keyCols.length == 0) {
keyCols = new int[callerColumnCount]; ArrayList<Integer> listKeys = new ArrayList<Integer>();
for (int i = 0; i < keyCols.length; ) {
keyCols[i] = ++i; for (int i = 0; i < callerColumnCount; i++ ) {
if(resultsetmd.getColumnType(i+1) != java.sql.Types.CLOB &&
resultsetmd.getColumnType(i+1) != java.sql.Types.STRUCT &&
resultsetmd.getColumnType(i+1) != java.sql.Types.SQLXML &&
resultsetmd.getColumnType(i+1) != java.sql.Types.BLOB &&
resultsetmd.getColumnType(i+1) != java.sql.Types.ARRAY &&
resultsetmd.getColumnType(i+1) != java.sql.Types.OTHER )
listKeys.add(i+1);
} }
keyCols = new int[listKeys.size()];
for (int i = 0; i < listKeys.size(); i++ )
keyCols[i] = listKeys.get(i);
} }
params = new Object[keyCols.length]; params = new Object[keyCols.length];
} }
...@@ -1359,4 +1424,17 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -1359,4 +1424,17 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
} }
} }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID =-8506030970299413976L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -157,4 +157,23 @@ public class InsertRow extends BaseRow implements Serializable, Cloneable { ...@@ -157,4 +157,23 @@ public class InsertRow extends BaseRow implements Serializable, Cloneable {
origVals[idx - 1] = val; origVals[idx - 1] = val;
markColInserted(idx - 1); markColInserted(idx - 1);
} }
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = 1066099658102869344L;
} }
/* /*
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -35,6 +35,7 @@ import javax.sql.rowset.spi.*; ...@@ -35,6 +35,7 @@ import javax.sql.rowset.spi.*;
import com.sun.rowset.*; import com.sun.rowset.*;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream;
/** /**
* There will be two sets of data which will be maintained by the rowset at the * There will be two sets of data which will be maintained by the rowset at the
...@@ -4837,4 +4838,23 @@ public class SyncResolverImpl extends CachedRowSetImpl implements SyncResolver { ...@@ -4837,4 +4838,23 @@ public class SyncResolverImpl extends CachedRowSetImpl implements SyncResolver {
throws SQLException { throws SQLException {
throw new UnsupportedOperationException("Operation not yet supported"); throw new UnsupportedOperationException("Operation not yet supported");
} }
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = -3345004441725080251L;
} //end class } //end class
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -216,4 +216,22 @@ public class WebRowSetXmlReader implements XmlReader, Serializable { ...@@ -216,4 +216,22 @@ public class WebRowSetXmlReader implements XmlReader, Serializable {
public void readData(RowSetInternal caller) { public void readData(RowSetInternal caller) {
} }
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = -9127058392819008014L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -663,4 +663,23 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable { ...@@ -663,4 +663,23 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable {
return s; return s;
} }
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID = 7163134986189677641L;
} }
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -245,4 +245,18 @@ public final class RIOptimisticProvider extends SyncProvider implements Serializ ...@@ -245,4 +245,18 @@ public final class RIOptimisticProvider extends SyncProvider implements Serializ
public String getVendor() { public String getVendor() {
return this.vendorName; return this.vendorName;
} }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Default state initialization happens here
ois.defaultReadObject();
// Initialization of transient Res Bundle happens here .
try {
resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
static final long serialVersionUID =-3143367176751761936L;
} }
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.ntlm;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
/**
* The NTLM client. Not multi-thread enabled.<p>
* Example:
* <pre>
* Client client = new Client(null, "host", "dummy",
* "REALM", "t0pSeCr3t".toCharArray());
* byte[] type1 = client.type1();
* // Send type1 to server and receive response as type2
* byte[] type3 = client.type3(type2, nonce);
* // Send type3 to server
* </pre>
*/
public final class Client extends NTLM {
final private String hostname;
final private String username;
private String domain; // might be updated by Type 2 msg
private byte[] pw1, pw2;
/**
* Creates an NTLM Client instance.
* @param version the NTLM version to use, which can be:
* <ul>
* <li>LM/NTLM: Original NTLM v1
* <li>LM: Original NTLM v1, LM only
* <li>NTLM: Original NTLM v1, NTLM only
* <li>NTLM2: NTLM v1 with Client Challenge
* <li>LMv2/NTLMv2: NTLM v2
* <li>LMv2: NTLM v2, LM only
* <li>NTLMv2: NTLM v2, NTLM only
* </ul>
* If null, "LMv2/NTLMv2" will be used.
* @param hostname hostname of the client, can be null
* @param username username to be authenticated, must not be null
* @param domain domain of {@code username}, can be null
* @param password password for {@code username}, must not be not null.
* This method does not make any modification to this parameter, it neither
* needs to access the content of this parameter after this method call,
* so you are free to modify or nullify this parameter after this call.
* @throws NullPointerException if {@code username} or {@code password} is null.
* @throws NTLMException if {@code version} is illegal
*/
public Client(String version, String hostname, String username,
String domain, char[] password) throws NTLMException {
super(version);
if ((username == null || password == null)) {
throw new NullPointerException("username/password cannot be null");
}
this.hostname = hostname;
this.username = username;
this.domain = domain;
this.pw1 = getP1(password);
this.pw2 = getP2(password);
debug("NTLM Client: (h,u,t,version(v)) = (%s,%s,%s,%s(%s))\n",
hostname, username, domain, version, v.toString());
}
/**
* Generates the Type 1 message
* @return the message generated
*/
public byte[] type1() {
Writer p = new Writer(1, 32);
int flags = 0x8203;
if (hostname != null) {
flags |= 0x2000;
}
if (domain != null) {
flags |= 0x1000;
}
if (v != Version.NTLM) {
flags |= 0x80000;
}
p.writeInt(12, flags);
p.writeSecurityBuffer(24, hostname, false);
p.writeSecurityBuffer(16, domain, false);
debug("NTLM Client: Type 1 created\n");
debug(p.getBytes());
return p.getBytes();
}
/**
* Generates the Type 3 message
* @param type2 the responding Type 2 message from server, must not be null
* @param nonce random 8-byte array to be used in message generation,
* must not be null except for original NTLM v1
* @return the message generated
* @throws NullPointerException if {@code type2} or {@code nonce} is null
* for NTLM v1.
* @throws NTLMException if the incoming message is invalid
*/
public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException {
if (type2 == null || (v != Version.NTLM && nonce == null)) {
throw new NullPointerException("type2 and nonce cannot be null");
}
debug("NTLM Client: Type 2 received\n");
debug(type2);
Reader r = new Reader(type2);
byte[] challenge = r.readBytes(24, 8);
int inputFlags = r.readInt(20);
boolean unicode = (inputFlags & 1) == 1;
String domainFromServer = r.readSecurityBuffer(12, unicode);
if (domainFromServer != null) {
domain = domainFromServer;
}
if (domain == null) {
throw new NTLMException(NTLMException.NO_DOMAIN_INFO,
"No domain info");
}
int flags = 0x88200 | (inputFlags & 3);
Writer p = new Writer(3, 64);
byte[] lm = null, ntlm = null;
p.writeSecurityBuffer(28, domain, unicode);
p.writeSecurityBuffer(36, username, unicode);
p.writeSecurityBuffer(44, hostname, unicode);
if (v == Version.NTLM) {
byte[] lmhash = calcLMHash(pw1);
byte[] nthash = calcNTHash(pw2);
if (writeLM) lm = calcResponse (lmhash, challenge);
if (writeNTLM) ntlm = calcResponse (nthash, challenge);
} else if (v == Version.NTLM2) {
byte[] nthash = calcNTHash(pw2);
lm = ntlm2LM(nonce);
ntlm = ntlm2NTLM(nthash, nonce, challenge);
} else {
byte[] nthash = calcNTHash(pw2);
if (writeLM) lm = calcV2(nthash,
username.toUpperCase(Locale.US)+domain, nonce, challenge);
if (writeNTLM) {
byte[] alist = type2.length > 48 ?
r.readSecurityBuffer(40) : new byte[0];
byte[] blob = new byte[32+alist.length];
System.arraycopy(new byte[]{1,1,0,0,0,0,0,0}, 0, blob, 0, 8);
// TS
byte[] time = BigInteger.valueOf(new Date().getTime())
.add(new BigInteger("11644473600000"))
.multiply(BigInteger.valueOf(10000))
.toByteArray();
for (int i=0; i<time.length; i++) {
blob[8+time.length-i-1] = time[i];
}
System.arraycopy(nonce, 0, blob, 16, 8);
System.arraycopy(new byte[]{0,0,0,0}, 0, blob, 24, 4);
System.arraycopy(alist, 0, blob, 28, alist.length);
System.arraycopy(new byte[]{0,0,0,0}, 0,
blob, 28+alist.length, 4);
ntlm = calcV2(nthash, username.toUpperCase(Locale.US)+domain,
blob, challenge);
}
}
p.writeSecurityBuffer(12, lm);
p.writeSecurityBuffer(20, ntlm);
p.writeSecurityBuffer(52, new byte[0]);
p.writeInt(60, flags);
debug("NTLM Client: Type 3 created\n");
debug(p.getBytes());
return p.getBytes();
}
/**
* Returns the domain value provided by server after the authentication
* is complete, or the domain value provided by the client before it.
* @return the domain
*/
public String getDomain() {
return domain;
}
/**
* Disposes any password-derived information.
*/
public void dispose() {
Arrays.fill(pw1, (byte)0);
Arrays.fill(pw2, (byte)0);
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.ntlm;
import static com.sun.security.ntlm.Version.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.SecretKeySpec;
/**
* NTLM authentication implemented according to MS-NLMP, version 12.1
* @since 1.7
*/
class NTLM {
private final SecretKeyFactory fac;
private final Cipher cipher;
private final MessageDigest md4;
private final Mac hmac;
private final MessageDigest md5;
private static final boolean DEBUG =
System.getProperty("ntlm.debug") != null;
final Version v;
final boolean writeLM;
final boolean writeNTLM;
protected NTLM(String version) throws NTLMException {
if (version == null) version = "LMv2/NTLMv2";
switch (version) {
case "LM": v = NTLM; writeLM = true; writeNTLM = false; break;
case "NTLM": v = NTLM; writeLM = false; writeNTLM = true; break;
case "LM/NTLM": v = NTLM; writeLM = writeNTLM = true; break;
case "NTLM2": v = NTLM2; writeLM = writeNTLM = true; break;
case "LMv2": v = NTLMv2; writeLM = true; writeNTLM = false; break;
case "NTLMv2": v = NTLMv2; writeLM = false; writeNTLM = true; break;
case "LMv2/NTLMv2": v = NTLMv2; writeLM = writeNTLM = true; break;
default: throw new NTLMException(NTLMException.BAD_VERSION,
"Unknown version " + version);
}
try {
fac = SecretKeyFactory.getInstance ("DES");
cipher = Cipher.getInstance ("DES/ECB/NoPadding");
md4 = sun.security.provider.MD4.getInstance();
hmac = Mac.getInstance("HmacMD5");
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchPaddingException e) {
throw new AssertionError();
} catch (NoSuchAlgorithmException e) {
throw new AssertionError();
}
}
/**
* Prints out a formatted string, called in various places inside then NTLM
* implementation for debugging/logging purposes. When the system property
* "ntlm.debug" is set, <code>System.out.printf(format, args)</code> is
* called. This method is designed to be overridden by child classes to
* match their own debugging/logging mechanisms.
* @param format a format string
* @param args the arguments referenced by <code>format</code>
* @see java.io.PrintStream#printf(java.lang.String, java.lang.Object[])
*/
public void debug(String format, Object... args) {
if (DEBUG) {
System.out.printf(format, args);
}
}
/**
* Prints out the content of a byte array, called in various places inside
* the NTLM implementation for debugging/logging purposes. When the system
* property "ntlm.debug" is set, the hexdump of the array is printed into
* System.out. This method is designed to be overridden by child classes to
* match their own debugging/logging mechanisms.
* @param bytes the byte array to print out
*/
public void debug(byte[] bytes) {
if (DEBUG) {
try {
new sun.misc.HexDumpEncoder().encodeBuffer(bytes, System.out);
} catch (IOException ioe) {
// Impossible
}
}
}
/**
* Reading an NTLM packet
*/
static class Reader {
private final byte[] internal;
Reader(byte[] data) {
internal = data;
}
int readInt(int offset) throws NTLMException {
try {
return internal[offset] & 0xff +
(internal[offset+1] & 0xff << 8) +
(internal[offset+2] & 0xff << 16) +
(internal[offset+3] & 0xff << 24);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Input message incorrect size");
}
}
int readShort(int offset) throws NTLMException {
try {
return internal[offset] & 0xff +
(internal[offset+1] & 0xff << 8);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Input message incorrect size");
}
}
byte[] readBytes(int offset, int len) throws NTLMException {
try {
return Arrays.copyOfRange(internal, offset, offset + len);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Input message incorrect size");
}
}
byte[] readSecurityBuffer(int offset) throws NTLMException {
int pos = readInt(offset+4);
if (pos == 0) return null;
try {
return Arrays.copyOfRange(
internal, pos, pos + readShort(offset));
} catch (ArrayIndexOutOfBoundsException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Input message incorrect size");
}
}
String readSecurityBuffer(int offset, boolean unicode)
throws NTLMException {
byte[] raw = readSecurityBuffer(offset);
try {
return raw == null ? null : new String(
raw, unicode ? "UnicodeLittleUnmarked" : "ISO8859_1");
} catch (UnsupportedEncodingException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Invalid input encoding");
}
}
}
/**
* Writing an NTLM packet
*/
static class Writer {
private byte[] internal; // buffer
private int current; // current written content interface buffer
/**
* Starts writing a NTLM packet
* @param type NEGOTIATE || CHALLENGE || AUTHENTICATE
* @param len the base length, without security buffers
*/
Writer(int type, int len) {
assert len < 256;
internal = new byte[256];
current = len;
System.arraycopy (
new byte[] {'N','T','L','M','S','S','P',0,(byte)type},
0, internal, 0, 9);
}
void writeShort(int offset, int number) {
internal[offset] = (byte)(number);
internal[offset+1] = (byte)(number >> 8);
}
void writeInt(int offset, int number) {
internal[offset] = (byte)(number);
internal[offset+1] = (byte)(number >> 8);
internal[offset+2] = (byte)(number >> 16);
internal[offset+3] = (byte)(number >> 24);
}
void writeBytes(int offset, byte[] data) {
System.arraycopy(data, 0, internal, offset, data.length);
}
void writeSecurityBuffer(int offset, byte[] data) {
if (data == null) {
writeShort(offset+4, current);
} else {
int len = data.length;
if (current + len > internal.length) {
internal = Arrays.copyOf(internal, current + len + 256);
}
writeShort(offset, len);
writeShort(offset+2, len);
writeShort(offset+4, current);
System.arraycopy(data, 0, internal, current, len);
current += len;
}
}
void writeSecurityBuffer(int offset, String str, boolean unicode) {
try {
writeSecurityBuffer(offset, str == null ? null : str.getBytes(
unicode ? "UnicodeLittleUnmarked" : "ISO8859_1"));
} catch (UnsupportedEncodingException ex) {
assert false;
}
}
byte[] getBytes() {
return Arrays.copyOf(internal, current);
}
}
// LM/NTLM
/* Convert a 7 byte array to an 8 byte array (for a des key with parity)
* input starts at offset off
*/
byte[] makeDesKey (byte[] input, int off) {
int[] in = new int [input.length];
for (int i=0; i<in.length; i++ ) {
in[i] = input[i]<0 ? input[i]+256: input[i];
}
byte[] out = new byte[8];
out[0] = (byte)in[off+0];
out[1] = (byte)(((in[off+0] << 7) & 0xFF) | (in[off+1] >> 1));
out[2] = (byte)(((in[off+1] << 6) & 0xFF) | (in[off+2] >> 2));
out[3] = (byte)(((in[off+2] << 5) & 0xFF) | (in[off+3] >> 3));
out[4] = (byte)(((in[off+3] << 4) & 0xFF) | (in[off+4] >> 4));
out[5] = (byte)(((in[off+4] << 3) & 0xFF) | (in[off+5] >> 5));
out[6] = (byte)(((in[off+5] << 2) & 0xFF) | (in[off+6] >> 6));
out[7] = (byte)((in[off+6] << 1) & 0xFF);
return out;
}
byte[] calcLMHash (byte[] pwb) {
byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
byte[] pwb1 = new byte [14];
int len = pwb.length;
if (len > 14)
len = 14;
System.arraycopy (pwb, 0, pwb1, 0, len); /* Zero padded */
try {
DESKeySpec dks1 = new DESKeySpec (makeDesKey (pwb1, 0));
DESKeySpec dks2 = new DESKeySpec (makeDesKey (pwb1, 7));
SecretKey key1 = fac.generateSecret (dks1);
SecretKey key2 = fac.generateSecret (dks2);
cipher.init (Cipher.ENCRYPT_MODE, key1);
byte[] out1 = cipher.doFinal (magic, 0, 8);
cipher.init (Cipher.ENCRYPT_MODE, key2);
byte[] out2 = cipher.doFinal (magic, 0, 8);
byte[] result = new byte [21];
System.arraycopy (out1, 0, result, 0, 8);
System.arraycopy (out2, 0, result, 8, 8);
return result;
} catch (InvalidKeyException ive) {
// Will not happen, all key material are 8 bytes
assert false;
} catch (InvalidKeySpecException ikse) {
// Will not happen, we only feed DESKeySpec to DES factory
assert false;
} catch (IllegalBlockSizeException ibse) {
// Will not happen, we encrypt 8 bytes
assert false;
} catch (BadPaddingException bpe) {
// Will not happen, this is encryption
assert false;
}
return null; // will not happen, we returned already
}
byte[] calcNTHash (byte[] pw) {
byte[] out = md4.digest (pw);
byte[] result = new byte [21];
System.arraycopy (out, 0, result, 0, 16);
return result;
}
/* key is a 21 byte array. Split it into 3 7 byte chunks,
* Convert each to 8 byte DES keys, encrypt the text arg with
* each key and return the three results in a sequential []
*/
byte[] calcResponse (byte[] key, byte[] text) {
try {
assert key.length == 21;
DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
SecretKey key1 = fac.generateSecret(dks1);
SecretKey key2 = fac.generateSecret(dks2);
SecretKey key3 = fac.generateSecret(dks3);
cipher.init(Cipher.ENCRYPT_MODE, key1);
byte[] out1 = cipher.doFinal(text, 0, 8);
cipher.init(Cipher.ENCRYPT_MODE, key2);
byte[] out2 = cipher.doFinal(text, 0, 8);
cipher.init(Cipher.ENCRYPT_MODE, key3);
byte[] out3 = cipher.doFinal(text, 0, 8);
byte[] result = new byte[24];
System.arraycopy(out1, 0, result, 0, 8);
System.arraycopy(out2, 0, result, 8, 8);
System.arraycopy(out3, 0, result, 16, 8);
return result;
} catch (IllegalBlockSizeException ex) { // None will happen
assert false;
} catch (BadPaddingException ex) {
assert false;
} catch (InvalidKeySpecException ex) {
assert false;
} catch (InvalidKeyException ex) {
assert false;
}
return null;
}
// LMv2/NTLMv2
byte[] hmacMD5(byte[] key, byte[] text) {
try {
SecretKeySpec skey =
new SecretKeySpec(Arrays.copyOf(key, 16), "HmacMD5");
hmac.init(skey);
return hmac.doFinal(text);
} catch (InvalidKeyException ex) {
assert false;
} catch (RuntimeException e) {
assert false;
}
return null;
}
byte[] calcV2(byte[] nthash, String text, byte[] blob, byte[] challenge) {
try {
byte[] ntlmv2hash = hmacMD5(nthash,
text.getBytes("UnicodeLittleUnmarked"));
byte[] cn = new byte[blob.length+8];
System.arraycopy(challenge, 0, cn, 0, 8);
System.arraycopy(blob, 0, cn, 8, blob.length);
byte[] result = new byte[16+blob.length];
System.arraycopy(hmacMD5(ntlmv2hash, cn), 0, result, 0, 16);
System.arraycopy(blob, 0, result, 16, blob.length);
return result;
} catch (UnsupportedEncodingException ex) {
assert false;
}
return null;
}
// NTLM2 LM/NTLM
static byte[] ntlm2LM(byte[] nonce) {
return Arrays.copyOf(nonce, 24);
}
byte[] ntlm2NTLM(byte[] ntlmHash, byte[] nonce, byte[] challenge) {
byte[] b = Arrays.copyOf(challenge, 16);
System.arraycopy(nonce, 0, b, 8, 8);
byte[] sesshash = Arrays.copyOf(md5.digest(b), 8);
return calcResponse(ntlmHash, sesshash);
}
// Password in ASCII and UNICODE
static byte[] getP1(char[] password) {
try {
return new String(password).toUpperCase().getBytes("ISO8859_1");
} catch (UnsupportedEncodingException ex) {
return null;
}
}
static byte[] getP2(char[] password) {
try {
return new String(password).getBytes("UnicodeLittleUnmarked");
} catch (UnsupportedEncodingException ex) {
return null;
}
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.ntlm;
import java.security.GeneralSecurityException;
/**
* An NTLM-related Exception
*/
public final class NTLMException extends GeneralSecurityException {
/**
* If the incoming packet is invalid.
*/
public final static int PACKET_READ_ERROR = 1;
/**
* If the client cannot get a domain value from the server and the
* caller has not provided one.
*/
public final static int NO_DOMAIN_INFO = 2;
/**
* If the domain provided by the client does not match the one received
* from server.
*/
//public final static int DOMAIN_UNMATCH = 3;
/**
* If the client name is not found on server's user database.
*/
public final static int USER_UNKNOWN = 3;
/**
* If authentication fails.
*/
public final static int AUTH_FAILED = 4;
/**
* If an illegal version string is provided.
*/
public final static int BAD_VERSION = 5;
private int errorCode;
/**
* Constructs an NTLMException object.
* @param errorCode the error code, which can be retrieved by
* the {@link #errorCode() } method.
* @param msg the string message, which can be retrived by
* the {@link Exception#getMessage() } method.
*/
public NTLMException(int errorCode, String msg) {
super(msg);
this.errorCode = errorCode;
}
/**
* Returns the error code associated with this NTLMException.
* @return the error code
*/
public int errorCode() {
return errorCode;
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.ntlm;
import java.util.Arrays;
import java.util.Locale;
/**
* The NTLM server, not multi-thread enabled.<p>
* Example:
* <pre>
* Server server = new Server(null, "REALM") {
* public char[] getPassword(String ntdomain, String username) {
* switch (username) {
* case "dummy": return "t0pSeCr3t".toCharArray();
* case "guest": return "".toCharArray();
* default: return null;
* }
* }
* };
* // Receive client request as type1
* byte[] type2 = server.type2(type1, nonce);
* // Send type2 to client and receive type3
* verify(type3, nonce);
* </pre>
*/
public abstract class Server extends NTLM {
final private String domain;
final private boolean allVersion;
/**
* Creates a Server instance.
* @param version the NTLM version to use, which can be:
* <ul>
* <li>NTLM: Original NTLM v1
* <li>NTLM2: NTLM v1 with Client Challenge
* <li>NTLMv2: NTLM v2
* </ul>
* If null, all versions will be supported. Please note that unless NTLM2
* is selected, authentication succeeds if one of LM (or LMv2) or
* NTLM (or NTLMv2) is verified.
* @param domain the domain, must not be null
* @throws NullPointerException if {@code domain} is null.
*/
public Server(String version, String domain) throws NTLMException {
super(version);
if (domain == null) {
throw new NullPointerException("domain cannot be null");
}
this.allVersion = (version == null);
this.domain = domain;
debug("NTLM Server: (t,version) = (%s,%s)\n", domain, version);
}
/**
* Generates the Type 2 message
* @param type1 the Type1 message received, must not be null
* @param nonce the random 8-byte array to be used in message generation,
* must not be null
* @return the message generated
* @throws NullPointerException if type1 or nonce is null
* @throws NTLMException if the incoming message is invalid
*/
public byte[] type2(byte[] type1, byte[] nonce) {
if (nonce == null) {
throw new NullPointerException("nonce cannot be null");
}
debug("NTLM Server: Type 1 received\n");
if (type1 != null) debug(type1);
Writer p = new Writer(2, 32);
int flags = 0x80205;
p.writeSecurityBuffer(12, domain, true);
p.writeInt(20, flags);
p.writeBytes(24, nonce);
debug("NTLM Server: Type 2 created\n");
debug(p.getBytes());
return p.getBytes();
}
/**
* Verifies the Type3 message received from client and returns
* various negotiated information.
* @param type3 the incoming Type3 message from client, must not be null
* @param nonce the same nonce provided in {@link #type2}, must not be null
* @return username and hostname of the client in a byte array
* @throws NullPointerException if {@code type3} or {@code nonce} is null
* @throws NTLMException if the incoming message is invalid
*/
public String[] verify(byte[] type3, byte[] nonce)
throws NTLMException {
if (type3 == null || nonce == null) {
throw new NullPointerException("type1 or nonce cannot be null");
}
debug("NTLM Server: Type 3 received\n");
if (type3 != null) debug(type3);
Reader r = new Reader(type3);
String username = r.readSecurityBuffer(36, true);
String hostname = r.readSecurityBuffer(44, true);
String incomingDomain = r.readSecurityBuffer(28, true);
/*if (incomingDomain != null && !incomingDomain.equals(domain)) {
throw new NTLMException(NTLMException.DOMAIN_UNMATCH,
"Wrong domain: " + incomingDomain +
" vs " + domain); // Needed?
}*/
boolean verified = false;
char[] password = getPassword(domain, username);
if (password == null) {
throw new NTLMException(NTLMException.USER_UNKNOWN,
"Unknown user");
}
byte[] incomingLM = r.readSecurityBuffer(12);
byte[] incomingNTLM = r.readSecurityBuffer(20);
if (!verified && (allVersion || v == Version.NTLM)) {
if (incomingLM.length > 0) {
byte[] pw1 = getP1(password);
byte[] lmhash = calcLMHash(pw1);
byte[] lmresponse = calcResponse (lmhash, nonce);
if (Arrays.equals(lmresponse, incomingLM)) {
verified = true;
}
}
if (incomingNTLM.length > 0) {
byte[] pw2 = getP2(password);
byte[] nthash = calcNTHash(pw2);
byte[] ntresponse = calcResponse (nthash, nonce);
if (Arrays.equals(ntresponse, incomingNTLM)) {
verified = true;
}
}
debug("NTLM Server: verify using NTLM: " + verified + "\n");
}
if (!verified && (allVersion || v == Version.NTLM2)) {
byte[] pw2 = getP2(password);
byte[] nthash = calcNTHash(pw2);
byte[] clientNonce = Arrays.copyOf(incomingLM, 8);
byte[] ntlmresponse = ntlm2NTLM(nthash, clientNonce, nonce);
if (Arrays.equals(incomingNTLM, ntlmresponse)) {
verified = true;
}
debug("NTLM Server: verify using NTLM2: " + verified + "\n");
}
if (!verified && (allVersion || v == Version.NTLMv2)) {
byte[] pw2 = getP2(password);
byte[] nthash = calcNTHash(pw2);
if (incomingLM.length > 0) {
byte[] clientNonce = Arrays.copyOfRange(
incomingLM, 16, incomingLM.length);
byte[] lmresponse = calcV2(nthash,
username.toUpperCase(Locale.US)+incomingDomain,
clientNonce, nonce);
if (Arrays.equals(lmresponse, incomingLM)) {
verified = true;
}
}
if (incomingNTLM.length > 0) {
byte[] clientBlob = Arrays.copyOfRange(
incomingNTLM, 16, incomingNTLM.length);
byte[] ntlmresponse = calcV2(nthash,
username.toUpperCase(Locale.US)+incomingDomain,
clientBlob, nonce);
if (Arrays.equals(ntlmresponse, incomingNTLM)) {
verified = true;
}
}
debug("NTLM Server: verify using NTLMv2: " + verified + "\n");
}
if (!verified) {
throw new NTLMException(NTLMException.AUTH_FAILED,
"None of LM and NTLM verified");
}
return new String[] {username, hostname};
}
/**
* Retrieves the password for a given user. This method should be
* overridden in a concrete class.
* @param domain can be null
* @param username must not be null
* @return the password for the user, or null if unknown
*/
public abstract char[] getPassword(String domain, String username);
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.ntlm;
enum Version {
NTLM, NTLM2, NTLMv2
}
/* /*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -35,10 +35,12 @@ import java.security.PrivilegedAction; ...@@ -35,10 +35,12 @@ import java.security.PrivilegedAction;
* - CRAM-MD5 * - CRAM-MD5
* - DIGEST-MD5 * - DIGEST-MD5
* - GSSAPI/Kerberos v5 * - GSSAPI/Kerberos v5
* - NTLM
* And server support for * And server support for
* - CRAM-MD5 * - CRAM-MD5
* - DIGEST-MD5 * - DIGEST-MD5
* - GSSAPI/Kerberos v5 * - GSSAPI/Kerberos v5
* - NTLM
*/ */
public final class Provider extends java.security.Provider { public final class Provider extends java.security.Provider {
...@@ -47,8 +49,8 @@ public final class Provider extends java.security.Provider { ...@@ -47,8 +49,8 @@ public final class Provider extends java.security.Provider {
private static final String info = "Sun SASL provider" + private static final String info = "Sun SASL provider" +
"(implements client mechanisms for: " + "(implements client mechanisms for: " +
"DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5;" + "DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5, NTLM;" +
" server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)"; " server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5, NTLM)";
public Provider() { public Provider() {
super("SunSASL", 1.7d, info); super("SunSASL", 1.7d, info);
...@@ -58,6 +60,8 @@ public final class Provider extends java.security.Provider { ...@@ -58,6 +60,8 @@ public final class Provider extends java.security.Provider {
// Client mechanisms // Client mechanisms
put("SaslClientFactory.DIGEST-MD5", put("SaslClientFactory.DIGEST-MD5",
"com.sun.security.sasl.digest.FactoryImpl"); "com.sun.security.sasl.digest.FactoryImpl");
put("SaslClientFactory.NTLM",
"com.sun.security.sasl.ntlm.FactoryImpl");
put("SaslClientFactory.GSSAPI", put("SaslClientFactory.GSSAPI",
"com.sun.security.sasl.gsskerb.FactoryImpl"); "com.sun.security.sasl.gsskerb.FactoryImpl");
...@@ -75,6 +79,8 @@ public final class Provider extends java.security.Provider { ...@@ -75,6 +79,8 @@ public final class Provider extends java.security.Provider {
"com.sun.security.sasl.gsskerb.FactoryImpl"); "com.sun.security.sasl.gsskerb.FactoryImpl");
put("SaslServerFactory.DIGEST-MD5", put("SaslServerFactory.DIGEST-MD5",
"com.sun.security.sasl.digest.FactoryImpl"); "com.sun.security.sasl.digest.FactoryImpl");
put("SaslServerFactory.NTLM",
"com.sun.security.sasl.ntlm.FactoryImpl");
return null; return null;
} }
}); });
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.sasl.ntlm;
import java.util.Map;
import javax.security.sasl.*;
import javax.security.auth.callback.CallbackHandler;
import com.sun.security.sasl.util.PolicyUtils;
/**
* Client and server factory for NTLM SASL client/server mechanisms.
* See NTLMClient and NTLMServer for input requirements.
*
* @since 1.7
*/
public final class FactoryImpl implements SaslClientFactory,
SaslServerFactory{
private static final String myMechs[] = { "NTLM" };
private static final int mechPolicies[] = {
PolicyUtils.NOPLAINTEXT|PolicyUtils.NOANONYMOUS
};
/**
* Empty constructor.
*/
public FactoryImpl() {
}
/**
* Returns a new instance of the NTLM SASL client mechanism.
* Argument checks are performed in SaslClient's constructor.
* @returns a new SaslClient ; otherwise null if unsuccessful.
* @throws SaslException If there is an error creating the NTLM
* SASL client.
*/
public SaslClient createSaslClient(String[] mechs,
String authorizationId, String protocol, String serverName,
Map<String,?> props, CallbackHandler cbh)
throws SaslException {
for (int i=0; i<mechs.length; i++) {
if (mechs[i].equals("NTLM") &&
PolicyUtils.checkPolicy(mechPolicies[0], props)) {
return new NTLMClient(mechs[i], authorizationId,
protocol, serverName, props, cbh);
}
}
return null;
}
/**
* Returns a new instance of the NTLM SASL server mechanism.
* Argument checks are performed in SaslServer's constructor.
* @returns a new SaslServer ; otherwise null if unsuccessful.
* @throws SaslException If there is an error creating the NTLM
* SASL server.
*/
public SaslServer createSaslServer(String mech,
String protocol, String serverName, Map<String,?> props, CallbackHandler cbh)
throws SaslException {
if (mech.equals("NTLM") &&
PolicyUtils.checkPolicy(mechPolicies[0], props)) {
if (props != null) {
String qop = (String)props.get(Sasl.QOP);
if (qop != null && !qop.equals("auth")) {
throw new SaslException("NTLM only support auth");
}
}
if (cbh == null) {
throw new SaslException(
"Callback handler with support for AuthorizeCallback, "+
"RealmCallback, NameCallback, and PasswordCallback " +
"required");
}
return new NTLMServer(mech, protocol, serverName, props, cbh);
}
return null;
}
/**
* Returns the authentication mechanisms that this factory can produce.
*
* @returns String[] {"NTLM"} if policies in env match those of this
* factory.
*/
public String[] getMechanismNames(Map<String,?> env) {
return PolicyUtils.filterMechs(myMechs, mechPolicies, env);
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.sasl.ntlm;
import com.sun.security.ntlm.Client;
import com.sun.security.ntlm.NTLMException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Random;
import javax.security.auth.callback.Callback;
import javax.security.sasl.*;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
/**
* Required callbacks:
* - RealmCallback
* handle can provide domain info for authentication, optional
* - NameCallback
* handler must enter username to use for authentication
* - PasswordCallback
* handler must enter password for username to use for authentication
*
* Environment properties that affect behavior of implementation:
*
* javax.security.sasl.qop
* String, quality of protection; only "auth" is accepted, default "auth"
*
* com.sun.security.sasl.ntlm.version
* String, name a specific version to use; can be:
* LM/NTLM: Original NTLM v1
* LM: Original NTLM v1, LM only
* NTLM: Original NTLM v1, NTLM only
* NTLM2: NTLM v1 with Client Challenge
* LMv2/NTLMv2: NTLM v2
* LMv2: NTLM v2, LM only
* NTLMv2: NTLM v2, NTLM only
* If not specified, use system property "ntlm.version". If
* still not specified, use default value "LMv2/NTLMv2".
*
* com.sun.security.sasl.ntlm.random
* java.util.Random, the nonce source to be used in NTLM v2 or NTLM v1 with
* Client Challenge. Default null, an internal java.util.Random object
* will be used
*
* Negotiated Properties:
*
* javax.security.sasl.qop
* Always "auth"
*
* com.sun.security.sasl.html.domain
* The domain for the user, provided by the server
*
* @see <a href="http://www.ietf.org/rfc/rfc2222.txt">RFC 2222</a>
* - Simple Authentication and Security Layer (SASL)
*
*/
final class NTLMClient implements SaslClient {
private static final String NTLM_VERSION =
"com.sun.security.sasl.ntlm.version";
private static final String NTLM_RANDOM =
"com.sun.security.sasl.ntlm.random";
private final static String NTLM_DOMAIN =
"com.sun.security.sasl.ntlm.domain";
private final static String NTLM_HOSTNAME =
"com.sun.security.sasl.ntlm.hostname";
private final Client client;
private final String mech;
private final Random random;
private int step = 0; // 0-start,1-nego,2-auth,3-done
/**
* @param mech non-null
* @param authorizationId can be null or empty and ignored
* @param protocol non-null for Sasl, useless for NTLM
* @param serverName non-null for Sasl, but can be null for NTLM
* @param props can be null
* @param cbh can be null for Sasl, but will throw NPE for NTLM
* @throws SaslException
*/
NTLMClient(String mech, String authzid, String protocol, String serverName,
Map props, CallbackHandler cbh) throws SaslException {
this.mech = mech;
String version = null;
Random rtmp = null;
String hostname = null;
if (props != null) {
String qop = (String)props.get(Sasl.QOP);
if (qop != null && !qop.equals("auth")) {
throw new SaslException("NTLM only support auth");
}
version = (String)props.get(NTLM_VERSION);
rtmp = (Random)props.get(NTLM_RANDOM);
hostname = (String)props.get(NTLM_HOSTNAME);
}
this.random = rtmp != null ? rtmp : new Random();
if (version == null) {
version = System.getProperty("ntlm.version");
}
RealmCallback dcb = (serverName != null && !serverName.isEmpty())?
new RealmCallback("Realm: ", serverName) :
new RealmCallback("Realm: ");
NameCallback ncb = (authzid != null && !authzid.isEmpty()) ?
new NameCallback("User name: ", authzid) :
new NameCallback("User name: ");
PasswordCallback pcb =
new PasswordCallback("Password: ", false);
try {
cbh.handle(new Callback[] {dcb, ncb, pcb});
} catch (UnsupportedCallbackException e) {
throw new SaslException("NTLM: Cannot perform callback to " +
"acquire realm, username or password", e);
} catch (IOException e) {
throw new SaslException(
"NTLM: Error acquiring realm, username or password", e);
}
if (hostname == null) {
try {
hostname = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
hostname = "localhost";
}
}
try {
client = new Client(version, hostname,
ncb.getName(),
dcb.getText(),
pcb.getPassword());
} catch (NTLMException ne) {
throw new SaslException(
"NTLM: Invalid version string: " + version, ne);
}
}
@Override
public String getMechanismName() {
return mech;
}
@Override
public boolean isComplete() {
return step >= 2;
}
@Override
public byte[] unwrap(byte[] incoming, int offset, int len)
throws SaslException {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public byte[] wrap(byte[] outgoing, int offset, int len)
throws SaslException {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public Object getNegotiatedProperty(String propName) {
if (propName.equals(Sasl.QOP)) {
return "auth";
} else if (propName.equals(NTLM_DOMAIN)) {
return client.getDomain();
} else {
return null;
}
}
@Override
public void dispose() throws SaslException {
client.dispose();
}
@Override
public boolean hasInitialResponse() {
return true;
}
@Override
public byte[] evaluateChallenge(byte[] challenge) throws SaslException {
step++;
if (step == 1) {
return client.type1();
} else {
try {
byte[] nonce = new byte[8];
random.nextBytes(nonce);
return client.type3(challenge, nonce);
} catch (NTLMException ex) {
throw new SaslException("Type3 creation failed", ex);
}
}
}
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.sasl.ntlm;
import com.sun.security.ntlm.NTLMException;
import com.sun.security.ntlm.Server;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Map;
import java.util.Random;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.*;
/**
* Required callbacks:
* - RealmCallback
* used as key by handler to fetch password, optional
* - NameCallback
* used as key by handler to fetch password
* - PasswordCallback
* handler must enter password for username/realm supplied
*
* Environment properties that affect the implementation:
*
* javax.security.sasl.qop
* String, quality of protection; only "auth" is accepted, default "auth"
*
* com.sun.security.sasl.ntlm.version
* String, name a specific version to accept:
* LM/NTLM: Original NTLM v1
* LM: Original NTLM v1, LM only
* NTLM: Original NTLM v1, NTLM only
* NTLM2: NTLM v1 with Client Challenge
* LMv2/NTLMv2: NTLM v2
* LMv2: NTLM v2, LM only
* NTLMv2: NTLM v2, NTLM only
* If not specified, use system property "ntlm.version". If also
* not specfied, all versions are accepted.
*
* com.sun.security.sasl.ntlm.domain
* String, the domain of the server, default is server name (fqdn parameter)
*
* com.sun.security.sasl.ntlm.random
* java.util.Random, the nonce source. Default null, an internal
* java.util.Random object will be used
*
* Negotiated Properties:
*
* javax.security.sasl.qop
* Always "auth"
*
* com.sun.security.sasl.ntlm.hostname
* The hostname for the user, provided by the client
*
*/
final class NTLMServer implements SaslServer {
private final static String NTLM_VERSION =
"com.sun.security.sasl.ntlm.version";
private final static String NTLM_DOMAIN =
"com.sun.security.sasl.ntlm.domain";
private final static String NTLM_HOSTNAME =
"com.sun.security.sasl.ntlm.hostname";
private static final String NTLM_RANDOM =
"com.sun.security.sasl.ntlm.random";
private final Random random;
private final Server server;
private byte[] nonce;
private int step = 0;
private String authzId;
private final String mech;
private String hostname;
/**
* @param mech not null
* @param protocol not null for Sasl, ignored in NTLM
* @param serverName not null for Sasl, can be null in NTLM. If non-null,
* might be used as domain if not provided in props
* @param props can be null
* @param cbh can be null for Sasl, but will throw NPE in auth for NTLM
* @throws SaslException
*/
NTLMServer(String mech, String protocol, String serverName,
Map props, final CallbackHandler cbh) throws SaslException {
this.mech = mech;
String version = null;
String domain = null;
Random rtmp = null;
if (props != null) {
domain = (String) props.get(NTLM_DOMAIN);
version = (String)props.get(NTLM_VERSION);
rtmp = (Random)props.get(NTLM_RANDOM);
}
random = rtmp != null ? rtmp : new Random();
if (version == null) {
version = System.getProperty("ntlm.version");
}
if (domain == null) {
domain = serverName;
}
if (domain == null) {
throw new NullPointerException("Domain must be provided as"
+ " the serverName argument or in props");
}
try {
server = new Server(version, domain) {
public char[] getPassword(String ntdomain, String username) {
try {
RealmCallback rcb = new RealmCallback(
"Domain: ", ntdomain);
NameCallback ncb = new NameCallback(
"Name: ", username);
PasswordCallback pcb = new PasswordCallback(
"Password: ", false);
cbh.handle(new Callback[] { rcb, ncb, pcb });
char[] passwd = pcb.getPassword();
pcb.clearPassword();
return passwd;
} catch (IOException ioe) {
return null;
} catch (UnsupportedCallbackException uce) {
return null;
}
}
};
} catch (NTLMException ne) {
throw new SaslException(
"NTLM: Invalid version string: " + version, ne);
}
nonce = new byte[8];
}
@Override
public String getMechanismName() {
return mech;
}
@Override
public byte[] evaluateResponse(byte[] response) throws SaslException {
try {
step++;
if (step == 1) {
random.nextBytes(nonce);
return server.type2(response, nonce);
} else {
String[] out = server.verify(response, nonce);
authzId = out[0];
hostname = out[1];
return null;
}
} catch (GeneralSecurityException ex) {
throw new SaslException("", ex);
}
}
@Override
public boolean isComplete() {
return step >= 2;
}
@Override
public String getAuthorizationID() {
return authzId;
}
@Override
public byte[] unwrap(byte[] incoming, int offset, int len)
throws SaslException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public byte[] wrap(byte[] outgoing, int offset, int len)
throws SaslException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Object getNegotiatedProperty(String propName) {
if (propName.equals(Sasl.QOP)) {
return "auth";
} else if (propName.equals(NTLM_HOSTNAME)) {
return hostname;
} else {
return null;
}
}
@Override
public void dispose() throws SaslException {
return;
}
}
...@@ -277,10 +277,8 @@ public class Dialog extends Window { ...@@ -277,10 +277,8 @@ public class Dialog extends Window {
*/ */
String title; String title;
private transient volatile boolean keepBlockingEDT = false;
private transient volatile boolean keepBlockingCT = false;
private transient ModalEventFilter modalFilter; private transient ModalEventFilter modalFilter;
private transient volatile SecondaryLoop secondaryLoop;
/* /*
* Indicates that this dialog is being hidden. This flag is set to true at * Indicates that this dialog is being hidden. This flag is set to true at
...@@ -1005,12 +1003,6 @@ public class Dialog extends Window { ...@@ -1005,12 +1003,6 @@ public class Dialog extends Window {
super.setVisible(b); super.setVisible(b);
} }
/**
* Stores the app context on which event dispatch thread the dialog
* is being shown. Initialized in show(), used in hideAndDisposeHandler()
*/
transient private AppContext showAppContext;
/** /**
* Makes the {@code Dialog} visible. If the dialog and/or its owner * Makes the {@code Dialog} visible. If the dialog and/or its owner
* are not yet displayable, both are made displayable. The * are not yet displayable, both are made displayable. The
...@@ -1037,39 +1029,18 @@ public class Dialog extends Window { ...@@ -1037,39 +1029,18 @@ public class Dialog extends Window {
if (!isModal()) { if (!isModal()) {
conditionalShow(null, null); conditionalShow(null, null);
} else { } else {
// Set this variable before calling conditionalShow(). That AppContext showAppContext = AppContext.getAppContext();
// way, if the Dialog is hidden right after being shown, we
// won't mistakenly block this thread.
keepBlockingEDT = true;
keepBlockingCT = true;
// Store the app context on which this dialog is being shown.
// Event dispatch thread of this app context will be sleeping until
// we wake it by any event from hideAndDisposeHandler().
showAppContext = AppContext.getAppContext();
AtomicLong time = new AtomicLong(); AtomicLong time = new AtomicLong();
Component predictedFocusOwner = null; Component predictedFocusOwner = null;
try { try {
predictedFocusOwner = getMostRecentFocusOwner(); predictedFocusOwner = getMostRecentFocusOwner();
if (conditionalShow(predictedFocusOwner, time)) { if (conditionalShow(predictedFocusOwner, time)) {
// We have two mechanisms for blocking: 1. If we're on the
// EventDispatchThread, start a new event pump. 2. If we're
// on any other thread, call wait() on the treelock.
modalFilter = ModalEventFilter.createFilterForDialog(this); modalFilter = ModalEventFilter.createFilterForDialog(this);
Conditional cond = new Conditional() {
final Runnable pumpEventsForFilter = new Runnable() { @Override
public void run() { public boolean evaluate() {
EventDispatchThread dispatchThread = return windowClosingException == null;
(EventDispatchThread)Thread.currentThread();
dispatchThread.pumpEventsForFilter(new Conditional() {
public boolean evaluate() {
synchronized (getTreeLock()) {
return keepBlockingEDT && windowClosingException == null;
}
}
}, modalFilter);
} }
}; };
...@@ -1096,44 +1067,10 @@ public class Dialog extends Window { ...@@ -1096,44 +1067,10 @@ public class Dialog extends Window {
modalityPushed(); modalityPushed();
try { try {
if (EventQueue.isDispatchThread()) { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
/* secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000);
* dispose SequencedEvent we are dispatching on current if (!secondaryLoop.enter()) {
* AppContext, to prevent us from hang. secondaryLoop = null;
*
*/
// BugId 4531693 (son@sparc.spb.su)
SequencedEvent currentSequencedEvent = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
if (currentSequencedEvent != null) {
currentSequencedEvent.dispose();
}
/*
* Event processing is done inside doPrivileged block so that
* it wouldn't matter even if user code is on the stack
* Fix for BugId 6300270
*/
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
pumpEventsForFilter.run();
return null;
}
});
} else {
synchronized (getTreeLock()) {
Toolkit.getEventQueue().postEvent(new PeerEvent(this,
pumpEventsForFilter,
PeerEvent.PRIORITY_EVENT));
while (keepBlockingCT && windowClosingException == null) {
try {
getTreeLock().wait();
} catch (InterruptedException e) {
break;
}
}
}
} }
} finally { } finally {
modalityPopped(); modalityPopped();
...@@ -1194,18 +1131,11 @@ public class Dialog extends Window { ...@@ -1194,18 +1131,11 @@ public class Dialog extends Window {
windowClosingException = null; windowClosingException = null;
} }
} }
final class WakingRunnable implements Runnable {
public void run() {
synchronized (getTreeLock()) {
keepBlockingCT = false;
getTreeLock().notifyAll();
}
}
}
private void hideAndDisposePreHandler() { private void hideAndDisposePreHandler() {
isInHide = true; isInHide = true;
synchronized (getTreeLock()) { synchronized (getTreeLock()) {
if (keepBlockingEDT) { if (secondaryLoop != null) {
modalHide(); modalHide();
// dialog can be shown and then disposed before its // dialog can be shown and then disposed before its
// modal filter is created // modal filter is created
...@@ -1217,20 +1147,9 @@ public class Dialog extends Window { ...@@ -1217,20 +1147,9 @@ public class Dialog extends Window {
} }
} }
private void hideAndDisposeHandler() { private void hideAndDisposeHandler() {
synchronized (getTreeLock()) { if (secondaryLoop != null) {
if (keepBlockingEDT) { secondaryLoop.exit();
keepBlockingEDT = false; secondaryLoop = null;
PeerEvent wakingEvent = new PeerEvent(getToolkit(), new WakingRunnable(), PeerEvent.PRIORITY_EVENT);
AppContext curAppContext = AppContext.getAppContext();
if (showAppContext != curAppContext) {
// Wake up event dispatch thread on which the dialog was
// initially shown
SunToolkit.postEvent(showAppContext, wakingEvent);
showAppContext = null;
} else {
Toolkit.getEventQueue().postEvent(wakingEvent);
}
}
} }
isInHide = false; isInHide = false;
} }
......
...@@ -113,8 +113,7 @@ class EventDispatchThread extends Thread { ...@@ -113,8 +113,7 @@ class EventDispatchThread extends Thread {
pumpEventsForHierarchy(id, cond, null); pumpEventsForHierarchy(id, cond, null);
} }
void pumpEventsForHierarchy(int id, Conditional cond, Component modalComponent) void pumpEventsForHierarchy(int id, Conditional cond, Component modalComponent) {
{
pumpEventsForFilter(id, cond, new HierarchyEventFilter(modalComponent)); pumpEventsForFilter(id, cond, new HierarchyEventFilter(modalComponent));
} }
...@@ -124,6 +123,7 @@ class EventDispatchThread extends Thread { ...@@ -124,6 +123,7 @@ class EventDispatchThread extends Thread {
void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) { void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
addEventFilter(filter); addEventFilter(filter);
doDispatch = true;
while (doDispatch && cond.evaluate()) { while (doDispatch && cond.evaluate()) {
if (isInterrupted() || !pumpOneEventForFilters(id)) { if (isInterrupted() || !pumpOneEventForFilters(id)) {
doDispatch = false; doDispatch = false;
...@@ -133,6 +133,7 @@ class EventDispatchThread extends Thread { ...@@ -133,6 +133,7 @@ class EventDispatchThread extends Thread {
} }
void addEventFilter(EventFilter filter) { void addEventFilter(EventFilter filter) {
eventLog.finest("adding the event filter: " + filter);
synchronized (eventFilters) { synchronized (eventFilters) {
if (!eventFilters.contains(filter)) { if (!eventFilters.contains(filter)) {
if (filter instanceof ModalEventFilter) { if (filter instanceof ModalEventFilter) {
...@@ -156,6 +157,7 @@ class EventDispatchThread extends Thread { ...@@ -156,6 +157,7 @@ class EventDispatchThread extends Thread {
} }
void removeEventFilter(EventFilter filter) { void removeEventFilter(EventFilter filter) {
eventLog.finest("removing the event filter: " + filter);
synchronized (eventFilters) { synchronized (eventFilters) {
eventFilters.remove(filter); eventFilters.remove(filter);
} }
......
...@@ -883,6 +883,41 @@ public class EventQueue { ...@@ -883,6 +883,41 @@ public class EventQueue {
} }
} }
/**
* Creates a new {@code secondary loop} associated with this
* event queue. Use the {@link SecondaryLoop#enter} and
* {@link SecondaryLoop#exit} methods to start and stop the
* event loop and dispatch the events from this queue.
*
* @return secondaryLoop A new secondary loop object, which can
* be used to launch a new nested event
* loop and dispatch events from this queue
*
* @see SecondaryLoop#enter
* @see SecondaryLoop#exit
*
* @since 1.7
*/
public SecondaryLoop createSecondaryLoop() {
return createSecondaryLoop(null, null, 0);
}
SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) {
pushPopLock.lock();
try {
if (nextQueue != null) {
// Forward the request to the top of EventQueue stack
return nextQueue.createSecondaryLoop(cond, filter, interval);
}
if (dispatchThread == null) {
initDispatchThread();
}
return new WaitDispatchSupport(dispatchThread, cond, filter, interval);
} finally {
pushPopLock.unlock();
}
}
/** /**
* Returns true if the calling thread is * Returns true if the calling thread is
* {@link Toolkit#getSystemEventQueue the current AWT EventQueue}'s * {@link Toolkit#getSystemEventQueue the current AWT EventQueue}'s
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.awt;
/**
* A helper interface to run the nested event loop.
* <p>
* Objects that implement this interface are created with the
* {@link EventQueue#createSecondaryLoop} method. The interface
* provides two methods, {@link enter} and {@link exit},
* which can be used to start and stop the event loop.
* <p>
* When the {@link enter} method is called, the current
* thread is blocked until the loop is terminated by the
* {@link exit} method. Also, a new event loop is started
* on the event dispatch thread, which may or may not be
* the current thread. The loop can be terminated on any
* thread by calling its {@link exit} method. After the
* loop is terminated, the {@code SecondaryLoop} object can
* be reused to run a new nested event loop.
* <p>
* A typical use case of applying this interface is AWT
* and Swing modal dialogs. When a modal dialog is shown on
* the event dispatch thread, it enters a new secondary loop.
* Later, when the dialog is hidden or disposed, it exits
* the loop, and the thread continues its execution.
* <p>
* The following example illustrates a simple use case of
* secondary loops:
*
* <pre>
* SecondaryLoop loop;
*
* JButton jButton = new JButton("Button");
* jButton.addActionListener(new ActionListener() {
* {@code @Override}
* public void actionPerformed(ActionEvent e) {
* Toolkit tk = Toolkit.getDefaultToolkit();
* EventQueue eq = tk.getSystemEventQueue();
* loop = eq.createSecondaryLoop();
*
* // Spawn a new thread to do the work
* Thread worker = new WorkerThread();
* worker.start();
*
* // Enter the loop to block the current event
* // handler, but leave UI responsive
* if (!loop.enter()) {
* // Report an error
* }
* }
* });
*
* class WorkerThread extends Thread {
* {@code @Override}
* public void run() {
* // Perform calculations
* doSomethingUseful();
*
* // Exit the loop
* loop.exit();
* }
* }
* </pre>
*
* @see Dialog#show
* @see EventQueue#createSecondaryLoop
* @see Toolkit#getSystemEventQueue
*
* @author Anton Tarasov, Artem Ananiev
*
* @since 1.7
*/
public interface SecondaryLoop {
/**
* Blocks the execution of the current thread and enters a new
* secondary event loop on the event dispatch thread.
* <p>
* This method can be called by any thread including the event
* dispatch thread. This thread will be blocked until the {@link
* exit} method is called or the loop is terminated. A new
* secondary loop will be created on the event dispatch thread
* for dispatching events in either case.
* <p>
* This method can only start one new event loop at a time per
* object. If a secondary event loop has already been started
* by this object and is currently still running, this method
* returns {@code false} to indicate that it was not successful
* in starting a new event loop. Otherwise, this method blocks
* the calling thread and later returns {@code true} when the
* new event loop is terminated. At such time, this object can
* again be used to start another new event loop.
*
* @return {@code true} after termination of the secondary loop,
* if the secondary loop was started by this call,
* {@code false} otherwise
*/
public boolean enter();
/**
* Unblocks the execution of the thread blocked by the {@link
* enter} method and exits the secondary loop.
* <p>
* This method resumes the thread that called the {@link enter}
* method and exits the secondary loop that was created when
* the {@link enter} method was invoked.
* <p>
* Note that if any other secondary loop is started while this
* loop is running, the blocked thread will not resume execution
* until the nested loop is terminated.
* <p>
* If this secondary loop has not been started with the {@link
* enter} method, or this secondary loop has already finished
* with the {@link exit} method, this method returns {@code
* false}, otherwise {@code true} is returned.
*
* @return {@code true} if this loop was previously started and
* has not yet been finished with the {@link exit} method,
* {@code false} otherwise
*/
public boolean exit();
}
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.awt;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import java.security.PrivilegedAction;
import java.security.AccessController;
import sun.awt.PeerEvent;
import sun.util.logging.PlatformLogger;
/**
* This utility class is used to suspend execution on a thread
* while still allowing {@code EventDispatchThread} to dispatch events.
* The API methods of the class are thread-safe.
*
* @author Anton Tarasov, Artem Ananiev
*
* @since 1.7
*/
class WaitDispatchSupport implements SecondaryLoop {
private final static PlatformLogger log =
PlatformLogger.getLogger("java.awt.event.WaitDispatchSupport");
private EventDispatchThread dispatchThread;
private EventFilter filter;
private volatile Conditional extCondition;
private volatile Conditional condition;
private long interval;
// Use a shared daemon timer to serve all the WaitDispatchSupports
private static Timer timer;
// When this WDS expires, we cancel the timer task leaving the
// shared timer up and running
private TimerTask timerTask;
private AtomicBoolean keepBlockingEDT = new AtomicBoolean(false);
private AtomicBoolean keepBlockingCT = new AtomicBoolean(false);
private static synchronized void initializeTimer() {
if (timer == null) {
timer = new Timer("AWT-WaitDispatchSupport-Timer", true);
}
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
*
* @since 1.7
*/
public WaitDispatchSupport(EventDispatchThread dispatchThread) {
this(dispatchThread, null);
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
* @param extCondition A conditional object used to determine
* if the loop should be terminated
*
* @since 1.7
*/
public WaitDispatchSupport(EventDispatchThread dispatchThread,
Conditional extCond)
{
if (dispatchThread == null) {
throw new IllegalArgumentException("The dispatchThread can not be null");
}
this.dispatchThread = dispatchThread;
this.extCondition = extCond;
this.condition = new Conditional() {
@Override
public boolean evaluate() {
if (log.isLoggable(PlatformLogger.FINEST)) {
log.finest("evaluate(): blockingEDT=" + keepBlockingEDT.get() +
", blockingCT=" + keepBlockingCT.get());
}
boolean extEvaluate =
(extCondition != null) ? extCondition.evaluate() : true;
if (!keepBlockingEDT.get() || !extEvaluate) {
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
return false;
}
return true;
}
};
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
* <p>
* The {@link EventFilter} is set on the {@code dispatchThread}
* while waiting. The filter is removed on completion of the
* waiting process.
* <p>
*
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
* @param filter {@code EventFilter} to be set
* @param interval A time interval to wait for. Note that
* when the waiting process takes place on EDT
* there is no guarantee to stop it in the given time
*
* @since 1.7
*/
public WaitDispatchSupport(EventDispatchThread dispatchThread,
Conditional extCondition,
EventFilter filter, long interval)
{
this(dispatchThread, extCondition);
this.filter = filter;
if (interval < 0) {
throw new IllegalArgumentException("The interval value must be >= 0");
}
this.interval = interval;
if (interval != 0) {
initializeTimer();
}
}
/**
* @inheritDoc
*/
@Override
public boolean enter() {
log.fine("enter(): blockingEDT=" + keepBlockingEDT.get() +
", blockingCT=" + keepBlockingCT.get());
if (!keepBlockingEDT.compareAndSet(false, true)) {
log.fine("The secondary loop is already running, aborting");
return false;
}
final Runnable run = new Runnable() {
public void run() {
log.fine("Starting a new event pump");
if (filter == null) {
dispatchThread.pumpEvents(condition);
} else {
dispatchThread.pumpEventsForFilter(condition, filter);
}
}
};
// We have two mechanisms for blocking: if we're on the
// dispatch thread, start a new event pump; if we're
// on any other thread, call wait() on the treelock
Thread currentThread = Thread.currentThread();
if (currentThread == dispatchThread) {
log.finest("On dispatch thread: " + dispatchThread);
if (interval != 0) {
log.finest("scheduling the timer for " + interval + " ms");
timer.schedule(timerTask = new TimerTask() {
@Override
public void run() {
if (keepBlockingEDT.compareAndSet(true, false)) {
wakeupEDT();
}
}
}, interval);
}
// Dispose SequencedEvent we are dispatching on the the current
// AppContext, to prevent us from hang - see 4531693 for details
SequencedEvent currentSE = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
if (currentSE != null) {
log.fine("Dispose current SequencedEvent: " + currentSE);
currentSE.dispose();
}
// In case the exit() method is called before starting
// new event pump it will post the waking event to EDT.
// The event will be handled after the the new event pump
// starts. Thus, the enter() method will not hang.
//
// Event pump should be privileged. See 6300270.
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
run.run();
return null;
}
});
} else {
log.finest("On non-dispatch thread: " + currentThread);
synchronized (getTreeLock()) {
if (filter != null) {
dispatchThread.addEventFilter(filter);
}
try {
EventQueue eq = dispatchThread.getEventQueue();
eq.postEvent(new PeerEvent(this, run, PeerEvent.PRIORITY_EVENT));
keepBlockingCT.set(true);
if (interval > 0) {
long currTime = System.currentTimeMillis();
while (keepBlockingCT.get() &&
((extCondition != null) ? extCondition.evaluate() : true) &&
(currTime + interval > System.currentTimeMillis()))
{
getTreeLock().wait(interval);
}
} else {
while (keepBlockingCT.get() &&
((extCondition != null) ? extCondition.evaluate() : true))
{
getTreeLock().wait();
}
}
log.fine("waitDone " + keepBlockingEDT.get() + " " + keepBlockingCT.get());
} catch (InterruptedException e) {
log.fine("Exception caught while waiting: " + e);
} finally {
if (filter != null) {
dispatchThread.removeEventFilter(filter);
}
}
// If the waiting process has been stopped because of the
// time interval passed or an exception occurred, the state
// should be changed
keepBlockingEDT.set(false);
keepBlockingCT.set(false);
}
}
return true;
}
/**
* @inheritDoc
*/
public boolean exit() {
log.fine("exit(): blockingEDT=" + keepBlockingEDT.get() +
", blockingCT=" + keepBlockingCT.get());
if (keepBlockingEDT.compareAndSet(true, false)) {
wakeupEDT();
return true;
}
return false;
}
private final static Object getTreeLock() {
return Component.LOCK;
}
private final Runnable wakingRunnable = new Runnable() {
public void run() {
log.fine("Wake up EDT");
synchronized (getTreeLock()) {
keepBlockingCT.set(false);
getTreeLock().notifyAll();
}
log.fine("Wake up EDT done");
}
};
private void wakeupEDT() {
log.finest("wakeupEDT(): EDT == " + dispatchThread);
EventQueue eq = dispatchThread.getEventQueue();
eq.postEvent(new PeerEvent(this, wakingRunnable, PeerEvent.PRIORITY_EVENT));
}
}
...@@ -34,8 +34,8 @@ package java.lang; ...@@ -34,8 +34,8 @@ package java.lang;
public interface AutoCloseable { public interface AutoCloseable {
/** /**
* Close this resource, relinquishing any underlying resources. * Close this resource, relinquishing any underlying resources.
* This method is invoked automatically by the automatic resource * This method is invoked automatically by the {@code
* management block construct. * try}-with-resources statement.
* *
* <p>Classes implementing this method are strongly encouraged to * <p>Classes implementing this method are strongly encouraged to
* be declared to throw more specific exceptions (or no exception * be declared to throw more specific exceptions (or no exception
......
/* /*
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided * particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code. * by Oracle in the LICENSE file that accompanied this code.
* *
* This code is distributed in the hope that it will be useful, but WITHOUT * This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation, * 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* CA 95054 USA or visit www.sun.com if you need additional information or * or visit www.oracle.com if you need additional information or have any
* have any questions. * questions.
*/ */
package java.lang; package java.lang;
......
...@@ -823,7 +823,7 @@ public abstract class ClassLoader { ...@@ -823,7 +823,7 @@ public abstract class ClassLoader {
* </tt></blockquote> * </tt></blockquote>
* *
* @param name * @param name
* The expected <a href="#name">binary name</a. of the class, or * The expected <a href="#name">binary name</a>. of the class, or
* <tt>null</tt> if not known * <tt>null</tt> if not known
* *
* @param b * @param b
......
...@@ -189,7 +189,9 @@ public class Object { ...@@ -189,7 +189,9 @@ public class Object {
* specific cloning operation. First, if the class of this object does * specific cloning operation. First, if the class of this object does
* not implement the interface {@code Cloneable}, then a * not implement the interface {@code Cloneable}, then a
* {@code CloneNotSupportedException} is thrown. Note that all arrays * {@code CloneNotSupportedException} is thrown. Note that all arrays
* are considered to implement the interface {@code Cloneable}. * are considered to implement the interface {@code Cloneable} and that
* the return type of the {@code clone} method of an array type {@code T[]}
* is {@code T[]} where T is any reference or primitive type.
* Otherwise, this method creates a new instance of the class of this * Otherwise, this method creates a new instance of the class of this
* object and initializes all its fields with exactly the contents of * object and initializes all its fields with exactly the contents of
* the corresponding fields of this object, as if by assignment; the * the corresponding fields of this object, as if by assignment; the
......
...@@ -498,8 +498,8 @@ public class Throwable implements Serializable { ...@@ -498,8 +498,8 @@ public class Throwable implements Serializable {
* } * }
* </pre> * </pre>
* As of release 7, the platform supports the notion of * As of release 7, the platform supports the notion of
* <i>suppressed exceptions</i> (in conjunction with automatic * <i>suppressed exceptions</i> (in conjunction with the {@code
* resource management blocks). Any exceptions that were * try}-with-resources statement). Any exceptions that were
* suppressed in order to deliver an exception are printed out * suppressed in order to deliver an exception are printed out
* beneath the stack trace. The format of this information * beneath the stack trace. The format of this information
* depends on the implementation, but the following example may be * depends on the implementation, but the following example may be
...@@ -805,7 +805,7 @@ public class Throwable implements Serializable { ...@@ -805,7 +805,7 @@ public class Throwable implements Serializable {
/** /**
* Adds the specified exception to the list of exceptions that * Adds the specified exception to the list of exceptions that
* were suppressed, typically by the automatic resource management * were suppressed, typically by the {@code try}-with-resources
* statement, in order to deliver this exception. * statement, in order to deliver this exception.
* *
* <p>Note that when one exception {@linkplain * <p>Note that when one exception {@linkplain
...@@ -839,7 +839,7 @@ public class Throwable implements Serializable { ...@@ -839,7 +839,7 @@ public class Throwable implements Serializable {
/** /**
* Returns an array containing all of the exceptions that were * Returns an array containing all of the exceptions that were
* suppressed, typically by the automatic resource management * suppressed, typically by the {@code try}-with-resources
* statement, in order to deliver this exception. * statement, in order to deliver this exception.
* *
* @return an array containing all of the exceptions that were * @return an array containing all of the exceptions that were
......
...@@ -166,8 +166,7 @@ public final ...@@ -166,8 +166,7 @@ public final
/** /**
* Returns the name of this constructor, as a string. This is * Returns the name of this constructor, as a string. This is
* always the same as the simple name of the constructor's declaring * the binary name of the constructor's declaring class.
* class.
*/ */
public String getName() { public String getName() {
return getDeclaringClass().getName(); return getDeclaringClass().getName();
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.net;
import java.io.IOException;
import java.io.FileDescriptor;
import sun.net.sdp.SdpSupport;
/**
* SocketImpl that supports the SDP protocol
*/
class SdpSocketImpl extends PlainSocketImpl {
SdpSocketImpl() { }
@Override
protected void create(boolean stream) throws IOException {
if (!stream)
throw new UnsupportedOperationException("Must be a stream socket");
fd = SdpSupport.createSocket();
if (socket != null)
socket.setCreated();
if (serverSocket != null)
serverSocket.setCreated();
}
}
...@@ -68,6 +68,15 @@ class ServerSocket implements java.io.Closeable { ...@@ -68,6 +68,15 @@ class ServerSocket implements java.io.Closeable {
*/ */
private boolean oldImpl = false; private boolean oldImpl = false;
/**
* Package-private constructor to create a ServerSocket associated with
* the given SocketImpl.
*/
ServerSocket(SocketImpl impl) {
this.impl = impl;
impl.setServerSocket(this);
}
/** /**
* Creates an unbound server socket. * Creates an unbound server socket.
* *
......
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.nio.file;
import java.util.ConcurrentModificationException;
import java.util.Objects;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.InvalidObjectException;
/**
* Runtime exception thrown if an I/O error is encountered when iterating over
* the entries in a directory. The I/O error is retrieved as an {@link
* IOException} using the {@link #getCause() getCause()} method.
*
* @since 1.7
* @see DirectoryStream
*/
public final class DirectoryIteratorException
extends ConcurrentModificationException
{
private static final long serialVersionUID = -6012699886086212874L;
/**
* Constructs an instance of this class.
*
* @param cause
* the {@code IOException} that caused the directory iteration
* to fail
*
* @throws NullPointerException
* if the cause is {@code null}
*/
public DirectoryIteratorException(IOException cause) {
super(Objects.nonNull(cause));
}
/**
* Returns the cause of this exception.
*
* @return the cause
*/
@Override
public IOException getCause() {
return (IOException)super.getCause();
}
/**
* Called to read the object from a stream.
*
* @throws InvalidObjectException
* if the object is invalid or has a cause that is not
* an {@code IOException}
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
Throwable cause = super.getCause();
if (!(cause instanceof IOException))
throw new InvalidObjectException("Cause must be an IOException");
}
}
...@@ -984,11 +984,11 @@ public abstract class Path ...@@ -984,11 +984,11 @@ public abstract class Path
* directory. * directory.
* *
* <p> Where the filter terminates due to an uncaught error or runtime * <p> Where the filter terminates due to an uncaught error or runtime
* exception then it is propogated to the iterator's {@link Iterator#hasNext() * exception then it is propagated to the {@link Iterator#hasNext()
* hasNext} or {@link Iterator#next() next} method. Where an {@code * hasNext} or {@link Iterator#next() next} method. Where an {@code
* IOException} is thrown, it is propogated as a {@link * IOException} is thrown, it results in the {@code hasNext} or {@code
* java.util.ConcurrentModificationException} with the {@code * next} method throwing a {@link DirectoryIteratorException} with the
* IOException} as the cause. * {@code IOException} as the cause.
* *
* <p> When an implementation supports operations on entries in the * <p> When an implementation supports operations on entries in the
* directory that execute in a race-free manner then the returned directory * directory that execute in a race-free manner then the returned directory
......
...@@ -47,15 +47,6 @@ import java.io.IOException; ...@@ -47,15 +47,6 @@ import java.io.IOException;
* newDirectoryStream} method will be a {@code SecureDirectoryStream} and must * newDirectoryStream} method will be a {@code SecureDirectoryStream} and must
* be cast to that type in order to invoke the methods defined by this interface. * be cast to that type in order to invoke the methods defined by this interface.
* *
* <p> As specified by {@code DirectoryStream}, the iterator's {@link
* java.util.Iterator#remove() remove} method removes the directory entry for
* the last element returned by the iterator. In the case of a {@code
* SecureDirectoryStream} the {@code remove} method behaves as if by invoking
* the {@link #deleteFile deleteFile} or {@link #deleteDirectory deleteDirectory}
* methods defined by this interface. The {@code remove} may require to examine
* the file to determine if the file is a directory, and consequently, it may
* not be atomic with respect to other file system operations.
*
* <p> In the case of the default {@link java.nio.file.spi.FileSystemProvider * <p> In the case of the default {@link java.nio.file.spi.FileSystemProvider
* provider}, and a security manager is set, then the permission checks are * provider}, and a security manager is set, then the permission checks are
* performed using the path obtained by resolving the given relative path * performed using the path obtained by resolving the given relative path
......
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -2436,4 +2436,64 @@ public interface CallableStatement extends PreparedStatement { ...@@ -2436,4 +2436,64 @@ public interface CallableStatement extends PreparedStatement {
*/ */
void setNClob(String parameterName, Reader reader) void setNClob(String parameterName, Reader reader)
throws SQLException; throws SQLException;
//------------------------- JDBC 4.1 -----------------------------------
/**
*<p>Returns an object representing the value of OUT parameter
* {@code parameterIndex} and will convert from the
* SQL type of the parameter to the requested Java data type, if the
* conversion is supported. If the conversion is not
* supported or null is specified for the type, a
* <code>SQLException</code> is thrown.
*<p>
* At a minimum, an implementation must support the conversions defined in
* Appendix B, Table B-3 and conversion of appropriate user defined SQL
* types to a Java type which implements {@code SQLData}, or {@code Struct}.
* Additional conversions may be supported and are vendor defined.
*
* @param parameterIndex the first parameter is 1, the second is 2, and so on
* @param type Class representing the Java data type to convert the
* designated parameter to.
* @return an instance of {@code type} holding the OUT parameter value
* @throws SQLException if conversion is not supported, type is null or
* another error occurs. The getCause() method of the
* exception may provide a more detailed exception, for example, if
* a conversion error occurs
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.7
*/
public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException;
/**
*<p>Returns an object representing the value of OUT parameter
* {@code parameterName} and will convert from the
* SQL type of the parameter to the requested Java data type, if the
* conversion is supported. If the conversion is not
* supported or null is specified for the type, a
* <code>SQLException</code> is thrown.
*<p>
* At a minimum, an implementation must support the conversions defined in
* Appendix B, Table B-3 and conversion of appropriate user defined SQL
* types to a Java type which implements {@code SQLData}, or {@code Struct}.
* Additional conversions may be supported and are vendor defined.
*
* @param parameterName the name of the parameter
* @param type Class representing the Java data type to convert
* the designated parameter to.
* @return an instance of {@code type} holding the OUT parameter
* value
* @throws SQLException if conversion is not supported, type is null or
* another error occurs. The getCause() method of the
* exception may provide a more detailed exception, for example, if
* a conversion error occurs
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.7
*/
public <T> T getObject(String parameterName, Class<T> type) throws SQLException;
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册