Mercurial > hg > jdk9-shenandoah > jdk
changeset 2744:299955417217
Merge
author | ohair |
---|---|
date | Tue, 07 Sep 2010 15:53:32 -0700 |
parents | df049d0b973f (current diff) cecc431cd78a (diff) |
children | fa00d112bb00 |
files | src/solaris/classes/sun/net/spi/SdpProvider.java src/solaris/native/sun/net/spi/SdpProvider.c test/tools/launcher/VerifyExceptions.java |
diffstat | 85 files changed, 4717 insertions(+), 1312 deletions(-) [+] |
line wrap: on
line diff
--- a/make/com/Makefile Tue Sep 07 15:17:43 2010 -0700 +++ b/make/com/Makefile Tue Sep 07 15:53:32 2010 -0700 @@ -31,7 +31,7 @@ PRODUCT = com include $(BUILDDIR)/common/Defs.gmk -SUBDIRS = sun +SUBDIRS = sun oracle include $(BUILDDIR)/common/Subdirs.gmk all build clean clobber::
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/com/oracle/Makefile Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,34 @@ +# +# 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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/com/oracle/net/Makefile Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,39 @@ +# +# 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 +
--- a/make/common/Release.gmk Tue Sep 07 15:17:43 2010 -0700 +++ b/make/common/Release.gmk Tue Sep 07 15:53:32 2010 -0700 @@ -573,13 +573,13 @@ $(ECHO) "sun/jvmstat/" >> $@ $(ECHO) "sun/nio/cs/ext/" >> $@ $(ECHO) "sun/awt/HKSCS.class" >> $@ - $(ECHO) "sun/awt/motif/X11GB2312$Decoder.class" >> $@ - $(ECHO) "sun/awt/motif/X11GB2312$Encoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11GB2312\$$Decoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11GB2312\$$Encoder.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/X11KSC5601$Decoder.class" >> $@ - $(ECHO) "sun/awt/motif/X11KSC5601$Encoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11KSC5601\$$Decoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11KSC5601\$$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11KSC5601.class" >> $@ $(ECHO) "sun/rmi/rmic/" >> $@ $(ECHO) "sun/tools/asm/" >> $@
--- a/make/docs/NON_CORE_PKGS.gmk Tue Sep 07 15:17:43 2010 -0700 +++ b/make/docs/NON_CORE_PKGS.gmk Tue Sep 07 15:53:32 2010 -0700 @@ -91,6 +91,8 @@ TRACING_PKGS = com.sun.tracing \ com.sun.tracing.dtrace +ORACLENET_PKGS = com.oracle.net + # non-core packages in rt.jar NON_CORE_PKGS = $(DOMAPI_PKGS) \ $(MGMT_PKGS) \ @@ -101,5 +103,6 @@ $(HTTPSERVER_PKGS) \ $(SMARTCARDIO_PKGS) \ $(TRACING_PKGS) \ - $(SCTPAPI_PKGS) + $(SCTPAPI_PKGS) \ + $(ORACLENET_PKGS)
--- a/make/java/net/FILES_c.gmk Tue Sep 07 15:17:43 2010 -0700 +++ b/make/java/net/FILES_c.gmk Tue Sep 07 15:53:32 2010 -0700 @@ -39,10 +39,6 @@ ResolverConfigurationImpl.c \ DefaultProxySelector.c -ifeq ($(PLATFORM), solaris) - FILES_c += SdpProvider.c -endif - ifeq ($(PLATFORM), linux) FILES_c += linux_close.c endif
--- a/make/java/net/Makefile Tue Sep 07 15:17:43 2010 -0700 +++ b/make/java/net/Makefile Tue Sep 07 15:53:32 2010 -0700 @@ -44,6 +44,8 @@ endif FILES_c += NTLMAuthSequence.c FILES_c += NetworkInterface_winXP.c +else + FILES_c += SdpSupport.c endif FILES_export = \ @@ -84,7 +86,8 @@ # # 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
--- a/make/java/net/mapfile-vers Tue Sep 07 15:17:43 2010 -0700 +++ b/make/java/net/mapfile-vers Tue Sep 07 15:53:32 2010 -0700 @@ -88,9 +88,10 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive; Java_sun_net_dns_ResolverConfigurationImpl_localDomain0; 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_getSystemProxy; - Java_sun_net_spi_SdpProvider_convert; NET_AllocSockaddr; NET_SockaddrToInetAddress; NET_SockaddrEqualsInetAddress;
--- a/make/java/nio/FILES_java.gmk Tue Sep 07 15:17:43 2010 -0700 +++ b/make/java/nio/FILES_java.gmk Tue Sep 07 15:53:32 2010 -0700 @@ -199,6 +199,7 @@ sun/nio/ch/PipeImpl.java \ sun/nio/ch/PollArrayWrapper.java \ sun/nio/ch/Reflect.java \ + sun/nio/ch/Secrets.java \ sun/nio/ch/SelectionKeyImpl.java \ sun/nio/ch/SelectorImpl.java \ sun/nio/ch/SelectorProviderImpl.java \
--- a/make/java/nio/mapfile-linux Tue Sep 07 15:17:43 2010 -0700 +++ b/make/java/nio/mapfile-linux Tue Sep 07 15:53:32 2010 -0700 @@ -89,7 +89,7 @@ Java_sun_nio_ch_IOUtil_drain; Java_sun_nio_ch_IOUtil_fdVal; 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_setfdVal; Java_sun_nio_ch_NativeThread_current;
--- a/make/java/nio/mapfile-solaris Tue Sep 07 15:17:43 2010 -0700 +++ b/make/java/nio/mapfile-solaris Tue Sep 07 15:53:32 2010 -0700 @@ -76,7 +76,7 @@ Java_sun_nio_ch_IOUtil_drain; Java_sun_nio_ch_IOUtil_fdVal; 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_setfdVal; Java_sun_nio_ch_NativeThread_current;
--- a/make/sun/net/FILES_java.gmk Tue Sep 07 15:17:43 2010 -0700 +++ b/make/sun/net/FILES_java.gmk Tue Sep 07 15:53:32 2010 -0700 @@ -53,6 +53,7 @@ sun/net/ftp/FtpProtocolException.java \ sun/net/ftp/impl/FtpClient.java \ sun/net/ftp/impl/DefaultFtpClientProvider.java \ + sun/net/sdp/SdpSupport.java \ sun/net/spi/DefaultProxySelector.java \ sun/net/spi/nameservice/NameServiceDescriptor.java \ sun/net/spi/nameservice/NameService.java \ @@ -136,8 +137,6 @@ ifeq ($(PLATFORM), windows) FILES_java += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java +else + FILES_java += sun/net/sdp/SdpProvider.java endif - -ifeq ($(PLATFORM), solaris) - FILES_java += sun/net/spi/SdpProvider.java -endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/oracle/net/Sdp.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,201 @@ +/* + * 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); + } +}
--- a/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -518,7 +518,7 @@ setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); - setTypeMap(null); + //setTypeMap(null); checkTransactionalWriter(); //Instantiating the vector for MatchColumns @@ -679,7 +679,10 @@ } else if (obj instanceof Clob) { obj = new SerialClob((Clob)obj); } 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); @@ -762,7 +765,8 @@ if( conn != null){ // 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 - dbmslocatorsUpdateCopy = conn.getMetaData().locatorsUpdateCopy(); + + dbmslocatorsUpdateCopy = conn.getMetaData().locatorsUpdateCopy(); } } @@ -6322,6 +6326,7 @@ crs.RowSetMD = RowSetMD; crs.numRows = 1; crs.cursorPos = 0; + crs.setTypeMap(this.getTypeMap()); // make sure we don't get someone playing with these // %%% is this now necessary ??? @@ -10114,7 +10119,7 @@ * 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 ois.defaultReadObject(); // Initialization of transient Res Bundle happens here . @@ -10125,5 +10130,6 @@ } } - static final long serialVersionUID =1884577171200622428L; + + static final long serialVersionUID =1884577171200622428L; }
--- a/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -1746,5 +1746,23 @@ onInsertRow = false; 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
--- a/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ private Vector strMatchColumns; - protected transient JdbcRowSetResourceBundle jdbcResBundle; + protected transient JdbcRowSetResourceBundle resBundle; /** * Constructs a default <code>JdbcRowSet</code> object. @@ -140,7 +140,7 @@ rs = null; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -154,42 +154,42 @@ try { setShowDeleted(false); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setshowdeleted").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setshowdeleted").toString() + sqle.getLocalizedMessage()); } try { setQueryTimeout(0); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + sqle.getLocalizedMessage()); } try { setMaxRows(0); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + sqle.getLocalizedMessage()); } try { setMaxFieldSize(0); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + sqle.getLocalizedMessage()); } try { setEscapeProcessing(true); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + sqle.getLocalizedMessage()); } try { setConcurrency(ResultSet.CONCUR_UPDATABLE); } catch (SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setconcurrency").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setconcurrency").toString() + sqle.getLocalizedMessage()); } @@ -198,7 +198,7 @@ try { setType(ResultSet.TYPE_SCROLL_INSENSITIVE); } catch(SQLException sqle){ - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.settype").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settype").toString() + sqle.getLocalizedMessage()); } @@ -207,7 +207,7 @@ try { setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } catch(SQLException sqle){ - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.settransactionisolation").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settransactionisolation").toString() + sqle.getLocalizedMessage()); } @@ -263,7 +263,7 @@ rs = null; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -338,7 +338,7 @@ rs = null; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -430,7 +430,7 @@ rs = res; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -517,7 +517,7 @@ // to the db, implies undesirable state so throw exception if (conn == null && ps == null && rs == null ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.invalstate").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.invalstate").toString()); } } @@ -593,28 +593,28 @@ try { ps.setEscapeProcessing(getEscapeProcessing()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + ex.getLocalizedMessage()); } try { ps.setMaxFieldSize(getMaxFieldSize()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + ex.getLocalizedMessage()); } try { ps.setMaxRows(getMaxRows()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + ex.getLocalizedMessage()); } try { ps.setQueryTimeout(getQueryTimeout()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + ex.getLocalizedMessage()); } @@ -651,7 +651,7 @@ } } catch (javax.naming.NamingException ex) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.connect").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.connect").toString()); } } else if (getUrl() != null) { @@ -681,7 +681,7 @@ } ps = conn.prepareStatement(getCommand(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.prepare").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.prepare").toString() + ex.getLocalizedMessage()); if (ps != null) @@ -721,15 +721,15 @@ if (param[0] instanceof java.sql.Date || param[0] instanceof java.sql.Time || param[0] instanceof java.sql.Timestamp) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.detecteddate")); + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.detecteddate")); if (param[1] instanceof java.util.Calendar) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.detectedcalendar")); + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.detectedcalendar")); ps.setDate(i + 1, (java.sql.Date)param[0], (java.util.Calendar)param[1]); continue; } else { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); } } @@ -770,7 +770,7 @@ (java.io.InputStream)param[0], ((Integer)param[1]).intValue()); default: - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); } } @@ -784,7 +784,7 @@ continue; } - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); } else { // common case - this catches all SQL92 types @@ -3749,7 +3749,7 @@ for( int j= 0 ;j < columnIdxes.length; j++) { i_val = (Integer.parseInt(iMatchColumns.get(j).toString())); if(columnIdxes[j] != i_val) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); } } @@ -3776,7 +3776,7 @@ for(int j = 0 ;j < columnIdxes.length; j++) { if( !columnIdxes[j].equals(strMatchColumns.get(j)) ){ - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); } } @@ -3800,7 +3800,7 @@ String []str_temp = new String[strMatchColumns.size()]; if( strMatchColumns.get(0) == null) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); } strMatchColumns.copyInto(str_temp); @@ -3825,7 +3825,7 @@ i_val = ((Integer)iMatchColumns.get(0)).intValue(); if( i_val == -1 ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); } @@ -3859,7 +3859,7 @@ for(int j = 0 ; j < columnIdxes.length; j++) { if( columnIdxes[j] < 0 ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); } } for(int i = 0 ;i < columnIdxes.length; i++) { @@ -3886,7 +3886,7 @@ for(int j = 0; j < columnNames.length; j++) { if( columnNames[j] == null || columnNames[j].equals("")) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); } } for( int i = 0; i < columnNames.length; i++) { @@ -3915,7 +3915,7 @@ public void setMatchColumn(int columnIdx) throws SQLException { // validate, if col is ok to be set if(columnIdx < 0) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); } else { // set iMatchColumn iMatchColumns.set(0, new Integer(columnIdx)); @@ -3941,7 +3941,7 @@ public void setMatchColumn(String columnName) throws SQLException { // validate, if col is ok to be set if(columnName.equals(null) || ((columnName = columnName.trim()) == "" )) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); } else { // set strMatchColumn strMatchColumns.set(0, columnName); @@ -3966,9 +3966,9 @@ public void unsetMatchColumn(int columnIdx) throws SQLException { // check if we are unsetting the SAME column if(! iMatchColumns.get(0).equals(new Integer(columnIdx) ) ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); } else if(strMatchColumns.get(0) != null) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.usecolname").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.usecolname").toString()); } else { // that is, we are unsetting it. iMatchColumns.set(0, new Integer(-1)); @@ -3995,9 +3995,9 @@ columnName = columnName.trim(); if(!((strMatchColumns.get(0)).equals(columnName))) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); } else if( ((Integer)(iMatchColumns.get(0))).intValue() > 0) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.usecolid").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.usecolid").toString()); } else { strMatchColumns.set(0, null); // that is, we are unsetting it. } @@ -4152,7 +4152,7 @@ private void checkTypeConcurrency() throws SQLException { if(rs.getType() == TYPE_FORWARD_ONLY || rs.getConcurrency() == CONCUR_READ_ONLY) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.resnotupd").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.resnotupd").toString()); } } @@ -4642,7 +4642,7 @@ * @since 6.0 */ public SQLXML getSQLXML(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4653,7 +4653,7 @@ * @throws SQLException if a database access error occurs */ public SQLXML getSQLXML(String colName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4668,7 +4668,7 @@ * @since 6.0 */ public RowId getRowId(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4683,7 +4683,7 @@ * @since 6.0 */ public RowId getRowId(String columnName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4699,7 +4699,7 @@ * @since 6.0 */ public void updateRowId(int columnIndex, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4715,7 +4715,7 @@ * @since 6.0 */ public void updateRowId(String columnName, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4725,7 +4725,7 @@ * @since 6.0 */ public int getHoldability() throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4736,7 +4736,7 @@ * @since 6.0 */ public boolean isClosed() throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4748,7 +4748,7 @@ * @since 6.0 */ public void updateNString(int columnIndex, String nString) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4760,7 +4760,7 @@ * @since 6.0 */ public void updateNString(String columnName, String nString) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4773,7 +4773,7 @@ * @since 6.0 */ public void updateNClob(int columnIndex, NClob nClob) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4785,7 +4785,7 @@ * @since 6.0 */ public void updateNClob(String columnName, NClob nClob) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4800,7 +4800,7 @@ * @since 6.0 */ public NClob getNClob(int i) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4816,7 +4816,7 @@ * @since 6.0 */ public NClob getNClob(String colName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{ @@ -4836,7 +4836,7 @@ * @since 1.6 */ public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4848,7 +4848,7 @@ * @since 1.6 */ public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4863,7 +4863,7 @@ * @since 1.6 */ public void setRowId(int parameterIndex, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4877,7 +4877,7 @@ * @since 1.6 */ public void setRowId(String parameterName, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4897,7 +4897,7 @@ * @since 1.6 */ public void setNString(int parameterIndex, String value) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4925,7 +4925,7 @@ * @since 1.6 */ public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4940,7 +4940,7 @@ * @since 1.6 */ public void setNClob(String parameterName, NClob value) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4960,7 +4960,7 @@ * @since 1.6 */ public java.io.Reader getNCharacterStream(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4980,7 +4980,7 @@ * @since 1.6 */ public java.io.Reader getNCharacterStream(String columnName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4996,7 +4996,7 @@ * @since 1.6 */ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5013,7 +5013,7 @@ * @since 1.6 */ public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5031,7 +5031,7 @@ * @since 1.6 */ public String getNString(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5049,7 +5049,7 @@ * @since 1.6 */ public String getNString(String columnName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5071,7 +5071,7 @@ java.io.Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5093,7 +5093,7 @@ java.io.Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5123,7 +5123,7 @@ */ public void updateNCharacterStream(int columnIndex, java.io.Reader x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5155,7 +5155,7 @@ */ public void updateNCharacterStream(String columnLabel, java.io.Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5188,7 +5188,7 @@ * @since 1.6 */ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5221,7 +5221,7 @@ * @since 1.6 */ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5256,7 +5256,7 @@ * @since 1.6 */ public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5291,7 +5291,7 @@ * @since 1.6 */ public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5323,7 +5323,7 @@ * @since 1.6 */ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5355,7 +5355,7 @@ * @since 1.6 */ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5389,7 +5389,7 @@ * @since 1.6 */ public void updateClob(int columnIndex, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5424,7 +5424,7 @@ * @since 1.6 */ public void updateClob(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5458,7 +5458,7 @@ * @since 1.6 */ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5492,7 +5492,7 @@ * @since 1.6 */ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5528,7 +5528,7 @@ * @since 1.6 */ public void updateNClob(int columnIndex, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5565,7 +5565,7 @@ * @since 1.6 */ public void updateNClob(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5590,7 +5590,7 @@ public void updateAsciiStream(int columnIndex, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5614,7 +5614,7 @@ public void updateBinaryStream(int columnIndex, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5638,7 +5638,7 @@ public void updateCharacterStream(int columnIndex, java.io.Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5662,7 +5662,7 @@ public void updateAsciiStream(String columnLabel, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5687,7 +5687,7 @@ */ public void updateAsciiStream(int columnIndex, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5713,7 +5713,7 @@ */ public void updateAsciiStream(String columnLabel, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5738,7 +5738,7 @@ public void updateBinaryStream(String columnLabel, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5763,7 +5763,7 @@ */ public void updateBinaryStream(int columnIndex, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5790,7 +5790,7 @@ */ public void updateBinaryStream(String columnLabel, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5816,7 +5816,7 @@ public void updateCharacterStream(String columnLabel, java.io.Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5841,7 +5841,7 @@ */ public void updateCharacterStream(int columnIndex, java.io.Reader x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5868,7 +5868,7 @@ */ public void updateCharacterStream(String columnLabel, java.io.Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5885,7 +5885,7 @@ * @since 1.4 */ public void setURL(int parameterIndex, java.net.URL x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5914,7 +5914,7 @@ */ public void setNClob(int parameterIndex, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5942,7 +5942,7 @@ */ public void setNClob(String parameterName, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5969,7 +5969,7 @@ */ public void setNClob(String parameterName, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5996,7 +5996,7 @@ */ public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6012,7 +6012,7 @@ * @since 1.6 */ public void setNClob(int parameterIndex, NClob value) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6029,7 +6029,7 @@ */ public void setNString(String parameterName, String value) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6046,7 +6046,7 @@ * @since 1.6 */ public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6066,7 +6066,7 @@ */ public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6092,7 +6092,7 @@ * @since 1.6 */ public void setNCharacterStream(String parameterName, Reader value) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6118,7 +6118,7 @@ */ public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6144,7 +6144,7 @@ */ public void setClob(String parameterName, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6163,7 +6163,7 @@ * @since 1.6 */ public void setClob (String parameterName, Clob x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6188,7 +6188,7 @@ */ public void setClob(String parameterName, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6210,7 +6210,7 @@ */ public void setDate(String parameterName, java.sql.Date x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6236,7 +6236,7 @@ */ public void setDate(String parameterName, java.sql.Date x, Calendar cal) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6256,7 +6256,7 @@ */ public void setTime(String parameterName, java.sql.Time x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6282,7 +6282,7 @@ */ public void setTime(String parameterName, java.sql.Time x, Calendar cal) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6308,7 +6308,7 @@ */ public void setClob(int parameterIndex, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6333,7 +6333,7 @@ */ public void setClob(int parameterIndex, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6363,7 +6363,7 @@ */ public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6395,7 +6395,7 @@ */ public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6426,7 +6426,7 @@ */ public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6444,7 +6444,7 @@ * @since 1.6 */ public void setBlob (String parameterName, Blob x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6470,7 +6470,7 @@ */ public void setBlob(String parameterName, InputStream inputStream) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6516,7 +6516,7 @@ */ public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6542,7 +6542,7 @@ */ public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6582,7 +6582,7 @@ * @since 1.4 */ public void setObject(String parameterName, Object x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6609,7 +6609,7 @@ */ public void setAsciiStream(String parameterName, java.io.InputStream x, int length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6636,7 +6636,7 @@ */ public void setBinaryStream(String parameterName, java.io.InputStream x, int length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6665,7 +6665,7 @@ public void setCharacterStream(String parameterName, java.io.Reader reader, int length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6692,7 +6692,7 @@ */ public void setAsciiStream(String parameterName, java.io.InputStream x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6719,7 +6719,7 @@ */ public void setBinaryStream(String parameterName, java.io.InputStream x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6748,7 +6748,7 @@ */ public void setCharacterStream(String parameterName, java.io.Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6767,7 +6767,7 @@ * @since 1.4 */ public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6788,7 +6788,7 @@ * @since 1.4 */ public void setString(String parameterName, String x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6810,7 +6810,7 @@ * @since 1.4 */ public void setBytes(String parameterName, byte x[]) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6830,7 +6830,7 @@ */ public void setTimestamp(String parameterName, java.sql.Timestamp x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6847,7 +6847,7 @@ * @since 1.4 */ public void setNull(String parameterName, int sqlType) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6884,7 +6884,7 @@ */ public void setNull (String parameterName, int sqlType, String typeName) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6902,7 +6902,7 @@ * @since 1.4 */ public void setBoolean(String parameterName, boolean x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6922,7 +6922,7 @@ * @since 1.4 */ public void setByte(String parameterName, byte x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6941,7 +6941,7 @@ * @since 1.4 */ public void setShort(String parameterName, short x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6960,7 +6960,7 @@ * @since 1.4 */ public void setInt(String parameterName, int x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6978,7 +6978,7 @@ * @since 1.4 */ public void setLong(String parameterName, long x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6997,7 +6997,7 @@ * @since 1.4 */ public void setFloat(String parameterName, float x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -7015,7 +7015,7 @@ * @since 1.4 */ public void setDouble(String parameterName, double x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -7023,12 +7023,12 @@ * 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 ois.defaultReadObject(); // Initialization of transient Res Bundle happens here . try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) {} }
--- a/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -153,4 +153,5 @@ return propResBundle.handleGetObject(key); } + static final long serialVersionUID = 436199386225359954L; }
--- a/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -127,6 +127,11 @@ strMatchKey = null; supportedJOINs = new boolean[] {false, true, false, false, false}; + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } } @@ -4306,5 +4311,22 @@ 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; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/rowset/RowSetFactoryImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,69 @@ +/* + * 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(); + } + +}
--- a/src/share/classes/com/sun/rowset/WebRowSetImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/WebRowSetImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -103,6 +103,12 @@ */ public WebRowSetImpl(Hashtable env) throws SQLException { + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + if ( env == null) { throw new SQLException(resBundle.handleGetObject("webrowsetimpl.nullhash").toString()); } @@ -263,5 +269,23 @@ 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; }
--- a/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -490,4 +490,17 @@ 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; }
--- a/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,13 @@ import java.io.*; import com.sun.rowset.*; +import java.text.MessageFormat; 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.*; @@ -53,6 +59,7 @@ * Standard JDBC RowSet implementations provide an object instance of this * writer by invoking the <code>SyncProvider.getRowSetWriter()</code> method. * + * @version 0.2 * @author Jonathan Bruce * @see javax.sql.rowset.spi.SyncProvider * @see javax.sql.rowset.spi.SyncFactory @@ -508,10 +515,11 @@ ResultSet rs = null; rs = pstmt.executeQuery(); - if (rs.next() == true) { + ResultSetMetaData rsmd = rs.getMetaData(); + 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 * uniquely identify the row where update * have to happen else if more than one @@ -528,7 +536,7 @@ // we require the record in rs to be used. // rs.close(); // pstmt.close(); - rs.first(); + rs.first(); // how many fields need to be updated int colsNotChanged = 0; @@ -552,6 +560,49 @@ orig = origVals.getObject(i); curr = crs.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 boolNull = true; @@ -669,6 +720,9 @@ } } //end for + rs.close(); + pstmt.close(); + this.crsResolve.insertRow(); this.crsResolve.moveToCurrentRow(); @@ -1179,11 +1233,22 @@ private void buildKeyDesc(CachedRowSet crs) throws SQLException { keyCols = crs.getKeyColumns(); + ResultSetMetaData resultsetmd = crs.getMetaData(); if (keyCols == null || keyCols.length == 0) { - keyCols = new int[callerColumnCount]; - for (int i = 0; i < keyCols.length; ) { - keyCols[i] = ++i; + ArrayList<Integer> listKeys = new ArrayList<Integer>(); + + 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]; } @@ -1359,4 +1424,17 @@ } } + 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; }
--- a/src/share/classes/com/sun/rowset/internal/InsertRow.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/internal/InsertRow.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -157,4 +157,23 @@ origVals[idx - 1] = val; 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; }
--- a/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import com.sun.rowset.*; import java.io.IOException; +import java.io.ObjectInputStream; /** * There will be two sets of data which will be maintained by the rowset at the @@ -4837,4 +4838,23 @@ throws SQLException { 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
--- a/src/share/classes/com/sun/rowset/internal/WebRowSetXmlReader.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/internal/WebRowSetXmlReader.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -216,4 +216,22 @@ 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; }
--- a/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -663,4 +663,23 @@ 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; }
--- a/src/share/classes/com/sun/rowset/providers/RIOptimisticProvider.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/rowset/providers/RIOptimisticProvider.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -245,4 +245,18 @@ public String getVendor() { 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; + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/ntlm/Client.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,212 @@ +/* + * 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); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/ntlm/NTLM.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,426 @@ +/* + * 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; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/ntlm/NTLMException.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,88 @@ +/* + * 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; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/ntlm/Server.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,205 @@ +/* + * 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); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/ntlm/Version.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,30 @@ +/* + * 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 +}
--- a/src/share/classes/com/sun/security/sasl/Provider.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/com/sun/security/sasl/Provider.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,12 @@ * - CRAM-MD5 * - DIGEST-MD5 * - GSSAPI/Kerberos v5 + * - NTLM * And server support for * - CRAM-MD5 * - DIGEST-MD5 * - GSSAPI/Kerberos v5 + * - NTLM */ public final class Provider extends java.security.Provider { @@ -47,8 +49,8 @@ private static final String info = "Sun SASL provider" + "(implements client mechanisms for: " + - "DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5;" + - " server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)"; + "DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5, NTLM;" + + " server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5, NTLM)"; public Provider() { super("SunSASL", 1.7d, info); @@ -58,6 +60,8 @@ // Client mechanisms put("SaslClientFactory.DIGEST-MD5", "com.sun.security.sasl.digest.FactoryImpl"); + put("SaslClientFactory.NTLM", + "com.sun.security.sasl.ntlm.FactoryImpl"); put("SaslClientFactory.GSSAPI", "com.sun.security.sasl.gsskerb.FactoryImpl"); @@ -75,6 +79,8 @@ "com.sun.security.sasl.gsskerb.FactoryImpl"); put("SaslServerFactory.DIGEST-MD5", "com.sun.security.sasl.digest.FactoryImpl"); + put("SaslServerFactory.NTLM", + "com.sun.security.sasl.ntlm.FactoryImpl"); return null; } });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,119 @@ +/* + * 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); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,231 @@ +/* + * 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); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,226 @@ +/* + * 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; + } +}
--- a/src/share/classes/java/lang/AutoCloseable.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/lang/AutoCloseable.java Tue Sep 07 15:53:32 2010 -0700 @@ -34,8 +34,8 @@ public interface AutoCloseable { /** * Close this resource, relinquishing any underlying resources. - * This method is invoked automatically by the automatic resource - * management block construct. + * This method is invoked automatically by the {@code + * try}-with-resources statement. * * <p>Classes implementing this method are strongly encouraged to * be declared to throw more specific exceptions (or no exception
--- a/src/share/classes/java/lang/ClassLoader.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/lang/ClassLoader.java Tue Sep 07 15:53:32 2010 -0700 @@ -823,7 +823,7 @@ * </tt></blockquote> * * @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 * * @param b
--- a/src/share/classes/java/lang/Object.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/lang/Object.java Tue Sep 07 15:53:32 2010 -0700 @@ -189,7 +189,9 @@ * specific cloning operation. First, if the class of this object does * not implement the interface {@code Cloneable}, then a * {@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 * object and initializes all its fields with exactly the contents of * the corresponding fields of this object, as if by assignment; the
--- a/src/share/classes/java/lang/Throwable.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/lang/Throwable.java Tue Sep 07 15:53:32 2010 -0700 @@ -498,8 +498,8 @@ * } * </pre> * As of release 7, the platform supports the notion of - * <i>suppressed exceptions</i> (in conjunction with automatic - * resource management blocks). Any exceptions that were + * <i>suppressed exceptions</i> (in conjunction with the {@code + * try}-with-resources statement). Any exceptions that were * suppressed in order to deliver an exception are printed out * beneath the stack trace. The format of this information * depends on the implementation, but the following example may be @@ -805,7 +805,7 @@ /** * 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. * * <p>Note that when one exception {@linkplain @@ -839,7 +839,7 @@ /** * 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. * * @return an array containing all of the exceptions that were
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/net/SdpSocketImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,49 @@ +/* + * 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(); + } +}
--- a/src/share/classes/java/net/ServerSocket.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/net/ServerSocket.java Tue Sep 07 15:53:32 2010 -0700 @@ -69,6 +69,15 @@ 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. * * @exception IOException IO error when opening the socket.
--- a/src/share/classes/java/sql/SQLDataException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLDataException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>22</i>'. This indicates - * various data errors, including but not limited to not-allowed conversion, division by 0 - * and invalid arguments to functions. - * + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>22</i>', or under vendor-specified conditions. This indicates + * various data errors, including but not limited to data conversion errors, + * division by 0, and invalid arguments to functions. + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLDataException extends SQLNonTransientException {
--- a/src/share/classes/java/sql/SQLIntegrityConstraintViolationException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLIntegrityConstraintViolationException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>23</i>'. This indicates that an integrity + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>23</i>', or under vendor-specified conditions. + * This indicates that an integrity * constraint (foreign key, primary key or unique key) has been violated. - * + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLIntegrityConstraintViolationException extends SQLNonTransientException {
--- a/src/share/classes/java/sql/SQLInvalidAuthorizationSpecException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLInvalidAuthorizationSpecException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>28</i>'. This indicated that the - * authorization credentials presented during connection establishment are not valid. - * + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>28</i>', or under vendor-specified conditions. This indicates that + * the authorization credentials presented during connection establishment + * are not valid. + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLInvalidAuthorizationSpecException extends SQLNonTransientException {
--- a/src/share/classes/java/sql/SQLNonTransientConnectionException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLNonTransientConnectionException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,13 @@ package java.sql; /** - * <P> The subclass of {@link SQLException} thrown for the SQLState - * class value '<i>08</i>', representing - * that the connection operation that failed will not succeed when + * The subclass of {@link SQLException} thrown for the SQLState + * class value '<i>08</i>', or under vendor-specified conditions. This + * indicates that the connection operation that failed will not succeed if * the operation is retried without the cause of the failure being corrected. * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLNonTransientConnectionException extends java.sql.SQLNonTransientException {
--- a/src/share/classes/java/sql/SQLSyntaxErrorException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLSyntaxErrorException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,12 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>42</i>'. This indicates that the + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>42</i>', or under vendor-specified conditions. This indicates that the * in-progress query has violated SQL syntax rules. - * + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLSyntaxErrorException extends SQLNonTransientException {
--- a/src/share/classes/java/sql/SQLTransactionRollbackException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLTransactionRollbackException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>40</i>'. This indicates that the - * current statement was automatically rolled back by the database becuase of deadlock or other - * transaction serialization failures. - * + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>40</i>', or under vendor-specified conditions. This indicates that the + * current statement was automatically rolled back by the database because + * of deadlock or other transaction serialization failures. + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLTransactionRollbackException extends SQLTransientException {
--- a/src/share/classes/java/sql/SQLTransientConnectionException.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/sql/SQLTransientConnectionException.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -27,11 +27,12 @@ /** * The subclass of {@link SQLException} for the SQLState class - * value '<i>08</i>', representing - * that the connection operation that failed might be able to succeed when + * value '<i>08</i>', or under vendor-specified conditions. This indicates + * that the connection operation that failed might be able to succeed if * the operation is retried without any application-level changes. - *<p> - * + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLTransientConnectionException extends java.sql.SQLTransientException {
--- a/src/share/classes/java/util/Properties.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/java/util/Properties.java Tue Sep 07 15:53:32 2010 -0700 @@ -912,9 +912,13 @@ * * <p>The specified stream remains open after this method returns. * - * @param os the output stream on which to emit the XML document. - * @param comment a description of the property list, or <code>null</code> - * if no comment is desired. + * @param os the output stream on which to emit the XML document. + * @param comment a description of the property list, or <code>null</code> + * if no comment is desired. + * @param encoding the name of a supported + * <a href="../lang/package-summary.html#charenc"> + * character encoding</a> + * * @throws IOException if writing to the specified output stream * results in an <tt>IOException</tt>. * @throws NullPointerException if <code>os</code> is <code>null</code>,
--- a/src/share/classes/javax/sql/rowset/CachedRowSet.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/javax/sql/rowset/CachedRowSet.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -644,10 +644,10 @@ * of <code>execute</code> that takes a <code>ResultSet</code> object. * * @param data the <code>ResultSet</code> object containing the data - * to be read into this <code>CachedRowSet</code> object + * to be read into this <code>CachedRowSet</code> object * @throws SQLException if a null <code>ResultSet</code> object is supplied - * or this <code>CachedRowSet</code> object cannot - * retrieve the associated <code>ResultSetMetaData</code> object + * or this <code>CachedRowSet</code> object cannot + * retrieve the associated <code>ResultSetMetaData</code> object * @see #execute * @see java.sql.ResultSet * @see java.sql.ResultSetMetaData @@ -674,10 +674,10 @@ * to commit outstanding updates, those updates are lost. * * @param conn a standard JDBC <code>Connection</code> object with valid - * properties + * properties * @throws SQLException if an invalid <code>Connection</code> object is supplied - * or an error occurs in establishing the connection to the - * data source + * or an error occurs in establishing the connection to the + * data source * @see #populate * @see java.sql.Connection */ @@ -736,8 +736,8 @@ * * @throws SQLException if the cursor is on the insert row * @throws SyncProviderException if the underlying - * synchronization provider's writer fails to write the updates - * back to the data source + * synchronization provider's writer fails to write the updates + * back to the data source * @see #acceptChanges(java.sql.Connection) * @see javax.sql.RowSetWriter * @see javax.sql.rowset.spi.SyncFactory @@ -807,8 +807,8 @@ * @param con a standard JDBC <code>Connection</code> object * @throws SQLException if the cursor is on the insert row * @throws SyncProviderException if the underlying - * synchronization provider's writer fails to write the updates - * back to the data source + * synchronization provider's writer fails to write the updates + * back to the data source * @see #acceptChanges() * @see javax.sql.RowSetWriter * @see javax.sql.rowset.spi.SyncFactory @@ -867,7 +867,7 @@ * the rowset's Java VM resources. * * @throws SQLException if an error occurs flushing the contents of this - * <code>CachedRowSet</code> object + * <code>CachedRowSet</code> object * @see javax.sql.RowSetListener#rowSetChanged * @see java.sql.ResultSet#close */ @@ -948,9 +948,9 @@ * * @param idx an <code>int</code> identifying the column to be checked for updates * @return <code>true</code> if the designated column has been visibly updated; - * <code>false</code> otherwise + * <code>false</code> otherwise * @throws SQLException if the cursor is on the insert row, before the first row, - * or after the last row + * or after the last row * @see java.sql.DatabaseMetaData#updatesAreDetected */ public boolean columnUpdated(int idx) throws SQLException; @@ -963,9 +963,9 @@ * @param columnName a <code>String</code> object giving the name of the * column to be checked for updates * @return <code>true</code> if the column has been visibly updated; - * <code>false</code> otherwise + * <code>false</code> otherwise * @throws SQLException if the cursor is on the insert row, before the first row, - * or after the last row + * or after the last row * @see java.sql.DatabaseMetaData#updatesAreDetected */ public boolean columnUpdated(String columnName) throws SQLException; @@ -1003,7 +1003,7 @@ * <P> * * @return a <code>Collection</code> object that contains the values in - * each row in this <code>CachedRowSet</code> object + * each row in this <code>CachedRowSet</code> object * @throws SQLException if an error occurs generating the collection * @see #toCollection(int) * @see #toCollection(String) @@ -1030,10 +1030,10 @@ * @param column an <code>int</code> indicating the column whose values * are to be represented in a <code>Collection</code> object * @return a <code>Collection</code> object that contains the values - * stored in the specified column of this <code>CachedRowSet</code> - * object + * stored in the specified column of this <code>CachedRowSet</code> + * object * @throws SQLException if an error occurs generating the collection or - * an invalid column id is provided + * an invalid column id is provided * @see #toCollection * @see #toCollection(String) */ @@ -1059,10 +1059,10 @@ * @param column a <code>String</code> object giving the name of the * column whose values are to be represented in a collection * @return a <code>Collection</code> object that contains the values - * stored in the specified column of this <code>CachedRowSet</code> - * object + * stored in the specified column of this <code>CachedRowSet</code> + * object * @throws SQLException if an error occurs generating the collection or - * an invalid column id is provided + * an invalid column id is provided * @see #toCollection * @see #toCollection(int) */ @@ -1100,7 +1100,7 @@ * @return the <code>SyncProvider</code> object that was set when the rowset * was instantiated, or if none was was set, the default provider * @throws SQLException if an error occurs while returning the - * <code>SyncProvider</code> object + * <code>SyncProvider</code> object * @see #setSyncProvider */ public SyncProvider getSyncProvider() throws SQLException; @@ -1127,7 +1127,7 @@ * @param provider a <code>String</code> object giving the fully qualified class * name of a <code>SyncProvider</code> implementation * @throws SQLException if an error occurs while attempting to reset the - * <code>SyncProvider</code> implementation + * <code>SyncProvider</code> implementation * @see #getSyncProvider */ public void setSyncProvider(String provider) throws SQLException; @@ -1152,9 +1152,9 @@ * object to the rowset. * * @param md a <code>RowSetMetaData</code> object containing - * metadata about the columns in this <code>CachedRowSet</code> object + * metadata about the columns in this <code>CachedRowSet</code> object * @throws SQLException if invalid metadata is supplied to the - * rowset + * rowset */ public void setMetaData(RowSetMetaData md) throws SQLException; @@ -1183,7 +1183,7 @@ * @return a <code>ResultSet</code> object that contains the original value for * this <code>CachedRowSet</code> object * @throws SQLException if an error occurs producing the - * <code>ResultSet</code> object + * <code>ResultSet</code> object */ public ResultSet getOriginal() throws SQLException; @@ -1217,7 +1217,7 @@ * A call to <code>setOriginalRow</code> is irreversible. * * @throws SQLException if there is no current row or an error is - * encountered resetting the contents of the original row + * encountered resetting the contents of the original row * @see #getOriginalRow */ public void setOriginalRow() throws SQLException; @@ -1326,7 +1326,7 @@ * as this <code>CachedRowSet</code> object and that has a cursor over * the same data * @throws SQLException if an error occurs or cloning is not - * supported in the underlying platform + * supported in the underlying platform * @see javax.sql.RowSetEvent * @see javax.sql.RowSetListener */ @@ -1344,10 +1344,10 @@ * established must be maintained. * * @return a new <code>RowSet</code> object that is a deep copy - * of this <code>CachedRowSet</code> object and is - * completely independent of this <code>CachedRowSet</code> object + * of this <code>CachedRowSet</code> object and is + * completely independent of this <code>CachedRowSet</code> object * @throws SQLException if an error occurs in generating the copy of - * the of this <code>CachedRowSet</code> object + * the of this <code>CachedRowSet</code> object * @see #createShared * @see #createCopySchema * @see #createCopyNoConstraints @@ -1396,10 +1396,10 @@ * in the copy. * * @return a new <code>CachedRowSet</code> object that is a deep copy - * of this <code>CachedRowSet</code> object and is - * completely independent of this <code>CachedRowSet</code> object + * of this <code>CachedRowSet</code> object and is + * completely independent of this <code>CachedRowSet</code> object * @throws SQLException if an error occurs in generating the copy of - * the of this <code>CachedRowSet</code> object + * the of this <code>CachedRowSet</code> object * @see #createCopy * @see #createShared * @see #createCopySchema @@ -1445,7 +1445,7 @@ * @return <code>true</code> if deleted rows are visible; * <code>false</code> otherwise * @throws SQLException if a rowset implementation is unable to - * to determine whether rows marked for deletion are visible + * to determine whether rows marked for deletion are visible * @see #setShowDeleted */ public boolean getShowDeleted() throws SQLException; @@ -1467,7 +1467,7 @@ * @param b <code>true</code> if deleted rows should be shown; * <code>false</code> otherwise * @exception SQLException if a rowset implementation is unable to - * to reset whether deleted rows should be visible + * to reset whether deleted rows should be visible * @see #getShowDeleted */ public void setShowDeleted(boolean b) throws SQLException; @@ -1523,9 +1523,12 @@ * set to false, the changes will <b>not</b> be committed until one of the * <code>CachedRowSet</code> interface transaction methods is called. * + * @deprecated Because this field is final (it is part of an interface), + * its value cannot be changed. * @see #commit * @see #rollback */ + @Deprecated public static final boolean COMMIT_ON_ACCEPT_CHANGES = true; /** @@ -1562,10 +1565,10 @@ * @param startRow the position in the <code>ResultSet</code> from where to start * populating the records in this <code>CachedRowSet</code> * @param rs the <code>ResultSet</code> object containing the data - * to be read into this <code>CachedRowSet</code> object + * to be read into this <code>CachedRowSet</code> object * @throws SQLException if a null <code>ResultSet</code> object is supplied - * or this <code>CachedRowSet</code> object cannot - * retrieve the associated <code>ResultSetMetaData</code> object + * or this <code>CachedRowSet</code> object cannot + * retrieve the associated <code>ResultSetMetaData</code> object * @see #execute * @see #populate(ResultSet) * @see java.sql.ResultSet @@ -1620,3 +1623,4 @@ public boolean previousPage() throws SQLException; } +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/javax/sql/rowset/RowSetFactory.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,99 @@ +/* + * 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 javax.sql.rowset; + +import java.sql.SQLException; + +/** + * An interface that defines the implementation of a factory that is used + * to obtain different types of {@code RowSet} implementations. + * + * @author Lance Andersen + * @since 1.7 + */ +public interface RowSetFactory{ + + /** + * <p>Creates a new instance of a CachedRowSet.</p> + * + * @return A new instance of a CachedRowSet. + * + * @throws SQLException if a CachedRowSet cannot + * be created. + * + * @since 1.7 + */ + public CachedRowSet createCachedRowSet() throws SQLException; + + /** + * <p>Creates a new instance of a FilteredRowSet.</p> + * + * @return A new instance of a FilteredRowSet. + * + * @throws SQLException if a FilteredRowSet cannot + * be created. + * + * @since 1.7 + */ + public FilteredRowSet createFilteredRowSet() throws SQLException; + + /** + * <p>Creates a new instance of a JdbcRowSet.</p> + * + * @return A new instance of a JdbcRowSet. + * + * @throws SQLException if a JdbcRowSet cannot + * be created. + * + * @since 1.7 + */ + public JdbcRowSet createJdbcRowSet() throws SQLException; + + /** + * <p>Creates a new instance of a JoinRowSet.</p> + * + * @return A new instance of a JoinRowSet. + * + * @throws SQLException if a JoinRowSet cannot + * be created. + * + * @since 1.7 + */ + public JoinRowSet createJoinRowSet() throws SQLException; + + /** + * <p>Creates a new instance of a WebRowSet.</p> + * + * @return A new instance of a WebRowSet. + * + * @throws SQLException if a WebRowSet cannot + * be created. + * + * @since 1.7 + */ + public WebRowSet createWebRowSet() throws SQLException; + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/javax/sql/rowset/RowSetProvider.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,305 @@ +/* + * 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 javax.sql.rowset; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.sql.SQLException; +import java.util.ServiceLoader; +import javax.sql.rowset.RowSetFactory; + +/** + * A factory API that enables applications to obtain a + * {@code RowSetFactory} implementation that can be used to create different + * types of {@code RowSet} implementations. + * <p> + * Example: + * </p> + * <pre> + * RowSetFactory aFactory = RowSetProvider.newFactory(); + * CachedRowSet crs = aFactory.createCachedRowSet(); + * ... + * RowSetFactory rsf = RowSetProvider.newFactory("com.sun.rowset.RowSetFactoryImpl", null); + * WebRowSet wrs = rsf.createWebRowSet(); + * </pre> + *<p> + * Tracing of this class may be enabled by setting the System property + * {@code javax.sql.rowset.RowSetFactory.debug} to any value but {@code false}. + * </p> + * + * @author Lance Andersen + * @since 1.7 + */ +public class RowSetProvider { + + private static final String ROWSET_DEBUG_PROPERTY = "javax.sql.rowset.RowSetProvider.debug"; + private static final String ROWSET_FACTORY_IMPL = "com.sun.rowset.RowSetFactoryImpl"; + private static final String ROWSET_FACTORY_NAME = "javax.sql.rowset.RowSetFactory"; + /** + * Internal debug flag. + */ + private static boolean debug = true; + + + static { + // Check to see if the debug property is set + String val = getSystemProperty(ROWSET_DEBUG_PROPERTY); + // Allow simply setting the prop to turn on debug + debug = val != null && !"false".equals(val); + } + + + protected RowSetProvider () { + } + + /** + * <p>Creates a new instance of a <code>RowSetFactory</code> + * implementation. This method uses the following + * look up order to determine + * the <code>RowSetFactory</code> implementation class to load:</p> + * <ul> + * <li> + * The System property {@code javax.sql.rowset.RowsetFactory}. For example: + * <ul> + * <li> + * -Djavax.sql.rowset.RowsetFactory=com.sun.rowset.RowSetFactoryImpl + * </li> + * </ul> + * <li> + * The ServiceLocator API. The ServiceLocator API will look + * for a classname in the file + * {@code META-INF/services/javax.sql.rowset.RowSetFactory} + * in jars available to the runtime. For example, to have the the RowSetFactory + * implementation {@code com.sun.rowset.RowSetFactoryImpl } loaded, the + * entry in {@code META-INF/services/javax.sql.rowset.RowSetFactory} would be: + * <ul> + * <li> + * {@code com.sun.rowset.RowSetFactoryImpl } + * </li> + * </ul> + * </li> + * <li> + * Platform default <code>RowSetFactory</code> instance. + * </li> + * </ul> + * + * <p>Once an application has obtained a reference to a {@code RowSetFactory}, + * it can use the factory to obtain RowSet instances.</p> + * + * @return New instance of a <code>RowSetFactory</code> + * + * @throws SQLException if the default factory class cannot be loaded, + * instantiated. The cause will be set to actual Exception + * + * @see ServiceLoader + * @since 1.7 + */ + public static RowSetFactory newFactory() + throws SQLException { + // Use the system property first + RowSetFactory factory = null; + String factoryClassName = null; + try { + trace("Checking for Rowset System Property..."); + factoryClassName = getSystemProperty(ROWSET_FACTORY_NAME); + if (factoryClassName != null) { + trace("Found system property, value=" + factoryClassName); + factory = (RowSetFactory) getFactoryClass(factoryClassName, null, true).newInstance(); + } + } catch (ClassNotFoundException e) { + throw new SQLException( + "RowSetFactory: " + factoryClassName + " not found", e); + } catch (Exception e) { + throw new SQLException( + "RowSetFactory: " + factoryClassName + " could not be instantiated: " + e, + e); + } + + // Check to see if we found the RowSetFactory via a System property + if (factory == null) { + // If the RowSetFactory is not found via a System Property, now + // look it up via the ServiceLoader API and if not found, use the + // Java SE default. + factory = loadViaServiceLoader(); + factory = + factory == null ? newFactory(ROWSET_FACTORY_IMPL, null) : factory; + } + return (factory); + } + + /** + * <p>Creates a new instance of a <code>RowSetFactory</code> from the + * specified factory class name. + * This function is useful when there are multiple providers in the classpath. + * It gives more control to the application as it can specify which provider + * should be loaded.</p> + * + * <p>Once an application has obtained a reference to a <code>RowSetFactory</code> + * it can use the factory to obtain RowSet instances.</p> + * + * @param factoryClassName fully qualified factory class name that + * provides an implementation of <code>javax.sql.rowset.RowSetFactory</code>. + * + * @param cl <code>ClassLoader</code> used to load the factory + * class. If <code>null</code> current <code>Thread</code>'s context + * classLoader is used to load the factory class. + * + * @return New instance of a <code>RowSetFactory</code> + * + * @throws SQLException if <code>factoryClassName</code> is + * <code>null</code>, or the factory class cannot be loaded, instantiated. + * + * @see #newFactory() + * + * @since 1.7 + */ + public static RowSetFactory newFactory(String factoryClassName, ClassLoader cl) + throws SQLException { + + trace("***In newInstance()"); + try { + Class providerClass = getFactoryClass(factoryClassName, cl, false); + RowSetFactory instance = (RowSetFactory) providerClass.newInstance(); + if (debug) { + trace("Created new instance of " + providerClass + + " using ClassLoader: " + cl); + } + return instance; + } catch (ClassNotFoundException x) { + throw new SQLException( + "Provider " + factoryClassName + " not found", x); + } catch (Exception x) { + throw new SQLException( + "Provider " + factoryClassName + " could not be instantiated: " + x, + x); + } + } + + /* + * Returns the class loader to be used. + * @return The ClassLoader to use. + * + */ + static private ClassLoader getContextClassLoader() throws SecurityException { + return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { + + public Object run() { + ClassLoader cl = null; + + cl = Thread.currentThread().getContextClassLoader(); + + if (cl == null) { + cl = ClassLoader.getSystemClassLoader(); + } + + return cl; + } + }); + } + + /** + * Attempt to load a class using the class loader supplied. If that fails + * and fall back is enabled, the current (i.e. bootstrap) class loader is + * tried. + * + * If the class loader supplied is <code>null</code>, first try using the + * context class loader followed by the current class loader. + * @return The class which was loaded + */ + static private Class getFactoryClass(String factoryClassName, ClassLoader cl, + boolean doFallback) throws ClassNotFoundException { + try { + if (cl == null) { + cl = getContextClassLoader(); + if (cl == null) { + throw new ClassNotFoundException(); + } else { + return cl.loadClass(factoryClassName); + } + } else { + return cl.loadClass(factoryClassName); + } + } catch (ClassNotFoundException e) { + if (doFallback) { + // Use current class loader + return Class.forName(factoryClassName, true, RowSetFactory.class.getClassLoader()); + } else { + throw e; + } + } + } + + /** + * Use the ServiceLoader mechanism to load the default RowSetFactory + * @return default RowSetFactory Implementation + */ + static private RowSetFactory loadViaServiceLoader() { + RowSetFactory theFactory = null; + trace("***in loadViaServiceLoader()"); + for (RowSetFactory factory : ServiceLoader.load(javax.sql.rowset.RowSetFactory.class)) { + trace(" Loading done by the java.util.ServiceLoader :" + factory.getClass().getName()); + theFactory = factory; + break; + } + return theFactory; + + } + + /** + * Returns the requested System Property. If a {@code SecurityException} + * occurs, just return NULL + * @param propName - System property to retreive + * @return The System property value or NULL if the property does not exist + * or a {@code SecurityException} occurs. + */ + static private String getSystemProperty(final String propName) { + String property = null; + try { + property = (String) AccessController.doPrivileged(new PrivilegedAction() { + + public Object run() { + return System.getProperty(propName); + } + }); + } catch (SecurityException se) { + if (debug) { + se.printStackTrace(); + } + } + return property; + } + + /** + * Debug routine which will output tracing if the System Property + * -Djavax.sql.rowset.RowSetFactory.debug is set + * @param msg - The debug message to display + */ + private static void trace(String msg) { + if (debug) { + System.err.println("###RowSets: " + msg); + } + } +}
--- a/src/share/classes/javax/sql/rowset/package.html Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/javax/sql/rowset/package.html Tue Sep 07 15:53:32 2010 -0700 @@ -5,7 +5,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- -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. This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,7 @@ data structure as defined in the JDBC 3.0 specification. <p> <li><a href="CachedRowSet.html"> -<b><code>CachedRowSet</code><sup><font size=-2>TM></font></sup</b></a> +<b><code>CachedRowSet</code>™</b></a> - A <tt>CachedRowSet</tt> object is a JavaBeans<sup><font size=-2>TM</font></sup> component that is scrollable, updatable, serializable, and generally disconnected from the source of its data. A <tt>CachedRowSet</tt> object @@ -148,7 +148,12 @@ on <a href="spi/SyncProvider.html"><code>SyncProvider</code></a> implementations. <p> <ul> -<li><b>3.1 Role of the <code>BaseRowSet</code> Class</b> +<li><b>3.1 Constructor</b> +<p> + All <code>RowSet</code> implementations <strong>must</strong> provide a +no-argument constructor. +</li> +<li><b>3.2 Role of the <code>BaseRowSet</code> Class</b> <p> A compliant JDBC <code>RowSet</code> implementation <b>must</b> implement one or more standard interfaces specified in this package and and <b>may</b> extend the @@ -215,7 +220,7 @@ </table> </blockquote> <p> -<li><b>3.2 Connected RowSet Requirements</b> +<li><b>3.3 Connected RowSet Requirements</b> <p> The <code>JdbcRowSet</code> describes a <code>RowSet</code> object that <b>must</b> always be connected to the originating data source. Implementations of the <code>JdbcRowSet</code> @@ -229,7 +234,7 @@ <p> <li> -<b>3.3 Disconnected RowSet Requirements</b> +<b>3.4 Disconnected RowSet Requirements</b> <p> A disconnected <code>RowSet</code> object, such as a <code>CachedRowSet</code> object, <b>should</b> delegate @@ -244,7 +249,7 @@ therefore ensure that no extraneous references remain on the <code>Connection</code> object. <p> -<li><b>3.4 Role of RowSetMetaDataImpl</b> +<li><b>3.5 Role of RowSetMetaDataImpl</b> <p> The <code>RowsetMetaDataImpl</code> class is a utility class that provides an implementation of the <a href="../RowSetMetaData.html">RowSetMetaData</a> interface, supplying standard setter @@ -252,7 +257,7 @@ <code>RowSet</code> objects. All implementations are free to use this standard implementation but are not required to do so. <p> -<li><b>3.5 RowSetWarning Class</b> +<li><b>3.6 RowSetWarning Class</b> <p> The <code>RowSetWarning</code> class provides warnings that can be set on <code>RowSet</code> implementations. @@ -270,7 +275,7 @@ <P> -<li><b>3.6 The Joinable Interface</b> +<li><b>3.7 The Joinable Interface</b> <P> The <code>Joinable</code> interface provides both connected and disconnected <code>RowSet</code> objects with the capability to be added to a @@ -278,7 +283,14 @@ A <code>RowSet</code> object that has implemented the <code>Joinable</code> interface can set a match column, retrieve a match column, or unset a match column. A <code>JoinRowSet</code> object can then use the <code>RowSet</code> object's -match column as a basis for adding the <code>RowSet</code> object. +match column as a basis for adding the <code>RowSet</code> object. +</li> + +<li><b>3.8 The RowSetFactory Interface</b> + <p> + A <code>RowSetFactory</code> implementation <strong>must</strong> + be provided. +</li> </ul> <h3><a name="relspec">4.0 Related Specifications</a></h3>
--- a/src/share/classes/javax/sql/rowset/spi/SyncFactory.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/javax/sql/rowset/spi/SyncFactory.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,6 @@ package javax.sql.rowset.spi; -import java.util.Map; -import java.util.Hashtable; -import java.util.Enumeration; -import java.util.Vector; -import java.util.Properties; -import java.util.Collection; -import java.util.StringTokenizer; import java.util.logging.*; import java.util.*; @@ -216,68 +209,64 @@ * Having a private constructor guarantees that no more than * one <code>SyncProvider</code> object can exist at a time. */ - private SyncFactory() {}; + private SyncFactory() { + } /** * The standard property-id for a synchronization provider implementation * name. */ - public static String ROWSET_SYNC_PROVIDER = - "rowset.provider.classname"; - + public static final String ROWSET_SYNC_PROVIDER = + "rowset.provider.classname"; /** * The standard property-id for a synchronization provider implementation * vendor name. */ - public static String ROWSET_SYNC_VENDOR = - "rowset.provider.vendor"; - + public static final String ROWSET_SYNC_VENDOR = + "rowset.provider.vendor"; /** * The standard property-id for a synchronization provider implementation * version tag. */ - public static String ROWSET_SYNC_PROVIDER_VERSION = - "rowset.provider.version"; - + public static final String ROWSET_SYNC_PROVIDER_VERSION = + "rowset.provider.version"; /** * The standard resource file name. */ private static String ROWSET_PROPERTIES = "rowset.properties"; - /** * The RI Optimistic Provider. */ private static String default_provider = - "com.sun.rowset.providers.RIOptimisticProvider"; - + "com.sun.rowset.providers.RIOptimisticProvider"; + /** + * Permission required to invoke setJNDIContext and setLogger + */ + private static final SQLPermission SET_SYNCFACTORY_PERMISSION = + new SQLPermission("setSyncFactory"); /** * The initial JNDI context where <code>SyncProvider</code> implementations can * be stored and from which they can be invoked. */ private static Context ic; - /** * The <code>Logger</code> object to be used by the <code>SyncFactory</code>. */ private static Logger rsLogger; - /** * */ private static Level rsLevel; - /** * The registry of available <code>SyncProvider</code> implementations. * See section 2.0 of the class comment for <code>SyncFactory</code> for an * explanation of how a provider can be added to this registry. */ private static Hashtable implementations; - /** * Internal sync object used to maintain the SPI as a singleton */ private static Object logSync = new Object(); - /** * Internal PrintWriter field for logging facility */ @@ -311,7 +300,7 @@ * @see #setJNDIContext */ public static synchronized void registerProvider(String providerID) - throws SyncFactoryException { + throws SyncFactoryException { ProviderImpl impl = new ProviderImpl(); impl.setClassname(providerID); @@ -325,29 +314,29 @@ * * @return the <code>SyncFactory</code> instance */ - public static SyncFactory getSyncFactory(){ + public static SyncFactory getSyncFactory() { - // This method uses the Singleton Design Pattern - // with Double-Checked Locking Pattern for - // 1. Creating single instance of the SyncFactory - // 2. Make the class thread safe, so that at one time - // only one thread enters the synchronized block - // to instantiate. + // This method uses the Singleton Design Pattern + // with Double-Checked Locking Pattern for + // 1. Creating single instance of the SyncFactory + // 2. Make the class thread safe, so that at one time + // only one thread enters the synchronized block + // to instantiate. - // if syncFactory object is already there - // don't go into synchronized block and return - // that object. - // else go into synchronized block + // if syncFactory object is already there + // don't go into synchronized block and return + // that object. + // else go into synchronized block - if(syncFactory == null){ - synchronized(SyncFactory.class) { - if(syncFactory == null){ + if (syncFactory == null) { + synchronized (SyncFactory.class) { + if (syncFactory == null) { syncFactory = new SyncFactory(); } //end if - } //end synchronized block - } //end if - return syncFactory; - } + } //end synchronized block + } //end if + return syncFactory; + } /** * Removes the designated currently registered synchronization provider from the @@ -358,13 +347,12 @@ * unregister a SyncProvider implementation that was not registered. */ public static synchronized void unregisterProvider(String providerID) - throws SyncFactoryException { + throws SyncFactoryException { initMapIfNecessary(); if (implementations.containsKey(providerID)) { implementations.remove(providerID); } } - private static String colon = ":"; private static String strFileSep = "/"; @@ -395,7 +383,7 @@ * Dependent on application */ String strRowsetProperties = System.getProperty("rowset.properties"); - if ( strRowsetProperties != null) { + if (strRowsetProperties != null) { // Load user's implementation of SyncProvider // here. -Drowset.properties=/abc/def/pqr.txt ROWSET_PROPERTIES = strRowsetProperties; @@ -407,8 +395,8 @@ * Always available */ ROWSET_PROPERTIES = "javax" + strFileSep + "sql" + - strFileSep + "rowset" + strFileSep + - "rowset.properties"; + strFileSep + "rowset" + strFileSep + + "rowset.properties"; // properties.load( // ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)); @@ -417,7 +405,7 @@ properties.load(cl.getResourceAsStream(ROWSET_PROPERTIES)); parseProperties(properties); - // removed else, has properties should sum together + // removed else, has properties should sum together } catch (FileNotFoundException e) { throw new SyncFactoryException("Cannot locate properties file: " + e); @@ -447,18 +435,15 @@ } } } - /** * The internal boolean switch that indicates whether a JNDI * context has been established or not. */ private static boolean jndiCtxEstablished = false; - /** * The internal debug switch. */ private static boolean debug = false; - /** * Internal registry count for the number of providers contained in the * registry. @@ -475,9 +460,9 @@ String key = null; String[] propertyNames = null; - for (Enumeration e = p.propertyNames(); e.hasMoreElements() ;) { + for (Enumeration e = p.propertyNames(); e.hasMoreElements();) { - String str = (String)e.nextElement(); + String str = (String) e.nextElement(); int w = str.length(); @@ -491,7 +476,7 @@ propertyNames = getPropertyNames(false); } else { // property index has been set. - propertyNames = getPropertyNames(true, str.substring(w-1)); + propertyNames = getPropertyNames(true, str.substring(w - 1)); } key = p.getProperty(propertyNames[0]); @@ -515,17 +500,17 @@ * overloaded property names that contain indexes. */ private static String[] getPropertyNames(boolean append, - String propertyIndex) { + String propertyIndex) { String dot = "."; String[] propertyNames = - new String[] {SyncFactory.ROWSET_SYNC_PROVIDER, - SyncFactory.ROWSET_SYNC_VENDOR, - SyncFactory.ROWSET_SYNC_PROVIDER_VERSION}; + new String[]{SyncFactory.ROWSET_SYNC_PROVIDER, + SyncFactory.ROWSET_SYNC_VENDOR, + SyncFactory.ROWSET_SYNC_PROVIDER_VERSION}; if (append) { for (int i = 0; i < propertyNames.length; i++) { propertyNames[i] = propertyNames[i] + - dot + - propertyIndex; + dot + + propertyIndex; } return propertyNames; } else { @@ -549,15 +534,21 @@ * * @param providerID the unique identifier of the provider * @return a <code>SyncProvider</code> implementation - * @throws SyncFactoryException If the SyncProvider cannot be found or + * @throws SyncFactoryException If the SyncProvider cannot be found, + * the providerID is {@code null}, or * some error was encountered when trying to invoke this provider. */ public static SyncProvider getInstance(String providerID) - throws SyncFactoryException { + throws SyncFactoryException { + + if(providerID == null) { + throw new SyncFactoryException("The providerID cannot be null"); + } + initMapIfNecessary(); // populate HashTable initJNDIContext(); // check JNDI context for any additional bindings - ProviderImpl impl = (ProviderImpl)implementations.get(providerID); + ProviderImpl impl = (ProviderImpl) implementations.get(providerID); if (impl == null) { // Requested SyncProvider is unavailable. Return default provider. @@ -575,11 +566,10 @@ * this SyncFactory and try to laod the SyncProvider class from * there. **/ - c = Class.forName(providerID, true, cl); if (c != null) { - return (SyncProvider)c.newInstance(); + return (SyncProvider) c.newInstance(); } else { return new com.sun.rowset.providers.RIOptimisticProvider(); } @@ -592,6 +582,7 @@ throw new SyncFactoryException("ClassNotFoundException: " + e.getMessage()); } } + /** * Returns an Enumeration of currently registered synchronization * providers. A <code>RowSet</code> implementation may use any provider in @@ -605,7 +596,7 @@ * providers that are registered with this Factory */ public static Enumeration<SyncProvider> getRegisteredProviders() - throws SyncFactoryException { + throws SyncFactoryException { initMapIfNecessary(); // return a collection of classnames // of type SyncProvider @@ -618,10 +609,26 @@ * <code>SyncProvider</code> implementations can log their events to * this object and the application can retrieve a handle to this * object using the <code>getLogger</code> method. + * <p> + * This method checks to see that there is an {@code SQLPermission} + * object which grants the permission {@code setSyncFactory} + * before allowing the method to succeed. If a + * {@code SecurityManager} exists and its + * {@code checkPermission} method denies calling {@code setLogger}, + * this method throws a + * {@code java.lang.SecurityException}. * * @param logger A Logger object instance + * @throws java.lang.SecurityException if a security manager exists and its + * {@code checkPermission} method denies calling {@code setLogger} + * @see SecurityManager#checkPermission */ public static void setLogger(Logger logger) { + + SecurityManager sec = System.getSecurityManager(); + if (sec != null) { + sec.checkPermission(SET_SYNCFACTORY_PERMISSION); + } rsLogger = logger; } @@ -631,14 +638,28 @@ * <code>SyncProvider</code> implementations can log their events * to this object and the application can retrieve a handle to this * object using the <code>getLogger</code> method. + * <p> + * This method checks to see that there is an {@code SQLPermission} + * object which grants the permission {@code setSyncFactory} + * before allowing the method to succeed. If a + * {@code SecurityManager} exists and its + * {@code checkPermission} method denies calling {@code setLogger}, + * this method throws a + * {@code java.lang.SecurityException}. * * @param logger a Logger object instance * @param level a Level object instance indicating the degree of logging * required + * @throws java.lang.SecurityException if a security manager exists and its + * {@code checkPermission} method denies calling {@code setLogger} + * @see SecurityManager#checkPermission */ public static void setLogger(Logger logger, Level level) { // singleton - + SecurityManager sec = System.getSecurityManager(); + if (sec != null) { + sec.checkPermission(SET_SYNCFACTORY_PERMISSION); + } rsLogger = logger; rsLogger.setLevel(level); } @@ -651,27 +672,42 @@ */ public static Logger getLogger() throws SyncFactoryException { // only one logger per session - if(rsLogger == null){ - throw new SyncFactoryException("(SyncFactory) : No logger has been set"); + if (rsLogger == null) { + throw new SyncFactoryException("(SyncFactory) : No logger has been set"); } return rsLogger; } - /** - * Sets the initial JNDI context from which SyncProvider implementations - * can be retrieved from a JNDI namespace - * - * @param ctx a valid JNDI context - * @throws SyncFactoryException if the supplied JNDI context is null - */ + /** + * Sets the initial JNDI context from which SyncProvider implementations + * can be retrieved from a JNDI namespace + * <p> + * This method checks to see that there is an {@code SQLPermission} + * object which grants the permission {@code setSyncFactory} + * before allowing the method to succeed. If a + * {@code SecurityManager} exists and its + * {@code checkPermission} method denies calling {@code setJNDIContext}, + * this method throws a + * {@code java.lang.SecurityException}. + * + * @param ctx a valid JNDI context + * @throws SyncFactoryException if the supplied JNDI context is null + * @throws java.lang.SecurityException if a security manager exists and its + * {@code checkPermission} method denies calling {@code setJNDIContext} + * @see SecurityManager#checkPermission + */ public static void setJNDIContext(javax.naming.Context ctx) - throws SyncFactoryException { + throws SyncFactoryException { + SecurityManager sec = System.getSecurityManager(); + if (sec != null) { + sec.checkPermission(SET_SYNCFACTORY_PERMISSION); + } if (ctx == null) { throw new SyncFactoryException("Invalid JNDI context supplied"); } ic = ctx; jndiCtxEstablished = true; - } + } /** * Controls JNDI context intialization. @@ -689,7 +725,7 @@ throw new SyncFactoryException("SPI: NamingException: " + e.getExplanation()); } catch (Exception e) { e.printStackTrace(); - throw new SyncFactoryException("SPI: Exception: " + e.getMessage()); + throw new SyncFactoryException("SPI: Exception: " + e.getMessage()); } } } @@ -720,7 +756,7 @@ * bindings have been enumerated. */ private static void enumerateBindings(NamingEnumeration bindings, - Properties properties) throws NamingException { + Properties properties) throws NamingException { boolean syncProviderObj = false; // move to parameters ? @@ -729,21 +765,21 @@ Object elementObj = null; String element = null; while (bindings.hasMore()) { - bd = (Binding)bindings.next(); + bd = (Binding) bindings.next(); element = bd.getName(); elementObj = bd.getObject(); if (!(ic.lookup(element) instanceof Context)) { - // skip directories/sub-contexts - if (ic.lookup(element) instanceof SyncProvider) { + // skip directories/sub-contexts + if (ic.lookup(element) instanceof SyncProvider) { syncProviderObj = true; - } + } } if (syncProviderObj) { - SyncProvider sync = (SyncProvider)elementObj; + SyncProvider sync = (SyncProvider) elementObj; properties.put(SyncFactory.ROWSET_SYNC_PROVIDER, - sync.getProviderID()); + sync.getProviderID()); syncProviderObj = false; // reset } @@ -756,142 +792,136 @@ } } - /** - * Internal class that defines the lazy reference construct for each registered - * SyncProvider implementation. - */ - class ProviderImpl extends SyncProvider { - private String className = null; - private String vendorName = null; - private String ver = null; - private int index; +/** + * Internal class that defines the lazy reference construct for each registered + * SyncProvider implementation. + */ +class ProviderImpl extends SyncProvider { + + private String className = null; + private String vendorName = null; + private String ver = null; + private int index; - public void setClassname(String classname) { - className = classname; - } - - public String getClassname() { - return className; - } + public void setClassname(String classname) { + className = classname; + } - public void setVendor(String vendor) { - vendorName = vendor; - } + public String getClassname() { + return className; + } - public String getVendor() { - return vendorName; - } + public void setVendor(String vendor) { + vendorName = vendor; + } - public void setVersion(String providerVer) { - ver = providerVer; - } + public String getVendor() { + return vendorName; + } - public String getVersion() { - return ver; - } + public void setVersion(String providerVer) { + ver = providerVer; + } - public void setIndex(int i) { - index = i; - } + public String getVersion() { + return ver; + } - public int getIndex() { - return index; - } + public void setIndex(int i) { + index = i; + } - public int getDataSourceLock() throws SyncProviderException { + public int getIndex() { + return index; + } - int dsLock = 0; - try - { - dsLock = SyncFactory.getInstance(className).getDataSourceLock(); - } catch(SyncFactoryException sfEx) { + public int getDataSourceLock() throws SyncProviderException { - throw new SyncProviderException(sfEx.getMessage()); - } + int dsLock = 0; + try { + dsLock = SyncFactory.getInstance(className).getDataSourceLock(); + } catch (SyncFactoryException sfEx) { - return dsLock; + throw new SyncProviderException(sfEx.getMessage()); } - public int getProviderGrade() { + return dsLock; + } - int grade = 0; + public int getProviderGrade() { - try - { - grade = SyncFactory.getInstance(className).getProviderGrade(); - } catch(SyncFactoryException sfEx) { - // - } + int grade = 0; - return grade; - } - - public String getProviderID() { - return className; + try { + grade = SyncFactory.getInstance(className).getProviderGrade(); + } catch (SyncFactoryException sfEx) { + // } - /* - public javax.sql.RowSetInternal getRowSetInternal() { - try - { - return SyncFactory.getInstance(className).getRowSetInternal(); - } catch(SyncFactoryException sfEx) { - // - } - } - */ + return grade; + } + + public String getProviderID() { + return className; + } - public javax.sql.RowSetReader getRowSetReader() { - - RowSetReader rsReader = null;; + /* + public javax.sql.RowSetInternal getRowSetInternal() { + try + { + return SyncFactory.getInstance(className).getRowSetInternal(); + } catch(SyncFactoryException sfEx) { + // + } + } + */ + public javax.sql.RowSetReader getRowSetReader() { - try - { - rsReader = SyncFactory.getInstance(className).getRowSetReader(); - } catch(SyncFactoryException sfEx) { - // - } + RowSetReader rsReader = null; - return rsReader; - + try { + rsReader = SyncFactory.getInstance(className).getRowSetReader(); + } catch (SyncFactoryException sfEx) { + // } - public javax.sql.RowSetWriter getRowSetWriter() { + return rsReader; + + } + + public javax.sql.RowSetWriter getRowSetWriter() { RowSetWriter rsWriter = null; - try - { - rsWriter = SyncFactory.getInstance(className).getRowSetWriter(); - } catch(SyncFactoryException sfEx) { - // - } - - return rsWriter; - } - public void setDataSourceLock(int param) - throws SyncProviderException { - - try - { - SyncFactory.getInstance(className).setDataSourceLock(param); - } catch(SyncFactoryException sfEx) { - - throw new SyncProviderException(sfEx.getMessage()); - } + try { + rsWriter = SyncFactory.getInstance(className).getRowSetWriter(); + } catch (SyncFactoryException sfEx) { + // } - public int supportsUpdatableView() { + return rsWriter; + } + + public void setDataSourceLock(int param) + throws SyncProviderException { + + try { + SyncFactory.getInstance(className).setDataSourceLock(param); + } catch (SyncFactoryException sfEx) { + + throw new SyncProviderException(sfEx.getMessage()); + } + } + + public int supportsUpdatableView() { int view = 0; - try - { - view = SyncFactory.getInstance(className).supportsUpdatableView(); - } catch(SyncFactoryException sfEx) { - // - } + try { + view = SyncFactory.getInstance(className).supportsUpdatableView(); + } catch (SyncFactoryException sfEx) { + // + } - return view; - } - + return view; } +}
--- a/src/share/classes/javax/sql/rowset/spi/SyncProvider.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/javax/sql/rowset/spi/SyncProvider.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, 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. * * This code is free software; you can redistribute it and/or modify it @@ -344,7 +344,7 @@ * source without checking the validity of any data. * */ - public static int GRADE_NONE = 1; + public static final int GRADE_NONE = 1; /** * Indicates a low level optimistic synchronization grade with @@ -354,7 +354,7 @@ * returning this grade will check only rows that have changed. * */ - public static int GRADE_CHECK_MODIFIED_AT_COMMIT = 2; + public static final int GRADE_CHECK_MODIFIED_AT_COMMIT = 2; /** * Indicates a high level optimistic synchronization grade with @@ -364,7 +364,7 @@ * returning this grade will check all rows, including rows that have not * changed. */ - public static int GRADE_CHECK_ALL_AT_COMMIT = 3; + public static final int GRADE_CHECK_ALL_AT_COMMIT = 3; /** * Indicates a pessimistic synchronization grade with @@ -374,7 +374,7 @@ * implementation returning this grade will lock the row in the originating * data source. */ - public static int GRADE_LOCK_WHEN_MODIFIED = 4; + public static final int GRADE_LOCK_WHEN_MODIFIED = 4; /** * Indicates the most pessimistic synchronization grade with @@ -384,47 +384,47 @@ * table affected by the original statement used to populate a * <code>RowSet</code> object. */ - public static int GRADE_LOCK_WHEN_LOADED = 5; + public static final int GRADE_LOCK_WHEN_LOADED = 5; /** * Indicates that no locks remain on the originating data source. This is the default * lock setting for all <code>SyncProvider</code> implementations unless * otherwise directed by a <code>RowSet</code> object. */ - public static int DATASOURCE_NO_LOCK = 1; + public static final int DATASOURCE_NO_LOCK = 1; /** * Indicates that a lock is placed on the rows that are touched by the original * SQL statement used to populate the <code>RowSet</code> object * that is using this <code>SyncProvider</code> object. */ - public static int DATASOURCE_ROW_LOCK = 2; + public static final int DATASOURCE_ROW_LOCK = 2; /** * Indicates that a lock is placed on all tables that are touched by the original * SQL statement used to populate the <code>RowSet</code> object * that is using this <code>SyncProvider</code> object. */ - public static int DATASOURCE_TABLE_LOCK = 3; + public static final int DATASOURCE_TABLE_LOCK = 3; /** * Indicates that a lock is placed on the entire data source that is the source of * data for the <code>RowSet</code> object * that is using this <code>SyncProvider</code> object. */ - public static int DATASOURCE_DB_LOCK = 4; + public static final int DATASOURCE_DB_LOCK = 4; /** * Indicates that a <code>SyncProvider</code> implementation * supports synchronization between a <code>RowSet</code> object and * the SQL <code>VIEW</code> used to populate it. */ - public static int UPDATABLE_VIEW_SYNC = 5; + public static final int UPDATABLE_VIEW_SYNC = 5; /** * Indicates that a <code>SyncProvider</code> implementation * does <B>not</B> support synchronization between a <code>RowSet</code> * object and the SQL <code>VIEW</code> used to populate it. */ - public static int NONUPDATABLE_VIEW_SYNC = 6; + public static final int NONUPDATABLE_VIEW_SYNC = 6; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/net/sdp/SdpSupport.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,81 @@ +/* + * 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 sun.net.sdp; + +import java.io.IOException; +import java.io.FileDescriptor; +import java.security.AccessController; + +import sun.misc.SharedSecrets; +import sun.misc.JavaIOFileDescriptorAccess; + + +/** + * This class defines methods for creating SDP sockets or "converting" existing + * file descriptors, referencing (unbound) TCP sockets, to SDP. + */ + +public final class SdpSupport { + private static final String os = AccessController + .doPrivileged(new sun.security.action.GetPropertyAction("os.name")); + private static final boolean isSupported = (os.equals("SunOS") || (os.equals("Linux"))); + private static final JavaIOFileDescriptorAccess fdAccess = + SharedSecrets.getJavaIOFileDescriptorAccess(); + + private SdpSupport() { } + + /** + * Creates a SDP socket, returning file descriptor referencing the socket. + */ + public static FileDescriptor createSocket() throws IOException { + if (!isSupported) + throw new UnsupportedOperationException("SDP not supported on this platform"); + int fdVal = create0(); + FileDescriptor fd = new FileDescriptor(); + fdAccess.set(fd, fdVal); + return fd; + } + + /** + * Converts an existing file descriptor, that references an unbound TCP socket, + * to SDP. + */ + public static void convertSocket(FileDescriptor fd) throws IOException { + if (!isSupported) + throw new UnsupportedOperationException("SDP not supported on this platform"); + int fdVal = fdAccess.get(fd); + convert0(fdVal); + } + + private static native int create0() throws IOException; + + private static native void convert0(int fd) throws IOException; + + static { + AccessController.doPrivileged( + new sun.security.action.LoadLibraryAction("net")); + } +}
--- a/src/share/classes/sun/nio/ch/IOUtil.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/sun/nio/ch/IOUtil.java Tue Sep 07 15:53:32 2010 -0700 @@ -319,7 +319,12 @@ static native boolean randomBytes(byte[] someBytes); - static native void initPipe(int[] fda, boolean blocking); + /** + * Returns two file descriptors for a pipe encoded in a long. + * The read end of the pipe is returned in the high 32 bits, + * while the write end is returned in the low 32 bits. + */ + static native long makePipe(boolean blocking); static native boolean drain(int fd) throws IOException;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/nio/ch/Secrets.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,63 @@ +/* + * 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 sun.nio.ch; + +import java.nio.channels.SocketChannel; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.spi.SelectorProvider; +import java.io.FileDescriptor; +import java.io.IOException; + +/** + * Provides access to implementation private constructors and methods. + */ + +public final class Secrets { + private Secrets() { } + + private static SelectorProvider provider() { + SelectorProvider p = SelectorProvider.provider(); + if (!(p instanceof SelectorProviderImpl)) + throw new UnsupportedOperationException(); + return p; + } + + public static SocketChannel newSocketChannel(FileDescriptor fd) { + try { + return new SocketChannelImpl(provider(), fd, false); + } catch (IOException ioe) { + throw new AssertionError(ioe); + } + } + + public static ServerSocketChannel newServerSocketChannel(FileDescriptor fd) { + try { + return new ServerSocketChannelImpl(provider(), fd, false); + } catch (IOException ioe) { + throw new AssertionError(ioe); + } + } +}
--- a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -80,21 +80,24 @@ // -- End of fields protected by stateLock - public ServerSocketChannelImpl(SelectorProvider sp) throws IOException { + ServerSocketChannelImpl(SelectorProvider sp) throws IOException { super(sp); this.fd = Net.serverSocket(true); this.fdVal = IOUtil.fdVal(fd); this.state = ST_INUSE; } - public ServerSocketChannelImpl(SelectorProvider sp, FileDescriptor fd) + ServerSocketChannelImpl(SelectorProvider sp, + FileDescriptor fd, + boolean bound) throws IOException { super(sp); this.fd = fd; this.fdVal = IOUtil.fdVal(fd); this.state = ST_INUSE; - localAddress = Net.localAddress(fd); + if (bound) + localAddress = Net.localAddress(fd); } public ServerSocket socket() {
--- a/src/share/classes/sun/nio/ch/SocketChannelImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/share/classes/sun/nio/ch/SocketChannelImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -103,6 +103,19 @@ this.state = ST_UNCONNECTED; } + SocketChannelImpl(SelectorProvider sp, + FileDescriptor fd, + boolean bound) + throws IOException + { + super(sp); + this.fd = fd; + this.fdVal = IOUtil.fdVal(fd); + this.state = ST_UNCONNECTED; + if (bound) + this.localAddress = Net.localAddress(fd); + } + // Constructor for sockets obtained from server sockets // SocketChannelImpl(SelectorProvider sp,
--- a/src/solaris/classes/java/lang/UNIXProcess.java.linux Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/java/lang/UNIXProcess.java.linux Tue Sep 07 15:53:32 2010 -0700 @@ -39,6 +39,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.ThreadFactory; import java.security.AccessController; +import static java.security.AccessController.doPrivileged; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; @@ -94,14 +95,13 @@ private final static ThreadGroup group = getRootThreadGroup(); private static ThreadGroup getRootThreadGroup() { - return AccessController.doPrivileged - (new PrivilegedAction<ThreadGroup> () { - public ThreadGroup run() { - ThreadGroup root = Thread.currentThread().getThreadGroup(); - while (root.getParent() != null) - root = root.getParent(); - return root; - }}); + return doPrivileged(new PrivilegedAction<ThreadGroup> () { + public ThreadGroup run() { + ThreadGroup root = Thread.currentThread().getThreadGroup(); + while (root.getParent() != null) + root = root.getParent(); + return root; + }}); } public Thread newThread(Runnable grimReaper) { @@ -117,8 +117,12 @@ /** * The thread pool of "process reaper" daemon threads. */ - private static final Executor processReaperExecutor - = Executors.newCachedThreadPool(new ProcessReaperThreadFactory()); + private static final Executor processReaperExecutor = + doPrivileged(new PrivilegedAction<Executor>() { + public Executor run() { + return Executors.newCachedThreadPool + (new ProcessReaperThreadFactory()); + }}); UNIXProcess(final byte[] prog, final byte[] argBlock, final int argc, @@ -136,8 +140,7 @@ redirectErrorStream); try { - AccessController.doPrivileged - (new PrivilegedExceptionAction<Void>() { + doPrivileged(new PrivilegedExceptionAction<Void>() { public Void run() throws IOException { initStreams(fds); return null;
--- a/src/solaris/classes/sun/net/NetHooks.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/net/NetHooks.java Tue Sep 07 15:53:32 2010 -0700 @@ -73,28 +73,7 @@ * be changed to use the ServiceLoader facility to allow the deployment of * other providers. */ - private static Provider loadProvider(final String cn) { - return AccessController - .doPrivileged(new PrivilegedAction<Provider>() { - @Override public Provider run() { - Class<Provider> c; - try { - c = (Class<Provider>)Class.forName(cn, true, null); - } catch (ClassNotFoundException x) { - return null; - } - try { - return c.newInstance(); - } catch (IllegalAccessException x) { - throw new AssertionError(x); - } catch (InstantiationException x) { - throw new AssertionError(x); - } - }}); - } - private static final Provider provider = AccessController - .doPrivileged(new GetPropertyAction("os.name")).equals("SunOS") ? - loadProvider("sun.net.spi.SdpProvider") : null; + private static final Provider provider = new sun.net.sdp.SdpProvider(); /** * Invoke prior to binding a TCP socket. @@ -104,8 +83,7 @@ int port) throws IOException { - if (provider != null) - provider.implBeforeTcpBind(fdObj, address, port); + provider.implBeforeTcpBind(fdObj, address, port); } /** @@ -116,7 +94,6 @@ int port) throws IOException { - if (provider != null) - provider.implBeforeTcpConnect(fdObj, address, port); + provider.implBeforeTcpConnect(fdObj, address, port); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/classes/sun/net/sdp/SdpProvider.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2009, 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 sun.net.sdp; + +import sun.net.NetHooks; +import java.net.InetAddress; +import java.net.Inet4Address; +import java.net.UnknownHostException; +import java.util.*; +import java.io.File; +import java.io.FileDescriptor; +import java.io.IOException; +import java.io.PrintStream; +import java.security.AccessController; + +import sun.net.sdp.SdpSupport; +import sun.security.action.GetPropertyAction; + +/** + * A NetHooks provider that converts sockets from the TCP to SDP protocol prior + * to binding or connecting. + */ + +public class SdpProvider extends NetHooks.Provider { + // maximum port + private static final int MAX_PORT = 65535; + + // indicates if SDP is enabled and the rules for when the protocol is used + private final boolean enabled; + private final List<Rule> rules; + + // logging for debug purposes + private PrintStream log; + + public SdpProvider() { + // if this property is not defined then there is nothing to do. + String file = AccessController.doPrivileged( + new GetPropertyAction("com.sun.sdp.conf")); + if (file == null) { + this.enabled = false; + this.rules = null; + return; + } + + // load configuration file + List<Rule> list = null; + if (file != null) { + try { + list = loadRulesFromFile(file); + } catch (IOException e) { + fail("Error reading %s: %s", file, e.getMessage()); + } + } + + // check if debugging is enabled + PrintStream out = null; + String logfile = AccessController.doPrivileged( + new GetPropertyAction("com.sun.sdp.debug")); + if (logfile != null) { + out = System.out; + if (logfile.length() > 0) { + try { + out = new PrintStream(logfile); + } catch (IOException ignore) { } + } + } + + this.enabled = !list.isEmpty(); + this.rules = list; + this.log = out; + } + + // supported actions + private static enum Action { + BIND, + CONNECT; + } + + // a rule for matching a bind or connect request + private static interface Rule { + boolean match(Action action, InetAddress address, int port); + } + + // rule to match port[-end] + private static class PortRangeRule implements Rule { + private final Action action; + private final int portStart; + private final int portEnd; + PortRangeRule(Action action, int portStart, int portEnd) { + this.action = action; + this.portStart = portStart; + this.portEnd = portEnd; + } + Action action() { + return action; + } + @Override + public boolean match(Action action, InetAddress address, int port) { + return (action == this.action && + port >= this.portStart && + port <= this.portEnd); + } + } + + // rule to match address[/prefix] port[-end] + private static class AddressPortRangeRule extends PortRangeRule { + private final byte[] addressAsBytes; + private final int prefixByteCount; + private final byte mask; + AddressPortRangeRule(Action action, InetAddress address, + int prefix, int port, int end) + { + super(action, port, end); + this.addressAsBytes = address.getAddress(); + this.prefixByteCount = prefix >> 3; + this.mask = (byte)(0xff << (8 - (prefix % 8))); + } + @Override + public boolean match(Action action, InetAddress address, int port) { + if (action != action()) + return false; + byte[] candidate = address.getAddress(); + // same address type? + if (candidate.length != addressAsBytes.length) + return false; + // check bytes + for (int i=0; i<prefixByteCount; i++) { + if (candidate[i] != addressAsBytes[i]) + return false; + } + // check remaining bits + if ((prefixByteCount < addressAsBytes.length) && + ((candidate[prefixByteCount] & mask) != + (addressAsBytes[prefixByteCount] & mask))) + return false; + return super.match(action, address, port); + } + } + + // parses port:[-end] + private static int[] parsePortRange(String s) { + int pos = s.indexOf('-'); + try { + int[] result = new int[2]; + if (pos < 0) { + boolean all = s.equals("*"); + result[0] = all ? 0 : Integer.parseInt(s); + result[1] = all ? MAX_PORT : result[0]; + } else { + String low = s.substring(0, pos); + if (low.length() == 0) low = "*"; + String high = s.substring(pos+1); + if (high.length() == 0) high = "*"; + result[0] = low.equals("*") ? 0 : Integer.parseInt(low); + result[1] = high.equals("*") ? MAX_PORT : Integer.parseInt(high); + } + return result; + } catch (NumberFormatException e) { + return new int[0]; + } + } + + private static void fail(String msg, Object... args) { + Formatter f = new Formatter(); + f.format(msg, args); + throw new RuntimeException(f.out().toString()); + } + + // loads rules from the given file + // Each non-blank/non-comment line must have the format: + // ("bind" | "connect") 1*LWSP-char (hostname | ipaddress["/" prefix]) + // 1*LWSP-char ("*" | port) [ "-" ("*" | port) ] + private static List<Rule> loadRulesFromFile(String file) + throws IOException + { + Scanner scanner = new Scanner(new File(file)); + try { + List<Rule> result = new ArrayList<Rule>(); + while (scanner.hasNextLine()) { + String line = scanner.nextLine().trim(); + + // skip blank lines and comments + if (line.length() == 0 || line.charAt(0) == '#') + continue; + + // must have 3 fields + String[] s = line.split("\\s+"); + if (s.length != 3) { + fail("Malformed line '%s'", line); + continue; + } + + // first field is the action ("bind" or "connect") + Action action = null; + for (Action a: Action.values()) { + if (s[0].equalsIgnoreCase(a.name())) { + action = a; + break; + } + } + if (action == null) { + fail("Action '%s' not recognized", s[0]); + continue; + } + + // * port[-end] + int[] ports = parsePortRange(s[2]); + if (ports.length == 0) { + fail("Malformed port range '%s'", s[2]); + continue; + } + + // match all addresses + if (s[1].equals("*")) { + result.add(new PortRangeRule(action, ports[0], ports[1])); + continue; + } + + // hostname | ipaddress[/prefix] + int pos = s[1].indexOf('/'); + try { + if (pos < 0) { + // hostname or ipaddress (no prefix) + InetAddress[] addresses = InetAddress.getAllByName(s[1]); + for (InetAddress address: addresses) { + int prefix = + (address instanceof Inet4Address) ? 32 : 128; + result.add(new AddressPortRangeRule(action, address, + prefix, ports[0], ports[1])); + } + } else { + // ipaddress/prefix + InetAddress address = InetAddress + .getByName(s[1].substring(0, pos)); + int prefix = -1; + try { + prefix = Integer.parseInt(s[1].substring(pos+1)); + if (address instanceof Inet4Address) { + // must be 1-31 + if (prefix < 0 || prefix > 32) prefix = -1; + } else { + // must be 1-128 + if (prefix < 0 || prefix > 128) prefix = -1; + } + } catch (NumberFormatException e) { + } + + if (prefix > 0) { + result.add(new AddressPortRangeRule(action, + address, prefix, ports[0], ports[1])); + } else { + fail("Malformed prefix '%s'", s[1]); + continue; + } + } + } catch (UnknownHostException uhe) { + fail("Unknown host or malformed IP address '%s'", s[1]); + continue; + } + } + return result; + } finally { + scanner.close(); + } + } + + // converts unbound TCP socket to a SDP socket if it matches the rules + private void convertTcpToSdpIfMatch(FileDescriptor fdObj, + Action action, + InetAddress address, + int port) + throws IOException + { + boolean matched = false; + for (Rule rule: rules) { + if (rule.match(action, address, port)) { + SdpSupport.convertSocket(fdObj); + matched = true; + break; + } + } + if (log != null) { + String addr = (address instanceof Inet4Address) ? + address.getHostAddress() : "[" + address.getHostAddress() + "]"; + if (matched) { + log.format("%s to %s:%d (socket converted to SDP protocol)\n", action, addr, port); + } else { + log.format("%s to %s:%d (no match)\n", action, addr, port); + } + } + } + + @Override + public void implBeforeTcpBind(FileDescriptor fdObj, + InetAddress address, + int port) + throws IOException + { + if (enabled) + convertTcpToSdpIfMatch(fdObj, Action.BIND, address, port); + } + + @Override + public void implBeforeTcpConnect(FileDescriptor fdObj, + InetAddress address, + int port) + throws IOException + { + if (enabled) + convertTcpToSdpIfMatch(fdObj, Action.CONNECT, address, port); + } +}
--- a/src/solaris/classes/sun/net/spi/SdpProvider.java Tue Sep 07 15:17:43 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,339 +0,0 @@ -/* - * Copyright (c) 2009, 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 sun.net.spi; - -import sun.net.NetHooks; -import java.net.InetAddress; -import java.net.Inet4Address; -import java.net.UnknownHostException; -import java.util.*; -import java.io.File; -import java.io.FileDescriptor; -import java.io.IOException; -import java.io.PrintStream; - -import sun.misc.SharedSecrets; -import sun.misc.JavaIOFileDescriptorAccess; - -/** - * A NetHooks provider that converts sockets from the TCP to SDP protocol prior - * to binding or connecting. - */ - -public class SdpProvider extends NetHooks.Provider { - private static final JavaIOFileDescriptorAccess fdAccess = - SharedSecrets.getJavaIOFileDescriptorAccess(); - - // maximum port - private static final int MAX_PORT = 65535; - - // indicates if SDP is enabled and the rules for when the protocol is used - private final boolean enabled; - private final List<Rule> rules; - - // logging for debug purposes - private PrintStream log; - - public SdpProvider() { - // if this property is not defined then there is nothing to do. - String file = System.getProperty("com.sun.sdp.conf"); - if (file == null) { - this.enabled = false; - this.rules = null; - return; - } - - // load configuration file - List<Rule> list = null; - if (file != null) { - try { - list = loadRulesFromFile(file); - } catch (IOException e) { - fail("Error reading %s: %s", file, e.getMessage()); - } - } - - // check if debugging is enabled - PrintStream out = null; - String logfile = System.getProperty("com.sun.sdp.debug"); - if (logfile != null) { - out = System.out; - if (logfile.length() > 0) { - try { - out = new PrintStream(logfile); - } catch (IOException ignore) { } - } - } - - this.enabled = !list.isEmpty(); - this.rules = list; - this.log = out; - } - - // supported actions - private static enum Action { - BIND, - CONNECT; - } - - // a rule for matching a bind or connect request - private static interface Rule { - boolean match(Action action, InetAddress address, int port); - } - - // rule to match port[-end] - private static class PortRangeRule implements Rule { - private final Action action; - private final int portStart; - private final int portEnd; - PortRangeRule(Action action, int portStart, int portEnd) { - this.action = action; - this.portStart = portStart; - this.portEnd = portEnd; - } - Action action() { - return action; - } - @Override - public boolean match(Action action, InetAddress address, int port) { - return (action == this.action && - port >= this.portStart && - port <= this.portEnd); - } - } - - // rule to match address[/prefix] port[-end] - private static class AddressPortRangeRule extends PortRangeRule { - private final byte[] addressAsBytes; - private final int prefixByteCount; - private final byte mask; - AddressPortRangeRule(Action action, InetAddress address, - int prefix, int port, int end) - { - super(action, port, end); - this.addressAsBytes = address.getAddress(); - this.prefixByteCount = prefix >> 3; - this.mask = (byte)(0xff << (8 - (prefix % 8))); - } - @Override - public boolean match(Action action, InetAddress address, int port) { - if (action != action()) - return false; - byte[] candidate = address.getAddress(); - // same address type? - if (candidate.length != addressAsBytes.length) - return false; - // check bytes - for (int i=0; i<prefixByteCount; i++) { - if (candidate[i] != addressAsBytes[i]) - return false; - } - // check remaining bits - if ((prefixByteCount < addressAsBytes.length) && - ((candidate[prefixByteCount] & mask) != - (addressAsBytes[prefixByteCount] & mask))) - return false; - return super.match(action, address, port); - } - } - - // parses port:[-end] - private static int[] parsePortRange(String s) { - int pos = s.indexOf('-'); - try { - int[] result = new int[2]; - if (pos < 0) { - boolean all = s.equals("*"); - result[0] = all ? 0 : Integer.parseInt(s); - result[1] = all ? MAX_PORT : result[0]; - } else { - String low = s.substring(0, pos); - if (low.length() == 0) low = "*"; - String high = s.substring(pos+1); - if (high.length() == 0) high = "*"; - result[0] = low.equals("*") ? 0 : Integer.parseInt(low); - result[1] = high.equals("*") ? MAX_PORT : Integer.parseInt(high); - } - return result; - } catch (NumberFormatException e) { - return new int[0]; - } - } - - private static void fail(String msg, Object... args) { - Formatter f = new Formatter(); - f.format(msg, args); - throw new RuntimeException(f.out().toString()); - } - - // loads rules from the given file - // Each non-blank/non-comment line must have the format: - // ("bind" | "connect") 1*LWSP-char (hostname | ipaddress["/" prefix]) - // 1*LWSP-char ("*" | port) [ "-" ("*" | port) ] - private static List<Rule> loadRulesFromFile(String file) - throws IOException - { - Scanner scanner = new Scanner(new File(file)); - try { - List<Rule> result = new ArrayList<Rule>(); - while (scanner.hasNextLine()) { - String line = scanner.nextLine().trim(); - - // skip blank lines and comments - if (line.length() == 0 || line.charAt(0) == '#') - continue; - - // must have 3 fields - String[] s = line.split("\\s+"); - if (s.length != 3) { - fail("Malformed line '%s'", line); - continue; - } - - // first field is the action ("bind" or "connect") - Action action = null; - for (Action a: Action.values()) { - if (s[0].equalsIgnoreCase(a.name())) { - action = a; - break; - } - } - if (action == null) { - fail("Action '%s' not recognized", s[0]); - continue; - } - - // * port[-end] - int[] ports = parsePortRange(s[2]); - if (ports.length == 0) { - fail("Malformed port range '%s'", s[2]); - continue; - } - - // match all addresses - if (s[1].equals("*")) { - result.add(new PortRangeRule(action, ports[0], ports[1])); - continue; - } - - // hostname | ipaddress[/prefix] - int pos = s[1].indexOf('/'); - try { - if (pos < 0) { - // hostname or ipaddress (no prefix) - InetAddress[] addresses = InetAddress.getAllByName(s[1]); - for (InetAddress address: addresses) { - int prefix = - (address instanceof Inet4Address) ? 32 : 128; - result.add(new AddressPortRangeRule(action, address, - prefix, ports[0], ports[1])); - } - } else { - // ipaddress/prefix - InetAddress address = InetAddress - .getByName(s[1].substring(0, pos)); - int prefix = -1; - try { - prefix = Integer.parseInt(s[1].substring(pos+1)); - if (address instanceof Inet4Address) { - // must be 1-31 - if (prefix < 0 || prefix > 32) prefix = -1; - } else { - // must be 1-128 - if (prefix < 0 || prefix > 128) prefix = -1; - } - } catch (NumberFormatException e) { - } - - if (prefix > 0) { - result.add(new AddressPortRangeRule(action, - address, prefix, ports[0], ports[1])); - } else { - fail("Malformed prefix '%s'", s[1]); - continue; - } - } - } catch (UnknownHostException uhe) { - fail("Unknown host or malformed IP address '%s'", s[1]); - continue; - } - } - return result; - } finally { - scanner.close(); - } - } - - // converts unbound TCP socket to a SDP socket if it matches the rules - private void convertTcpToSdpIfMatch(FileDescriptor fdObj, - Action action, - InetAddress address, - int port) - throws IOException - { - boolean matched = false; - for (Rule rule: rules) { - if (rule.match(action, address, port)) { - int fd = fdAccess.get(fdObj); - convert(fd); - matched = true; - break; - } - } - if (log != null) { - String addr = (address instanceof Inet4Address) ? - address.getHostAddress() : "[" + address.getHostAddress() + "]"; - if (matched) { - log.format("%s to %s:%d (socket converted to SDP protocol)\n", action, addr, port); - } else { - log.format("%s to %s:%d (no match)\n", action, addr, port); - } - } - } - - @Override - public void implBeforeTcpBind(FileDescriptor fdObj, - InetAddress address, - int port) - throws IOException - { - if (enabled) - convertTcpToSdpIfMatch(fdObj, Action.BIND, address, port); - } - - @Override - public void implBeforeTcpConnect(FileDescriptor fdObj, - InetAddress address, - int port) - throws IOException - { - if (enabled) - convertTcpToSdpIfMatch(fdObj, Action.CONNECT, address, port); - } - - // -- native methods -- - private static native void convert(int fd) throws IOException; -}
--- a/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java Tue Sep 07 15:53:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, 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. * * This code is free software; you can redistribute it and/or modify it @@ -25,20 +25,14 @@ package sun.net.www.protocol.http.ntlm; +import com.sun.security.ntlm.Client; +import com.sun.security.ntlm.NTLMException; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.PasswordAuthentication; import java.net.UnknownHostException; import java.net.URL; import java.security.GeneralSecurityException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import javax.crypto.Cipher; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.SecretKey; -import javax.crypto.SecretKeyFactory; -import javax.crypto.spec.DESKeySpec; import sun.net.www.HeaderParser; import sun.net.www.protocol.http.AuthenticationInfo; @@ -72,14 +66,8 @@ */ public class NTLMAuthentication extends AuthenticationInfo { - private static final long serialVersionUID = -2403849171106437142L; + private static final long serialVersionUID = 170L; - private byte[] type1; - private byte[] type3; - - private SecretKeyFactory fac; - private Cipher cipher; - private MessageDigest md4; private String hostname; private static String defaultDomain; /* Domain to use if not specified by user */ @@ -94,53 +82,28 @@ } private void init0() { - type1 = new byte[256]; - type3 = new byte[256]; - System.arraycopy (new byte[] {'N','T','L','M','S','S','P',0,1}, 0, type1, 0, 9); - type1[12] = (byte) 3; - type1[13] = (byte) 0xb2; - type1[28] = (byte) 0x20; - System.arraycopy (new byte[] {'N','T','L','M','S','S','P',0,3}, 0, type3, 0, 9); - type3[12] = (byte) 0x18; - type3[14] = (byte) 0x18; - type3[20] = (byte) 0x18; - type3[22] = (byte) 0x18; - type3[32] = (byte) 0x40; - type3[60] = (byte) 1; - type3[61] = (byte) 0x82; - try { - hostname = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<String>() { - public String run() { - String localhost; - try { - localhost = InetAddress.getLocalHost().getHostName().toUpperCase(); - } catch (UnknownHostException e) { - localhost = "localhost"; - } - return localhost; + hostname = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction<String>() { + public String run() { + String localhost; + try { + localhost = InetAddress.getLocalHost().getHostName().toUpperCase(); + } catch (UnknownHostException e) { + localhost = "localhost"; } - }); - int x = hostname.indexOf ('.'); - if (x != -1) { - hostname = hostname.substring (0, x); + return localhost; } - fac = SecretKeyFactory.getInstance ("DES"); - cipher = Cipher.getInstance ("DES/ECB/NoPadding"); - md4 = sun.security.provider.MD4.getInstance(); - } catch (NoSuchPaddingException e) { - assert false; - } catch (NoSuchAlgorithmException e) { - assert false; + }); + int x = hostname.indexOf ('.'); + if (x != -1) { + hostname = hostname.substring (0, x); } }; PasswordAuthentication pw; - String username; - String ntdomain; - String password; + Client client; /** * Create a NTLMAuthentication: * Username may be specified as domain<BACKSLASH>username in the application Authenticator. @@ -156,6 +119,9 @@ } private void init (PasswordAuthentication pw) { + String username; + String ntdomain; + char[] password; this.pw = pw; String s = pw.getUserName(); int i = s.indexOf ('\\'); @@ -166,8 +132,19 @@ ntdomain = s.substring (0, i).toUpperCase(); username = s.substring (i+1); } - password = new String (pw.getPassword()); + password = pw.getPassword(); init0(); + try { + client = new Client(System.getProperty("ntlm.version"), hostname, + username, ntdomain, password); + } catch (NTLMException ne) { + try { + client = new Client(null, hostname, username, ntdomain, password); + } catch (NTLMException ne2) { + // Will never happen + throw new AssertionError("Really?"); + } + } } /** @@ -240,181 +217,26 @@ } } - private void copybytes (byte[] dest, int destpos, String src, String enc) { - try { - byte[] x = src.getBytes(enc); - System.arraycopy (x, 0, dest, destpos, x.length); - } catch (UnsupportedEncodingException e) { - assert false; - } - } - private String buildType1Msg () { - int dlen = ntdomain.length(); - type1[16]= (byte) (dlen % 256); - type1[17]= (byte) (dlen / 256); - type1[18] = type1[16]; - type1[19] = type1[17]; - - int hlen = hostname.length(); - type1[24]= (byte) (hlen % 256); - type1[25]= (byte) (hlen / 256); - type1[26] = type1[24]; - type1[27] = type1[25]; - - copybytes (type1, 32, hostname, "ISO8859_1"); - copybytes (type1, hlen+32, ntdomain, "ISO8859_1"); - type1[20] = (byte) ((hlen+32) % 256); - type1[21] = (byte) ((hlen+32) / 256); - - byte[] msg = new byte [32 + hlen + dlen]; - System.arraycopy (type1, 0, msg, 0, 32 + hlen + dlen); + byte[] msg = client.type1(); String result = "NTLM " + (new B64Encoder()).encode (msg); return result; } - - /* Convert a 7 byte array to an 8 byte array (for a des key with parity) - * input starts at offset off - */ - private 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; - } - - private byte[] calcLMHash () throws GeneralSecurityException { - byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; - byte[] pwb = password.toUpperCase ().getBytes(); - byte[] pwb1 = new byte [14]; - int len = password.length(); - if (len > 14) - len = 14; - System.arraycopy (pwb, 0, pwb1, 0, len); /* Zero padded */ - - 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; - } - - private byte[] calcNTHash () throws GeneralSecurityException { - byte[] pw = null; - try { - pw = password.getBytes ("UnicodeLittleUnmarked"); - } catch (UnsupportedEncodingException e) { - assert false; - } - 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 [] - */ - private byte[] calcResponse (byte[] key, byte[] text) - throws GeneralSecurityException { - 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; - } - private String buildType3Msg (String challenge) throws GeneralSecurityException, IOException { /* First decode the type2 message to get the server nonce */ /* nonce is located at type2[24] for 8 bytes */ byte[] type2 = (new sun.misc.BASE64Decoder()).decodeBuffer (challenge); - byte[] nonce = new byte [8]; - System.arraycopy (type2, 24, nonce, 0, 8); - - int ulen = username.length()*2; - type3[36] = type3[38] = (byte) (ulen % 256); - type3[37] = type3[39] = (byte) (ulen / 256); - int dlen = ntdomain.length()*2; - type3[28] = type3[30] = (byte) (dlen % 256); - type3[29] = type3[31] = (byte) (dlen / 256); - int hlen = hostname.length()*2; - type3[44] = type3[46] = (byte) (hlen % 256); - type3[45] = type3[47] = (byte) (hlen / 256); - - int l = 64; - copybytes (type3, l, ntdomain, "UnicodeLittleUnmarked"); - type3[32] = (byte) (l % 256); - type3[33] = (byte) (l / 256); - l += dlen; - copybytes (type3, l, username, "UnicodeLittleUnmarked"); - type3[40] = (byte) (l % 256); - type3[41] = (byte) (l / 256); - l += ulen; - copybytes (type3, l, hostname, "UnicodeLittleUnmarked"); - type3[48] = (byte) (l % 256); - type3[49] = (byte) (l / 256); - l += hlen; - - byte[] lmhash = calcLMHash(); - byte[] lmresponse = calcResponse (lmhash, nonce); - byte[] nthash = calcNTHash(); - byte[] ntresponse = calcResponse (nthash, nonce); - System.arraycopy (lmresponse, 0, type3, l, 24); - type3[16] = (byte) (l % 256); - type3[17] = (byte) (l / 256); - l += 24; - System.arraycopy (ntresponse, 0, type3, l, 24); - type3[24] = (byte) (l % 256); - type3[25] = (byte) (l / 256); - l += 24; - type3[56] = (byte) (l % 256); - type3[57] = (byte) (l / 256); - - byte[] msg = new byte [l]; - System.arraycopy (type3, 0, msg, 0, l); + byte[] nonce = new byte[8]; + new java.util.Random().nextBytes(nonce); + byte[] msg = client.type3(type2, nonce); String result = "NTLM " + (new B64Encoder()).encode (msg); return result; } - } - class B64Encoder extends sun.misc.BASE64Encoder { /* to force it to to the entire encoding in one line */ protected int bytesPerLine () {
--- a/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -65,10 +65,9 @@ */ DevPollSelectorImpl(SelectorProvider sp) { super(sp); - int[] fdes = new int[2]; - IOUtil.initPipe(fdes, false); - fd0 = fdes[0]; - fd1 = fdes[1]; + long pipeFds = IOUtil.makePipe(false); + fd0 = (int) (pipeFds >>> 32); + fd1 = (int) pipeFds; pollWrapper = new DevPollArrayWrapper(); pollWrapper.initInterrupt(fd0, fd1); fdToKey = new HashMap<Integer,SelectionKeyImpl>(); @@ -147,7 +146,7 @@ selectedKeys = null; // Deregister channels - Iterator i = keys.iterator(); + Iterator<SelectionKey> i = keys.iterator(); while (i.hasNext()) { SelectionKeyImpl ski = (SelectionKeyImpl)i.next(); deregister(ski);
--- a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -62,10 +62,9 @@ */ EPollSelectorImpl(SelectorProvider sp) { super(sp); - int[] fdes = new int[2]; - IOUtil.initPipe(fdes, false); - fd0 = fdes[0]; - fd1 = fdes[1]; + long pipeFds = IOUtil.makePipe(false); + fd0 = (int) (pipeFds >>> 32); + fd1 = (int) pipeFds; pollWrapper = new EPollArrayWrapper(); pollWrapper.initInterrupt(fd0, fd1); fdToKey = new HashMap<Integer,SelectionKeyImpl>(); @@ -144,7 +143,7 @@ selectedKeys = null; // Deregister channels - Iterator i = keys.iterator(); + Iterator<SelectionKey> i = keys.iterator(); while (i.hasNext()) { SelectionKeyImpl ski = (SelectionKeyImpl)i.next(); deregister(ski);
--- a/src/solaris/classes/sun/nio/ch/InheritedChannel.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/nio/ch/InheritedChannel.java Tue Sep 07 15:53:32 2010 -0700 @@ -96,7 +96,7 @@ FileDescriptor fd) throws IOException { - super(sp, fd); + super(sp, fd, true); } protected void implCloseSelectableChannel() throws IOException {
--- a/src/solaris/classes/sun/nio/ch/PipeImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/nio/ch/PipeImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -39,13 +39,14 @@ private final SinkChannel sink; PipeImpl(SelectorProvider sp) { - int[] fdes = new int[2]; - IOUtil.initPipe(fdes, true); + long pipeFds = IOUtil.makePipe(true); + int readFd = (int) (pipeFds >>> 32); + int writeFd = (int) pipeFds; FileDescriptor sourcefd = new FileDescriptor(); - IOUtil.setfdVal(sourcefd, fdes[0]); + IOUtil.setfdVal(sourcefd, readFd); source = new SourceChannelImpl(sp, sourcefd); FileDescriptor sinkfd = new FileDescriptor(); - IOUtil.setfdVal(sinkfd, fdes[1]); + IOUtil.setfdVal(sinkfd, writeFd); sink = new SinkChannelImpl(sp, sinkfd); }
--- a/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java Tue Sep 07 15:53:32 2010 -0700 @@ -54,10 +54,9 @@ */ PollSelectorImpl(SelectorProvider sp) { super(sp, 1, 1); - int[] fdes = new int[2]; - IOUtil.initPipe(fdes, false); - fd0 = fdes[0]; - fd1 = fdes[1]; + long pipeFds = IOUtil.makePipe(false); + fd0 = (int) (pipeFds >>> 32); + fd1 = (int) pipeFds; pollWrapper = new PollArrayWrapper(INIT_CAP); pollWrapper.initInterrupt(fd0, fd1); channelArray = new SelectionKeyImpl[INIT_CAP];
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/native/sun/net/sdp/SdpSupport.c Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2009, 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. + */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <errno.h> + +#if defined(__solaris__) + #if !defined(PROTO_SDP) + #define PROTO_SDP 257 + #endif +#elif defined(__linux__) + #if !defined(AF_INET_SDP) + #define AF_INET_SDP 27 + #endif +#endif + +#include "jni.h" +#include "jni_util.h" +#include "net_util.h" + +#define RESTARTABLE(_cmd, _result) do { \ + do { \ + _result = _cmd; \ + } while((_result == -1) && (errno == EINTR)); \ +} while(0) + + +/** + * Creates a SDP socket. + */ +static int create(JNIEnv* env) +{ + int s; + +#if defined(__solaris__) + #ifdef AF_INET6 + int domain = ipv6_available() ? AF_INET6 : AF_INET; + #else + int domain = AF_INET; + #endif + s = socket(domain, SOCK_STREAM, PROTO_SDP); +#elif defined(__linux__) + /** + * IPv6 not supported by SDP on Linux + */ + if (ipv6_available()) { + JNU_ThrowIOException(env, "IPv6 not supported"); + return; + } + s = socket(AF_INET_SDP, SOCK_STREAM, 0); +#else + /* not supported on other platforms at this time */ + s = -1; + errno = EPROTONOSUPPORT; +#endif + + if (s < 0) + JNU_ThrowIOExceptionWithLastError(env, "socket"); + return s; +} + +/** + * Creates a SDP socket, returning file descriptor referencing the socket. + */ +JNIEXPORT jint JNICALL +Java_sun_net_sdp_SdpSupport_create0(JNIEnv *env, jclass cls) +{ + return create(env); +} + +/** + * Converts an existing file descriptor, that references an unbound TCP socket, + * to SDP. + */ +JNIEXPORT void JNICALL +Java_sun_net_sdp_SdpSupport_convert0(JNIEnv *env, jclass cls, int fd) +{ + int s = create(env); + if (s >= 0) { + socklen_t len; + int arg, res; + struct linger linger; + + /* copy socket options that are relevant to SDP */ + len = sizeof(arg); + if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, &len) == 0) + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, len); + len = sizeof(arg); + if (getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, &len) == 0) + setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, len); + len = sizeof(linger); + if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (void*)&linger, &len) == 0) + setsockopt(s, SOL_SOCKET, SO_LINGER, (char*)&linger, len); + + RESTARTABLE(dup2(s, fd), res); + if (res < 0) + JNU_ThrowIOExceptionWithLastError(env, "dup2"); + RESTARTABLE(close(s), res); + } +}
--- a/src/solaris/native/sun/net/spi/SdpProvider.c Tue Sep 07 15:17:43 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2009, 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. - */ - -#include <sys/types.h> -#include <sys/socket.h> - -#if defined(__solaris__) && !defined(PROTO_SDP) -#define PROTO_SDP 257 -#endif - -#include "jni.h" -#include "jni_util.h" -#include "net_util.h" - -#define RESTARTABLE(_cmd, _result) do { \ - do { \ - _result = _cmd; \ - } while((_result == -1) && (errno == EINTR)); \ -} while(0) - -JNIEXPORT void JNICALL -Java_sun_net_spi_SdpProvider_convert(JNIEnv *env, jclass cls, jint fd) -{ -#ifdef PROTO_SDP -#ifdef AF_INET6 - int domain = ipv6_available() ? AF_INET6 : AF_INET; -#else - int domain = AF_INET; -#endif - int s = socket(domain, SOCK_STREAM, PROTO_SDP); - if (s < 0) { - JNU_ThrowIOExceptionWithLastError(env, "socket"); - } else { - int arg, len, res; - struct linger linger; - - /* copy socket options that are relevant to SDP */ - len = sizeof(arg); - if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, &len) == 0) - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, len); - len = sizeof(arg); - if (getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, &len) == 0) - setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, len); - len = sizeof(linger); - if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (void*)&linger, &len) == 0) - setsockopt(s, SOL_SOCKET, SO_LINGER, (char*)&linger, len); - - RESTARTABLE(dup2(s, fd), res); - if (res < 0) - JNU_ThrowIOExceptionWithLastError(env, "dup2"); - RESTARTABLE(close(s), res); - } -#else - JNU_ThrowInternalError(env, "should not reach here"); -#endif -}
--- a/src/solaris/native/sun/nio/ch/IOUtil.c Tue Sep 07 15:17:43 2010 -0700 +++ b/src/solaris/native/sun/nio/ch/IOUtil.c Tue Sep 07 15:53:32 2010 -0700 @@ -67,12 +67,9 @@ configureBlocking(int fd, jboolean blocking) { int flags = fcntl(fd, F_GETFL); + int newflags = blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK); - if ((blocking == JNI_FALSE) && !(flags & O_NONBLOCK)) - return fcntl(fd, F_SETFL, flags | O_NONBLOCK); - else if ((blocking == JNI_TRUE) && (flags & O_NONBLOCK)) - return fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - return 0; + return (flags == newflags) ? 0 : fcntl(fd, F_SETFL, newflags); } JNIEXPORT void JNICALL @@ -83,27 +80,25 @@ JNU_ThrowIOExceptionWithLastError(env, "Configure blocking failed"); } -JNIEXPORT void JNICALL -Java_sun_nio_ch_IOUtil_initPipe(JNIEnv *env, jobject this, - jintArray intArray, jboolean block) +JNIEXPORT jlong JNICALL +Java_sun_nio_ch_IOUtil_makePipe(JNIEnv *env, jobject this, jboolean blocking) { int fd[2]; - jint *ptr = 0; if (pipe(fd) < 0) { JNU_ThrowIOExceptionWithLastError(env, "Pipe failed"); - return; + return 0; } - if (block == JNI_FALSE) { + if (blocking == JNI_FALSE) { if ((configureBlocking(fd[0], JNI_FALSE) < 0) || (configureBlocking(fd[1], JNI_FALSE) < 0)) { JNU_ThrowIOExceptionWithLastError(env, "Configure blocking failed"); + close(fd[0]); + close(fd[1]); + return 0; } } - ptr = (*env)->GetPrimitiveArrayCritical(env, intArray, 0); - ptr[0] = fd[0]; - ptr[1] = fd[1]; - (*env)->ReleasePrimitiveArrayCritical(env, intArray, ptr, 0); + return ((jlong) fd[0] << 32) | (jlong) fd[1]; } JNIEXPORT jboolean JNICALL @@ -131,21 +126,22 @@ { if (n > 0) /* Number of bytes written */ return n; - if (n < 0) { - if (errno == EAGAIN) - return IOS_UNAVAILABLE; - if (errno == EINTR) - return IOS_INTERRUPTED; - } - if (n == 0) { + else if (n == 0) { if (reading) { return IOS_EOF; /* EOF is -1 in javaland */ } else { return 0; } } - JNU_ThrowIOExceptionWithLastError(env, "Read/write failed"); - return IOS_THROWN; + else if (errno == EAGAIN) + return IOS_UNAVAILABLE; + else if (errno == EINTR) + return IOS_INTERRUPTED; + else { + const char *msg = reading ? "Read failed" : "Write failed"; + JNU_ThrowIOExceptionWithLastError(env, msg); + return IOS_THROWN; + } } /* Declared in nio_util.h for use elsewhere in NIO */ @@ -155,21 +151,22 @@ { if (n > 0) /* Number of bytes written */ return n; - if (n < 0) { - if (errno == EAGAIN) - return IOS_UNAVAILABLE; - if (errno == EINTR) - return IOS_INTERRUPTED; - } - if (n == 0) { + else if (n == 0) { if (reading) { return IOS_EOF; /* EOF is -1 in javaland */ } else { return 0; } } - JNU_ThrowIOExceptionWithLastError(env, "Read/write failed"); - return IOS_THROWN; + else if (errno == EAGAIN) + return IOS_UNAVAILABLE; + else if (errno == EINTR) + return IOS_INTERRUPTED; + else { + const char *msg = reading ? "Read failed" : "Write failed"; + JNU_ThrowIOExceptionWithLastError(env, msg); + return IOS_THROWN; + } } jint
--- a/src/windows/bin/java_md.c Tue Sep 07 15:17:43 2010 -0700 +++ b/src/windows/bin/java_md.c Tue Sep 07 15:53:32 2010 -0700 @@ -105,15 +105,15 @@ exit(1); } - /* Do this before we read jvm.cfg */ - EnsureJreInstallation(jrepath); - /* Find out where the JRE is that we will be using. */ if (!GetJREPath(jrepath, so_jrepath)) { JLI_ReportErrorMessage(JRE_ERROR1); exit(2); } + /* Do this before we read jvm.cfg and after jrepath is initialized */ + EnsureJreInstallation(jrepath); + /* Find the specified JVM type */ if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) { JLI_ReportErrorMessage(CFG_ERROR7); @@ -213,6 +213,7 @@ } /* Does our bundle directory exist ? */ JLI_Snprintf(tmpbuf, sizeof(tmpbuf), "%s\\lib\\bundles", jrepath); + JLI_TraceLauncher("EnsureJreInstallation: %s\n", tmpbuf); if (stat(tmpbuf, &s) != 0) { return; }
--- a/test/ProblemList.txt Tue Sep 07 15:17:43 2010 -0700 +++ b/test/ProblemList.txt Tue Sep 07 15:53:32 2010 -0700 @@ -201,9 +201,6 @@ # Windows X64, RuntimeException: MyThread expected to have RUNNABLE but got WAITING java/lang/Thread/ThreadStateTest.java generic-all -# Timeout on windows 64bit -java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all - ############################################################################ # jdk_management
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/oracle/net/Sanity.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,142 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.net.Sdp; + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.*; + +/** + * Exercise com.oracle.net.Sdp with each IP address plumbed to InfiniBand + * interfaces listed in a given file. + */ + +public class Sanity { + public static void main(String[] args) throws Exception { + // The file is a list of interfaces to test. + Scanner s = new Scanner(new File(args[0])); + try { + while (s.hasNextLine()) { + String link = s.nextLine(); + NetworkInterface ni = NetworkInterface.getByName(link); + if (ni != null) { + Enumeration<InetAddress> addrs = ni.getInetAddresses(); + while (addrs.hasMoreElements()) { + InetAddress addr = addrs.nextElement(); + System.out.format("Testing %s: %s\n", link, addr.getHostAddress()); + test(addr); + } + } + } + } finally { + s.close(); + } + } + + static void test(InetAddress addr) throws Exception { + // Test SocketChannel and ServerSocketChannel + ServerSocketChannel ssc = Sdp.openServerSocketChannel(); + try { + ssc.socket().bind(new InetSocketAddress(addr, 0)); + int port = ssc.socket().getLocalPort(); + + // SocketChannel.connect (implicit bind) + SocketChannel client = Sdp.openSocketChannel(); + try { + client.connect(new InetSocketAddress(addr, port)); + SocketChannel peer = ssc.accept(); + try { + testConnection(Channels.newOutputStream(client), + Channels.newInputStream(peer)); + } finally { + peer.close(); + } + } finally { + client.close(); + } + + // SocketChannel.connect (explicit bind) + client = Sdp.openSocketChannel(); + try { + client.socket().bind(new InetSocketAddress(addr, 0)); + client.connect(new InetSocketAddress(addr, port)); + ssc.accept().close(); + } finally { + client.close(); + } + } finally { + ssc.close(); + } + + // Test Socket and ServerSocket + ServerSocket ss = Sdp.openServerSocket(); + try { + ss.bind(new InetSocketAddress(addr, 0)); + int port = ss.getLocalPort(); + + // Socket.connect (implicit bind) + Socket s = Sdp.openSocket(); + try { + s.connect(new InetSocketAddress(addr, port)); + Socket peer = ss.accept(); + try { + testConnection(s.getOutputStream(), peer.getInputStream()); + } finally { + peer.close(); + } + } finally { + s.close(); + } + + // Socket.connect (explicit bind) + s = Sdp.openSocket(); + try { + s.bind(new InetSocketAddress(addr, 0)); + s.connect(new InetSocketAddress(addr, port)); + ss.accept().close(); + } finally { + s.close(); + } + } finally { + ss.close(); + } + } + + static void testConnection(OutputStream out, InputStream in) + throws IOException + { + byte[] msg = "hello".getBytes(); + out.write(msg); + + byte[] ba = new byte[100]; + int nread = 0; + while (nread < msg.length) { + int n = in.read(ba); + if (n < 0) + throw new IOException("EOF not expected!"); + nread += n; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/oracle/net/sanity.sh Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,66 @@ +# +# 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. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 6965072 +# @summary Unit test for SDP support +# @build Sanity +# @run shell sanity.sh + +IB_LINKS=ib.links + +OS=`uname -s` +case "$OS" in + SunOS ) + /usr/sbin/dladm show-part -o LINK -p > ${IB_LINKS} + if [ $? != 0 ]; then + echo "Unable to get InfiniBand parition link information" + exit 0 + fi + ;; + Linux ) + if [ ! -f /proc/net/sdp ]; then + echo "InfiniBand SDP module not installed" + exit 0 + fi + egrep "^[ \t]+ib" /proc/net/dev|cut -d':' -f1|tr -d '\t ' > ${IB_LINKS} + ;; + * ) + echo "This test only runs on Solaris or Linux" + exit 0 + ;; +esac + +if [ -z "$TESTJAVA" ]; then + JAVA=java + TESTCLASSES=. + TESTSRC=. +else + JAVA="${TESTJAVA}/bin/java" +fi + +CLASSPATH=${TESTCLASSES}:${TESTSRC} +export CLASSPATH + +# Run sanity test (IPv4-only for now) +$JAVA -Djava.net.preferIPv4Stack=true Sanity ${IB_LINKS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/security/sasl/ntlm/NTLMTest.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,416 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6911951 + * @summary NTLM should be a supported Java SASL mechanism + */ +import java.io.IOException; +import javax.security.sasl.*; +import javax.security.auth.callback.*; +import java.util.*; + +import com.sun.security.ntlm.NTLMException; + +public class NTLMTest { + + private static final String MECH = "NTLM"; + private static final String REALM = "REALM"; + private static final String PROTOCOL = "jmx"; + private static final byte[] EMPTY = new byte[0]; + + private static final String USER1 = "dummy"; + private static final char[] PASS1 = "bogus".toCharArray(); + private static final String USER2 = "foo"; + private static final char[] PASS2 = "bar".toCharArray(); + + private static final Map<String,char[]> maps = + new HashMap<String,char[]>(); + static { + maps.put(USER1, PASS1); + maps.put(USER2, PASS2); + } + + static char[] getPass(String d, String u) { + if (!d.equals(REALM)) return null; + return maps.get(u); + } + + public static void main(String[] args) throws Exception { + + checkAuthOnly(); + checkClientNameOverride(); + checkServerDomainOverride(); + checkClientDomainOverride(); + checkVersions(); + checkClientHostname(); + } + + static void checkVersions() throws Exception { + // Server accepts all version + checkVersion(null, null); + checkVersion("LM/NTLM", null); + checkVersion("LM", null); + checkVersion("NTLM", null); + checkVersion("NTLM2", null); + checkVersion("LMv2/NTLMv2", null); + checkVersion("LMv2", null); + checkVersion("NTLMv2", null); + + // Client's default version is LMv2 + checkVersion(null, "LMv2"); + + // Also works if they specified identical versions + checkVersion("LM/NTLM", "LM"); + checkVersion("LM", "LM"); + checkVersion("NTLM", "LM"); + checkVersion("NTLM2", "NTLM2"); + checkVersion("LMv2/NTLMv2", "LMv2"); + checkVersion("LMv2", "LMv2"); + checkVersion("NTLMv2", "LMv2"); + + // But should not work if different + try { + checkVersion("LM/NTLM", "LMv2"); + throw new Exception("Should not succeed"); + } catch (SaslException se) { + NTLMException ne = (NTLMException)se.getCause(); + if (ne.errorCode() != NTLMException.AUTH_FAILED) { + throw new Exception("Failed false"); + } + } + try { + checkVersion("LMv2/NTLMv2", "LM"); + throw new Exception("Should not succeed"); + } catch (SaslException se) { + NTLMException ne = (NTLMException)se.getCause(); + if (ne.errorCode() != NTLMException.AUTH_FAILED) { + throw new Exception("Failed false"); + } + } + + } + + /** + * A test on version matching + * @param vc ntlm version specified for client + * @param vs ntlm version specified for server + * @throws Exception + */ + private static void checkVersion(String vc, String vs) throws Exception { + Map<String,Object> pc = new HashMap<>(); + pc.put("com.sun.security.sasl.ntlm.version", vc); + Map<String,Object> ps = new HashMap<>(); + ps.put("com.sun.security.sasl.ntlm.version", vs); + SaslClient clnt = Sasl.createSaslClient( + new String[]{MECH}, USER1, PROTOCOL, null, pc, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + NameCallback ncb = (NameCallback)cb; + ncb.setName(ncb.getDefaultName()); + } else if (cb instanceof PasswordCallback) { + ((PasswordCallback)cb).setPassword(PASS1); + } + } + } + }); + + SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, REALM, ps, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + String domain = null, name = null; + PasswordCallback pcb = null; + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + name = ((NameCallback)cb).getDefaultName(); + } else if (cb instanceof RealmCallback) { + domain = ((RealmCallback)cb).getDefaultText(); + } else if (cb instanceof PasswordCallback) { + pcb = (PasswordCallback)cb; + } + } + if (pcb != null) { + pcb.setPassword(getPass(domain, name)); + } + } + }); + + handshake(clnt, srv); + } + + private static void checkClientHostname() throws Exception { + Map<String,Object> pc = new HashMap<>(); + pc.put("com.sun.security.sasl.ntlm.hostname", "this.is.com"); + SaslClient clnt = Sasl.createSaslClient( + new String[]{MECH}, USER1, PROTOCOL, null, pc, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + NameCallback ncb = (NameCallback)cb; + ncb.setName(ncb.getDefaultName()); + } else if (cb instanceof PasswordCallback) { + ((PasswordCallback)cb).setPassword(PASS1); + } + } + } + }); + + SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, REALM, null, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + String domain = null, name = null; + PasswordCallback pcb = null; + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + name = ((NameCallback)cb).getDefaultName(); + } else if (cb instanceof RealmCallback) { + domain = ((RealmCallback)cb).getDefaultText(); + } else if (cb instanceof PasswordCallback) { + pcb = (PasswordCallback)cb; + } + } + if (pcb != null) { + pcb.setPassword(getPass(domain, name)); + } + } + }); + + handshake(clnt, srv); + if (!"this.is.com".equals( + srv.getNegotiatedProperty("com.sun.security.sasl.ntlm.hostname"))) { + throw new Exception("Hostname not trasmitted to server"); + } + } + + /** + * Client realm override, but finally overridden by server response + */ + private static void checkClientDomainOverride() throws Exception { + SaslClient clnt = Sasl.createSaslClient( + new String[]{MECH}, USER1, PROTOCOL, "ANOTHERREALM", null, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + NameCallback ncb = (NameCallback)cb; + ncb.setName(ncb.getDefaultName()); + } else if(cb instanceof RealmCallback) { + RealmCallback dcb = (RealmCallback)cb; + dcb.setText("THIRDDOMAIN"); + } else if (cb instanceof PasswordCallback) { + ((PasswordCallback)cb).setPassword(PASS1); + } + } + } + }); + + SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, REALM, null, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + String domain = null, name = null; + PasswordCallback pcb = null; + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + name = ((NameCallback)cb).getDefaultName(); + } else if (cb instanceof RealmCallback) { + domain = ((RealmCallback)cb).getDefaultText(); + } else if (cb instanceof PasswordCallback) { + pcb = (PasswordCallback)cb; + } + } + if (pcb != null) { + pcb.setPassword(getPass(domain, name)); + } + } + }); + + handshake(clnt, srv); + } + + /** + * Client side user name provided in callback. + * @throws Exception + */ + private static void checkClientNameOverride() throws Exception { + SaslClient clnt = Sasl.createSaslClient( + new String[]{MECH}, null, PROTOCOL, null, null, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + NameCallback ncb = (NameCallback)cb; + ncb.setName(USER1); + } else if (cb instanceof PasswordCallback) { + ((PasswordCallback)cb).setPassword(PASS1); + } + } + } + }); + + SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, REALM, null, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + String domain = null, name = null; + PasswordCallback pcb = null; + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + name = ((NameCallback)cb).getDefaultName(); + } else if (cb instanceof RealmCallback) { + domain = ((RealmCallback)cb).getDefaultText(); + } else if (cb instanceof PasswordCallback) { + pcb = (PasswordCallback)cb; + } + } + if (pcb != null) { + pcb.setPassword(getPass(domain, name)); + } + } + }); + + handshake(clnt, srv); + } + + /** + * server side domain provided in props. + * @throws Exception + */ + private static void checkServerDomainOverride() throws Exception { + SaslClient clnt = Sasl.createSaslClient( + new String[]{MECH}, USER1, PROTOCOL, null, null, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + NameCallback ncb = (NameCallback)cb; + ncb.setName(ncb.getDefaultName()); + } else if (cb instanceof PasswordCallback) { + ((PasswordCallback)cb).setPassword(PASS1); + } + } + } + }); + + Map<String,Object> ps = new HashMap<>(); + ps.put("com.sun.security.sasl.ntlm.domain", REALM); + SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, null, ps, + new CallbackHandler() { + public void handle(Callback[] callbacks) + throws IOException, UnsupportedCallbackException { + String domain = null, name = null; + PasswordCallback pcb = null; + for (Callback cb: callbacks) { + if (cb instanceof NameCallback) { + name = ((NameCallback)cb).getDefaultName(); + } else if (cb instanceof RealmCallback) { + domain = ((RealmCallback)cb).getDefaultText(); + } else if (cb instanceof PasswordCallback) { + pcb = (PasswordCallback)cb; + } + } + if (pcb != null) { + pcb.setPassword(getPass(domain, name)); + } + } + }); + + handshake(clnt, srv); + } + + private static void checkAuthOnly() throws Exception { + Map<String,Object> props = new HashMap<>(); + props.put(Sasl.QOP, "auth-conf"); + try { + Sasl.createSaslClient( + new String[]{MECH}, USER2, PROTOCOL, REALM, props, null); + throw new Exception("NTLM should not support auth-conf"); + } catch (SaslException se) { + // Normal + } + } + + private static void handshake(SaslClient clnt, SaslServer srv) + throws Exception { + if (clnt == null) { + throw new IllegalStateException( + "Unable to find client impl for " + MECH); + } + if (srv == null) { + throw new IllegalStateException( + "Unable to find server impl for " + MECH); + } + + byte[] response = (clnt.hasInitialResponse() + ? clnt.evaluateChallenge(EMPTY) : EMPTY); + System.out.println("Initial:"); + new sun.misc.HexDumpEncoder().encodeBuffer(response, System.out); + byte[] challenge; + + while (!clnt.isComplete() || !srv.isComplete()) { + challenge = srv.evaluateResponse(response); + response = null; + if (challenge != null) { + System.out.println("Challenge:"); + new sun.misc.HexDumpEncoder().encodeBuffer(challenge, System.out); + response = clnt.evaluateChallenge(challenge); + } + if (response != null) { + System.out.println("Response:"); + new sun.misc.HexDumpEncoder().encodeBuffer(response, System.out); + } + } + + if (clnt.isComplete() && srv.isComplete()) { + System.out.println("SUCCESS"); + if (!srv.getAuthorizationID().equals(USER1)) { + throw new Exception("Not correct user"); + } + } else { + throw new IllegalStateException( + "FAILURE: mismatched state:" + + " client complete? " + clnt.isComplete() + + " server complete? " + srv.isComplete()); + } + + if (!clnt.getNegotiatedProperty(Sasl.QOP).equals("auth") || + !srv.getNegotiatedProperty(Sasl.QOP).equals("auth") || + !clnt.getNegotiatedProperty( + "com.sun.security.sasl.ntlm.domain").equals(REALM)) { + throw new Exception("Negotiated property error"); + } + clnt.dispose(); + srv.dispose(); + } +}
--- a/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh Tue Sep 07 15:17:43 2010 -0700 +++ b/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh Tue Sep 07 15:53:32 2010 -0700 @@ -25,7 +25,7 @@ # @summary (cl) ClassLoader.loadClass locks all instances in chain # when delegating # -# @run shell/timeout=10 TestCrossDelegate.sh +# @run shell/timeout=300 TestCrossDelegate.sh # if running by hand on windows, change TESTSRC and TESTCLASSES to "." if [ "${TESTSRC}" = "" ] ; then @@ -41,10 +41,6 @@ echo "FAILED!!!" exit 1 fi -echo TESTSRC=${TESTSRC} -echo TESTCLASSES=${TESTCLASSES} -echo TESTJAVA=${TESTJAVA} -echo "" # set platform-specific variables OS=`uname -s` @@ -55,11 +51,20 @@ Linux ) FS="/" ;; - Windows* | CYGWIN* ) + Windows*) FS="\\" ;; + CYGWIN* ) + FS="\\" + TESTCLASSES=`/usr/bin/cygpath -a -s -m ${TESTCLASSES}` + ;; esac +echo TESTSRC=${TESTSRC} +echo TESTCLASSES=${TESTCLASSES} +echo TESTJAVA=${TESTJAVA} +echo "" + # compile test ${TESTJAVA}${FS}bin${FS}javac \ -d ${TESTCLASSES} \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/ProcessBuilder/SecurityManagerClinit.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,79 @@ +/* + * Copyright 2010 Google Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6980747 + * @summary Check that Process-related classes have the proper + * doPrivileged blocks, and can be initialized with an adversarial + * security manager. + * @run main/othervm SecurityManagerClinit + * @author Martin Buchholz + */ + +import java.io.*; +import java.security.*; + +public class SecurityManagerClinit { + private static class Policy extends java.security.Policy { + private Permissions perms; + + public Policy(Permission... permissions) { + perms = new Permissions(); + for (Permission permission : permissions) + perms.add(permission); + } + + public boolean implies(ProtectionDomain pd, Permission p) { + return perms.implies(p); + } + } + + public static void main(String[] args) throws Throwable { + String javaExe = + System.getProperty("java.home") + + File.separator + "bin" + File.separator + "java"; + + // A funky contrived security setup, just for bug repro purposes. + java.security.Security.setProperty("package.access", "java.util"); + + final Policy policy = + new Policy + (new FilePermission("<<ALL FILES>>", "execute"), + new RuntimePermission("setSecurityManager")); + Policy.setPolicy(policy); + + System.setSecurityManager(new SecurityManager()); + + try { + String[] cmd = { javaExe, "-version" }; + Process p = Runtime.getRuntime().exec(cmd); + p.getOutputStream().close(); + p.getInputStream().close(); + p.getErrorStream().close(); + p.waitFor(); + } finally { + System.setSecurityManager(null); + } + } +}
--- a/test/sun/net/sdp/ProbeIB.java Tue Sep 07 15:17:43 2010 -0700 +++ b/test/sun/net/sdp/ProbeIB.java Tue Sep 07 15:53:32 2010 -0700 @@ -34,21 +34,16 @@ public class ProbeIB { public static void main(String[] args) throws IOException { - Scanner s = new Scanner(new File("/etc/path_to_inst")); + Scanner s = new Scanner(new File(args[0])); try { while (s.hasNextLine()) { - String line = s.nextLine(); - if (line.startsWith("#")) - continue; - String[] fields = line.split("\\s+"); - if (!fields[2].equals("\"ibd\"")) - continue; - String name = fields[2].substring(1, fields[2].length()-1) + fields[1]; - NetworkInterface ni = NetworkInterface.getByName(name); + String link = s.nextLine(); + NetworkInterface ni = NetworkInterface.getByName(link); if (ni != null) { Enumeration<InetAddress> addrs = ni.getInetAddresses(); while (addrs.hasMoreElements()) { - System.out.println(addrs.nextElement().getHostAddress()); + InetAddress addr = addrs.nextElement(); + System.out.println(addr.getHostAddress()); } } }
--- a/test/sun/net/sdp/sanity.sh Tue Sep 07 15:17:43 2010 -0700 +++ b/test/sun/net/sdp/sanity.sh Tue Sep 07 15:53:32 2010 -0700 @@ -33,14 +33,15 @@ echo "This is a Solaris-only test" exit 0 fi -SDPADM=/usr/sbin/sdpadm -if [ ! -f ${SDPADM} ]; then - echo "SDP not available" - exit 0 -fi -${SDPADM} status|grep Enabled -if [ $? != 0 ]; then - echo "SDP not enabled" + +IB_LINKS=ib.links +IB_ADDRS=ib.addrs + +# Display IB partition link information +# (requires Solaris 11, will fail on Solaris 10) +/usr/sbin/dladm show-part -o LINK -p > ${IB_LINKS} +if [ $? != 0 ]; then + echo "Unable to get IB parition link information" exit 0 fi @@ -56,13 +57,13 @@ export CLASSPATH # Probe for IP addresses plumbed to IB interfaces -$JAVA -Djava.net.preferIPv4Stack=true ProbeIB > ib_addrs +$JAVA -Djava.net.preferIPv4Stack=true ProbeIB ${IB_LINKS} > ${IB_ADDRS} # Create sdp.conf SDPCONF=sdp.conf rm ${SDPCONF} touch ${SDPCONF} -cat ib_addrs | while read ADDR +cat ${IB_ADDRS} | while read ADDR do echo "bind ${ADDR} *" > ${SDPCONF} echo "connect ${ADDR} *" >> ${SDPCONF}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/launcher/MiscTests.java Tue Sep 07 15:53:32 2010 -0700 @@ -0,0 +1,90 @@ +/* + * 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6856415 6981001 + * @summary Miscellaneous tests, Exceptions, EnsureJRE etc. + * @compile -XDignore.symbol.file MiscTests.java TestHelper.java + * @run main MiscTests + */ + + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.HashMap; +import java.util.Map; + + +public class MiscTests { + + // 6856415: Checks to ensure that proper exceptions are thrown by java + static void test6856415() { + // No pkcs library on win-x64, so we bail out. + if (TestHelper.is64Bit && TestHelper.isWindows) { + return; + } + StringBuilder sb = new StringBuilder(); + sb.append("public static void main(String... args) {\n"); + sb.append("java.security.Provider p = new sun.security.pkcs11.SunPKCS11(args[0]);\n"); + sb.append("java.security.Security.insertProviderAt(p, 1);\n"); + sb.append("}"); + File testJar = new File("Foo.jar"); + testJar.delete(); + try { + TestHelper.createJar(testJar, sb.toString()); + } catch (FileNotFoundException fnfe) { + throw new RuntimeException(fnfe); + } + TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd, + "-Djava.security.manager", "-jar", testJar.getName(), "foo.bak"); + for (String s : tr.testOutput) { + System.out.println(s); + } + if (!tr.contains("java.security.AccessControlException:" + + " access denied (\"java.lang.RuntimePermission\"" + + " \"accessClassInPackage.sun.security.pkcs11\")")) { + System.out.println(tr.status); + } + } + // 6981001 : Check EnsureJreInstallation is ok, note we cannot + // thoroughly test this function, we simply do our best. + static void test6981001() { + if (TestHelper.is64Bit || !TestHelper.isWindows) { + return; + } + Map<String, String> env = new HashMap<String, String>(); + env.put("_JAVA_LAUNCHER_DEBUG", "true"); + TestHelper.TestResult tr = TestHelper.doExec(env, TestHelper.javaCmd); + if (!tr.contains(TestHelper.JAVAHOME + "\\lib\\bundles")) { + System.out.println(tr.status); + } + } + public static void main(String... args) { + test6856415(); + test6981001(); + if (TestHelper.testExitValue != 0) { + throw new Error(TestHelper.testExitValue + " tests failed"); + } +} +}
--- a/test/tools/launcher/VerifyExceptions.java Tue Sep 07 15:17:43 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6856415 - * @summary Checks to ensure that proper exceptions are thrown by java - * @compile -XDignore.symbol.file VerifyExceptions.java TestHelper.java - * @run main VerifyExceptions - */ - - -import java.io.File; -import java.io.FileNotFoundException; - - -public class VerifyExceptions { - - static void test6856415() { - // No pkcs library on win-x64, so we bail out. - if (TestHelper.is64Bit && TestHelper.isWindows) { - return; - } - StringBuilder sb = new StringBuilder(); - sb.append("public static void main(String... args) {\n"); - sb.append("java.security.Provider p = new sun.security.pkcs11.SunPKCS11(args[0]);\n"); - sb.append("java.security.Security.insertProviderAt(p, 1);\n"); - sb.append("}"); - File testJar = new File("Foo.jar"); - testJar.delete(); - try { - TestHelper.createJar(testJar, sb.toString()); - } catch (FileNotFoundException fnfe) { - throw new RuntimeException(fnfe); - } - TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javacCmd, - "-Djava.security.manager", "-jar", testJar.getName(), "foo.bak"); - tr.checkNegative(); - tr.contains("Exception in thread \"main\" java.security.AccessControlException: access denied (\"java.lang.RuntimePermission\" \"accessClassInPackage.sun.security.pkcs11\")\")"); - } - - public static void main(String... args) { - test6856415(); - } -}