1.1 --- a/make/com/sun/org/apache/xml/Makefile Thu Oct 13 10:35:43 2011 -0700
1.2 +++ b/make/com/sun/org/apache/xml/Makefile Mon Oct 17 19:06:53 2011 -0700
1.3 @@ -30,6 +30,8 @@
1.4 BUILDDIR = ../../../../..
1.5 PACKAGE = com.sun.org.apache.xml
1.6 PRODUCT = xml
1.7 +JAVAC_MAX_WARNINGS = true
1.8 +JAVAC_WARNINGS_FATAL = true
1.9 include $(BUILDDIR)/common/Defs.gmk
1.10
1.11 #
2.1 --- a/make/common/Defs-linux.gmk Thu Oct 13 10:35:43 2011 -0700
2.2 +++ b/make/common/Defs-linux.gmk Mon Oct 17 19:06:53 2011 -0700
2.3 @@ -373,6 +373,7 @@
2.4 override LIBPOSIX4 =
2.5 override LIBSOCKET =
2.6 override LIBNSL =
2.7 +override LIBSCF =
2.8 override LIBTHREAD =
2.9 override MOOT_PRIORITIES = true
2.10 override NO_INTERRUPTIBLE_IO = true
3.1 --- a/make/common/Defs-solaris.gmk Thu Oct 13 10:35:43 2011 -0700
3.2 +++ b/make/common/Defs-solaris.gmk Mon Oct 17 19:06:53 2011 -0700
3.3 @@ -711,6 +711,9 @@
3.4 # Network Services library
3.5 LIBNSL = -lnsl
3.6
3.7 +# service configuration facility library
3.8 +LIBSCF = -lscf
3.9 +
3.10 # GLOBAL_KPIC: If set means all libraries are PIC, position independent code
3.11 # EXCEPT for select compiles
3.12 # If a .o file is compiled non-PIC then it should be forced
4.1 --- a/make/java/java/Makefile Thu Oct 13 10:35:43 2011 -0700
4.2 +++ b/make/java/java/Makefile Mon Oct 17 19:06:53 2011 -0700
4.3 @@ -208,7 +208,7 @@
4.4 -libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \
4.5 shell32.lib delayimp.lib /DELAYLOAD:shell32.dll
4.6 else
4.7 -OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
4.8 +OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) $(LIBSCF) -ldl \
4.9 -L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
4.10 endif
4.11
5.1 --- a/make/java/security/Makefile Thu Oct 13 10:35:43 2011 -0700
5.2 +++ b/make/java/security/Makefile Mon Oct 17 19:06:53 2011 -0700
5.3 @@ -26,8 +26,8 @@
5.4 BUILDDIR = ../..
5.5 PACKAGE = java.security
5.6 PRODUCT = sun
5.7 -JAVAC_MAX_WARNINGS = false
5.8 -JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
5.9 +JAVAC_MAX_WARNINGS = true
5.10 +JAVAC_LINT_OPTIONS = -Xlint:all
5.11 JAVAC_WARNINGS_FATAL = true
5.12 include $(BUILDDIR)/common/Defs.gmk
5.13
6.1 --- a/make/javax/Makefile Thu Oct 13 10:35:43 2011 -0700
6.2 +++ b/make/javax/Makefile Mon Oct 17 19:06:53 2011 -0700
6.3 @@ -30,7 +30,7 @@
6.4 BUILDDIR = ..
6.5 include $(BUILDDIR)/common/Defs.gmk
6.6
6.7 -SUBDIRS = others
6.8 +SUBDIRS = others security
6.9
6.10 SUBDIRS_management = management
6.11
7.1 --- a/make/javax/others/Makefile Thu Oct 13 10:35:43 2011 -0700
7.2 +++ b/make/javax/others/Makefile Mon Oct 17 19:06:53 2011 -0700
7.3 @@ -38,10 +38,6 @@
7.4 com/sun/naming/internal \
7.5 javax/net \
7.6 javax/script \
7.7 - javax/security/auth \
7.8 - javax/security/cert \
7.9 - javax/security/sasl \
7.10 - javax/smartcardio \
7.11 javax/tools \
7.12 javax/xml
7.13
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/make/javax/security/Makefile Mon Oct 17 19:06:53 2011 -0700
8.3 @@ -0,0 +1,49 @@
8.4 +#
8.5 +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
8.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8.7 +#
8.8 +# This code is free software; you can redistribute it and/or modify it
8.9 +# under the terms of the GNU General Public License version 2 only, as
8.10 +# published by the Free Software Foundation. Oracle designates this
8.11 +# particular file as subject to the "Classpath" exception as provided
8.12 +# by Oracle in the LICENSE file that accompanied this code.
8.13 +#
8.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
8.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8.17 +# version 2 for more details (a copy is included in the LICENSE file that
8.18 +# accompanied this code).
8.19 +#
8.20 +# You should have received a copy of the GNU General Public License version
8.21 +# 2 along with this work; if not, write to the Free Software Foundation,
8.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8.23 +#
8.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8.25 +# or visit www.oracle.com if you need additional information or have any
8.26 +# questions.
8.27 +#
8.28 +
8.29 +#
8.30 +# Makefile for building javax (security classes)
8.31 +#
8.32 +
8.33 +BUILDDIR = ../..
8.34 +JAVAC_MAX_WARNINGS = true
8.35 +JAVAC_WARNINGS_FATAL = true
8.36 +
8.37 +include $(BUILDDIR)/common/Defs.gmk
8.38 +
8.39 +#
8.40 +# Files to compile
8.41 +#
8.42 +AUTO_FILES_JAVA_DIRS = \
8.43 + javax/security/auth \
8.44 + javax/security/cert \
8.45 + javax/security/sasl \
8.46 + javax/smartcardio
8.47 +
8.48 +#
8.49 +# Rules
8.50 +#
8.51 +include $(BUILDDIR)/common/Classes.gmk
8.52 +
9.1 --- a/make/org/ietf/jgss/Makefile Thu Oct 13 10:35:43 2011 -0700
9.2 +++ b/make/org/ietf/jgss/Makefile Mon Oct 17 19:06:53 2011 -0700
9.3 @@ -26,6 +26,8 @@
9.4 BUILDDIR = ../../..
9.5 PACKAGE = org.ietf.jgss
9.6 PRODUCT = sun
9.7 +JAVAC_MAX_WARNINGS = true
9.8 +JAVAC_WARNINGS_FATAL = true
9.9 include $(BUILDDIR)/common/Defs.gmk
9.10
9.11 #
10.1 --- a/make/sun/security/other/Makefile Thu Oct 13 10:35:43 2011 -0700
10.2 +++ b/make/sun/security/other/Makefile Mon Oct 17 19:06:53 2011 -0700
10.3 @@ -26,7 +26,7 @@
10.4 BUILDDIR = ../../..
10.5 PACKAGE = sun.security.other
10.6 PRODUCT = sun
10.7 -JAVAC_MAX_WARNINGS=false
10.8 +JAVAC_MAX_WARNINGS=true
10.9 JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
10.10 JAVAC_WARNINGS_FATAL=true
10.11 include $(BUILDDIR)/common/Defs.gmk
11.1 --- a/src/share/classes/com/sun/jndi/ldap/Connection.java Thu Oct 13 10:35:43 2011 -0700
11.2 +++ b/src/share/classes/com/sun/jndi/ldap/Connection.java Mon Oct 17 19:06:53 2011 -0700
11.3 @@ -32,6 +32,7 @@
11.4 import java.io.OutputStream;
11.5 import java.io.InputStream;
11.6 import java.net.Socket;
11.7 +import javax.net.ssl.SSLSocket;
11.8
11.9 import javax.naming.CommunicationException;
11.10 import javax.naming.ServiceUnavailableException;
11.11 @@ -361,6 +362,19 @@
11.12 }
11.13 }
11.14
11.15 + // For LDAP connect timeouts on LDAP over SSL connections must treat
11.16 + // the SSL handshake following socket connection as part of the timeout.
11.17 + // So explicitly set a socket read timeout, trigger the SSL handshake,
11.18 + // then reset the timeout.
11.19 + if (connectTimeout > 0 && socket instanceof SSLSocket) {
11.20 + SSLSocket sslSocket = (SSLSocket) socket;
11.21 + int socketTimeout = sslSocket.getSoTimeout();
11.22 +
11.23 + sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
11.24 + sslSocket.startHandshake();
11.25 + sslSocket.setSoTimeout(socketTimeout);
11.26 + }
11.27 +
11.28 return socket;
11.29 }
11.30
12.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java Thu Oct 13 10:35:43 2011 -0700
12.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java Mon Oct 17 19:06:53 2011 -0700
12.3 @@ -115,9 +115,9 @@
12.4 // provider mechanism instead if implementing their own
12.5 // transform or canonicalization algorithms.
12.6 // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
12.7 - InputStream is = (InputStream) AccessController.doPrivileged(
12.8 - new PrivilegedAction() {
12.9 - public Object run() {
12.10 + InputStream is = AccessController.doPrivileged(
12.11 + new PrivilegedAction<InputStream>() {
12.12 + public InputStream run() {
12.13 // String cfile = System.getProperty
12.14 // ("com.sun.org.apache.xml.internal.security.resource.config");
12.15 return getClass().getResourceAsStream
13.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java Thu Oct 13 10:35:43 2011 -0700
13.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java Mon Oct 17 19:06:53 2011 -0700
13.3 @@ -45,9 +45,9 @@
13.4
13.5
13.6
13.7 - private static Map uriToJCEName;
13.8 + private static Map<String, String> uriToJCEName;
13.9
13.10 - private static Map algorithmsMap;
13.11 + private static Map<String, Algorithm> algorithmsMap;
13.12
13.13 private static String providerName = null;
13.14 /**
13.15 @@ -63,8 +63,8 @@
13.16
13.17 static void loadAlgorithms( Element algorithmsEl) {
13.18 Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
13.19 - uriToJCEName = new HashMap( algorithms.length * 2);
13.20 - algorithmsMap = new HashMap( algorithms.length * 2);
13.21 + uriToJCEName = new HashMap<String, String>( algorithms.length * 2);
13.22 + algorithmsMap = new HashMap<String, Algorithm>( algorithms.length * 2);
13.23 for (int i = 0 ;i < algorithms.length ;i ++) {
13.24 Element el = algorithms[i];
13.25 String id = el.getAttribute("URI");
13.26 @@ -76,7 +76,7 @@
13.27 }
13.28
13.29 static Algorithm getAlgorithmMapping(String algoURI) {
13.30 - return ((Algorithm)algorithmsMap.get(algoURI));
13.31 + return algorithmsMap.get(algoURI);
13.32 }
13.33
13.34 /**
13.35 @@ -90,7 +90,7 @@
13.36 if (log.isLoggable(java.util.logging.Level.FINE))
13.37 log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
13.38
13.39 - String jceName = (String) uriToJCEName.get(AlgorithmURI);
13.40 + String jceName = uriToJCEName.get(AlgorithmURI);
13.41 return jceName;
13.42 }
13.43
13.44 @@ -106,7 +106,7 @@
13.45 if (log.isLoggable(java.util.logging.Level.FINE))
13.46 log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
13.47
13.48 - return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass;
13.49 + return (algorithmsMap.get(AlgorithmURI)).algorithmClass;
13.50 }
13.51
13.52 /**
13.53 @@ -116,7 +116,7 @@
13.54 * @return The length of the key used in the alogrithm
13.55 */
13.56 public static int getKeyLengthFromURI(String AlgorithmURI) {
13.57 - return Integer.parseInt(((Algorithm) algorithmsMap.get(AlgorithmURI)).keyLength);
13.58 + return Integer.parseInt((algorithmsMap.get(AlgorithmURI)).keyLength);
13.59 }
13.60
13.61 /**
13.62 @@ -128,7 +128,7 @@
13.63 */
13.64 public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) {
13.65
13.66 - return ((Algorithm) algorithmsMap.get(AlgorithmURI)).requiredKey;
13.67 + return (algorithmsMap.get(AlgorithmURI)).requiredKey;
13.68
13.69 }
13.70
14.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java Thu Oct 13 10:35:43 2011 -0700
14.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java Mon Oct 17 19:06:53 2011 -0700
14.3 @@ -71,9 +71,10 @@
14.4 this.algorithm = messageDigest;
14.5 }
14.6
14.7 - static ThreadLocal instances=new ThreadLocal() {
14.8 - protected Object initialValue() {
14.9 - return new HashMap();
14.10 + static ThreadLocal<Map<String, MessageDigest>> instances=new
14.11 + ThreadLocal<Map<String, MessageDigest>>() {
14.12 + protected Map<String, MessageDigest> initialValue() {
14.13 + return new HashMap<String, MessageDigest>();
14.14 };
14.15 };
14.16
14.17 @@ -92,7 +93,7 @@
14.18 }
14.19
14.20 private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
14.21 - MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI);
14.22 + MessageDigest result= instances.get().get(algorithmURI);
14.23 if (result!=null)
14.24 return result;
14.25 String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
14.26 @@ -121,7 +122,7 @@
14.27
14.28 throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
14.29 }
14.30 - ((Map)instances.get()).put(algorithmURI, md);
14.31 + instances.get().put(algorithmURI, md);
14.32 return md;
14.33 }
14.34
15.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java Thu Oct 13 10:35:43 2011 -0700
15.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java Mon Oct 17 19:06:53 2011 -0700
15.3 @@ -51,28 +51,28 @@
15.4 static boolean _alreadyInitialized = false;
15.5
15.6 /** All available algorithm classes are registered here */
15.7 - static HashMap _algorithmHash = null;
15.8 + static Map<String, Class<? extends SignatureAlgorithmSpi>> _algorithmHash = null;
15.9
15.10 - static ThreadLocal instancesSigning=new ThreadLocal() {
15.11 - protected Object initialValue() {
15.12 - return new HashMap();
15.13 + static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesSigning=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() {
15.14 + protected Map<String, SignatureAlgorithmSpi> initialValue() {
15.15 + return new HashMap<String, SignatureAlgorithmSpi>();
15.16 };
15.17 };
15.18
15.19 - static ThreadLocal instancesVerify=new ThreadLocal() {
15.20 - protected Object initialValue() {
15.21 - return new HashMap();
15.22 + static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesVerify=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() {
15.23 + protected Map<String, SignatureAlgorithmSpi> initialValue() {
15.24 + return new HashMap<String, SignatureAlgorithmSpi>();
15.25 };
15.26 };
15.27
15.28 - static ThreadLocal keysSigning=new ThreadLocal() {
15.29 - protected Object initialValue() {
15.30 - return new HashMap();
15.31 + static ThreadLocal<Map<String, Key>> keysSigning=new ThreadLocal<Map<String, Key>>() {
15.32 + protected Map<String, Key> initialValue() {
15.33 + return new HashMap<String, Key>();
15.34 };
15.35 };
15.36 - static ThreadLocal keysVerify=new ThreadLocal() {
15.37 - protected Object initialValue() {
15.38 - return new HashMap();
15.39 + static ThreadLocal<Map<String, Key>> keysVerify=new ThreadLocal<Map<String, Key>>() {
15.40 + protected Map<String, Key> initialValue() {
15.41 + return new HashMap<String, Key>();
15.42 };
15.43 };
15.44 // boolean isForSigning=false;
15.45 @@ -105,34 +105,34 @@
15.46 .engineGetContextFromElement(this._constructionElement);
15.47 }
15.48 private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException {
15.49 - SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI);
15.50 + SignatureAlgorithmSpi result= instancesSigning.get().get(algorithmURI);
15.51 if (result!=null) {
15.52 result.reset();
15.53 return result;
15.54 }
15.55 result=buildSigner(algorithmURI, result);
15.56 - ((Map)instancesSigning.get()).put(algorithmURI,result);
15.57 + instancesSigning.get().put(algorithmURI,result);
15.58 return result;
15.59 }
15.60 private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException {
15.61 - SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI);
15.62 + SignatureAlgorithmSpi result= instancesVerify.get().get(algorithmURI);
15.63 if (result!=null) {
15.64 result.reset();
15.65 return result;
15.66 }
15.67 result=buildSigner(algorithmURI, result);
15.68 - ((Map)instancesVerify.get()).put(algorithmURI,result);
15.69 + instancesVerify.get().put(algorithmURI,result);
15.70 return result;
15.71 }
15.72
15.73 private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException {
15.74 try {
15.75 - Class implementingClass =
15.76 + Class<? extends SignatureAlgorithmSpi> implementingClass =
15.77 SignatureAlgorithm.getImplementingClass(algorithmURI);
15.78 if (log.isLoggable(java.util.logging.Level.FINE))
15.79 log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
15.80 + implementingClass + "\"");
15.81 - result=(SignatureAlgorithmSpi) implementingClass.newInstance();
15.82 + result= implementingClass.newInstance();
15.83 return result;
15.84 } catch (IllegalAccessException ex) {
15.85 Object exArgs[] = { algorithmURI, ex.getMessage() };
15.86 @@ -270,7 +270,7 @@
15.87 */
15.88 public void initSign(Key signingKey) throws XMLSignatureException {
15.89 initializeAlgorithm(true);
15.90 - Map map=(Map)keysSigning.get();
15.91 + Map<String, Key> map=keysSigning.get();
15.92 if (map.get(this.algorithmURI)==signingKey) {
15.93 return;
15.94 }
15.95 @@ -329,7 +329,7 @@
15.96 */
15.97 public void initVerify(Key verificationKey) throws XMLSignatureException {
15.98 initializeAlgorithm(false);
15.99 - Map map=(Map)keysVerify.get();
15.100 + Map<String, Key> map=keysVerify.get();
15.101 if (map.get(this.algorithmURI)==verificationKey) {
15.102 return;
15.103 }
15.104 @@ -375,7 +375,7 @@
15.105 log.log(java.util.logging.Level.FINE, "Init() called");
15.106
15.107 if (!SignatureAlgorithm._alreadyInitialized) {
15.108 - SignatureAlgorithm._algorithmHash = new HashMap(10);
15.109 + SignatureAlgorithm._algorithmHash = new HashMap<String, Class<? extends SignatureAlgorithmSpi>>(10);
15.110 SignatureAlgorithm._alreadyInitialized = true;
15.111 }
15.112 }
15.113 @@ -388,6 +388,7 @@
15.114 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
15.115 * @throws XMLSignatureException
15.116 */
15.117 + @SuppressWarnings("unchecked")
15.118 public static void register(String algorithmURI, String implementingClass)
15.119 throws AlgorithmAlreadyRegisteredException,XMLSignatureException {
15.120
15.121 @@ -396,7 +397,7 @@
15.122 log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
15.123
15.124 // are we already registered?
15.125 - Class registeredClassClass =
15.126 + Class<? extends SignatureAlgorithmSpi> registeredClassClass =
15.127 SignatureAlgorithm.getImplementingClass(algorithmURI);
15.128 if (registeredClassClass!=null) {
15.129 String registeredClass = registeredClassClass.getName();
15.130 @@ -409,7 +410,7 @@
15.131 }
15.132 }
15.133 try {
15.134 - SignatureAlgorithm._algorithmHash.put(algorithmURI, Class.forName(implementingClass));
15.135 + SignatureAlgorithm._algorithmHash.put(algorithmURI, (Class <? extends SignatureAlgorithmSpi>)Class.forName(implementingClass));
15.136 } catch (ClassNotFoundException ex) {
15.137 Object exArgs[] = { algorithmURI, ex.getMessage() };
15.138
15.139 @@ -431,13 +432,13 @@
15.140 * @param URI
15.141 * @return the class that implements the URI
15.142 */
15.143 - private static Class getImplementingClass(String URI) {
15.144 + private static Class<? extends SignatureAlgorithmSpi> getImplementingClass(String URI) {
15.145
15.146 if (SignatureAlgorithm._algorithmHash == null) {
15.147 return null;
15.148 }
15.149
15.150 - return (Class) SignatureAlgorithm._algorithmHash.get(URI);
15.151 + return SignatureAlgorithm._algorithmHash.get(URI);
15.152 }
15.153
15.154 /**
16.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java Thu Oct 13 10:35:43 2011 -0700
16.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java Mon Oct 17 19:06:53 2011 -0700
16.3 @@ -28,6 +28,7 @@
16.4
16.5 import javax.xml.parsers.DocumentBuilder;
16.6 import javax.xml.parsers.DocumentBuilderFactory;
16.7 +import javax.xml.xpath.XPath;
16.8
16.9 import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
16.10 import org.w3c.dom.Document;
16.11 @@ -83,7 +84,7 @@
16.12 ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
16.13
16.14 static boolean _alreadyInitialized = false;
16.15 - static Map _canonicalizerHash = null;
16.16 + static Map<String,Class<? extends CanonicalizerSpi>> _canonicalizerHash = null;
16.17
16.18 protected CanonicalizerSpi canonicalizerSpi = null;
16.19
16.20 @@ -94,7 +95,7 @@
16.21 public static void init() {
16.22
16.23 if (!Canonicalizer._alreadyInitialized) {
16.24 - Canonicalizer._canonicalizerHash = new HashMap(10);
16.25 + Canonicalizer._canonicalizerHash = new HashMap<String, Class<? extends CanonicalizerSpi>>(10);
16.26 Canonicalizer._alreadyInitialized = true;
16.27 }
16.28 }
16.29 @@ -109,10 +110,11 @@
16.30 throws InvalidCanonicalizerException {
16.31
16.32 try {
16.33 - Class implementingClass = getImplementingClass(algorithmURI);
16.34 + Class<? extends CanonicalizerSpi> implementingClass =
16.35 + getImplementingClass(algorithmURI);
16.36
16.37 this.canonicalizerSpi =
16.38 - (CanonicalizerSpi) implementingClass.newInstance();
16.39 + implementingClass.newInstance();
16.40 this.canonicalizerSpi.reset=true;
16.41 } catch (Exception e) {
16.42 Object exArgs[] = { algorithmURI };
16.43 @@ -144,11 +146,12 @@
16.44 * @param implementingClass
16.45 * @throws AlgorithmAlreadyRegisteredException
16.46 */
16.47 + @SuppressWarnings("unchecked")
16.48 public static void register(String algorithmURI, String implementingClass)
16.49 throws AlgorithmAlreadyRegisteredException {
16.50
16.51 // check whether URI is already registered
16.52 - Class registeredClass = getImplementingClass(algorithmURI);
16.53 + Class<? extends CanonicalizerSpi> registeredClass = getImplementingClass(algorithmURI);
16.54
16.55 if (registeredClass != null) {
16.56 Object exArgs[] = { algorithmURI, registeredClass };
16.57 @@ -158,7 +161,7 @@
16.58 }
16.59
16.60 try {
16.61 - _canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
16.62 + _canonicalizerHash.put(algorithmURI, (Class<? extends CanonicalizerSpi>) Class.forName(implementingClass));
16.63 } catch (ClassNotFoundException e) {
16.64 throw new RuntimeException("c14n class not found");
16.65 }
16.66 @@ -304,7 +307,7 @@
16.67 * @return the result of the c14n.
16.68 * @throws CanonicalizationException
16.69 */
16.70 - public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
16.71 + public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
16.72 throws CanonicalizationException {
16.73 return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
16.74 }
16.75 @@ -317,7 +320,7 @@
16.76 * @return the result of the c14n.
16.77 * @throws CanonicalizationException
16.78 */
16.79 - public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet,
16.80 + public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
16.81 String inclusiveNamespaces) throws CanonicalizationException {
16.82 return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
16.83 inclusiveNamespaces);
16.84 @@ -347,8 +350,8 @@
16.85 * @param URI
16.86 * @return the name of the class that implements the given URI
16.87 */
16.88 - private static Class getImplementingClass(String URI) {
16.89 - return (Class) _canonicalizerHash.get(URI);
16.90 + private static Class<? extends CanonicalizerSpi> getImplementingClass(String URI) {
16.91 + return _canonicalizerHash.get(URI);
16.92 }
16.93
16.94 /**
17.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java Thu Oct 13 10:35:43 2011 -0700
17.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java Mon Oct 17 19:06:53 2011 -0700
17.3 @@ -28,6 +28,7 @@
17.4
17.5 import javax.xml.parsers.DocumentBuilder;
17.6 import javax.xml.parsers.DocumentBuilderFactory;
17.7 +import javax.xml.xpath.XPath;
17.8
17.9 import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
17.10 import org.w3c.dom.Document;
17.11 @@ -151,7 +152,7 @@
17.12 * @return the c14n bytes
17.13 * @throws CanonicalizationException
17.14 */
17.15 - public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
17.16 + public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
17.17 throws CanonicalizationException;
17.18
17.19 /**
17.20 @@ -162,7 +163,7 @@
17.21 * @return the c14n bytes
17.22 * @throws CanonicalizationException
17.23 */
17.24 - public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
17.25 + public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
17.26 throws CanonicalizationException;
17.27
17.28 /**
18.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java Thu Oct 13 10:35:43 2011 -0700
18.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java Mon Oct 17 19:06:53 2011 -0700
18.3 @@ -41,7 +41,7 @@
18.4 *
18.5 * @author Christian Geuer-Pollmann
18.6 */
18.7 -public class AttrCompare implements Comparator, Serializable {
18.8 +public class AttrCompare implements Comparator<Attr>, Serializable {
18.9
18.10 private final static long serialVersionUID = -7113259629930576230L;
18.11 private final static int ATTR0_BEFORE_ATTR1 = -1;
18.12 @@ -62,16 +62,14 @@
18.13 * key (an empty namespace URI is lexicographically least).
18.14 * </UL>
18.15 *
18.16 - * @param obj0 casted Attr
18.17 - * @param obj1 casted Attr
18.18 + * @param attr0
18.19 + * @param attr1
18.20 * @return returns a negative integer, zero, or a positive integer as
18.21 * obj0 is less than, equal to, or greater than obj1
18.22 *
18.23 */
18.24 - public int compare(Object obj0, Object obj1) {
18.25 + public int compare(Attr attr0, Attr attr1) {
18.26
18.27 - Attr attr0 = (Attr) obj0;
18.28 - Attr attr1 = (Attr) obj1;
18.29 String namespaceURI0 = attr0.getNamespaceURI();
18.30 String namespaceURI1 = attr1.getNamespaceURI();
18.31
19.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java Thu Oct 13 10:35:43 2011 -0700
19.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java Mon Oct 17 19:06:53 2011 -0700
19.3 @@ -25,6 +25,7 @@
19.4 import java.net.URISyntaxException;
19.5 import java.util.ArrayList;
19.6 import java.util.Collection;
19.7 +import java.util.Comparator;
19.8 import java.util.HashMap;
19.9 import java.util.Iterator;
19.10 import java.util.List;
19.11 @@ -33,6 +34,7 @@
19.12 import java.util.SortedSet;
19.13 import java.util.TreeSet;
19.14 import javax.xml.parsers.ParserConfigurationException;
19.15 +import javax.xml.xpath.XPath;
19.16 import org.w3c.dom.Attr;
19.17 import org.w3c.dom.Document;
19.18 import org.w3c.dom.Element;
19.19 @@ -59,7 +61,7 @@
19.20 */
19.21 public abstract class Canonicalizer11 extends CanonicalizerBase {
19.22 boolean firstCall = true;
19.23 - final SortedSet result = new TreeSet(COMPARE);
19.24 + final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
19.25 static final String XMLNS_URI = Constants.NamespaceSpecNS;
19.26 static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
19.27
19.28 @@ -72,9 +74,9 @@
19.29 static class XmlsStackElement {
19.30 int level;
19.31 boolean rendered = false;
19.32 - List nodes = new ArrayList();
19.33 + List<Attr> nodes = new ArrayList<Attr>();
19.34 };
19.35 - List levels = new ArrayList();
19.36 + List<XmlsStackElement> levels = new ArrayList<XmlsStackElement>();
19.37 void push(int level) {
19.38 currentLevel = level;
19.39 if (currentLevel == -1)
19.40 @@ -86,7 +88,7 @@
19.41 lastlevel = 0;
19.42 return;
19.43 }
19.44 - lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
19.45 + lastlevel=(levels.get(levels.size()-1)).level;
19.46 }
19.47 }
19.48 void addXmlnsAttr(Attr n) {
19.49 @@ -98,7 +100,7 @@
19.50 }
19.51 cur.nodes.add(n);
19.52 }
19.53 - void getXmlnsAttr(Collection col) {
19.54 + void getXmlnsAttr(Collection<Attr> col) {
19.55 if (cur == null) {
19.56 cur = new XmlsStackElement();
19.57 cur.level = currentLevel;
19.58 @@ -111,7 +113,7 @@
19.59 if (size == -1) {
19.60 parentRendered = true;
19.61 } else {
19.62 - e = (XmlsStackElement) levels.get(size);
19.63 + e = levels.get(size);
19.64 if (e.rendered && e.level+1 == currentLevel)
19.65 parentRendered = true;
19.66 }
19.67 @@ -121,17 +123,17 @@
19.68 return;
19.69 }
19.70
19.71 - Map loa = new HashMap();
19.72 - List baseAttrs = new ArrayList();
19.73 + Map<String, Attr> loa = new HashMap<String, Attr>();
19.74 + List<Attr> baseAttrs = new ArrayList<Attr>();
19.75 boolean successiveOmitted = true;
19.76 for (;size>=0;size--) {
19.77 - e = (XmlsStackElement) levels.get(size);
19.78 + e = levels.get(size);
19.79 if (e.rendered) {
19.80 successiveOmitted = false;
19.81 }
19.82 - Iterator it = e.nodes.iterator();
19.83 + Iterator<Attr> it = e.nodes.iterator();
19.84 while (it.hasNext() && successiveOmitted) {
19.85 - Attr n = (Attr) it.next();
19.86 + Attr n = it.next();
19.87 if (n.getLocalName().equals("base")) {
19.88 if (!e.rendered) {
19.89 baseAttrs.add(n);
19.90 @@ -141,11 +143,11 @@
19.91 }
19.92 }
19.93 if (!baseAttrs.isEmpty()) {
19.94 - Iterator it = cur.nodes.iterator();
19.95 + Iterator<Attr> it = cur.nodes.iterator();
19.96 String base = null;
19.97 Attr baseAttr = null;
19.98 while (it.hasNext()) {
19.99 - Attr n = (Attr) it.next();
19.100 + Attr n = it.next();
19.101 if (n.getLocalName().equals("base")) {
19.102 base = n.getValue();
19.103 baseAttr = n;
19.104 @@ -154,7 +156,7 @@
19.105 }
19.106 it = baseAttrs.iterator();
19.107 while (it.hasNext()) {
19.108 - Attr n = (Attr) it.next();
19.109 + Attr n = it.next();
19.110 if (base == null) {
19.111 base = n.getValue();
19.112 baseAttr = n;
19.113 @@ -202,13 +204,13 @@
19.114 * @return the Attr[]s to be outputted
19.115 * @throws CanonicalizationException
19.116 */
19.117 - Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
19.118 + Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
19.119 throws CanonicalizationException {
19.120 if (!E.hasAttributes() && !firstCall) {
19.121 return null;
19.122 }
19.123 // result will contain the attrs which have to be outputted
19.124 - final SortedSet result = this.result;
19.125 + final SortedSet<Attr> result = this.result;
19.126 result.clear();
19.127 NamedNodeMap attrs = E.getAttributes();
19.128 int attrsLength = attrs.getLength();
19.129 @@ -236,7 +238,7 @@
19.130
19.131 if (n != null) {
19.132 // Render the ns definition
19.133 - result.add(n);
19.134 + result.add((Attr)n);
19.135 if (C14nHelper.namespaceIsRelative(N)) {
19.136 Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
19.137 throw new CanonicalizationException(
19.138 @@ -251,13 +253,15 @@
19.139 // to the output.
19.140 ns.getUnrenderedNodes(result);
19.141 // output the attributes in the xml namespace.
19.142 - xmlattrStack.getXmlnsAttr(result);
19.143 + xmlattrStack.getXmlnsAttr(getSortedSetAsCollection(result));
19.144 firstCall = false;
19.145 }
19.146
19.147 return result.iterator();
19.148 }
19.149
19.150 +
19.151 +
19.152 /**
19.153 * Returns the Attr[]s to be outputted for the given element.
19.154 * <br>
19.155 @@ -271,7 +275,7 @@
19.156 * @return the Attr[]s to be outputted
19.157 * @throws CanonicalizationException
19.158 */
19.159 - Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
19.160 + Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns)
19.161 throws CanonicalizationException {
19.162 // result will contain the attrs which have to be output
19.163 xmlattrStack.push(ns.getLevel());
19.164 @@ -283,11 +287,11 @@
19.165 attrsLength = attrs.getLength();
19.166 }
19.167
19.168 - SortedSet result = this.result;
19.169 + SortedSet<Attr> result = this.result;
19.170 result.clear();
19.171
19.172 for (int i = 0; i < attrsLength; i++) {
19.173 - Attr N = (Attr) attrs.item(i);
19.174 + Attr N = (Attr)attrs.item(i);
19.175 String NUri = N.getNamespaceURI();
19.176
19.177 if (XMLNS_URI != NUri) {
19.178 @@ -332,7 +336,7 @@
19.179 // (NName, NValue, N, isRealVisible);
19.180 Node n = ns.addMappingAndRender(NName, NValue, N);
19.181 if (n != null) {
19.182 - result.add(n);
19.183 + result.add((Attr)n);
19.184 if (C14nHelper.namespaceIsRelative(N)) {
19.185 Object exArgs[] =
19.186 { E.getTagName(), NName, N.getNodeValue() };
19.187 @@ -362,7 +366,7 @@
19.188 }
19.189 // output the xmlns def if needed.
19.190 if (n != null) {
19.191 - result.add(n);
19.192 + result.add((Attr)n);
19.193 }
19.194 // Float all xml:* attributes of the unselected parent elements to
19.195 // this one. addXmlAttributes(E,result);
19.196 @@ -381,7 +385,7 @@
19.197 * @return none it always fails
19.198 * @throws CanonicalizationException always
19.199 */
19.200 - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
19.201 + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
19.202 String inclusiveNamespaces) throws CanonicalizationException {
19.203 throw new CanonicalizationException(
19.204 "c14n.Canonicalizer.UnsupportedOperation");
20.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java Thu Oct 13 10:35:43 2011 -0700
20.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java Mon Oct 17 19:06:53 2011 -0700
20.3 @@ -57,7 +57,7 @@
20.4 */
20.5 public abstract class Canonicalizer20010315 extends CanonicalizerBase {
20.6 boolean firstCall=true;
20.7 - final SortedSet result= new TreeSet(COMPARE);
20.8 + final SortedSet<Attr> result= new TreeSet<Attr>(COMPARE);
20.9 static final String XMLNS_URI=Constants.NamespaceSpecNS;
20.10 static final String XML_LANG_URI=Constants.XML_LANG_SPACE_SpecNS;
20.11 static class XmlAttrStack {
20.12 @@ -67,9 +67,9 @@
20.13 static class XmlsStackElement {
20.14 int level;
20.15 boolean rendered=false;
20.16 - List nodes=new ArrayList();
20.17 + List<Attr> nodes=new ArrayList<Attr>();
20.18 };
20.19 - List levels=new ArrayList();
20.20 + List<XmlsStackElement> levels=new ArrayList<XmlsStackElement>();
20.21 void push(int level) {
20.22 currentLevel=level;
20.23 if (currentLevel==-1)
20.24 @@ -81,7 +81,7 @@
20.25 lastlevel=0;
20.26 return;
20.27 }
20.28 - lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
20.29 + lastlevel=(levels.get(levels.size()-1)).level;
20.30 }
20.31 }
20.32 void addXmlnsAttr(Attr n) {
20.33 @@ -93,7 +93,7 @@
20.34 }
20.35 cur.nodes.add(n);
20.36 }
20.37 - void getXmlnsAttr(Collection col) {
20.38 + void getXmlnsAttr(Collection<Attr> col) {
20.39 int size=levels.size()-1;
20.40 if (cur==null) {
20.41 cur=new XmlsStackElement();
20.42 @@ -106,7 +106,7 @@
20.43 if (size==-1) {
20.44 parentRendered=true;
20.45 } else {
20.46 - e=(XmlsStackElement)levels.get(size);
20.47 + e=levels.get(size);
20.48 if (e.rendered && e.level+1==currentLevel)
20.49 parentRendered=true;
20.50
20.51 @@ -117,12 +117,12 @@
20.52 return;
20.53 }
20.54
20.55 - Map loa = new HashMap();
20.56 + Map<String,Attr> loa = new HashMap<String,Attr>();
20.57 for (;size>=0;size--) {
20.58 - e=(XmlsStackElement)levels.get(size);
20.59 - Iterator it=e.nodes.iterator();
20.60 + e=levels.get(size);
20.61 + Iterator<Attr> it=e.nodes.iterator();
20.62 while (it.hasNext()) {
20.63 - Attr n=(Attr)it.next();
20.64 + Attr n=it.next();
20.65 if (!loa.containsKey(n.getName()))
20.66 loa.put(n.getName(),n);
20.67 }
20.68 @@ -161,13 +161,13 @@
20.69 * @return the Attr[]s to be outputted
20.70 * @throws CanonicalizationException
20.71 */
20.72 - Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns )
20.73 + Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns )
20.74 throws CanonicalizationException {
20.75 if (!E.hasAttributes() && !firstCall) {
20.76 return null;
20.77 }
20.78 // result will contain the attrs which have to be outputted
20.79 - final SortedSet result = this.result;
20.80 + final SortedSet<Attr> result = this.result;
20.81 result.clear();
20.82 NamedNodeMap attrs = E.getAttributes();
20.83 int attrsLength = attrs.getLength();
20.84 @@ -194,7 +194,7 @@
20.85
20.86 if (n!=null) {
20.87 //Render the ns definition
20.88 - result.add(n);
20.89 + result.add((Attr)n);
20.90 if (C14nHelper.namespaceIsRelative(N)) {
20.91 Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
20.92 throw new CanonicalizationException(
20.93 @@ -206,7 +206,7 @@
20.94 if (firstCall) {
20.95 //It is the first node of the subtree
20.96 //Obtain all the namespaces defined in the parents, and added to the output.
20.97 - ns.getUnrenderedNodes(result);
20.98 + ns.getUnrenderedNodes(getSortedSetAsCollection(result));
20.99 //output the attributes in the xml namespace.
20.100 xmlattrStack.getXmlnsAttr(result);
20.101 firstCall=false;
20.102 @@ -227,7 +227,7 @@
20.103 * @return the Attr[]s to be outputted
20.104 * @throws CanonicalizationException
20.105 */
20.106 - Iterator handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException {
20.107 + Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException {
20.108 // result will contain the attrs which have to be outputted
20.109 xmlattrStack.push(ns.getLevel());
20.110 boolean isRealVisible=isVisibleDO(E,ns.getLevel())==1;
20.111 @@ -239,7 +239,7 @@
20.112 }
20.113
20.114
20.115 - SortedSet result = this.result;
20.116 + SortedSet<Attr> result = this.result;
20.117 result.clear();
20.118
20.119 for (int i = 0; i < attrsLength; i++) {
20.120 @@ -277,7 +277,7 @@
20.121 //Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
20.122 Node n=ns.addMappingAndRender(NName,NValue,N);
20.123 if (n!=null) {
20.124 - result.add(n);
20.125 + result.add((Attr)n);
20.126 if (C14nHelper.namespaceIsRelative(N)) {
20.127 Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
20.128 throw new CanonicalizationException(
20.129 @@ -306,12 +306,12 @@
20.130 }
20.131 //output the xmlns def if needed.
20.132 if (n!=null) {
20.133 - result.add(n);
20.134 + result.add((Attr)n);
20.135 }
20.136 //Float all xml:* attributes of the unselected parent elements to this one.
20.137 //addXmlAttributes(E,result);
20.138 xmlattrStack.getXmlnsAttr(result);
20.139 - ns.getUnrenderedNodes(result);
20.140 + ns.getUnrenderedNodes(getSortedSetAsCollection(result));
20.141
20.142 }
20.143
20.144 @@ -325,7 +325,7 @@
20.145 * @return none it always fails
20.146 * @throws CanonicalizationException always
20.147 */
20.148 - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
20.149 + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
20.150 throws CanonicalizationException {
20.151
20.152 /** $todo$ well, should we throw UnsupportedOperationException ? */
21.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java Thu Oct 13 10:35:43 2011 -0700
21.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java Mon Oct 17 19:06:53 2011 -0700
21.3 @@ -61,9 +61,9 @@
21.4 * This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
21.5 * the inclusive namespaces.
21.6 */
21.7 - TreeSet _inclusiveNSSet = new TreeSet();
21.8 + TreeSet<String> _inclusiveNSSet = new TreeSet<String>();
21.9 static final String XMLNS_URI=Constants.NamespaceSpecNS;
21.10 - final SortedSet result = new TreeSet(COMPARE);
21.11 + final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
21.12 /**
21.13 * Constructor Canonicalizer20010315Excl
21.14 *
21.15 @@ -106,8 +106,7 @@
21.16 */
21.17 public byte[] engineCanonicalizeSubTree(Node rootNode,
21.18 String inclusiveNamespaces,Node excl) throws CanonicalizationException {
21.19 - this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
21.20 - .prefixStr2Set(inclusiveNamespaces);
21.21 + this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
21.22 return super.engineCanonicalizeSubTree(rootNode,excl);
21.23 }
21.24 /**
21.25 @@ -117,10 +116,10 @@
21.26 * @return the rootNode c14n.
21.27 * @throws CanonicalizationException
21.28 */
21.29 + @SuppressWarnings("unchecked")
21.30 public byte[] engineCanonicalize(XMLSignatureInput rootNode,
21.31 String inclusiveNamespaces) throws CanonicalizationException {
21.32 - this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
21.33 - .prefixStr2Set(inclusiveNamespaces);
21.34 + this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
21.35 return super.engineCanonicalize(rootNode);
21.36 }
21.37
21.38 @@ -130,12 +129,12 @@
21.39 * @param E
21.40 * @throws CanonicalizationException
21.41 */
21.42 - Iterator handleAttributesSubtree(Element E,NameSpaceSymbTable ns)
21.43 + Iterator<Attr> handleAttributesSubtree(Element E,NameSpaceSymbTable ns)
21.44 throws CanonicalizationException {
21.45 // System.out.println("During the traversal, I encountered " +
21.46 // XMLUtils.getXPath(E));
21.47 // result will contain the attrs which have to be outputted
21.48 - SortedSet result = this.result;
21.49 + SortedSet<Attr> result = this.result;
21.50 result.clear();
21.51 NamedNodeMap attrs=null;
21.52
21.53 @@ -145,7 +144,7 @@
21.54 attrsLength = attrs.getLength();
21.55 }
21.56 //The prefix visibly utilized(in the attribute or in the name) in the element
21.57 - SortedSet visiblyUtilized =(SortedSet) _inclusiveNSSet.clone();
21.58 + SortedSet<String> visiblyUtilized = getNSSetClone();
21.59
21.60 for (int i = 0; i < attrsLength; i++) {
21.61 Attr N = (Attr) attrs.item(i);
21.62 @@ -187,9 +186,9 @@
21.63 visiblyUtilized.add(prefix);
21.64
21.65 //This can be optimezed by I don't have time
21.66 - Iterator it=visiblyUtilized.iterator();
21.67 + Iterator<String> it=visiblyUtilized.iterator();
21.68 while (it.hasNext()) {
21.69 - String s=(String)it.next();
21.70 + String s=it.next();
21.71 Attr key=ns.getMapping(s);
21.72 if (key==null) {
21.73 continue;
21.74 @@ -207,25 +206,35 @@
21.75 * @param inclusiveNamespaces
21.76 * @throws CanonicalizationException
21.77 */
21.78 - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
21.79 + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
21.80 String inclusiveNamespaces) throws CanonicalizationException {
21.81
21.82 -
21.83 - this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
21.84 - .prefixStr2Set(inclusiveNamespaces);
21.85 + this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
21.86 return super.engineCanonicalizeXPathNodeSet(xpathNodeSet);
21.87
21.88 }
21.89
21.90 + @SuppressWarnings("unchecked")
21.91 + private TreeSet<String> getInclusiveNameSpace(String inclusiveNameSpaces) {
21.92 + return (TreeSet<String>)InclusiveNamespaces.prefixStr2Set(inclusiveNameSpaces);
21.93 + }
21.94 +
21.95 +
21.96 + @SuppressWarnings("unchecked")
21.97 + private SortedSet<String> getNSSetClone() {
21.98 + return (SortedSet<String>) this._inclusiveNSSet.clone();
21.99 + }
21.100 +
21.101 +
21.102 /**
21.103 * @inheritDoc
21.104 * @param E
21.105 * @throws CanonicalizationException
21.106 */
21.107 - final Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
21.108 + final Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns)
21.109 throws CanonicalizationException {
21.110 // result will contain the attrs which have to be outputted
21.111 - SortedSet result = this.result;
21.112 + SortedSet<Attr> result = this.result;
21.113 result.clear();
21.114 NamedNodeMap attrs = null;
21.115 int attrsLength = 0;
21.116 @@ -234,11 +243,11 @@
21.117 attrsLength = attrs.getLength();
21.118 }
21.119 //The prefix visibly utilized(in the attribute or in the name) in the element
21.120 - Set visiblyUtilized =null;
21.121 + Set<String> visiblyUtilized =null;
21.122 //It's the output selected.
21.123 boolean isOutputElement=isVisibleDO(E,ns.getLevel())==1;
21.124 if (isOutputElement) {
21.125 - visiblyUtilized = (Set) this._inclusiveNSSet.clone();
21.126 + visiblyUtilized = getNSSetClone();
21.127 }
21.128
21.129 for (int i = 0; i < attrsLength; i++) {
21.130 @@ -272,7 +281,7 @@
21.131 if (!isOutputElement && isVisible(N) && _inclusiveNSSet.contains(NName) && !ns.removeMappingIfRender(NName)) {
21.132 Node n=ns.addMappingAndRender(NName,NNodeValue,N);
21.133 if (n!=null) {
21.134 - result.add(n);
21.135 + result.add((Attr)n);
21.136 if (C14nHelper.namespaceIsRelative(N)) {
21.137 Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
21.138 throw new CanonicalizationException(
21.139 @@ -315,9 +324,9 @@
21.140 }
21.141 //This can be optimezed by I don't have time
21.142 //visiblyUtilized.addAll(this._inclusiveNSSet);
21.143 - Iterator it=visiblyUtilized.iterator();
21.144 + Iterator<String> it=visiblyUtilized.iterator();
21.145 while (it.hasNext()) {
21.146 - String s=(String)it.next();
21.147 + String s=it.next();
21.148 Attr key=ns.getMapping(s);
21.149 if (key==null) {
21.150 continue;
22.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java Thu Oct 13 10:35:43 2011 -0700
22.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java Mon Oct 17 19:06:53 2011 -0700
22.3 @@ -33,9 +33,12 @@
22.4 import java.util.ListIterator;
22.5 import java.util.Map;
22.6 import java.util.Set;
22.7 +import java.util.SortedSet;
22.8 +import java.util.Collection;
22.9
22.10 import javax.xml.parsers.DocumentBuilderFactory;
22.11 import javax.xml.parsers.ParserConfigurationException;
22.12 +import javax.xml.xpath.XPath;
22.13
22.14 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
22.15 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizerSpi;
22.16 @@ -94,10 +97,10 @@
22.17 }
22.18 }
22.19
22.20 - List nodeFilter;
22.21 + List<NodeFilter> nodeFilter;
22.22
22.23 boolean _includeComments;
22.24 - Set _xpathNodeSet = null;
22.25 + Set<Node> _xpathNodeSet = null;
22.26 /**
22.27 * The node to be skiped/excluded from the DOM tree
22.28 * in subtree canonicalizations.
22.29 @@ -130,7 +133,7 @@
22.30 * @param xpathNodeSet
22.31 * @throws CanonicalizationException
22.32 */
22.33 - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
22.34 + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
22.35 throws CanonicalizationException {
22.36 this._xpathNodeSet = xpathNodeSet;
22.37 return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
22.38 @@ -251,7 +254,7 @@
22.39 final OutputStream writer=this._writer;
22.40 final Node excludeNode=this._excludeNode;
22.41 final boolean includeComments=this._includeComments;
22.42 - Map cache=new HashMap();
22.43 + Map<String, byte[]> cache=new HashMap<String, byte[]>();
22.44 do {
22.45 switch (currentNode.getNodeType()) {
22.46
22.47 @@ -298,11 +301,11 @@
22.48 String name=currentElement.getTagName();
22.49 UtfHelpper.writeByte(name,writer,cache);
22.50
22.51 - Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
22.52 + Iterator<Attr> attrs = this.handleAttributesSubtree(currentElement,ns);
22.53 if (attrs!=null) {
22.54 //we output all Attrs which are available
22.55 while (attrs.hasNext()) {
22.56 - Attr attr = (Attr) attrs.next();
22.57 + Attr attr = attrs.next();
22.58 outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
22.59 }
22.60 }
22.61 @@ -394,7 +397,7 @@
22.62 Node parentNode=null;
22.63 OutputStream writer=this._writer;
22.64 int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
22.65 - Map cache=new HashMap();
22.66 + Map<String, byte[]> cache=new HashMap<String,byte[]>();
22.67 do {
22.68 switch (currentNode.getNodeType()) {
22.69
22.70 @@ -464,11 +467,11 @@
22.71 ns.push();
22.72 }
22.73
22.74 - Iterator attrs = handleAttributes(currentElement,ns);
22.75 + Iterator<Attr> attrs = handleAttributes(currentElement,ns);
22.76 if (attrs!=null) {
22.77 //we output all Attrs which are available
22.78 while (attrs.hasNext()) {
22.79 - Attr attr = (Attr) attrs.next();
22.80 + Attr attr = attrs.next();
22.81 outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
22.82 }
22.83 }
22.84 @@ -522,9 +525,9 @@
22.85 }
22.86 int isVisibleDO(Node currentNode,int level) {
22.87 if (nodeFilter!=null) {
22.88 - Iterator it=nodeFilter.iterator();
22.89 + Iterator<NodeFilter> it=nodeFilter.iterator();
22.90 while (it.hasNext()) {
22.91 - int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
22.92 + int i=(it.next()).isNodeIncludeDO(currentNode,level);
22.93 if (i!=1)
22.94 return i;
22.95 }
22.96 @@ -535,9 +538,9 @@
22.97 }
22.98 int isVisibleInt(Node currentNode) {
22.99 if (nodeFilter!=null) {
22.100 - Iterator it=nodeFilter.iterator();
22.101 + Iterator<NodeFilter> it=nodeFilter.iterator();
22.102 while (it.hasNext()) {
22.103 - int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
22.104 + int i=(it.next()).isNodeInclude(currentNode);
22.105 if (i!=1)
22.106 return i;
22.107 }
22.108 @@ -549,9 +552,9 @@
22.109
22.110 boolean isVisible(Node currentNode) {
22.111 if (nodeFilter!=null) {
22.112 - Iterator it=nodeFilter.iterator();
22.113 + Iterator<NodeFilter> it=nodeFilter.iterator();
22.114 while (it.hasNext()) {
22.115 - if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
22.116 + if ((it.next()).isNodeInclude(currentNode)!=1)
22.117 return false;
22.118 }
22.119 }
22.120 @@ -589,7 +592,7 @@
22.121 * @param ns
22.122 */
22.123 final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
22.124 - List parents=new ArrayList(10);
22.125 + List<Element> parents=new ArrayList<Element>(10);
22.126 Node n1=el.getParentNode();
22.127 if (!(n1 instanceof Element)) {
22.128 return;
22.129 @@ -605,9 +608,9 @@
22.130 parent=(Element)n;
22.131 }
22.132 //Visit them in reverse order.
22.133 - ListIterator it=parents.listIterator(parents.size());
22.134 + ListIterator<Element> it=parents.listIterator(parents.size());
22.135 while (it.hasPrevious()) {
22.136 - Element ele=(Element)it.previous();
22.137 + Element ele=it.previous();
22.138 handleParent(ele, ns);
22.139 }
22.140 Attr nsprefix;
22.141 @@ -624,7 +627,7 @@
22.142 * @return the attributes nodes to output.
22.143 * @throws CanonicalizationException
22.144 */
22.145 - abstract Iterator handleAttributes(Element E, NameSpaceSymbTable ns )
22.146 + abstract Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns )
22.147 throws CanonicalizationException;
22.148
22.149 /**
22.150 @@ -635,7 +638,7 @@
22.151 * @return the attributes nodes to output.
22.152 * @throws CanonicalizationException
22.153 */
22.154 - abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
22.155 + abstract Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
22.156 throws CanonicalizationException;
22.157
22.158 abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException;
22.159 @@ -660,7 +663,7 @@
22.160 * @throws IOException
22.161 */
22.162 static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
22.163 - final Map cache) throws IOException {
22.164 + final Map<String, byte[]> cache) throws IOException {
22.165 writer.write(' ');
22.166 UtfHelpper.writeByte(name,writer,cache);
22.167 writer.write(equalsStr);
22.168 @@ -841,4 +844,10 @@
22.169 }
22.170 }
22.171
22.172 + @SuppressWarnings("unchecked")
22.173 + protected Collection<Attr> getSortedSetAsCollection(SortedSet<Attr> result) {
22.174 + return (Collection<Attr>)(Collection)result;
22.175 + }
22.176 +
22.177 +
22.178 }
23.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java Thu Oct 13 10:35:43 2011 -0700
23.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java Mon Oct 17 19:06:53 2011 -0700
23.3 @@ -44,7 +44,7 @@
23.4 /**The level of nameSpaces (for Inclusive visibility).*/
23.5 int nameSpaces=0;
23.6 /**The stacks for removing the definitions when doing pop.*/
23.7 - List level;
23.8 + List<SymbMap> level;
23.9 boolean cloned=true;
23.10 static final String XMLNS="xmlns";
23.11 final static SymbMap initialMap=new SymbMap();
23.12 @@ -57,7 +57,7 @@
23.13 * Default constractor
23.14 **/
23.15 public NameSpaceSymbTable() {
23.16 - level = new ArrayList(10);
23.17 + level = new ArrayList<SymbMap>(10);
23.18 //Insert the default binding for xmlns.
23.19 symb=(SymbMap) initialMap.clone();
23.20 }
23.21 @@ -67,11 +67,11 @@
23.22 * For Inclusive rendering
23.23 * @param result the list where to fill the unrendered xmlns definitions.
23.24 **/
23.25 - public void getUnrenderedNodes(Collection result) {
23.26 + public void getUnrenderedNodes(Collection<Attr> result) {
23.27 //List result=new ArrayList();
23.28 - Iterator it=symb.entrySet().iterator();
23.29 + Iterator<NameSpaceSymbEntry> it=symb.entrySet().iterator();
23.30 while (it.hasNext()) {
23.31 - NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
23.32 + NameSpaceSymbEntry n= it.next();
23.33 //put them rendered?
23.34 if ((!n.rendered) && (n.n!=null)) {
23.35 n=(NameSpaceSymbEntry) n.clone();
23.36 @@ -339,8 +339,8 @@
23.37 }
23.38 }
23.39
23.40 - List entrySet() {
23.41 - List a=new ArrayList();
23.42 + List<NameSpaceSymbEntry> entrySet() {
23.43 + List<NameSpaceSymbEntry> a=new ArrayList<NameSpaceSymbEntry>();
23.44 for (int i=0;i<entries.length;i++) {
23.45 if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
23.46 a.add(entries[i]);
24.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java Thu Oct 13 10:35:43 2011 -0700
24.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java Mon Oct 17 19:06:53 2011 -0700
24.3 @@ -6,8 +6,8 @@
24.4
24.5 public class UtfHelpper {
24.6
24.7 - final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
24.8 - byte []result=(byte[]) cache.get(str);
24.9 + final static void writeByte(final String str,final OutputStream out,Map<String,byte[]> cache) throws IOException {
24.10 + byte []result= cache.get(str);
24.11 if (result==null) {
24.12 result=getStringInUtf8(str);
24.13 cache.put(str,result);
25.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java Thu Oct 13 10:35:43 2011 -0700
25.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java Mon Oct 17 19:06:53 2011 -0700
25.3 @@ -95,7 +95,7 @@
25.4 * Returns aditional information regarding the <code>AgreementMethod</code>.
25.5 * @return
25.6 */
25.7 - Iterator getAgreementMethodInformation();
25.8 + Iterator<Element> getAgreementMethodInformation();
25.9
25.10 /**
25.11 * Adds additional <code>AgreementMethod</code> information.
26.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java Thu Oct 13 10:35:43 2011 -0700
26.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java Mon Oct 17 19:06:53 2011 -0700
26.3 @@ -89,7 +89,7 @@
26.4 * @return an <code>Iterator</code> over all the additional infomation
26.5 * about the <code>EncryptionMethod</code>.
26.6 */
26.7 - Iterator getEncryptionMethodInformation();
26.8 + Iterator<Element> getEncryptionMethodInformation();
26.9
26.10 /**
26.11 * Adds encryption method information.
27.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java Thu Oct 13 10:35:43 2011 -0700
27.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java Mon Oct 17 19:06:53 2011 -0700
27.3 @@ -67,7 +67,7 @@
27.4 *
27.5 * @return an <code>Iterator</code> over all the encryption properties.
27.6 */
27.7 - Iterator getEncryptionProperties();
27.8 + Iterator<EncryptionProperty> getEncryptionProperties();
27.9
27.10 /**
27.11 * Adds an <code>EncryptionProperty</code>.
28.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java Thu Oct 13 10:35:43 2011 -0700
28.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java Mon Oct 17 19:06:53 2011 -0700
28.3 @@ -101,7 +101,7 @@
28.4 * @return an <code>Iterator</code> over all the addiitonal encryption
28.5 * information contained in this class.
28.6 */
28.7 - Iterator getEncryptionInformation();
28.8 + Iterator<Element> getEncryptionInformation();
28.9
28.10 /**
28.11 * Adds encryption information.
29.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java Thu Oct 13 10:35:43 2011 -0700
29.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java Mon Oct 17 19:06:53 2011 -0700
29.3 @@ -74,7 +74,7 @@
29.4 *
29.5 * @return child elements.
29.6 */
29.7 - Iterator getElementRetrievalInformation();
29.8 + Iterator<Element> getElementRetrievalInformation();
29.9
29.10 /**
29.11 * Adds retrieval information.
30.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java Thu Oct 13 10:35:43 2011 -0700
30.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java Mon Oct 17 19:06:53 2011 -0700
30.3 @@ -87,7 +87,7 @@
30.4 *
30.5 * @return Iterator.
30.6 */
30.7 - public Iterator getReferences();
30.8 + public Iterator<Reference> getReferences();
30.9
30.10 /**
30.11 * <code>DataReference</code> factory method. Returns a
31.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java Thu Oct 13 10:35:43 2011 -0700
31.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java Mon Oct 17 19:06:53 2011 -0700
31.3 @@ -2772,7 +2772,7 @@
31.4 // </complexType>
31.5 private class AgreementMethodImpl implements AgreementMethod {
31.6 private byte[] kaNonce = null;
31.7 - private List agreementMethodInformation = null;
31.8 + private List<Element> agreementMethodInformation = null;
31.9 private KeyInfo originatorKeyInfo = null;
31.10 private KeyInfo recipientKeyInfo = null;
31.11 private String algorithmURI = null;
31.12 @@ -2781,7 +2781,7 @@
31.13 * @param algorithm
31.14 */
31.15 public AgreementMethodImpl(String algorithm) {
31.16 - agreementMethodInformation = new LinkedList();
31.17 + agreementMethodInformation = new LinkedList<Element>();
31.18 URI tmpAlgorithm = null;
31.19 try {
31.20 tmpAlgorithm = new URI(algorithm);
31.21 @@ -2802,7 +2802,7 @@
31.22 }
31.23
31.24 /** @inheritDoc */
31.25 - public Iterator getAgreementMethodInformation() {
31.26 + public Iterator<Element> getAgreementMethodInformation() {
31.27 return (agreementMethodInformation.iterator());
31.28 }
31.29
31.30 @@ -2879,9 +2879,9 @@
31.31 _contextDocument.createTextNode(new String(kaNonce)));
31.32 }
31.33 if (!agreementMethodInformation.isEmpty()) {
31.34 - Iterator itr = agreementMethodInformation.iterator();
31.35 + Iterator<Element> itr = agreementMethodInformation.iterator();
31.36 while (itr.hasNext()) {
31.37 - result.appendChild((Element) itr.next());
31.38 + result.appendChild(itr.next());
31.39 }
31.40 }
31.41 if (null != originatorKeyInfo) {
31.42 @@ -3486,7 +3486,7 @@
31.43 private String algorithm = null;
31.44 private int keySize = Integer.MIN_VALUE;
31.45 private byte[] oaepParams = null;
31.46 - private List encryptionMethodInformation = null;
31.47 + private List<Element> encryptionMethodInformation = null;
31.48 /**
31.49 *
31.50 * @param algorithm
31.51 @@ -3499,7 +3499,7 @@
31.52 // complain
31.53 }
31.54 this.algorithm = tmpAlgorithm.toString();
31.55 - encryptionMethodInformation = new LinkedList();
31.56 + encryptionMethodInformation = new LinkedList<Element>();
31.57 }
31.58 /** @inheritDoc */
31.59 public String getAlgorithm() {
31.60 @@ -3522,7 +3522,7 @@
31.61 oaepParams = params;
31.62 }
31.63 /** @inheritDoc */
31.64 - public Iterator getEncryptionMethodInformation() {
31.65 + public Iterator<Element> getEncryptionMethodInformation() {
31.66 return (encryptionMethodInformation.iterator());
31.67 }
31.68 /** @inheritDoc */
31.69 @@ -3565,8 +3565,8 @@
31.70 new String(oaepParams))));
31.71 }
31.72 if (!encryptionMethodInformation.isEmpty()) {
31.73 - Iterator itr = encryptionMethodInformation.iterator();
31.74 - result.appendChild((Element) itr.next());
31.75 + Iterator<Element> itr = encryptionMethodInformation.iterator();
31.76 + result.appendChild(itr.next());
31.77 }
31.78
31.79 return (result);
31.80 @@ -3582,13 +3582,13 @@
31.81 // </complexType>
31.82 private class EncryptionPropertiesImpl implements EncryptionProperties {
31.83 private String id = null;
31.84 - private List encryptionProperties = null;
31.85 + private List<EncryptionProperty> encryptionProperties = null;
31.86 /**
31.87 *
31.88 *
31.89 */
31.90 public EncryptionPropertiesImpl() {
31.91 - encryptionProperties = new LinkedList();
31.92 + encryptionProperties = new LinkedList<EncryptionProperty>();
31.93 }
31.94 /** @inheritDoc */
31.95 public String getId() {
31.96 @@ -3599,7 +3599,7 @@
31.97 this.id = id;
31.98 }
31.99 /** @inheritDoc */
31.100 - public Iterator getEncryptionProperties() {
31.101 + public Iterator<EncryptionProperty> getEncryptionProperties() {
31.102 return (encryptionProperties.iterator());
31.103 }
31.104 /** @inheritDoc */
31.105 @@ -3625,7 +3625,7 @@
31.106 if (null != id) {
31.107 result.setAttributeNS(null, EncryptionConstants._ATT_ID, id);
31.108 }
31.109 - Iterator itr = getEncryptionProperties();
31.110 + Iterator<EncryptionProperty> itr = getEncryptionProperties();
31.111 while (itr.hasNext()) {
31.112 result.appendChild(((EncryptionPropertyImpl)
31.113 itr.next()).toElement());
31.114 @@ -3647,15 +3647,15 @@
31.115 private class EncryptionPropertyImpl implements EncryptionProperty {
31.116 private String target = null;
31.117 private String id = null;
31.118 - private HashMap attributeMap = new HashMap();
31.119 - private List encryptionInformation = null;
31.120 + private HashMap<String,String> attributeMap = new HashMap<String,String>();
31.121 + private List<Element> encryptionInformation = null;
31.122
31.123 /**
31.124 *
31.125 *
31.126 */
31.127 public EncryptionPropertyImpl() {
31.128 - encryptionInformation = new LinkedList();
31.129 + encryptionInformation = new LinkedList<Element>();
31.130 }
31.131 /** @inheritDoc */
31.132 public String getTarget() {
31.133 @@ -3692,14 +3692,14 @@
31.134 }
31.135 /** @inheritDoc */
31.136 public String getAttribute(String attribute) {
31.137 - return (String) attributeMap.get(attribute);
31.138 + return attributeMap.get(attribute);
31.139 }
31.140 /** @inheritDoc */
31.141 public void setAttribute(String attribute, String value) {
31.142 attributeMap.put(attribute, value);
31.143 }
31.144 /** @inheritDoc */
31.145 - public Iterator getEncryptionInformation() {
31.146 + public Iterator<Element> getEncryptionInformation() {
31.147 return (encryptionInformation.iterator());
31.148 }
31.149 /** @inheritDoc */
31.150 @@ -3821,8 +3821,8 @@
31.151 // </complexType>
31.152 //</element>
31.153 private class ReferenceListImpl implements ReferenceList {
31.154 - private Class sentry;
31.155 - private List references;
31.156 + private Class<?> sentry;
31.157 + private List<Reference> references;
31.158 /**
31.159 *
31.160 * @param type
31.161 @@ -3835,7 +3835,7 @@
31.162 } else {
31.163 throw new IllegalArgumentException();
31.164 }
31.165 - references = new LinkedList();
31.166 + references = new LinkedList<Reference>();
31.167 }
31.168 /** @inheritDoc */
31.169 public void add(Reference reference) {
31.170 @@ -3860,7 +3860,7 @@
31.171 return (references.isEmpty());
31.172 }
31.173 /** @inheritDoc */
31.174 - public Iterator getReferences() {
31.175 + public Iterator<Reference> getReferences() {
31.176 return (references.iterator());
31.177 }
31.178
31.179 @@ -3869,9 +3869,9 @@
31.180 _contextDocument,
31.181 EncryptionConstants.EncryptionSpecNS,
31.182 EncryptionConstants._TAG_REFERENCELIST);
31.183 - Iterator eachReference = references.iterator();
31.184 + Iterator<Reference> eachReference = references.iterator();
31.185 while (eachReference.hasNext()) {
31.186 - Reference reference = (Reference) eachReference.next();
31.187 + Reference reference = eachReference.next();
31.188 result.appendChild(
31.189 ((ReferenceImpl) reference).toElement());
31.190 }
31.191 @@ -3894,18 +3894,18 @@
31.192 */
31.193 private abstract class ReferenceImpl implements Reference {
31.194 private String uri;
31.195 - private List referenceInformation;
31.196 + private List<Element> referenceInformation;
31.197
31.198 ReferenceImpl(String _uri) {
31.199 this.uri = _uri;
31.200 - referenceInformation = new LinkedList();
31.201 + referenceInformation = new LinkedList<Element>();
31.202 }
31.203 /** @inheritDoc */
31.204 public String getURI() {
31.205 return (uri);
31.206 }
31.207 /** @inheritDoc */
31.208 - public Iterator getElementRetrievalInformation() {
31.209 + public Iterator<Element> getElementRetrievalInformation() {
31.210 return (referenceInformation.iterator());
31.211 }
31.212 /** @inheritDoc */
32.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java Thu Oct 13 10:35:43 2011 -0700
32.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java Mon Oct 17 19:06:53 2011 -0700
32.3 @@ -97,12 +97,12 @@
32.4 /** {@link java.util.logging} logging facility */
32.5 static java.util.logging.Logger log =
32.6 java.util.logging.Logger.getLogger(KeyInfo.class.getName());
32.7 - List x509Datas=null;
32.8 - List encryptedKeys=null;
32.9 + List<X509Data> x509Datas=null;
32.10 + List<EncryptedKey> encryptedKeys=null;
32.11
32.12 - static final List nullList;
32.13 + static final List<StorageResolver> nullList;
32.14 static {
32.15 - List list = new ArrayList();
32.16 + List<StorageResolver> list = new ArrayList<StorageResolver>(1);
32.17 list.add(null);
32.18 nullList = Collections.unmodifiableList(list);
32.19 }
32.20 @@ -297,7 +297,7 @@
32.21 */
32.22 public void add(X509Data x509data) {
32.23 if (x509Datas==null)
32.24 - x509Datas=new ArrayList();
32.25 + x509Datas=new ArrayList<X509Data>();
32.26 x509Datas.add(x509data);
32.27 this._constructionElement.appendChild(x509data.getElement());
32.28 XMLUtils.addReturnToElement(this._constructionElement);
32.29 @@ -313,7 +313,7 @@
32.30 public void add(EncryptedKey encryptedKey)
32.31 throws XMLEncryptionException {
32.32 if (encryptedKeys==null)
32.33 - encryptedKeys=new ArrayList();
32.34 + encryptedKeys=new ArrayList<EncryptedKey>();
32.35 encryptedKeys.add(encryptedKey);
32.36 XMLCipher cipher = XMLCipher.getInstance();
32.37 this._constructionElement.appendChild(cipher.martial(encryptedKey));
32.38 @@ -541,7 +541,7 @@
32.39 */
32.40 public X509Data itemX509Data(int i) throws XMLSecurityException {
32.41 if (x509Datas!=null) {
32.42 - return (X509Data) x509Datas.get(i);
32.43 + return x509Datas.get(i);
32.44 }
32.45 Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
32.46 Constants._TAG_X509DATA,i);
32.47 @@ -562,7 +562,7 @@
32.48
32.49 public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
32.50 if (encryptedKeys!=null) {
32.51 - return (EncryptedKey) encryptedKeys.get(i);
32.52 + return encryptedKeys.get(i);
32.53 }
32.54 Element e =
32.55 XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
32.56 @@ -728,16 +728,16 @@
32.57 PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
32.58 int length=KeyResolver.length();
32.59 int storageLength=this._storageResolvers.size();
32.60 - Iterator it= KeyResolver.iterator();
32.61 + Iterator<KeyResolverSpi> it= KeyResolver.iterator();
32.62 for (int i = 0; i < length; i++) {
32.63 - KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
32.64 + KeyResolverSpi keyResolver = it.next();
32.65 Node currentChild=this._constructionElement.getFirstChild();
32.66 String uri= this.getBaseURI();
32.67 while (currentChild!=null) {
32.68 if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
32.69 for (int k = 0; k < storageLength; k++) {
32.70 StorageResolver storage =
32.71 - (StorageResolver) this._storageResolvers.get(k);
32.72 + this._storageResolvers.get(k);
32.73
32.74 PublicKey pk =
32.75 keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
32.76 @@ -776,7 +776,7 @@
32.77 if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
32.78 for (int k = 0; k < storageLength; k++) {
32.79 StorageResolver storage =
32.80 - (StorageResolver) this._storageResolvers.get(k);
32.81 + this._storageResolvers.get(k);
32.82 PublicKey pk = keyResolver
32.83 .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
32.84
32.85 @@ -845,9 +845,9 @@
32.86 String uri=this.getBaseURI();
32.87 int length= KeyResolver.length();
32.88 int storageLength=this._storageResolvers.size();
32.89 - Iterator it = KeyResolver.iterator();
32.90 + Iterator<KeyResolverSpi> it = KeyResolver.iterator();
32.91 for (int i = 0; i <length; i++) {
32.92 - KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
32.93 + KeyResolverSpi keyResolver = it.next();
32.94 X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
32.95 if (cert!=null) {
32.96 KeyResolver.hit(it);
32.97 @@ -863,7 +863,7 @@
32.98 if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
32.99 for (int k = 0; k < storageLength; k++) {
32.100 StorageResolver storage =
32.101 - (StorageResolver) this._storageResolvers.get(k);
32.102 + this._storageResolvers.get(k);
32.103
32.104 X509Certificate cert = keyResolver
32.105 .engineLookupResolveX509Certificate((Element) currentChild, uri,
32.106 @@ -944,9 +944,9 @@
32.107 SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
32.108 final int length=KeyResolver.length();
32.109 int storageLength=this._storageResolvers.size();
32.110 - Iterator it = KeyResolver.iterator();
32.111 + Iterator<KeyResolverSpi> it = KeyResolver.iterator();
32.112 for (int i = 0; i < length; i++) {
32.113 - KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
32.114 + KeyResolverSpi keyResolver = it.next();
32.115
32.116 Node currentChild=this._constructionElement.getFirstChild();
32.117 String uri=this.getBaseURI();
32.118 @@ -954,7 +954,7 @@
32.119 if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
32.120 for (int k = 0; k < storageLength; k++) {
32.121 StorageResolver storage =
32.122 - (StorageResolver) this._storageResolvers.get(k);
32.123 + this._storageResolvers.get(k);
32.124
32.125 SecretKey sk =
32.126 keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
32.127 @@ -992,7 +992,7 @@
32.128 if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
32.129 for (int k = 0; k < storageLength; k++) {
32.130 StorageResolver storage =
32.131 - (StorageResolver) this._storageResolvers.get(k);
32.132 + this._storageResolvers.get(k);
32.133
32.134 SecretKey sk = keyResolver
32.135 .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
32.136 @@ -1012,7 +1012,7 @@
32.137 /**
32.138 * Stores the individual (per-KeyInfo) {@link KeyResolver}s
32.139 */
32.140 - List _internalKeyResolvers = null;
32.141 + List<KeyResolverSpi> _internalKeyResolvers = null;
32.142
32.143 /**
32.144 * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
32.145 @@ -1022,7 +1022,7 @@
32.146 */
32.147 public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
32.148 if (_internalKeyResolvers==null) {
32.149 - _internalKeyResolvers=new ArrayList();
32.150 + _internalKeyResolvers=new ArrayList<KeyResolverSpi>();
32.151 }
32.152 this._internalKeyResolvers.add(realKeyResolver);
32.153 }
32.154 @@ -1044,11 +1044,11 @@
32.155 * @return the KeyResolverSpi for the index.
32.156 */
32.157 KeyResolverSpi itemInternalKeyResolver(int i) {
32.158 - return (KeyResolverSpi) this._internalKeyResolvers.get(i);
32.159 + return this._internalKeyResolvers.get(i);
32.160 }
32.161
32.162 /** Field _storageResolvers */
32.163 - List _storageResolvers = nullList;
32.164 + List<StorageResolver> _storageResolvers = nullList;
32.165
32.166 /**
32.167 * Method addStorageResolver
32.168 @@ -1057,7 +1057,7 @@
32.169 */
32.170 public void addStorageResolver(StorageResolver storageResolver) {
32.171 if (_storageResolvers == nullList ){
32.172 - _storageResolvers=new ArrayList();
32.173 + _storageResolvers=new ArrayList<StorageResolver>();
32.174 }
32.175 this._storageResolvers.add(storageResolver);
32.176
33.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java Thu Oct 13 10:35:43 2011 -0700
33.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java Mon Oct 17 19:06:53 2011 -0700
33.3 @@ -52,7 +52,7 @@
33.4 static boolean _alreadyInitialized = false;
33.5
33.6 /** Field _resolverVector */
33.7 - static List _resolverVector = null;
33.8 + static List<KeyResolver> _resolverVector = null;
33.9
33.10 /** Field _resolverSpi */
33.11 protected KeyResolverSpi _resolverSpi = null;
33.12 @@ -85,12 +85,12 @@
33.13 return KeyResolver._resolverVector.size();
33.14 }
33.15
33.16 - public static void hit(Iterator hintI) {
33.17 + public static void hit(Iterator<KeyResolverSpi> hintI) {
33.18 ResolverIterator hint = (ResolverIterator) hintI;
33.19 int i = hint.i;
33.20 if (i!=1 && hint.res ==_resolverVector) {
33.21 - List resolverVector=(List)((ArrayList)_resolverVector).clone();
33.22 - Object ob=resolverVector.remove(i-1);
33.23 + List<KeyResolver> resolverVector=getResolverVectorClone();
33.24 + KeyResolver ob=resolverVector.remove(i-1);
33.25 resolverVector.add(0,ob);
33.26 _resolverVector=resolverVector;
33.27 } else {
33.28 @@ -113,12 +113,9 @@
33.29 throws KeyResolverException {
33.30
33.31 // use the old vector to not be hit by updates
33.32 - List resolverVector = KeyResolver._resolverVector;
33.33 - for (int i = 0; i < resolverVector.size(); i++) {
33.34 - KeyResolver resolver=
33.35 - (KeyResolver) resolverVector.get(i);
33.36 -
33.37 - if (resolver==null) {
33.38 + List<KeyResolver> resolverVector = KeyResolver._resolverVector;
33.39 + for (KeyResolver resolver : resolverVector) {
33.40 + if (resolver==null) {
33.41 Object exArgs[] = {
33.42 (((element != null)
33.43 && (element.getNodeType() == Node.ELEMENT_NODE))
33.44 @@ -157,10 +154,8 @@
33.45 Element element, String BaseURI, StorageResolver storage)
33.46 throws KeyResolverException {
33.47
33.48 - List resolverVector = KeyResolver._resolverVector;
33.49 - for (int i = 0; i < resolverVector.size(); i++) {
33.50 - KeyResolver resolver=
33.51 - (KeyResolver) resolverVector.get(i);
33.52 + List<KeyResolver> resolverVector = KeyResolver._resolverVector;
33.53 + for (KeyResolver resolver : resolverVector) {
33.54
33.55 if (resolver==null) {
33.56 Object exArgs[] = {
33.57 @@ -176,11 +171,11 @@
33.58
33.59 PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
33.60 if (cert!=null) {
33.61 - if (i!=0 && resolverVector==_resolverVector) {
33.62 + if (resolverVector.indexOf(resolver)!=0 && resolverVector==_resolverVector) {
33.63 //update resolver.
33.64 - resolverVector=(List)((ArrayList)_resolverVector).clone();
33.65 - Object ob=resolverVector.remove(i);
33.66 - resolverVector.add(0,ob);
33.67 + resolverVector=getResolverVectorClone();
33.68 + resolverVector.remove(resolver);
33.69 + resolverVector.add(0,resolver);
33.70 _resolverVector=resolverVector;
33.71 }
33.72 return cert;
33.73 @@ -195,13 +190,19 @@
33.74 throw new KeyResolverException("utils.resolver.noClass", exArgs);
33.75 }
33.76
33.77 +
33.78 + @SuppressWarnings("unchecked")
33.79 + private static List<KeyResolver> getResolverVectorClone() {
33.80 + return (List<KeyResolver>)((ArrayList<KeyResolver>)_resolverVector).clone();
33.81 + }
33.82 +
33.83 /**
33.84 * The init() function is called by com.sun.org.apache.xml.internal.security.Init.init()
33.85 */
33.86 public static void init() {
33.87
33.88 if (!KeyResolver._alreadyInitialized) {
33.89 - KeyResolver._resolverVector = new ArrayList(10);
33.90 + KeyResolver._resolverVector = new ArrayList<KeyResolver>(10);
33.91 _alreadyInitialized = true;
33.92 }
33.93 }
33.94 @@ -230,8 +231,8 @@
33.95 *
33.96 * @param className
33.97 */
33.98 - public static void registerAtStart(String className) {
33.99 - KeyResolver._resolverVector.add(0, className);
33.100 + public static void registerAtStart(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
33.101 + register(className);
33.102 }
33.103
33.104 /**
33.105 @@ -322,11 +323,11 @@
33.106 return this._resolverSpi.getClass().getName();
33.107 }
33.108
33.109 - static class ResolverIterator implements Iterator {
33.110 - List res;
33.111 - Iterator it;
33.112 + static class ResolverIterator implements Iterator<KeyResolverSpi> {
33.113 + List<KeyResolver> res;
33.114 + Iterator<KeyResolver> it;
33.115 int i;
33.116 - public ResolverIterator(List list) {
33.117 + public ResolverIterator(List<KeyResolver> list) {
33.118 res = list;
33.119 it = res.iterator();
33.120 }
33.121 @@ -335,9 +336,9 @@
33.122 return it.hasNext();
33.123 }
33.124
33.125 - public Object next() {
33.126 + public KeyResolverSpi next() {
33.127 i++;
33.128 - KeyResolver resolver = (KeyResolver) it.next();
33.129 + KeyResolver resolver = it.next();
33.130 if (resolver==null) {
33.131 throw new RuntimeException("utils.resolver.noClass");
33.132 }
33.133 @@ -351,7 +352,7 @@
33.134 }
33.135
33.136 };
33.137 - public static Iterator iterator() {
33.138 + public static Iterator<KeyResolverSpi> iterator() {
33.139 return new ResolverIterator(_resolverVector);
33.140 }
33.141 }
34.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java Thu Oct 13 10:35:43 2011 -0700
34.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java Mon Oct 17 19:06:53 2011 -0700
34.3 @@ -32,7 +32,7 @@
34.4 /**
34.5 * This class is abstract class for a child KeyInfo Elemnet.
34.6 *
34.7 - * If you want the your KeyResolver, at firstly you must extand this class, and register
34.8 + * If you want your KeyResolver, at first you must extend this class, and register
34.9 * as following in config.xml
34.10 * <PRE>
34.11 * <KeyResolver URI="http://www.w3.org/2000/09/xmldsig#KeyValue"
34.12 @@ -177,7 +177,7 @@
34.13 }
34.14
34.15 /** Field _properties */
34.16 - protected java.util.Map _properties = null;
34.17 + protected java.util.Map<String,String> _properties = null;
34.18
34.19 protected boolean globalResolver=false;
34.20
34.21 @@ -189,7 +189,7 @@
34.22 */
34.23 public void engineSetProperty(String key, String value) {
34.24 if (_properties==null)
34.25 - _properties=new HashMap();
34.26 + _properties=new HashMap<String,String>();
34.27 this._properties.put(key, value);
34.28 }
34.29
34.30 @@ -203,7 +203,7 @@
34.31 if (_properties==null)
34.32 return null;
34.33
34.34 - return (String) this._properties.get(key);
34.35 + return this._properties.get(key);
34.36 }
34.37
34.38 /**
35.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java Thu Oct 13 10:35:43 2011 -0700
35.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java Mon Oct 17 19:06:53 2011 -0700
35.3 @@ -278,18 +278,18 @@
35.4 return null;
35.5 }
35.6
35.7 - static Element getDocumentElement(Set set) {
35.8 - Iterator it=set.iterator();
35.9 + static Element getDocumentElement(Set<Node> set) {
35.10 + Iterator<Node> it=set.iterator();
35.11 Element e=null;
35.12 while (it.hasNext()) {
35.13 - Node currentNode=(Node)it.next();
35.14 + Node currentNode=it.next();
35.15 if (currentNode instanceof Element) {
35.16 e=(Element)currentNode;
35.17 break;
35.18 }
35.19
35.20 }
35.21 - List parents=new ArrayList(10);
35.22 + List<Element> parents=new ArrayList<Element>(10);
35.23
35.24 //Obtain all the parents of the elemnt
35.25 do {
35.26 @@ -301,10 +301,10 @@
35.27 e=(Element)n;
35.28 } while (e!=null);
35.29 //Visit them in reverse order.
35.30 - ListIterator it2=parents.listIterator(parents.size()-1);
35.31 + ListIterator<Element> it2=parents.listIterator(parents.size()-1);
35.32 Element ele=null;
35.33 while (it2.hasPrevious()) {
35.34 - ele=(Element)it2.previous();
35.35 + ele=it2.previous();
35.36 if (set.contains(ele)) {
35.37 return ele;
35.38 }
36.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java Thu Oct 13 10:35:43 2011 -0700
36.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java Mon Oct 17 19:06:53 2011 -0700
36.3 @@ -42,10 +42,10 @@
36.4 java.util.logging.Logger.getLogger(StorageResolver.class.getName());
36.5
36.6 /** Field _storageResolvers */
36.7 - List _storageResolvers = null;
36.8 + List<Object> _storageResolvers = null;
36.9
36.10 /** Field _iterator */
36.11 - Iterator _iterator = null;
36.12 + Iterator<Object> _iterator = null;
36.13
36.14 /**
36.15 * Constructor StorageResolver
36.16 @@ -69,7 +69,7 @@
36.17 */
36.18 public void add(StorageResolverSpi resolver) {
36.19 if (_storageResolvers==null)
36.20 - _storageResolvers=new ArrayList();
36.21 + _storageResolvers=new ArrayList<Object>();
36.22 this._storageResolvers.add(resolver);
36.23
36.24 this._iterator = null;
36.25 @@ -121,11 +121,11 @@
36.26 * @return the iterator for the resolvers.
36.27 *
36.28 */
36.29 - public Iterator getIterator() {
36.30 + public Iterator<Object> getIterator() {
36.31
36.32 if (this._iterator == null) {
36.33 if (_storageResolvers==null)
36.34 - _storageResolvers=new ArrayList();
36.35 + _storageResolvers=new ArrayList<Object>();
36.36 this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
36.37 }
36.38
36.39 @@ -141,7 +141,7 @@
36.40
36.41 if (this._iterator == null) {
36.42 if (_storageResolvers==null)
36.43 - _storageResolvers=new ArrayList();
36.44 + _storageResolvers=new ArrayList<Object>();
36.45 this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
36.46 }
36.47
36.48 @@ -163,17 +163,17 @@
36.49 * @author $Author: mullan $
36.50 * @version $Revision: 1.5 $
36.51 */
36.52 - static class StorageResolverIterator implements Iterator {
36.53 + static class StorageResolverIterator implements Iterator<Object> {
36.54
36.55 /** Field _resolvers */
36.56 - Iterator _resolvers = null;
36.57 + Iterator<Object> _resolvers = null;
36.58
36.59 /**
36.60 * Constructor FilesystemIterator
36.61 *
36.62 * @param resolvers
36.63 */
36.64 - public StorageResolverIterator(Iterator resolvers) {
36.65 + public StorageResolverIterator(Iterator<Object> resolvers) {
36.66 this._resolvers = resolvers;
36.67 }
36.68
37.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java Thu Oct 13 10:35:43 2011 -0700
37.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java Mon Oct 17 19:06:53 2011 -0700
37.3 @@ -36,5 +36,5 @@
37.4 *
37.5 * @return the iterator for the storage
37.6 */
37.7 - public abstract Iterator getIterator();
37.8 + public abstract Iterator<?> getIterator();
37.9 }
38.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java Thu Oct 13 10:35:43 2011 -0700
38.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java Mon Oct 17 19:06:53 2011 -0700
38.3 @@ -54,10 +54,10 @@
38.4 String _merlinsCertificatesDir = null;
38.5
38.6 /** Field _certs */
38.7 - private List _certs = new ArrayList();
38.8 + private List<X509Certificate> _certs = new ArrayList<X509Certificate>();
38.9
38.10 /** Field _iterator */
38.11 - Iterator _iterator = null;
38.12 + Iterator<X509Certificate> _iterator = null;
38.13
38.14 /**
38.15 *
38.16 @@ -83,7 +83,7 @@
38.17 private void readCertsFromHarddrive() throws StorageResolverException {
38.18
38.19 File certDir = new File(this._merlinsCertificatesDir);
38.20 - ArrayList al = new ArrayList();
38.21 + ArrayList<String> al = new ArrayList<String>();
38.22 String[] names = certDir.list();
38.23
38.24 for (int i = 0; i < names.length; i++) {
38.25 @@ -108,7 +108,7 @@
38.26
38.27 for (int i = 0; i < al.size(); i++) {
38.28 String filename = certDir.getAbsolutePath() + File.separator
38.29 - + (String) al.get(i);
38.30 + + al.get(i);
38.31 File file = new File(filename);
38.32 boolean added = false;
38.33 String dn = null;
38.34 @@ -146,7 +146,7 @@
38.35 }
38.36
38.37 /** @inheritDoc */
38.38 - public Iterator getIterator() {
38.39 + public Iterator<X509Certificate> getIterator() {
38.40 return this._iterator;
38.41 }
38.42
38.43 @@ -156,10 +156,10 @@
38.44 * @author $Author: mullan $
38.45 * @version $Revision: 1.5 $
38.46 */
38.47 - private static class FilesystemIterator implements Iterator {
38.48 + private static class FilesystemIterator implements Iterator<X509Certificate> {
38.49
38.50 /** Field _certs */
38.51 - List _certs = null;
38.52 + List<X509Certificate> _certs = null;
38.53
38.54 /** Field _i */
38.55 int _i;
38.56 @@ -169,7 +169,7 @@
38.57 *
38.58 * @param certs
38.59 */
38.60 - public FilesystemIterator(List certs) {
38.61 + public FilesystemIterator(List<X509Certificate> certs) {
38.62 this._certs = certs;
38.63 this._i = 0;
38.64 }
38.65 @@ -180,7 +180,7 @@
38.66 }
38.67
38.68 /** @inheritDoc */
38.69 - public Object next() {
38.70 + public X509Certificate next() {
38.71 return this._certs.get(this._i++);
38.72 }
38.73
38.74 @@ -206,8 +206,8 @@
38.75 new CertsInFilesystemDirectoryResolver(
38.76 "data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs");
38.77
38.78 - for (Iterator i = krs.getIterator(); i.hasNext(); ) {
38.79 - X509Certificate cert = (X509Certificate) i.next();
38.80 + for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) {
38.81 + X509Certificate cert = i.next();
38.82 byte[] ski =
38.83 com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
38.84 .getSKIBytesFromCert(cert);
39.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java Thu Oct 13 10:35:43 2011 -0700
39.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java Mon Oct 17 19:06:53 2011 -0700
39.3 @@ -42,7 +42,7 @@
39.4 KeyStore _keyStore = null;
39.5
39.6 /** Field _iterator */
39.7 - Iterator _iterator = null;
39.8 + Iterator<X509Certificate> _iterator = null;
39.9
39.10 /**
39.11 * Constructor KeyStoreResolver
39.12 @@ -56,7 +56,7 @@
39.13 }
39.14
39.15 /** @inheritDoc */
39.16 - public Iterator getIterator() {
39.17 + public Iterator<X509Certificate> getIterator() {
39.18 return this._iterator;
39.19 }
39.20
39.21 @@ -66,13 +66,13 @@
39.22 * @author $Author: mullan $
39.23 * @version $Revision: 1.5 $
39.24 */
39.25 - static class KeyStoreIterator implements Iterator {
39.26 + static class KeyStoreIterator implements Iterator<X509Certificate> {
39.27
39.28 /** Field _keyStore */
39.29 KeyStore _keyStore = null;
39.30
39.31 /** Field _aliases */
39.32 - Enumeration _aliases = null;
39.33 + Enumeration<String> _aliases = null;
39.34
39.35 /**
39.36 * Constructor KeyStoreIterator
39.37 @@ -97,12 +97,13 @@
39.38 }
39.39
39.40 /** @inheritDoc */
39.41 - public Object next() {
39.42 + @SuppressWarnings("unchecked")
39.43 + public X509Certificate next() {
39.44
39.45 - String alias = (String) this._aliases.nextElement();
39.46 + String alias = this._aliases.nextElement();
39.47
39.48 try {
39.49 - return this._keyStore.getCertificate(alias);
39.50 + return (X509Certificate)this._keyStore.getCertificate(alias);
39.51 } catch (KeyStoreException ex) {
39.52 return null;
39.53 }
39.54 @@ -135,8 +136,8 @@
39.55
39.56 KeyStoreResolver krs = new KeyStoreResolver(ks);
39.57
39.58 - for (Iterator i = krs.getIterator(); i.hasNext(); ) {
39.59 - X509Certificate cert = (X509Certificate) i.next();
39.60 + for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) {
39.61 + X509Certificate cert = i.next();
39.62 byte[] ski =
39.63 com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
39.64 .getSKIBytesFromCert(cert);
40.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java Thu Oct 13 10:35:43 2011 -0700
40.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java Mon Oct 17 19:06:53 2011 -0700
40.3 @@ -38,7 +38,7 @@
40.4 X509Certificate _certificate = null;
40.5
40.6 /** Field _iterator */
40.7 - Iterator _iterator = null;
40.8 + Iterator<X509Certificate> _iterator = null;
40.9
40.10 /**
40.11 *
40.12 @@ -51,7 +51,7 @@
40.13 }
40.14
40.15 /** @inheritDoc */
40.16 - public Iterator getIterator() {
40.17 + public Iterator<X509Certificate> getIterator() {
40.18 return this._iterator;
40.19 }
40.20
40.21 @@ -61,7 +61,7 @@
40.22 * @author $Author: mullan $
40.23 * @version $Revision: 1.5 $
40.24 */
40.25 - static class InternalIterator implements Iterator {
40.26 + static class InternalIterator implements Iterator<X509Certificate> {
40.27
40.28 /** Field _alreadyReturned */
40.29 boolean _alreadyReturned = false;
40.30 @@ -84,7 +84,7 @@
40.31 }
40.32
40.33 /** @inheritDoc */
40.34 - public Object next() {
40.35 + public X509Certificate next() {
40.36
40.37 this._alreadyReturned = true;
40.38
41.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java Thu Oct 13 10:35:43 2011 -0700
41.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java Mon Oct 17 19:06:53 2011 -0700
41.3 @@ -28,6 +28,7 @@
41.4 import java.util.Iterator;
41.5 import java.util.List;
41.6 import java.util.Set;
41.7 +import java.util.Map;
41.8
41.9 import javax.xml.parsers.ParserConfigurationException;
41.10
41.11 @@ -62,17 +63,17 @@
41.12 java.util.logging.Logger.getLogger(Manifest.class.getName());
41.13
41.14 /** Field _references */
41.15 - List _references;
41.16 + List<Reference> _references;
41.17 Element[] _referencesEl;
41.18
41.19 /** Field verificationResults[] */
41.20 private boolean verificationResults[] = null;
41.21
41.22 /** Field _resolverProperties */
41.23 - HashMap _resolverProperties = null;
41.24 + Map<String,String> _resolverProperties = null;
41.25
41.26 /** Field _perManifestResolvers */
41.27 - List _perManifestResolvers = null;
41.28 + List<ResourceResolver> _perManifestResolvers = null;
41.29
41.30 /**
41.31 * Consturts {@link Manifest}
41.32 @@ -85,7 +86,7 @@
41.33
41.34 XMLUtils.addReturnToElement(this._constructionElement);
41.35
41.36 - this._references = new ArrayList();
41.37 + this._references = new ArrayList<Reference>();
41.38 }
41.39
41.40 /**
41.41 @@ -117,7 +118,7 @@
41.42 }
41.43
41.44 // create Vector
41.45 - this._references = new ArrayList(le);
41.46 + this._references = new ArrayList<Reference>(le);
41.47
41.48 for (int i = 0; i < le; i++) {
41.49 this._references.add(null);
41.50 @@ -175,7 +176,7 @@
41.51 for (int i = 0; i < this.getLength(); i++) {
41.52
41.53 // update the cached Reference object, the Element content is automatically updated
41.54 - Reference currentRef = (Reference) this._references.get(i);
41.55 + Reference currentRef = this._references.get(i);
41.56
41.57 currentRef.generateDigestValue();
41.58 }
41.59 @@ -208,7 +209,7 @@
41.60 this._references.set(i, ref);
41.61 }
41.62
41.63 - return (Reference) this._references.get(i);
41.64 + return this._references.get(i);
41.65
41.66 }
41.67
41.68 @@ -323,12 +324,12 @@
41.69 try {
41.70 XMLSignatureInput signedManifestNodes =
41.71 currentRef.dereferenceURIandPerformTransforms(null);
41.72 - Set nl = signedManifestNodes.getNodeSet();
41.73 + Set<Node> nl = signedManifestNodes.getNodeSet();
41.74 Manifest referencedManifest = null;
41.75 - Iterator nlIterator = nl.iterator();
41.76 + Iterator<Node> nlIterator = nl.iterator();
41.77
41.78 findManifest: while (nlIterator.hasNext()) {
41.79 - Node n = (Node) nlIterator.next();
41.80 + Node n = nlIterator.next();
41.81
41.82 if ((n.getNodeType() == Node.ELEMENT_NODE) && ((Element) n)
41.83 .getNamespaceURI()
41.84 @@ -449,7 +450,7 @@
41.85 return;
41.86 }
41.87 if (_perManifestResolvers==null)
41.88 - _perManifestResolvers = new ArrayList();
41.89 + _perManifestResolvers = new ArrayList<ResourceResolver>();
41.90 this._perManifestResolvers.add(resolver);
41.91
41.92 }
41.93 @@ -465,7 +466,7 @@
41.94 return;
41.95 }
41.96 if (_perManifestResolvers==null)
41.97 - _perManifestResolvers = new ArrayList();
41.98 + _perManifestResolvers = new ArrayList<ResourceResolver>();
41.99 this._perManifestResolvers.add(new ResourceResolver(resolverSpi));
41.100
41.101 }
41.102 @@ -479,7 +480,7 @@
41.103 */
41.104 public void setResolverProperty(String key, String value) {
41.105 if (_resolverProperties==null) {
41.106 - _resolverProperties=new HashMap(10);
41.107 + _resolverProperties=new HashMap<String, String>(10);
41.108 }
41.109 this._resolverProperties.put(key, value);
41.110 }
41.111 @@ -491,7 +492,7 @@
41.112 * @return the value
41.113 */
41.114 public String getResolverProperty(String key) {
41.115 - return (String) this._resolverProperties.get(key);
41.116 + return this._resolverProperties.get(key);
41.117 }
41.118
41.119 /**
42.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java Thu Oct 13 10:35:43 2011 -0700
42.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java Mon Oct 17 19:06:53 2011 -0700
42.3 @@ -436,6 +436,7 @@
42.4 *
42.5 * @deprecated use getContentsBeforeTransformation
42.6 */
42.7 + @Deprecated
42.8 public XMLSignatureInput getTransformsInput() throws ReferenceNotInitializedException
42.9 {
42.10 XMLSignatureInput input=getContentsBeforeTransformation();
42.11 @@ -557,7 +558,7 @@
42.12
42.13 try {
42.14 XMLSignatureInput nodes = this.getNodesetBeforeFirstCanonicalization();
42.15 - Set inclusiveNamespaces = new HashSet();
42.16 + Set<String> inclusiveNamespaces = new HashSet<String>();
42.17
42.18 {
42.19 Transforms transforms = this.getTransforms();
42.20 @@ -710,7 +711,7 @@
42.21 XMLSignatureInput output=this.dereferenceURIandPerformTransforms(os);
42.22 // if signing and c14n11 property == true explicitly add
42.23 // C14N11 transform if needed
42.24 - if (this.useC14N11 && !validating &&
42.25 + if (Reference.useC14N11 && !validating &&
42.26 !output.isOutputStreamSet() && !output.isOctetStream()) {
42.27 if (transforms == null) {
42.28 transforms = new Transforms(this._doc);
43.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java Thu Oct 13 10:35:43 2011 -0700
43.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java Mon Oct 17 19:06:53 2011 -0700
43.3 @@ -74,7 +74,7 @@
43.4 /**
43.5 * The original NodeSet for this XMLSignatureInput
43.6 */
43.7 - Set _inputNodeSet = null;
43.8 + Set<Node> _inputNodeSet = null;
43.9 /**
43.10 * The original Element
43.11 */
43.12 @@ -107,7 +107,7 @@
43.13 /**
43.14 * Node Filter list.
43.15 */
43.16 - List nodeFilters=new ArrayList();
43.17 + List<NodeFilter> nodeFilters=new ArrayList<NodeFilter>();
43.18
43.19 boolean needsToBeExpanded=false;
43.20 OutputStream outputStream=null;
43.21 @@ -164,6 +164,7 @@
43.22 * @deprecated
43.23 * @param inputStr the input String which including XML document or node
43.24 */
43.25 + @Deprecated
43.26 public XMLSignatureInput(String inputStr) {
43.27 this(inputStr.getBytes());
43.28 }
43.29 @@ -179,6 +180,7 @@
43.30 * @param encoding the encoding of <code>inputStr</code>
43.31 * @throws UnsupportedEncodingException
43.32 */
43.33 + @Deprecated
43.34 public XMLSignatureInput(String inputStr, String encoding)
43.35 throws UnsupportedEncodingException {
43.36 this(inputStr.getBytes(encoding));
43.37 @@ -201,7 +203,7 @@
43.38 * @param inputNodeSet
43.39 * @param usedXPathAPI
43.40 */
43.41 - public XMLSignatureInput(Set inputNodeSet) {
43.42 + public XMLSignatureInput(Set<Node> inputNodeSet) {
43.43 this._inputNodeSet = inputNodeSet;
43.44 }
43.45
43.46 @@ -215,7 +217,7 @@
43.47 * @throws ParserConfigurationException
43.48 * @throws CanonicalizationException
43.49 */
43.50 - public Set getNodeSet() throws CanonicalizationException,
43.51 + public Set<Node> getNodeSet() throws CanonicalizationException,
43.52 ParserConfigurationException, IOException, SAXException {
43.53 return getNodeSet(false);
43.54 }
43.55 @@ -231,7 +233,7 @@
43.56 * @throws ParserConfigurationException
43.57 * @throws CanonicalizationException
43.58 */
43.59 - public Set getNodeSet(boolean circumvent)
43.60 + public Set<Node> getNodeSet(boolean circumvent)
43.61 throws ParserConfigurationException, IOException, SAXException,
43.62 CanonicalizationException {
43.63 if (this._inputNodeSet!=null) {
43.64 @@ -242,13 +244,13 @@
43.65 if (circumvent) {
43.66 XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
43.67 }
43.68 - this._inputNodeSet = new HashSet();
43.69 + this._inputNodeSet = new HashSet<Node>();
43.70 XMLUtils.getSet(_subNode,this._inputNodeSet, excludeNode, this.excludeComments);
43.71
43.72 return this._inputNodeSet;
43.73 } else if (this.isOctetStream()) {
43.74 convertToNodes();
43.75 - HashSet result=new HashSet();
43.76 + HashSet<Node> result=new HashSet<Node>();
43.77 XMLUtils.getSet(_subNode, result,null,false);
43.78 //this._inputNodeSet=result;
43.79 return result;
43.80 @@ -447,7 +449,7 @@
43.81 * @throws XMLSignatureException
43.82 * @return The HTML representation for this XMLSignature
43.83 */
43.84 - public String getHTMLRepresentation(Set inclusiveNamespaces)
43.85 + public String getHTMLRepresentation(Set<String> inclusiveNamespaces)
43.86 throws XMLSignatureException {
43.87
43.88 XMLSignatureInputDebugger db = new XMLSignatureInputDebugger( this,
43.89 @@ -584,7 +586,7 @@
43.90 /**
43.91 * @return the node filters
43.92 */
43.93 - public List getNodeFilters() {
43.94 + public List<NodeFilter> getNodeFilters() {
43.95 // TODO Auto-generated method stub
43.96 return nodeFilters;
43.97 }
44.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java Thu Oct 13 10:35:43 2011 -0700
44.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java Mon Oct 17 19:06:53 2011 -0700
44.3 @@ -47,9 +47,9 @@
44.4
44.5
44.6 /** Field _xmlSignatureInput */
44.7 - private Set _xpathNodeSet;
44.8 + private Set<Node> _xpathNodeSet;
44.9
44.10 - private Set _inclusiveNamespaces;
44.11 + private Set<String> _inclusiveNamespaces;
44.12
44.13 /** Field _doc */
44.14 private Document _doc = null;
44.15 @@ -159,7 +159,7 @@
44.16 * @param inclusiveNamespace
44.17 */
44.18 public XMLSignatureInputDebugger(
44.19 - XMLSignatureInput xmlSignatureInput, Set inclusiveNamespace) {
44.20 + XMLSignatureInput xmlSignatureInput, Set<String> inclusiveNamespace) {
44.21
44.22 this(xmlSignatureInput);
44.23
44.24 @@ -182,7 +182,7 @@
44.25 {
44.26
44.27 // get only a single node as anchor to fetch the owner document
44.28 - Node n = (Node) this._xpathNodeSet.iterator().next();
44.29 + Node n = this._xpathNodeSet.iterator().next();
44.30
44.31 this._doc = XMLUtils.getOwnerDocument(n);
44.32 }
44.33 @@ -341,10 +341,10 @@
44.34 // we output all Attrs which are available
44.35 NamedNodeMap attrs = currentElement.getAttributes();
44.36 int attrsLength = attrs.getLength();
44.37 - Object attrs2[] = new Object[attrsLength];
44.38 + Attr attrs2[] = new Attr[attrsLength];
44.39
44.40 for (int i = 0; i < attrsLength; i++) {
44.41 - attrs2[i] = attrs.item(i);
44.42 + attrs2[i] = (Attr)attrs.item(i);
44.43 }
44.44
44.45 Arrays.sort(attrs2, ATTR_COMPARE);
45.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java Thu Oct 13 10:35:43 2011 -0700
45.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java Mon Oct 17 19:06:53 2011 -0700
45.3 @@ -25,6 +25,7 @@
45.4 import java.security.AccessController;
45.5 import java.security.PrivilegedAction;
45.6 import java.util.HashMap;
45.7 +import java.util.Map;
45.8 import javax.xml.parsers.ParserConfigurationException;
45.9
45.10 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
45.11 @@ -65,9 +66,9 @@
45.12 private static boolean alreadyInitialized = false;
45.13
45.14 /** All available Transform classes are registered here */
45.15 - private static HashMap transformClassHash = null;
45.16 + private static Map<String, Class<?>> transformClassHash = null;
45.17
45.18 - private static HashMap transformSpiHash = new HashMap();
45.19 + private static Map<String, TransformSpi> transformSpiHash = new HashMap<String, TransformSpi>();
45.20
45.21 private TransformSpi transformSpi = null;
45.22
45.23 @@ -209,7 +210,7 @@
45.24 */
45.25 public static void init() {
45.26 if (!alreadyInitialized) {
45.27 - transformClassHash = new HashMap(10);
45.28 + transformClassHash = new HashMap<String,Class<?>>(10);
45.29 // make sure builtin algorithms are all registered first
45.30 com.sun.org.apache.xml.internal.security.Init.init();
45.31 alreadyInitialized = true;
45.32 @@ -231,7 +232,7 @@
45.33 throws AlgorithmAlreadyRegisteredException {
45.34
45.35 // are we already registered?
45.36 - Class registeredClass = getImplementingClass(algorithmURI);
45.37 + Class<? extends TransformSpi> registeredClass = getImplementingClass(algorithmURI);
45.38 if ((registeredClass != null) ) {
45.39 Object exArgs[] = { algorithmURI, registeredClass };
45.40 throw new AlgorithmAlreadyRegisteredException(
45.41 @@ -331,20 +332,21 @@
45.42 * @param URI
45.43 * @return The name of the class implementing the URI.
45.44 */
45.45 - private static Class getImplementingClass(String URI) {
45.46 - return (Class) transformClassHash.get(URI);
45.47 + @SuppressWarnings("unchecked")
45.48 + private static Class<? extends TransformSpi> getImplementingClass(String URI) {
45.49 + return (Class<? extends TransformSpi>)transformClassHash.get(URI);
45.50 }
45.51
45.52 private static TransformSpi getTransformSpi(String URI)
45.53 throws InvalidTransformException {
45.54 try {
45.55 - Object value = transformSpiHash.get(URI);
45.56 + TransformSpi value = transformSpiHash.get(URI);
45.57 if (value != null) {
45.58 - return (TransformSpi) value;
45.59 + return value;
45.60 }
45.61 - Class cl = (Class) transformClassHash.get(URI);
45.62 + Class<? extends TransformSpi> cl = getImplementingClass(URI);
45.63 if (cl != null) {
45.64 - TransformSpi tr = (TransformSpi) cl.newInstance();
45.65 + TransformSpi tr = cl.newInstance();
45.66 transformSpiHash.put(URI, tr);
45.67 return tr;
45.68 }
46.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java Thu Oct 13 10:35:43 2011 -0700
46.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java Mon Oct 17 19:06:53 2011 -0700
46.3 @@ -41,6 +41,7 @@
46.4 * For API compatibility not thread safe.
46.5 * @deprecated
46.6 */
46.7 + @Deprecated
46.8 protected Transform _transformObject = null;
46.9 /**
46.10 * Set the transform object.
46.11 @@ -48,6 +49,7 @@
46.12 * @param transform the Transform
46.13 * @deprecated
46.14 */
46.15 + @Deprecated
46.16 protected void setTransform(Transform transform) {
46.17 this._transformObject = transform;
46.18 }
46.19 @@ -120,6 +122,7 @@
46.20 * @throws SAXException
46.21 * @throws TransformationException
46.22 */
46.23 + @Deprecated
46.24 protected XMLSignatureInput enginePerformTransform(
46.25 XMLSignatureInput input)
46.26 throws IOException,
47.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java Thu Oct 13 10:35:43 2011 -0700
47.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java Mon Oct 17 19:06:53 2011 -0700
47.3 @@ -154,6 +154,7 @@
47.4 * @param vars
47.5 * @param globalsSize
47.6 */
47.7 + @SuppressWarnings("rawtypes")
47.8 public void fixupVariables(java.util.Vector vars, int globalsSize) {
47.9
47.10 // do nothing
48.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java Thu Oct 13 10:35:43 2011 -0700
48.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java Mon Oct 17 19:06:53 2011 -0700
48.3 @@ -96,9 +96,9 @@
48.4 throws TransformationException {
48.5 CachedXPathAPIHolder.setDoc(_transformObject.getElement().getOwnerDocument());
48.6 try {
48.7 - List unionNodes=new ArrayList();
48.8 - List substractNodes=new ArrayList();
48.9 - List intersectNodes=new ArrayList();
48.10 + List<NodeList> unionNodes=new ArrayList<NodeList>();
48.11 + List<NodeList> substractNodes=new ArrayList<NodeList>();
48.12 + List<NodeList> intersectNodes=new ArrayList<NodeList>();
48.13
48.14 CachedXPathFuncHereAPI xPathFuncHereAPI =
48.15 new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
48.16 @@ -170,18 +170,15 @@
48.17 throw new TransformationException("empty", ex);
48.18 }
48.19 }
48.20 - static Set convertNodeListToSet(List l){
48.21 - Set result=new HashSet();
48.22 - for (int j=0;j<l.size();j++) {
48.23 - NodeList rootNodes=(NodeList) l.get(j);
48.24 + static Set<Node> convertNodeListToSet(List<NodeList> l){
48.25 + Set<Node> result=new HashSet<Node>();
48.26 +
48.27 + for (NodeList rootNodes : l) {
48.28 int length = rootNodes.getLength();
48.29 -
48.30 for (int i = 0; i < length; i++) {
48.31 Node rootNode = rootNodes.item(i);
48.32 result.add(rootNode);
48.33 -
48.34 }
48.35 -
48.36 }
48.37 return result;
48.38 }
48.39 @@ -191,8 +188,8 @@
48.40 boolean hasUnionNodes;
48.41 boolean hasSubstractNodes;
48.42 boolean hasIntersectNodes;
48.43 - XPath2NodeFilter(Set unionNodes, Set substractNodes,
48.44 - Set intersectNodes) {
48.45 + XPath2NodeFilter(Set<Node> unionNodes, Set<Node> substractNodes,
48.46 + Set<Node> intersectNodes) {
48.47 this.unionNodes=unionNodes;
48.48 hasUnionNodes=!unionNodes.isEmpty();
48.49 this.substractNodes=substractNodes;
48.50 @@ -200,9 +197,9 @@
48.51 this.intersectNodes=intersectNodes;
48.52 hasIntersectNodes=!intersectNodes.isEmpty();
48.53 }
48.54 - Set unionNodes;
48.55 - Set substractNodes;
48.56 - Set intersectNodes;
48.57 + Set<Node> unionNodes;
48.58 + Set<Node> substractNodes;
48.59 + Set<Node> intersectNodes;
48.60
48.61
48.62 /**
48.63 @@ -282,16 +279,15 @@
48.64 *
48.65 * @return if rooted bye the rootnodes
48.66 */
48.67 - static boolean rooted(Node currentNode, Set nodeList ) {
48.68 + static boolean rooted(Node currentNode, Set<Node> nodeList ) {
48.69 if (nodeList.contains(currentNode)) {
48.70 return true;
48.71 }
48.72 - Iterator it=nodeList.iterator();
48.73 - while (it.hasNext()) {
48.74 - Node rootNode = (Node) it.next();
48.75 - if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) {
48.76 - return true;
48.77 - }
48.78 +
48.79 + for(Node rootNode : nodeList) {
48.80 + if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) {
48.81 + return true;
48.82 + }
48.83 }
48.84 return false;
48.85 }
48.86 @@ -303,7 +299,7 @@
48.87 *
48.88 * @return if rooted bye the rootnodes
48.89 */
48.90 - static boolean inList(Node currentNode, Set nodeList ) {
48.91 + static boolean inList(Node currentNode, Set<Node> nodeList ) {
48.92 return nodeList.contains(currentNode);
48.93 }
48.94 }
49.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java Thu Oct 13 10:35:43 2011 -0700
49.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java Mon Oct 17 19:06:53 2011 -0700
49.3 @@ -62,14 +62,6 @@
49.4 static final String defaultXSLTSpecNSprefix = "xslt";
49.5 static final String XSLTSTYLESHEET = "stylesheet";
49.6
49.7 - // check for secure processing feature
49.8 - private static Class xClass = null;
49.9 - static {
49.10 - try {
49.11 - xClass = Class.forName("javax.xml.XMLConstants");
49.12 - } catch (Exception e) {}
49.13 - }
49.14 -
49.15 static java.util.logging.Logger log =
49.16 java.util.logging.Logger.getLogger(
49.17 TransformXSLT.class.getName());
49.18 @@ -101,10 +93,6 @@
49.19 protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream baos, Transform _transformObject)
49.20 throws IOException,
49.21 TransformationException {
49.22 - if (xClass == null) {
49.23 - Object exArgs[] = { "SECURE_PROCESSING_FEATURE not supported" };
49.24 - throw new TransformationException("generic.EmptyMessage", exArgs);
49.25 - }
49.26 try {
49.27 Element transformElement = _transformObject.getElement();
49.28
49.29 @@ -119,11 +107,9 @@
49.30 }
49.31
49.32 TransformerFactory tFactory = TransformerFactory.newInstance();
49.33 - Class c = tFactory.getClass();
49.34 - Method m = c.getMethod("setFeature", new Class[] {String.class, boolean.class});
49.35 +
49.36 // Process XSLT stylesheets in a secure manner
49.37 - m.invoke(tFactory, new Object[] {"http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE});
49.38 -
49.39 + tFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE);
49.40 /*
49.41 * This transform requires an octet stream as input. If the actual
49.42 * input is an XPath node-set, then the signature application should
49.43 @@ -193,18 +179,6 @@
49.44 Object exArgs[] = { ex.getMessage() };
49.45
49.46 throw new TransformationException("generic.EmptyMessage", exArgs, ex);
49.47 - } catch (NoSuchMethodException ex) {
49.48 - Object exArgs[] = { ex.getMessage() };
49.49 -
49.50 - throw new TransformationException("generic.EmptyMessage", exArgs, ex);
49.51 - } catch (IllegalAccessException ex) {
49.52 - Object exArgs[] = { ex.getMessage() };
49.53 -
49.54 - throw new TransformationException("generic.EmptyMessage", exArgs, ex);
49.55 - } catch (java.lang.reflect.InvocationTargetException ex) {
49.56 - Object exArgs[] = { ex.getMessage() };
49.57 -
49.58 - throw new TransformationException("generic.EmptyMessage", exArgs, ex);
49.59 }
49.60 }
49.61 }
50.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java Thu Oct 13 10:35:43 2011 -0700
50.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java Mon Oct 17 19:06:53 2011 -0700
50.3 @@ -74,19 +74,16 @@
50.4 * @param doc
50.5 * @param prefixes
50.6 */
50.7 - public InclusiveNamespaces(Document doc, Set prefixes) {
50.8 + public InclusiveNamespaces(Document doc, Set<String> prefixes) {
50.9
50.10 super(doc);
50.11
50.12 StringBuffer sb = new StringBuffer();
50.13 - SortedSet prefixList = new TreeSet(prefixes);
50.14 + SortedSet<String> prefixList = new TreeSet<String>(prefixes);
50.15
50.16
50.17 - Iterator it = prefixList.iterator();
50.18
50.19 - while (it.hasNext()) {
50.20 - String prefix = (String) it.next();
50.21 -
50.22 + for (String prefix : prefixList) {
50.23 if (prefix.equals("xmlns")) {
50.24 sb.append("#default ");
50.25 } else {
50.26 @@ -138,9 +135,9 @@
50.27 * @param inclusiveNamespaces
50.28 * @return A set to string
50.29 */
50.30 - public static SortedSet prefixStr2Set(String inclusiveNamespaces) {
50.31 + public static SortedSet<String> prefixStr2Set(String inclusiveNamespaces) {
50.32
50.33 - SortedSet prefixes = new TreeSet();
50.34 + SortedSet<String> prefixes = new TreeSet<String>();
50.35
50.36 if ((inclusiveNamespaces == null)
50.37 || (inclusiveNamespaces.length() == 0)) {
51.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java Thu Oct 13 10:35:43 2011 -0700
51.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java Mon Oct 17 19:06:53 2011 -0700
51.3 @@ -28,8 +28,8 @@
51.4 */
51.5 public class CachedXPathAPIHolder {
51.6
51.7 - static ThreadLocal local=new ThreadLocal();
51.8 - static ThreadLocal localDoc=new ThreadLocal();
51.9 + static ThreadLocal<CachedXPathAPI> local=new ThreadLocal<CachedXPathAPI>();
51.10 + static ThreadLocal<Document> localDoc=new ThreadLocal<Document>();
51.11
51.12 /**
51.13 * Sets the doc for the xpath transformation. Resets the cache if needed
51.14 @@ -37,7 +37,7 @@
51.15 */
51.16 public static void setDoc(Document doc) {
51.17 if (localDoc.get()!=doc) {
51.18 - CachedXPathAPI cx=(CachedXPathAPI)local.get();
51.19 + CachedXPathAPI cx=local.get();
51.20 if (cx==null) {
51.21 cx=new CachedXPathAPI();
51.22 local.set(cx);
51.23 @@ -54,7 +54,7 @@
51.24 * @return the cachexpathapi for this thread
51.25 */
51.26 public static CachedXPathAPI getCachedXPathAPI() {
51.27 - CachedXPathAPI cx=(CachedXPathAPI)local.get();
51.28 + CachedXPathAPI cx=local.get();
51.29 if (cx==null) {
51.30 cx=new CachedXPathAPI();
51.31 local.set(cx);
52.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java Thu Oct 13 10:35:43 2011 -0700
52.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java Mon Oct 17 19:06:53 2011 -0700
52.3 @@ -173,6 +173,7 @@
52.4 * @throws TransformerException
52.5 * @deprecated
52.6 */
52.7 + @Deprecated
52.8 public NodeIterator selectNodeIterator(
52.9 Node contextNode, Node xpathnode, Node namespaceNode)
52.10 throws TransformerException {
52.11 @@ -195,6 +196,7 @@
52.12 * @throws TransformerException
52.13 * @deprecated
52.14 */
52.15 + @Deprecated
52.16 public NodeList selectNodeList(Node contextNode, Node xpathnode)
52.17 throws TransformerException {
52.18 return selectNodeList(contextNode, xpathnode, getStrFromNode(xpathnode), contextNode);
52.19 @@ -239,6 +241,7 @@
52.20 * @throws TransformerException
52.21 * @deprecated
52.22 */
52.23 + @Deprecated
52.24 public XObject eval(Node contextNode, Node xpathnode)
52.25 throws TransformerException {
52.26 return eval(contextNode, xpathnode, getStrFromNode(xpathnode),contextNode);
52.27 @@ -375,12 +378,12 @@
52.28
52.29 private XPath createXPath(String str, PrefixResolver prefixResolver) throws TransformerException {
52.30 XPath xpath = null;
52.31 - Class[] classes = new Class[]{String.class, SourceLocator.class, PrefixResolver.class, int.class,
52.32 + Class<?>[] classes = new Class<?>[]{String.class, SourceLocator.class, PrefixResolver.class, int.class,
52.33 ErrorListener.class, FunctionTable.class};
52.34 Object[] objects = new Object[]{str, null, prefixResolver, new Integer(XPath.SELECT), null, _funcTable};
52.35 try {
52.36 - Constructor constructor = XPath.class.getConstructor(classes);
52.37 - xpath = (XPath) constructor.newInstance(objects);
52.38 + Constructor<XPath> constructor = XPath.class.getConstructor(classes);
52.39 + xpath = constructor.newInstance(objects);
52.40 } catch (Throwable t) {
52.41 }
52.42 if (xpath == null) {
53.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java Thu Oct 13 10:35:43 2011 -0700
53.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java Mon Oct 17 19:06:53 2011 -0700
53.3 @@ -24,6 +24,7 @@
53.4
53.5 import java.math.BigInteger;
53.6 import java.util.HashMap;
53.7 +import java.util.Map;
53.8
53.9 import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
53.10 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
53.11 @@ -370,6 +371,7 @@
53.12 * @return the bytes
53.13 * @throws XMLSecurityException
53.14 */
53.15 + @Deprecated
53.16 public byte[] getBytesFromChildElement(String localname, String namespace)
53.17 throws XMLSecurityException {
53.18
53.19 @@ -392,14 +394,12 @@
53.20 */
53.21 public String getTextFromChildElement(String localname, String namespace) {
53.22
53.23 - Text t =
53.24 - (Text) XMLUtils.selectNode(
53.25 - this._constructionElement.getFirstChild(),
53.26 - namespace,
53.27 - localname,
53.28 - 0).getFirstChild();
53.29 + return XMLUtils.selectNode(
53.30 + this._constructionElement.getFirstChild(),
53.31 + namespace,
53.32 + localname,
53.33 + 0).getFirstChild().getNodeValue();
53.34
53.35 - return t.getData();
53.36 }
53.37
53.38 /**
53.39 @@ -493,8 +493,8 @@
53.40 }
53.41
53.42 /** Field _prefixMappings */
53.43 - static HashMap _prefixMappings = new HashMap();
53.44 - static HashMap _prefixMappingsBindings = new HashMap();
53.45 + static Map<String, String> _prefixMappings = new HashMap<String,String>();
53.46 + static Map<String, String> _prefixMappingsBindings = new HashMap<String,String>();
53.47
53.48 /**
53.49 * Method setDefaultPrefix
53.50 @@ -533,10 +533,10 @@
53.51 * @return the default prefix bind to this element.
53.52 */
53.53 public static String getDefaultPrefix(String namespace) {
53.54 - return (String) ElementProxy._prefixMappings.get(namespace);
53.55 + return ElementProxy._prefixMappings.get(namespace);
53.56 }
53.57
53.58 public static String getDefaultPrefixBindings(String namespace) {
53.59 - return (String) ElementProxy._prefixMappingsBindings.get(namespace);
53.60 + return ElementProxy._prefixMappingsBindings.get(namespace);
53.61 }
53.62 }
54.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java Thu Oct 13 10:35:43 2011 -0700
54.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java Mon Oct 17 19:06:53 2011 -0700
54.3 @@ -21,6 +21,7 @@
54.4 package com.sun.org.apache.xml.internal.security.utils;
54.5
54.6 import java.util.ArrayList;
54.7 +import java.util.List;
54.8
54.9 import org.w3c.dom.Document;
54.10 import org.w3c.dom.Node;
54.11 @@ -34,7 +35,7 @@
54.12 public class HelperNodeList implements NodeList {
54.13
54.14 /** Field nodes */
54.15 - ArrayList nodes = new ArrayList(20);
54.16 + List<Node> nodes = new ArrayList<Node>(20);
54.17 boolean _allNodesMustHaveSameParent = false;
54.18
54.19 /**
54.20 @@ -62,7 +63,7 @@
54.21
54.22 // log.log(java.util.logging.Level.FINE, "item(" + index + ") of " + this.getLength() + " nodes");
54.23
54.24 - return (Node) nodes.get(index);
54.25 + return nodes.get(index);
54.26 }
54.27
54.28 /**
55.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java Thu Oct 13 10:35:43 2011 -0700
55.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java Mon Oct 17 19:06:53 2011 -0700
55.3 @@ -23,6 +23,7 @@
55.4 import java.lang.ref.WeakReference;
55.5 import java.util.Arrays;
55.6 import java.util.WeakHashMap;
55.7 +import java.util.Map;
55.8
55.9 import org.w3c.dom.Attr;
55.10 import org.w3c.dom.Document;
55.11 @@ -52,7 +53,8 @@
55.12 private static java.util.logging.Logger log =
55.13 java.util.logging.Logger.getLogger(IdResolver.class.getName());
55.14
55.15 - private static WeakHashMap docMap = new WeakHashMap();
55.16 + private static Map<Document, Map<String, WeakReference<Element>>> docMap =
55.17 + new WeakHashMap<Document, Map<String, WeakReference<Element>>>();
55.18
55.19 /**
55.20 * Constructor IdResolver
55.21 @@ -70,15 +72,15 @@
55.22 */
55.23 public static void registerElementById(Element element, String idValue) {
55.24 Document doc = element.getOwnerDocument();
55.25 - WeakHashMap elementMap;
55.26 + Map<String, WeakReference<Element>> elementMap;
55.27 synchronized (docMap) {
55.28 - elementMap = (WeakHashMap) docMap.get(doc);
55.29 + elementMap = docMap.get(doc);
55.30 if (elementMap == null) {
55.31 - elementMap = new WeakHashMap();
55.32 + elementMap = new WeakHashMap<String, WeakReference<Element>>();
55.33 docMap.put(doc, elementMap);
55.34 }
55.35 }
55.36 - elementMap.put(idValue, new WeakReference(element));
55.37 + elementMap.put(idValue, new WeakReference<Element>(element));
55.38 }
55.39
55.40 /**
55.41 @@ -156,20 +158,20 @@
55.42 private static Element getElementByIdType(Document doc, String id) {
55.43 if (log.isLoggable(java.util.logging.Level.FINE))
55.44 log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id);
55.45 - WeakHashMap elementMap;
55.46 + Map<String, WeakReference<Element>> elementMap;
55.47 synchronized (docMap) {
55.48 - elementMap = (WeakHashMap) docMap.get(doc);
55.49 + elementMap = docMap.get(doc);
55.50 }
55.51 if (elementMap != null) {
55.52 - WeakReference weakReference = (WeakReference) elementMap.get(id);
55.53 + WeakReference<Element> weakReference = elementMap.get(id);
55.54 if (weakReference != null) {
55.55 - return (Element) weakReference.get();
55.56 + return weakReference.get();
55.57 }
55.58 }
55.59 return null;
55.60 }
55.61
55.62 - private static java.util.List names;
55.63 + private static java.util.List<String> names;
55.64 private static int namesLength;
55.65 static {
55.66 String namespaces[]={
56.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java Thu Oct 13 10:35:43 2011 -0700
56.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java Mon Oct 17 19:06:53 2011 -0700
56.3 @@ -33,8 +33,8 @@
56.4
56.5 final byte[] buf;
56.6 static final int size=8*1024;
56.7 - private static ThreadLocal bufCahce = new ThreadLocal() {
56.8 - protected synchronized Object initialValue() {
56.9 + private static ThreadLocal<byte[]> bufCahce = new ThreadLocal<byte[]>() {
56.10 + protected synchronized byte[] initialValue() {
56.11 return new byte[size];
56.12 }
56.13 };
56.14 @@ -44,7 +44,7 @@
56.15 * @param out the outputstream to buffer
56.16 */
56.17 public UnsyncBufferedOutputStream(OutputStream out) {
56.18 - buf=(byte[])bufCahce.get();
56.19 + buf=bufCahce.get();
56.20 this.out=out;
56.21 }
56.22
57.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Thu Oct 13 10:35:43 2011 -0700
57.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Mon Oct 17 19:06:53 2011 -0700
57.3 @@ -29,8 +29,8 @@
57.4 */
57.5 public class UnsyncByteArrayOutputStream extends OutputStream {
57.6 private static final int INITIAL_SIZE = 8192;
57.7 - private static ThreadLocal bufCache = new ThreadLocal() {
57.8 - protected synchronized Object initialValue() {
57.9 + private static ThreadLocal<byte[]> bufCache = new ThreadLocal<byte[]>() {
57.10 + protected synchronized byte[] initialValue() {
57.11 return new byte[INITIAL_SIZE];
57.12 }
57.13 };
57.14 @@ -40,7 +40,7 @@
57.15 private int pos = 0;
57.16
57.17 public UnsyncByteArrayOutputStream() {
57.18 - buf = (byte[])bufCache.get();
57.19 + buf = bufCache.get();
57.20 }
57.21
57.22 public void write(byte[] arg0) {
58.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Thu Oct 13 10:35:43 2011 -0700
58.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Mon Oct 17 19:06:53 2011 -0700
58.3 @@ -82,13 +82,15 @@
58.4 * @param exclude
58.5 * @param com wheather comments or not
58.6 */
58.7 - public static void getSet(Node rootNode,Set result,Node exclude ,boolean com) {
58.8 + public static void getSet(Node rootNode,Set<Node> result,Node exclude ,boolean com) {
58.9 if ((exclude!=null) && isDescendantOrSelf(exclude,rootNode)){
58.10 return;
58.11 }
58.12 getSetRec(rootNode,result,exclude,com);
58.13 }
58.14 - static final void getSetRec(final Node rootNode,final Set result,
58.15 +
58.16 + @SuppressWarnings("fallthrough")
58.17 + static final void getSetRec(final Node rootNode,final Set<Node> result,
58.18 final Node exclude ,final boolean com) {
58.19 //Set result = new HashSet();
58.20 if (rootNode==exclude) {
58.21 @@ -104,7 +106,7 @@
58.22 result.add(nl.item(i));
58.23 }
58.24 }
58.25 - //no return keep working
58.26 + //no return keep working - ignore fallthrough warning
58.27 case Node.DOCUMENT_NODE:
58.28 for (Node r=rootNode.getFirstChild();r!=null;r=r.getNextSibling()){
58.29 if (r.getNodeType()==Node.TEXT_NODE) {
58.30 @@ -230,7 +232,7 @@
58.31
58.32
58.33 static String dsPrefix=null;
58.34 - static Map namePrefixes=new HashMap();
58.35 + static Map<String, String> namePrefixes=new HashMap<String, String>();
58.36 /**
58.37 * Creates an Element in the XML Signature specification namespace.
58.38 *
58.39 @@ -248,7 +250,7 @@
58.40 if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
58.41 return doc.createElementNS(Constants.SignatureSpecNS, elementName);
58.42 }
58.43 - String namePrefix=(String) namePrefixes.get(elementName);
58.44 + String namePrefix= namePrefixes.get(elementName);
58.45 if (namePrefix==null) {
58.46 StringBuffer tag=new StringBuffer(dsPrefix);
58.47 tag.append(':');
58.48 @@ -318,11 +320,9 @@
58.49 * @param xpathNodeSet
58.50 * @return the owner document
58.51 */
58.52 - public static Document getOwnerDocument(Set xpathNodeSet) {
58.53 + public static Document getOwnerDocument(Set<Node> xpathNodeSet) {
58.54 NullPointerException npe = null;
58.55 - Iterator iterator = xpathNodeSet.iterator();
58.56 - while(iterator.hasNext()) {
58.57 - Node node = (Node) iterator.next();
58.58 + for (Node node : xpathNodeSet) {
58.59 int nodeType =node.getNodeType();
58.60 if (nodeType == Node.DOCUMENT_NODE) {
58.61 return (Document) node;
58.62 @@ -397,14 +397,14 @@
58.63 * @param xpathNodeSet
58.64 * @return the set with the nodelist
58.65 */
58.66 - public static Set convertNodelistToSet(NodeList xpathNodeSet) {
58.67 + public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet) {
58.68
58.69 if (xpathNodeSet == null) {
58.70 - return new HashSet();
58.71 + return new HashSet<Node>();
58.72 }
58.73
58.74 int length = xpathNodeSet.getLength();
58.75 - Set set = new HashSet(length);
58.76 + Set<Node> set = new HashSet<Node>(length);
58.77
58.78 for (int i = 0; i < length; i++) {
58.79 set.add(xpathNodeSet.item(i));
58.80 @@ -446,6 +446,7 @@
58.81 * @param node
58.82 * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">Namespace axis resolution is not XPath compliant </A>
58.83 */
58.84 + @SuppressWarnings("fallthrough")
58.85 private static void circumventBug2650internal(Node node) {
58.86 Node parent=null;
58.87 Node sibling=null;
58.88 @@ -642,12 +643,12 @@
58.89 * @param inputSet
58.90 * @return nodes with the constrain
58.91 */
58.92 - public static Set excludeNodeFromSet(Node signatureElement, Set inputSet) {
58.93 - Set resultSet = new HashSet();
58.94 - Iterator iterator = inputSet.iterator();
58.95 + public static Set<Node> excludeNodeFromSet(Node signatureElement, Set<Node> inputSet) {
58.96 + Set<Node> resultSet = new HashSet<Node>();
58.97 + Iterator<Node> iterator = inputSet.iterator();
58.98
58.99 while (iterator.hasNext()) {
58.100 - Node inputNode = (Node) iterator.next();
58.101 + Node inputNode = iterator.next();
58.102
58.103 if (!XMLUtils
58.104 .isDescendantOrSelf(signatureElement, inputNode)) {
59.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java Thu Oct 13 10:35:43 2011 -0700
59.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java Mon Oct 17 19:06:53 2011 -0700
59.3 @@ -56,7 +56,7 @@
59.4 static boolean _alreadyInitialized = false;
59.5
59.6 /** these are the system-wide resolvers */
59.7 - static List _resolverVector = null;
59.8 + static List<ResourceResolver> _resolverVector = null;
59.9
59.10 static boolean allThreadSafeInList=true;
59.11
59.12 @@ -102,7 +102,7 @@
59.13 int length=ResourceResolver._resolverVector.size();
59.14 for (int i = 0; i < length; i++) {
59.15 ResourceResolver resolver =
59.16 - (ResourceResolver) ResourceResolver._resolverVector.get(i);
59.17 + ResourceResolver._resolverVector.get(i);
59.18 ResourceResolver resolverTmp=null;
59.19 try {
59.20 resolverTmp = allThreadSafeInList || resolver._resolverSpi.engineIsThreadSafe() ? resolver :
59.21 @@ -120,7 +120,7 @@
59.22 if (i!=0) {
59.23 //update resolver.
59.24 //System.out.println("Swaping");
59.25 - List resolverVector=(List)((ArrayList)_resolverVector).clone();
59.26 + List<ResourceResolver> resolverVector=getResolverVectorClone();
59.27 resolverVector.remove(i);
59.28 resolverVector.add(0,resolver);
59.29 _resolverVector=resolverVector;
59.30 @@ -139,6 +139,17 @@
59.31 throw new ResourceResolverException("utils.resolver.noClass", exArgs,
59.32 uri, BaseURI);
59.33 }
59.34 +
59.35 + /**
59.36 + * Method getResolverVectorClone
59.37 + *
59.38 + * @return clone of _resolverVector
59.39 + */
59.40 + @SuppressWarnings("unchecked")
59.41 + private static List<ResourceResolver> getResolverVectorClone() {
59.42 + return (List<ResourceResolver>)((ArrayList<ResourceResolver>)_resolverVector).clone();
59.43 + }
59.44 +
59.45 /**
59.46 * Method getInstance
59.47 *
59.48 @@ -150,7 +161,7 @@
59.49 * @throws ResourceResolverException
59.50 */
59.51 public static final ResourceResolver getInstance(
59.52 - Attr uri, String BaseURI, List individualResolvers)
59.53 + Attr uri, String BaseURI, List<ResourceResolver> individualResolvers)
59.54 throws ResourceResolverException {
59.55 if (log.isLoggable(java.util.logging.Level.FINE)) {
59.56
59.57 @@ -163,7 +174,7 @@
59.58 if ((individualResolvers != null) && ((size=individualResolvers.size()) > 0)) {
59.59 for (int i = 0; i < size; i++) {
59.60 ResourceResolver resolver =
59.61 - (ResourceResolver) individualResolvers.get(i);
59.62 + individualResolvers.get(i);
59.63
59.64 if (resolver != null) {
59.65 String currentClass = resolver._resolverSpi.getClass().getName();
59.66 @@ -186,7 +197,7 @@
59.67 public static void init() {
59.68
59.69 if (!ResourceResolver._alreadyInitialized) {
59.70 - ResourceResolver._resolverVector = new ArrayList(10);
59.71 + ResourceResolver._resolverVector = new ArrayList<ResourceResolver>(10);
59.72 _alreadyInitialized = true;
59.73 }
59.74 }
59.75 @@ -288,7 +299,7 @@
59.76 *
59.77 * @param properties
59.78 */
59.79 - public void addProperties(Map properties) {
59.80 + public void addProperties(Map<String,String> properties) {
59.81 this._resolverSpi.engineAddProperies(properties);
59.82 }
59.83
60.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java Thu Oct 13 10:35:43 2011 -0700
60.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java Mon Oct 17 19:06:53 2011 -0700
60.3 @@ -41,7 +41,7 @@
60.4 ResourceResolverSpi.class.getName());
60.5
60.6 /** Field _properties */
60.7 - protected java.util.Map _properties = null;
60.8 + protected java.util.Map<String,String> _properties = null;
60.9
60.10 /**
60.11 * This is the workhorse method used to resolve resources.
60.12 @@ -63,7 +63,7 @@
60.13 */
60.14 public void engineSetProperty(String key, String value) {
60.15 if (_properties==null) {
60.16 - _properties=new HashMap();
60.17 + _properties=new HashMap<String,String>();
60.18 }
60.19 this._properties.put(key, value);
60.20 }
60.21 @@ -78,17 +78,17 @@
60.22 if (_properties==null) {
60.23 return null;
60.24 }
60.25 - return (String) this._properties.get(key);
60.26 + return this._properties.get(key);
60.27 }
60.28
60.29 /**
60.30 *
60.31 * @param properties
60.32 */
60.33 - public void engineAddProperies(Map properties) {
60.34 + public void engineAddProperies(Map<String,String> properties) {
60.35 if (properties!=null) {
60.36 if (_properties==null) {
60.37 - _properties=new HashMap();
60.38 + _properties=new HashMap<String,String>();
60.39 }
60.40 this._properties.putAll(properties);
60.41 }
61.1 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java Thu Oct 13 10:35:43 2011 -0700
61.2 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java Mon Oct 17 19:06:53 2011 -0700
61.3 @@ -289,7 +289,7 @@
61.4 * @inheritDoc
61.5 */
61.6 public String[] engineGetPropertyKeys() {
61.7 - return (String[]) ResolverDirectHTTP.properties.clone();
61.8 + return ResolverDirectHTTP.properties.clone();
61.9 }
61.10
61.11 private URI getNewURI(String uri, String BaseURI)
62.1 --- a/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Thu Oct 13 10:35:43 2011 -0700
62.2 +++ b/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Mon Oct 17 19:06:53 2011 -0700
62.3 @@ -725,7 +725,7 @@
62.4 cred = builder.action().getCreds();
62.5 }
62.6 if (storeKey) {
62.7 - encKeys = builder.getKeys();
62.8 + encKeys = builder.getKeys(isInitiator);
62.9 // When encKeys is empty, the login actually fails.
62.10 // For compatibility, exception is thrown in commit().
62.11 }
63.1 --- a/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java Thu Oct 13 10:35:43 2011 -0700
63.2 +++ b/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java Mon Oct 17 19:06:53 2011 -0700
63.3 @@ -44,7 +44,7 @@
63.4 int timeout = 0;
63.5 boolean connected = false;
63.6 private int trafficClass = 0;
63.7 - private InetAddress connectedAddress = null;
63.8 + protected InetAddress connectedAddress = null;
63.9 private int connectedPort = -1;
63.10
63.11 /* cached socket options */
64.1 --- a/src/share/classes/java/net/AbstractPlainSocketImpl.java Thu Oct 13 10:35:43 2011 -0700
64.2 +++ b/src/share/classes/java/net/AbstractPlainSocketImpl.java Mon Oct 17 19:06:53 2011 -0700
64.3 @@ -71,7 +71,7 @@
64.4
64.5 /* whether this Socket is a stream (TCP) socket or not (UDP)
64.6 */
64.7 - private boolean stream;
64.8 + protected boolean stream;
64.9
64.10 /**
64.11 * Load net library into runtime.
64.12 @@ -86,10 +86,11 @@
64.13 * is a stream socket (true) or an unconnected UDP socket (false).
64.14 */
64.15 protected synchronized void create(boolean stream) throws IOException {
64.16 - fd = new FileDescriptor();
64.17 this.stream = stream;
64.18 if (!stream) {
64.19 ResourceManager.beforeUdpCreate();
64.20 + // only create the fd after we know we will be able to create the socket
64.21 + fd = new FileDescriptor();
64.22 try {
64.23 socketCreate(false);
64.24 } catch (IOException ioe) {
64.25 @@ -98,6 +99,7 @@
64.26 throw ioe;
64.27 }
64.28 } else {
64.29 + fd = new FileDescriptor();
64.30 socketCreate(true);
64.31 }
64.32 if (socket != null)
65.1 --- a/src/share/classes/java/net/DatagramSocket.java Thu Oct 13 10:35:43 2011 -0700
65.2 +++ b/src/share/classes/java/net/DatagramSocket.java Mon Oct 17 19:06:53 2011 -0700
65.3 @@ -287,7 +287,7 @@
65.4 AccessController.doPrivileged(
65.5 new PrivilegedExceptionAction<Void>() {
65.6 public Void run() throws NoSuchMethodException {
65.7 - Class[] cl = new Class[1];
65.8 + Class<?>[] cl = new Class<?>[1];
65.9 cl[0] = DatagramPacket.class;
65.10 impl.getClass().getDeclaredMethod("peekData", cl);
65.11 return null;
66.1 --- a/src/share/classes/java/net/InMemoryCookieStore.java Thu Oct 13 10:35:43 2011 -0700
66.2 +++ b/src/share/classes/java/net/InMemoryCookieStore.java Mon Oct 17 19:06:53 2011 -0700
66.3 @@ -91,8 +91,10 @@
66.4 if (cookie.getDomain() != null) {
66.5 addIndex(domainIndex, cookie.getDomain(), cookie);
66.6 }
66.7 - // add it to uri index, too
66.8 - addIndex(uriIndex, getEffectiveURI(uri), cookie);
66.9 + if (uri != null) {
66.10 + // add it to uri index, too
66.11 + addIndex(uriIndex, getEffectiveURI(uri), cookie);
66.12 + }
66.13 }
66.14 } finally {
66.15 lock.unlock();
67.1 --- a/src/share/classes/java/security/Signature.java Thu Oct 13 10:35:43 2011 -0700
67.2 +++ b/src/share/classes/java/security/Signature.java Mon Oct 17 19:06:53 2011 -0700
67.3 @@ -899,6 +899,7 @@
67.4 * and its original parent (Object).
67.5 */
67.6
67.7 + @SuppressWarnings("deprecation")
67.8 private static class Delegate extends Signature {
67.9
67.10 // The provider implementation (delegate)
67.11 @@ -1203,6 +1204,7 @@
67.12 }
67.13
67.14 // adapter for RSA/ECB/PKCS1Padding ciphers
67.15 + @SuppressWarnings("deprecation")
67.16 private static class CipherAdapter extends SignatureSpi {
67.17
67.18 private final Cipher cipher;
68.1 --- a/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Thu Oct 13 10:35:43 2011 -0700
68.2 +++ b/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Mon Oct 17 19:06:53 2011 -0700
68.3 @@ -117,7 +117,7 @@
68.4 * The set contains elements of type,
68.5 * <code>PrivateCredentialPermission.CredOwner</code>.
68.6 */
68.7 - private Set principals; // ignored - kept around for compatibility
68.8 + private Set<Principal> principals; // ignored - kept around for compatibility
68.9 private transient CredOwner[] credOwners;
68.10
68.11 /**
69.1 --- a/src/share/classes/javax/security/auth/Subject.java Thu Oct 13 10:35:43 2011 -0700
69.2 +++ b/src/share/classes/javax/security/auth/Subject.java Mon Oct 17 19:06:53 2011 -0700
69.3 @@ -1291,6 +1291,7 @@
69.4 oos.writeFields();
69.5 }
69.6
69.7 + @SuppressWarnings("unchecked")
69.8 private void readObject(ObjectInputStream ois)
69.9 throws IOException, ClassNotFoundException
69.10 {
69.11 @@ -1329,6 +1330,7 @@
69.12 }
69.13 }
69.14
69.15 + @SuppressWarnings("unchecked") /*To suppress warning from line 1374*/
69.16 private void populateSet() {
69.17 final Iterator<?> iterator;
69.18 switch(which) {
70.1 --- a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Thu Oct 13 10:35:43 2011 -0700
70.2 +++ b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Mon Oct 17 19:06:53 2011 -0700
70.3 @@ -56,6 +56,7 @@
70.4 sun.security.util.Debug.getInstance("combiner",
70.5 "\t[SubjectDomainCombiner]");
70.6
70.7 + @SuppressWarnings("deprecation")
70.8 // Note: check only at classloading time, not dynamically during combine()
70.9 private static final boolean useJavaxPolicy =
70.10 javax.security.auth.Policy.isCustomPolicySet(debug);
70.11 @@ -300,6 +301,7 @@
70.12 if (!allowCaching) {
70.13 java.security.AccessController.doPrivileged
70.14 (new PrivilegedAction<Void>() {
70.15 + @SuppressWarnings("deprecation")
70.16 public Void run() {
70.17 // Call refresh only caching is disallowed
70.18 javax.security.auth.Policy.getPolicy().refresh();
70.19 @@ -308,6 +310,7 @@
70.20 });
70.21 }
70.22
70.23 +
70.24 int cLen = (currentDomains == null ? 0 : currentDomains.length);
70.25 int aLen = (assignedDomains == null ? 0 : assignedDomains.length);
70.26
70.27 @@ -348,13 +351,13 @@
70.28 // get the original perms
70.29 Permissions perms = new Permissions();
70.30 PermissionCollection coll = pd.getPermissions();
70.31 - java.util.Enumeration e;
70.32 + java.util.Enumeration<Permission> e;
70.33 if (coll != null) {
70.34 synchronized (coll) {
70.35 e = coll.elements();
70.36 while (e.hasMoreElements()) {
70.37 Permission newPerm =
70.38 - (Permission)e.nextElement();
70.39 + e.nextElement();
70.40 perms.add(newPerm);
70.41 }
70.42 }
70.43 @@ -367,6 +370,7 @@
70.44 PermissionCollection newPerms =
70.45 java.security.AccessController.doPrivileged
70.46 (new PrivilegedAction<PermissionCollection>() {
70.47 + @SuppressWarnings("deprecation")
70.48 public PermissionCollection run() {
70.49 return
70.50 javax.security.auth.Policy.getPolicy().getPermissions
70.51 @@ -379,7 +383,7 @@
70.52 synchronized (newPerms) {
70.53 e = newPerms.elements();
70.54 while (e.hasMoreElements()) {
70.55 - Permission newPerm = (Permission)e.nextElement();
70.56 + Permission newPerm = e.nextElement();
70.57 if (!perms.implies(newPerm)) {
70.58 perms.add(newPerm);
70.59 if (debug != null)
71.1 --- a/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Thu Oct 13 10:35:43 2011 -0700
71.2 +++ b/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Mon Oct 17 19:06:53 2011 -0700
71.3 @@ -375,6 +375,7 @@
71.4 /*
71.5 * Reads in a Vector of DelegationPermissions and saves them in the perms field.
71.6 */
71.7 + @SuppressWarnings("unchecked")
71.8 private void readObject(ObjectInputStream in) throws IOException,
71.9 ClassNotFoundException {
71.10 // Don't call defaultReadObject()
72.1 --- a/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Thu Oct 13 10:35:43 2011 -0700
72.2 +++ b/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Mon Oct 17 19:06:53 2011 -0700
72.3 @@ -583,6 +583,7 @@
72.4 /*
72.5 * Reads in a Vector of ServicePermissions and saves them in the perms field.
72.6 */
72.7 + @SuppressWarnings("unchecked")
72.8 private void readObject(ObjectInputStream in) throws IOException,
72.9 ClassNotFoundException {
72.10 // Don't call defaultReadObject()
73.1 --- a/src/share/classes/javax/security/auth/login/LoginContext.java Thu Oct 13 10:35:43 2011 -0700
73.2 +++ b/src/share/classes/javax/security/auth/login/LoginContext.java Mon Oct 17 19:06:53 2011 -0700
73.3 @@ -214,14 +214,14 @@
73.4 private boolean subjectProvided = false;
73.5 private boolean loginSucceeded = false;
73.6 private CallbackHandler callbackHandler;
73.7 - private Map state = new HashMap();
73.8 + private Map<String,?> state = new HashMap<String,Object>();
73.9
73.10 private Configuration config;
73.11 private boolean configProvided = false;
73.12 private AccessControlContext creatorAcc = null;
73.13 private ModuleInfo[] moduleStack;
73.14 private ClassLoader contextClassLoader = null;
73.15 - private static final Class[] PARAMS = { };
73.16 + private static final Class<?>[] PARAMS = { };
73.17
73.18 // state saved in the event a user-specified asynchronous exception
73.19 // was specified and thrown
73.20 @@ -306,7 +306,7 @@
73.21 (DEFAULT_HANDLER);
73.22 if (defaultHandler == null || defaultHandler.length() == 0)
73.23 return null;
73.24 - Class c = Class.forName(defaultHandler,
73.25 + Class<?> c = Class.forName(defaultHandler,
73.26 true,
73.27 finalLoader);
73.28 return (CallbackHandler)c.newInstance();
73.29 @@ -743,12 +743,12 @@
73.30 } else {
73.31
73.32 // instantiate the LoginModule
73.33 - Class c = Class.forName
73.34 + Class<?> c = Class.forName
73.35 (moduleStack[i].entry.getLoginModuleName(),
73.36 true,
73.37 contextClassLoader);
73.38
73.39 - Constructor constructor = c.getConstructor(PARAMS);
73.40 + Constructor<?> constructor = c.getConstructor(PARAMS);
73.41 Object[] args = { };
73.42
73.43 // allow any object to be a LoginModule
74.1 --- a/src/share/classes/javax/security/auth/x500/X500Principal.java Thu Oct 13 10:35:43 2011 -0700
74.2 +++ b/src/share/classes/javax/security/auth/x500/X500Principal.java Mon Oct 17 19:06:53 2011 -0700
74.3 @@ -118,7 +118,7 @@
74.4 * is improperly specified
74.5 */
74.6 public X500Principal(String name) {
74.7 - this(name, (Map<String, String>) Collections.EMPTY_MAP);
74.8 + this(name, Collections.<String, String>emptyMap());
74.9 }
74.10
74.11 /**
75.1 --- a/src/share/classes/javax/security/cert/CertificateEncodingException.java Thu Oct 13 10:35:43 2011 -0700
75.2 +++ b/src/share/classes/javax/security/cert/CertificateEncodingException.java Mon Oct 17 19:06:53 2011 -0700
75.3 @@ -41,6 +41,7 @@
75.4 */
75.5 public class CertificateEncodingException extends CertificateException {
75.6
75.7 + private static final long serialVersionUID = -8187642723048403470L;
75.8 /**
75.9 * Constructs a CertificateEncodingException with no detail message. A
75.10 * detail message is a String that describes this particular
76.1 --- a/src/share/classes/javax/security/cert/CertificateException.java Thu Oct 13 10:35:43 2011 -0700
76.2 +++ b/src/share/classes/javax/security/cert/CertificateException.java Mon Oct 17 19:06:53 2011 -0700
76.3 @@ -41,6 +41,7 @@
76.4 */
76.5 public class CertificateException extends Exception {
76.6
76.7 + private static final long serialVersionUID = -5757213374030785290L;
76.8 /**
76.9 * Constructs a certificate exception with no detail message. A detail
76.10 * message is a String that describes this particular exception.
77.1 --- a/src/share/classes/javax/security/cert/CertificateExpiredException.java Thu Oct 13 10:35:43 2011 -0700
77.2 +++ b/src/share/classes/javax/security/cert/CertificateExpiredException.java Mon Oct 17 19:06:53 2011 -0700
77.3 @@ -43,6 +43,7 @@
77.4 */
77.5 public class CertificateExpiredException extends CertificateException {
77.6
77.7 + private static final long serialVersionUID = 5091601212177261883L;
77.8 /**
77.9 * Constructs a CertificateExpiredException with no detail message. A
77.10 * detail message is a String that describes this particular
78.1 --- a/src/share/classes/javax/security/cert/CertificateNotYetValidException.java Thu Oct 13 10:35:43 2011 -0700
78.2 +++ b/src/share/classes/javax/security/cert/CertificateNotYetValidException.java Mon Oct 17 19:06:53 2011 -0700
78.3 @@ -43,6 +43,7 @@
78.4 */
78.5 public class CertificateNotYetValidException extends CertificateException {
78.6
78.7 + private static final long serialVersionUID = -8976172474266822818L;
78.8 /**
78.9 * Constructs a CertificateNotYetValidException with no detail message. A
78.10 * detail message is a String that describes this particular
79.1 --- a/src/share/classes/javax/security/cert/CertificateParsingException.java Thu Oct 13 10:35:43 2011 -0700
79.2 +++ b/src/share/classes/javax/security/cert/CertificateParsingException.java Mon Oct 17 19:06:53 2011 -0700
79.3 @@ -1,5 +1,5 @@
79.4 /*
79.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
79.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
79.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
79.8 *
79.9 * This code is free software; you can redistribute it and/or modify it
79.10 @@ -42,6 +42,8 @@
79.11 */
79.12 public class CertificateParsingException extends CertificateException {
79.13
79.14 + private static final long serialVersionUID = -8449352422951136229L;
79.15 +
79.16 /**
79.17 * Constructs a CertificateParsingException with no detail message. A
79.18 * detail message is a String that describes this particular
80.1 --- a/src/share/classes/javax/security/cert/X509Certificate.java Thu Oct 13 10:35:43 2011 -0700
80.2 +++ b/src/share/classes/javax/security/cert/X509Certificate.java Mon Oct 17 19:06:53 2011 -0700
80.3 @@ -219,11 +219,11 @@
80.4 className = "com.sun.security.cert.internal.x509.X509V1CertImpl";
80.5 }
80.6 try {
80.7 - Class[] params = null;
80.8 + Class<?>[] params = null;
80.9 if (value instanceof InputStream) {
80.10 - params = new Class[] { InputStream.class };
80.11 + params = new Class<?>[] { InputStream.class };
80.12 } else if (value instanceof byte[]) {
80.13 - params = new Class[] { value.getClass() };
80.14 + params = new Class<?>[] { value.getClass() };
80.15 } else
80.16 throw new CertificateException("Unsupported argument type");
80.17 Class<?> certClass = Class.forName(className);
81.1 --- a/src/share/classes/javax/security/sasl/Sasl.java Thu Oct 13 10:35:43 2011 -0700
81.2 +++ b/src/share/classes/javax/security/sasl/Sasl.java Mon Oct 17 19:06:53 2011 -0700
81.3 @@ -395,7 +395,7 @@
81.4 * will be thrown.
81.5 */
81.6 ClassLoader cl = p.getClass().getClassLoader();
81.7 - Class implClass;
81.8 + Class<?> implClass;
81.9 implClass = Class.forName(className, true, cl);
81.10 return implClass.newInstance();
81.11 } catch (ClassNotFoundException e) {
81.12 @@ -576,7 +576,7 @@
81.13 classes.clear();
81.14
81.15 // Check the keys for each provider.
81.16 - for (Enumeration e = providers[i].keys(); e.hasMoreElements(); ) {
81.17 + for (Enumeration<Object> e = providers[i].keys(); e.hasMoreElements(); ) {
81.18 String currentKey = (String)e.nextElement();
81.19 if (currentKey.startsWith(serviceName)) {
81.20 // We should skip the currentKey if it contains a
82.1 --- a/src/share/classes/javax/smartcardio/TerminalFactory.java Thu Oct 13 10:35:43 2011 -0700
82.2 +++ b/src/share/classes/javax/smartcardio/TerminalFactory.java Mon Oct 17 19:06:53 2011 -0700
82.3 @@ -113,7 +113,7 @@
82.4 type = "PC/SC";
82.5 Provider sun = Security.getProvider("SunPCSC");
82.6 if (sun == null) {
82.7 - Class clazz = Class.forName("sun.security.smartcardio.SunPCSC");
82.8 + Class<?> clazz = Class.forName("sun.security.smartcardio.SunPCSC");
82.9 sun = (Provider)clazz.newInstance();
82.10 }
82.11 factory = TerminalFactory.getInstance(type, null, sun);
82.12 @@ -131,6 +131,8 @@
82.13 }
82.14
82.15 private static final class NoneProvider extends Provider {
82.16 +
82.17 + private static final long serialVersionUID = 2745808869881593918L;
82.18 final static Provider INSTANCE = new NoneProvider();
82.19 private NoneProvider() {
82.20 super("None", 1.0d, "none");
83.1 --- a/src/share/classes/javax/swing/BufferStrategyPaintManager.java Thu Oct 13 10:35:43 2011 -0700
83.2 +++ b/src/share/classes/javax/swing/BufferStrategyPaintManager.java Mon Oct 17 19:06:53 2011 -0700
83.3 @@ -24,20 +24,17 @@
83.4 */
83.5 package javax.swing;
83.6
83.7 -import java.applet.Applet;
83.8 import java.awt.*;
83.9 import java.awt.event.*;
83.10 import java.awt.image.*;
83.11 import java.lang.reflect.*;
83.12 import java.lang.ref.WeakReference;
83.13 -import java.security.AccessController;
83.14 import java.util.*;
83.15
83.16 import com.sun.java.swing.SwingUtilities3;
83.17
83.18 import sun.awt.SubRegionShowable;
83.19 import sun.java2d.SunGraphics2D;
83.20 -import sun.security.action.GetPropertyAction;
83.21 import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
83.22 import sun.awt.SunToolkit;
83.23 import sun.util.logging.PlatformLogger;
83.24 @@ -120,10 +117,6 @@
83.25 */
83.26 private JComponent rootJ;
83.27 /**
83.28 - * Parent Applet/Window for the current paint/copyArea
83.29 - */
83.30 - private Container root;
83.31 - /**
83.32 * Location of component being painted relative to root.
83.33 */
83.34 private int xOffset;
83.35 @@ -278,7 +271,9 @@
83.36 public boolean paint(JComponent paintingComponent,
83.37 JComponent bufferComponent, Graphics g,
83.38 int x, int y, int w, int h) {
83.39 - if (prepare(paintingComponent, true, x, y, w, h)) {
83.40 + Container root = fetchRoot(paintingComponent);
83.41 +
83.42 + if (prepare(paintingComponent, root, true, x, y, w, h)) {
83.43 if ((g instanceof SunGraphics2D) &&
83.44 ((SunGraphics2D)g).getDestination() == root) {
83.45 // BufferStrategy may have already constrained the Graphics. To
83.46 @@ -319,7 +314,9 @@
83.47 //
83.48 // If the buffer isn't in sync there is no point in doing a copyArea,
83.49 // it has garbage.
83.50 - if (prepare(c, false, 0, 0, 0, 0) && bufferInfo.isInSync()) {
83.51 + Container root = fetchRoot(c);
83.52 +
83.53 + if (prepare(c, root, false, 0, 0, 0, 0) && bufferInfo.isInSync()) {
83.54 if (clip) {
83.55 Rectangle cBounds = c.getVisibleRect();
83.56 int relX = xOffset + x;
83.57 @@ -500,14 +497,14 @@
83.58 *
83.59 * @return true if should use buffering per window in painting.
83.60 */
83.61 - private boolean prepare(JComponent c, boolean isPaint, int x, int y,
83.62 + private boolean prepare(JComponent c, Container root, boolean isPaint, int x, int y,
83.63 int w, int h) {
83.64 if (bsg != null) {
83.65 bsg.dispose();
83.66 bsg = null;
83.67 }
83.68 bufferStrategy = null;
83.69 - if (fetchRoot(c)) {
83.70 + if (root != null) {
83.71 boolean contentsLost = false;
83.72 BufferInfo bufferInfo = getBufferInfo(root);
83.73 if (bufferInfo == null) {
83.74 @@ -567,10 +564,10 @@
83.75 return false;
83.76 }
83.77
83.78 - private boolean fetchRoot(JComponent c) {
83.79 + private Container fetchRoot(JComponent c) {
83.80 boolean encounteredHW = false;
83.81 rootJ = c;
83.82 - root = c;
83.83 + Container root = c;
83.84 xOffset = yOffset = 0;
83.85 while (root != null &&
83.86 (!(root instanceof Window) &&
83.87 @@ -597,7 +594,7 @@
83.88 // heavyweights. If we didn't do this when we
83.89 // went to show the descendants of the nested hw
83.90 // you would see nothing, so, we bail out here.
83.91 - return false;
83.92 + return null;
83.93 }
83.94 }
83.95 }
83.96 @@ -613,11 +610,11 @@
83.97 // bit tricky with Swing. This gives a good approximation
83.98 // of the various ways to turn on double buffering for
83.99 // components.
83.100 - return true;
83.101 + return root;
83.102 }
83.103 }
83.104 // Don't do true double buffering.
83.105 - return false;
83.106 + return null;
83.107 }
83.108
83.109 /**
84.1 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Thu Oct 13 10:35:43 2011 -0700
84.2 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Mon Oct 17 19:06:53 2011 -0700
84.3 @@ -1661,7 +1661,7 @@
84.4 public IOException run() throws Exception {
84.5 return (IOException)
84.6 rememberedException.getClass()
84.7 - .getConstructor(new Class[] { String.class })
84.8 + .getConstructor(new Class<?>[] { String.class })
84.9 .newInstance(args);
84.10 }
84.11 });
85.1 --- a/src/share/classes/sun/security/ec/ECPublicKeyImpl.java Thu Oct 13 10:35:43 2011 -0700
85.2 +++ b/src/share/classes/sun/security/ec/ECPublicKeyImpl.java Mon Oct 17 19:06:53 2011 -0700
85.3 @@ -1,5 +1,5 @@
85.4 /*
85.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
85.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
85.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
85.8 *
85.9 * This code is free software; you can redistribute it and/or modify it
85.10 @@ -51,6 +51,7 @@
85.11 * Construct a key from its components. Used by the
85.12 * ECKeyFactory and SunPKCS11.
85.13 */
85.14 + @SuppressWarnings("deprecation")
85.15 public ECPublicKeyImpl(ECPoint w, ECParameterSpec params)
85.16 throws InvalidKeyException {
85.17 this.w = w;
85.18 @@ -85,6 +86,7 @@
85.19
85.20 // Internal API to get the encoded point. Currently used by SunPKCS11.
85.21 // This may change/go away depending on what we do with the public API.
85.22 + @SuppressWarnings("deprecation")
85.23 public byte[] getEncodedPublicValue() {
85.24 return key.clone();
85.25 }
85.26 @@ -92,6 +94,7 @@
85.27 /**
85.28 * Parse the key. Called by X509Key.
85.29 */
85.30 + @SuppressWarnings("deprecation")
85.31 protected void parseKeyBits() throws InvalidKeyException {
85.32 try {
85.33 AlgorithmParameters algParams = this.algid.getParameters();
86.1 --- a/src/share/classes/sun/security/jgss/krb5/AcceptSecContextToken.java Thu Oct 13 10:35:43 2011 -0700
86.2 +++ b/src/share/classes/sun/security/jgss/krb5/AcceptSecContextToken.java Mon Oct 17 19:06:53 2011 -0700
86.3 @@ -94,7 +94,7 @@
86.4 */
86.5 EncryptionKey subKey = apRep.getSubKey();
86.6 if (subKey != null) {
86.7 - context.setKey(subKey);
86.8 + context.setKey(Krb5Context.ACCEPTOR_SUBKEY, subKey);
86.9 /*
86.10 System.out.println("\n\nSub-Session key from AP-REP is: " +
86.11 getHexBytes(subKey.getBytes()) + "\n");
87.1 --- a/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java Thu Oct 13 10:35:43 2011 -0700
87.2 +++ b/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java Mon Oct 17 19:06:53 2011 -0700
87.3 @@ -74,9 +74,9 @@
87.4
87.5 EncryptionKey subKey = apReq.getSubKey();
87.6 if (subKey != null)
87.7 - context.setKey(subKey);
87.8 + context.setKey(Krb5Context.INITIATOR_SUBKEY, subKey);
87.9 else
87.10 - context.setKey(serviceTicket.getSessionKey());
87.11 + context.setKey(Krb5Context.SESSION_KEY, serviceTicket.getSessionKey());
87.12
87.13 if (!mutualRequired)
87.14 context.resetPeerSequenceNumber(0);
87.15 @@ -117,13 +117,13 @@
87.16
87.17 EncryptionKey subKey = apReq.getSubKey();
87.18 if (subKey != null) {
87.19 - context.setKey(subKey);
87.20 + context.setKey(Krb5Context.INITIATOR_SUBKEY, subKey);
87.21 /*
87.22 System.out.println("Sub-Session key from authenticator is: " +
87.23 getHexBytes(subKey.getBytes()) + "\n");
87.24 */
87.25 } else {
87.26 - context.setKey(sessionKey);
87.27 + context.setKey(Krb5Context.SESSION_KEY, sessionKey);
87.28 //System.out.println("Sub-Session Key Missing in Authenticator.\n");
87.29 }
87.30
88.1 --- a/src/share/classes/sun/security/jgss/krb5/Krb5Context.java Thu Oct 13 10:35:43 2011 -0700
88.2 +++ b/src/share/classes/sun/security/jgss/krb5/Krb5Context.java Mon Oct 17 19:06:53 2011 -0700
88.3 @@ -67,6 +67,10 @@
88.4
88.5 private int state = STATE_NEW;
88.6
88.7 + public static final int SESSION_KEY = 0;
88.8 + public static final int INITIATOR_SUBKEY = 1;
88.9 + public static final int ACCEPTOR_SUBKEY = 2;
88.10 +
88.11 /*
88.12 * Optional features that the application can set and their default
88.13 * values.
88.14 @@ -82,6 +86,7 @@
88.15
88.16 private int mySeqNumber;
88.17 private int peerSeqNumber;
88.18 + private int keySrc;
88.19 private TokenTracker peerTokenTracker;
88.20
88.21 private CipherHelper cipherHelper = null;
88.22 @@ -384,12 +389,17 @@
88.23 }
88.24 }
88.25
88.26 - final void setKey(EncryptionKey key) throws GSSException {
88.27 + final void setKey(int keySrc, EncryptionKey key) throws GSSException {
88.28 this.key = key;
88.29 + this.keySrc = keySrc;
88.30 // %%% to do: should clear old cipherHelper first
88.31 cipherHelper = new CipherHelper(key); // Need to use new key
88.32 }
88.33
88.34 + public final int getKeySrc() {
88.35 + return keySrc;
88.36 + }
88.37 +
88.38 private final EncryptionKey getKey() {
88.39 return key;
88.40 }
89.1 --- a/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java Thu Oct 13 10:35:43 2011 -0700
89.2 +++ b/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java Mon Oct 17 19:06:53 2011 -0700
89.3 @@ -141,6 +141,7 @@
89.4 // Context properties
89.5 private boolean confState = true;
89.6 private boolean initiator = true;
89.7 + private boolean have_acceptor_subkey = false;
89.8
89.9 /* cipher instance used by the corresponding GSSContext */
89.10 CipherHelper cipherHelper = null;
89.11 @@ -233,7 +234,6 @@
89.12 }
89.13
89.14 if (tokenId == Krb5Token.WRAP_ID_v2) {
89.15 - // Does non-confidential data needs a rotate?
89.16 rotate();
89.17 }
89.18
89.19 @@ -312,8 +312,7 @@
89.20 }
89.21
89.22 // Create a new gss token header as defined in RFC 4121
89.23 - tokenHeader = new MessageTokenHeader(tokenId,
89.24 - prop.getPrivacy(), true);
89.25 + tokenHeader = new MessageTokenHeader(tokenId, prop.getPrivacy());
89.26 // debug("\n\t Message Header = " +
89.27 // getHexBytes(tokenHeader.getBytes(), tokenHeader.getBytes().length));
89.28
89.29 @@ -421,10 +420,12 @@
89.30 int conf_flag = tokenHeaderBytes[TOKEN_FLAG_POS] &
89.31 FLAG_WRAP_CONFIDENTIAL;
89.32
89.33 - // clear EC in token header for checksum calculation
89.34 + // clear EC and RRC in token header for checksum calculation
89.35 if ((conf_flag == 0) && (tokenId == WRAP_ID_v2)) {
89.36 tokenHeaderBytes[4] = 0;
89.37 tokenHeaderBytes[5] = 0;
89.38 + tokenHeaderBytes[6] = 0;
89.39 + tokenHeaderBytes[7] = 0;
89.40 }
89.41 return cipherHelper.calculateChecksum(tokenHeaderBytes, data,
89.42 offset, len, key_usage);
89.43 @@ -460,6 +461,8 @@
89.44
89.45 this.initiator = context.isInitiator();
89.46
89.47 + this.have_acceptor_subkey = context.getKeySrc() == Krb5Context.ACCEPTOR_SUBKEY;
89.48 +
89.49 this.cipherHelper = context.getCipherHelper(null);
89.50 // debug("In MessageToken.Cons");
89.51 }
89.52 @@ -500,8 +503,7 @@
89.53 private byte[] bytes = new byte[TOKEN_HEADER_SIZE];
89.54
89.55 // Writes a new token header
89.56 - public MessageTokenHeader(int tokenId, boolean conf,
89.57 - boolean have_acceptor_subkey) throws GSSException {
89.58 + public MessageTokenHeader(int tokenId, boolean conf) throws GSSException {
89.59
89.60 this.tokenId = tokenId;
89.61
90.1 --- a/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java Thu Oct 13 10:35:43 2011 -0700
90.2 +++ b/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java Mon Oct 17 19:06:53 2011 -0700
90.3 @@ -144,15 +144,18 @@
90.4
90.5 /**
90.6 * Retrieves an array of secret keys for the client. This is used when
90.7 - * the client supplies password but need keys to act as an acceptor
90.8 - * (in JAAS words, isInitiator=true and storeKey=true)
90.9 + * the client supplies password but need keys to act as an acceptor. For
90.10 + * an initiator, it must be called after AS-REQ is performed (state is OK).
90.11 + * For an acceptor, it can be called when this KrbAsReqBuilder object is
90.12 + * constructed (state is INIT).
90.13 + * @param isInitiator if the caller is an initiator
90.14 * @return generated keys from password. PA-DATA from server might be used.
90.15 * All "default_tkt_enctypes" keys will be generated, Never null.
90.16 * @throws IllegalStateException if not constructed from a password
90.17 * @throws KrbException
90.18 */
90.19 - public EncryptionKey[] getKeys() throws KrbException {
90.20 - checkState(State.REQ_OK, "Cannot get keys");
90.21 + public EncryptionKey[] getKeys(boolean isInitiator) throws KrbException {
90.22 + checkState(isInitiator?State.REQ_OK:State.INIT, "Cannot get keys");
90.23 if (password != null) {
90.24 int[] eTypes = EType.getDefaults("default_tkt_enctypes");
90.25 EncryptionKey[] result = new EncryptionKey[eTypes.length];
91.1 --- a/src/share/classes/sun/security/pkcs11/SunPKCS11.java Thu Oct 13 10:35:43 2011 -0700
91.2 +++ b/src/share/classes/sun/security/pkcs11/SunPKCS11.java Mon Oct 17 19:06:53 2011 -0700
91.3 @@ -1335,10 +1335,10 @@
91.4 return null;
91.5 }
91.6
91.7 - Class c = Class.forName
91.8 - (defaultHandler,
91.9 - true,
91.10 - Thread.currentThread().getContextClassLoader());
91.11 + Class<?> c = Class.forName
91.12 + (defaultHandler,
91.13 + true,
91.14 + Thread.currentThread().getContextClassLoader());
91.15 return (CallbackHandler)c.newInstance();
91.16 }
91.17 });
92.1 --- a/src/share/classes/sun/security/validator/PKIXValidator.java Thu Oct 13 10:35:43 2011 -0700
92.2 +++ b/src/share/classes/sun/security/validator/PKIXValidator.java Mon Oct 17 19:06:53 2011 -0700
92.3 @@ -327,6 +327,7 @@
92.4 * Set the check date (for debugging).
92.5 */
92.6 private void setDate(PKIXBuilderParameters params) {
92.7 + @SuppressWarnings("deprecation")
92.8 Date date = validationDate;
92.9 if (date != null) {
92.10 params.setDate(date);
93.1 --- a/src/share/classes/sun/security/validator/SimpleValidator.java Thu Oct 13 10:35:43 2011 -0700
93.2 +++ b/src/share/classes/sun/security/validator/SimpleValidator.java Mon Oct 17 19:06:53 2011 -0700
93.3 @@ -131,6 +131,7 @@
93.4 // make sure chain includes a trusted cert
93.5 chain = buildTrustedChain(chain);
93.6
93.7 + @SuppressWarnings("deprecation")
93.8 Date date = validationDate;
93.9 if (date == null) {
93.10 date = new Date();
94.1 --- a/src/share/classes/sun/security/x509/X509CertImpl.java Thu Oct 13 10:35:43 2011 -0700
94.2 +++ b/src/share/classes/sun/security/x509/X509CertImpl.java Mon Oct 17 19:06:53 2011 -0700
94.3 @@ -1323,7 +1323,7 @@
94.4
94.5 for (Extension ex : exts.getAllExtensions()) {
94.6 ObjectIdentifier inCertOID = ex.getExtensionId();
94.7 - if (inCertOID.equals(findOID)) {
94.8 + if (inCertOID.equals((Object)findOID)) {
94.9 certExt = ex;
94.10 break;
94.11 }
95.1 --- a/src/share/classes/sun/util/LocaleServiceProviderPool.java Thu Oct 13 10:35:43 2011 -0700
95.2 +++ b/src/share/classes/sun/util/LocaleServiceProviderPool.java Mon Oct 17 19:06:53 2011 -0700
95.3 @@ -40,6 +40,7 @@
95.4 import java.util.ServiceLoader;
95.5 import java.util.Set;
95.6 import java.util.concurrent.ConcurrentHashMap;
95.7 +import java.util.concurrent.ConcurrentMap;
95.8 import java.util.spi.LocaleServiceProvider;
95.9
95.10 import sun.util.logging.PlatformLogger;
95.11 @@ -57,8 +58,8 @@
95.12 * A Map that holds singleton instances of this class. Each instance holds a
95.13 * set of provider implementations of a particular locale sensitive service.
95.14 */
95.15 - private static Map<Class, LocaleServiceProviderPool> poolOfPools =
95.16 - new ConcurrentHashMap<Class, LocaleServiceProviderPool>();
95.17 + private static ConcurrentMap<Class, LocaleServiceProviderPool> poolOfPools =
95.18 + new ConcurrentHashMap<>();
95.19
95.20 /**
95.21 * A Set containing locale service providers that implement the
95.22 @@ -109,7 +110,7 @@
95.23 if (pool == null) {
95.24 LocaleServiceProviderPool newPool =
95.25 new LocaleServiceProviderPool(providerClass);
95.26 - pool = poolOfPools.put(providerClass, newPool);
95.27 + pool = poolOfPools.putIfAbsent(providerClass, newPool);
95.28 if (pool == null) {
95.29 pool = newPool;
95.30 }
95.31 @@ -257,10 +258,11 @@
95.32 synchronized (LocaleServiceProviderPool.class) {
95.33 if (availableJRELocales == null) {
95.34 Locale[] allLocales = LocaleData.getAvailableLocales();
95.35 - availableJRELocales = new ArrayList<Locale>(allLocales.length);
95.36 + List<Locale> tmpList = new ArrayList<>(allLocales.length);
95.37 for (Locale locale : allLocales) {
95.38 - availableJRELocales.add(getLookupLocale(locale));
95.39 + tmpList.add(getLookupLocale(locale));
95.40 }
95.41 + availableJRELocales = tmpList;
95.42 }
95.43 }
95.44 }
96.1 --- a/src/solaris/bin/java_md.c Thu Oct 13 10:35:43 2011 -0700
96.2 +++ b/src/solaris/bin/java_md.c Mon Oct 17 19:06:53 2011 -0700
96.3 @@ -820,7 +820,6 @@
96.4 jboolean
96.5 LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
96.6 {
96.7 - Dl_info dlinfo;
96.8 void *libjvm;
96.9
96.10 JLI_TraceLauncher("JVM path is %s\n", jvmpath);
97.1 --- a/src/solaris/native/java/util/TimeZone_md.c Thu Oct 13 10:35:43 2011 -0700
97.2 +++ b/src/solaris/native/java/util/TimeZone_md.c Mon Oct 17 19:06:53 2011 -0700
97.3 @@ -1,5 +1,5 @@
97.4 /*
97.5 - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
97.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
97.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
97.8 *
97.9 * This code is free software; you can redistribute it and/or modify it
97.10 @@ -30,13 +30,13 @@
97.11 #include <limits.h>
97.12 #include <errno.h>
97.13 #include <stddef.h>
97.14 -
97.15 -#ifdef __linux__
97.16 +#include <sys/stat.h>
97.17 +#include <sys/types.h>
97.18 #include <string.h>
97.19 #include <dirent.h>
97.20 -#include <sys/stat.h>
97.21 -#include <sys/types.h>
97.22 #include <unistd.h>
97.23 +#ifdef __solaris__
97.24 +#include <libscf.h>
97.25 #endif
97.26
97.27 #include "jvm.h"
97.28 @@ -54,17 +54,22 @@
97.29 static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
97.30 static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
97.31 static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
97.32 +#else
97.33 +static const char *SYS_INIT_FILE = "/etc/default/init";
97.34 +static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo";
97.35 +static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime";
97.36 +#endif /*__linux__*/
97.37
97.38 /*
97.39 - * Returns a point to the zone ID portion of the given zoneinfo file
97.40 - * name.
97.41 + * Returns a pointer to the zone ID portion of the given zoneinfo file
97.42 + * name, or NULL if the given string doesn't contain "zoneinfo/".
97.43 */
97.44 static char *
97.45 getZoneName(char *str)
97.46 {
97.47 static const char *zidir = "zoneinfo/";
97.48
97.49 - char * pos = strstr((const char *)str, zidir);
97.50 + char *pos = strstr((const char *)str, zidir);
97.51 if (pos == NULL) {
97.52 return NULL;
97.53 }
97.54 @@ -74,7 +79,7 @@
97.55 /*
97.56 * Returns a path name created from the given 'dir' and 'name' under
97.57 * UNIX. This function allocates memory for the pathname calling
97.58 - * malloc().
97.59 + * malloc(). NULL is returned if malloc() fails.
97.60 */
97.61 static char *
97.62 getPathName(const char *dir, const char *name) {
97.63 @@ -89,19 +94,18 @@
97.64
97.65 /*
97.66 * Scans the specified directory and its subdirectories to find a
97.67 - * zoneinfo file which has the same content as /etc/localtime given in
97.68 - * 'buf'. Returns a zone ID if found, otherwise, NULL is returned.
97.69 + * zoneinfo file which has the same content as /etc/localtime on Linux
97.70 + * or /usr/share/lib/zoneinfo/localtime (most likely a symbolic link)
97.71 + * on Solaris given in 'buf'. Returns a zone ID if found, otherwise,
97.72 + * NULL is returned.
97.73 */
97.74 static char *
97.75 findZoneinfoFile(char *buf, size_t size, const char *dir)
97.76 {
97.77 DIR *dirp = NULL;
97.78 struct stat statbuf;
97.79 - union {
97.80 - struct dirent d;
97.81 - char b[offsetof (struct dirent, d_name) + NAME_MAX + 1];
97.82 - } entry;
97.83 - struct dirent *dp;
97.84 + struct dirent *dp = NULL;
97.85 + struct dirent *entry = NULL;
97.86 char *pathname = NULL;
97.87 int fd = -1;
97.88 char *dbuf = NULL;
97.89 @@ -112,7 +116,19 @@
97.90 return NULL;
97.91 }
97.92
97.93 - while (readdir_r(dirp, &entry.d, &dp) == 0 && dp != NULL) {
97.94 + entry = (struct dirent *) malloc((size_t) pathconf(dir, _PC_NAME_MAX));
97.95 + if (entry == NULL) {
97.96 + (void) closedir(dirp);
97.97 + return NULL;
97.98 + }
97.99 +
97.100 +#if defined(__linux__) || (defined(__solaris__) && (defined(_POSIX_PTHREAD_SEMANTICS) || \
97.101 + defined(_LP64)))
97.102 + while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) {
97.103 +#else
97.104 + while ((dp = readdir_r(dirp, entry)) != NULL) {
97.105 +#endif
97.106 +
97.107 /*
97.108 * Skip '.' and '..' (and possibly other .* files)
97.109 */
97.110 @@ -121,11 +137,17 @@
97.111 }
97.112
97.113 /*
97.114 - * Skip "ROC", "posixrules", and "localtime" since Java doesn't
97.115 - * support them.
97.116 + * Skip "ROC", "posixrules", and "localtime".
97.117 */
97.118 if ((strcmp(dp->d_name, "ROC") == 0)
97.119 || (strcmp(dp->d_name, "posixrules") == 0)
97.120 +#ifdef __solaris__
97.121 + /*
97.122 + * Skip the "src" and "tab" directories on Solaris.
97.123 + */
97.124 + || (strcmp(dp->d_name, "src") == 0)
97.125 + || (strcmp(dp->d_name, "tab") == 0)
97.126 +#endif
97.127 || (strcmp(dp->d_name, "localtime") == 0)) {
97.128 continue;
97.129 }
97.130 @@ -149,7 +171,6 @@
97.131 break;
97.132 }
97.133 if ((fd = open(pathname, O_RDONLY)) == -1) {
97.134 - fd = 0;
97.135 break;
97.136 }
97.137 if (read(fd, dbuf, size) != (ssize_t) size) {
97.138 @@ -165,19 +186,22 @@
97.139 free((void *) dbuf);
97.140 dbuf = NULL;
97.141 (void) close(fd);
97.142 - fd = 0;
97.143 + fd = -1;
97.144 }
97.145 free((void *) pathname);
97.146 pathname = NULL;
97.147 }
97.148
97.149 + if (entry != NULL) {
97.150 + free((void *) entry);
97.151 + }
97.152 if (dirp != NULL) {
97.153 (void) closedir(dirp);
97.154 }
97.155 if (pathname != NULL) {
97.156 free((void *) pathname);
97.157 }
97.158 - if (fd != 0) {
97.159 + if (fd != -1) {
97.160 (void) close(fd);
97.161 }
97.162 if (dbuf != NULL) {
97.163 @@ -186,8 +210,10 @@
97.164 return tz;
97.165 }
97.166
97.167 +#ifdef __linux__
97.168 +
97.169 /*
97.170 - * Performs libc implementation specific mapping and returns a zone ID
97.171 + * Performs Linux specific mapping and returns a zone ID
97.172 * if found. Otherwise, NULL is returned.
97.173 */
97.174 static char *
97.175 @@ -408,12 +434,11 @@
97.176 }
97.177 #endif /* not __sparcv9 */
97.178
97.179 -static const char *sys_init_file = "/etc/default/init";
97.180
97.181 /*
97.182 - * Performs libc implementation dependent mapping. Returns a zone ID
97.183 - * if found. Otherwise, NULL is returned. Solaris libc looks up
97.184 - * "/etc/default/init" to get a default TZ value if TZ is not defined
97.185 + * Performs Solaris dependent mapping. Returns a zone ID if
97.186 + * found. Otherwise, NULL is returned. Solaris libc looks up
97.187 + * "/etc/default/init" to get the default TZ value if TZ is not defined
97.188 * as an environment variable.
97.189 */
97.190 static char *
97.191 @@ -425,7 +450,7 @@
97.192 /*
97.193 * Try the TZ entry in /etc/default/init.
97.194 */
97.195 - if ((fp = fileopen(sys_init_file, "r")) != NULL) {
97.196 + if ((fp = fileopen(SYS_INIT_FILE, "r")) != NULL) {
97.197 char line[256];
97.198 char quote = '\0';
97.199
97.200 @@ -473,8 +498,113 @@
97.201 return tz;
97.202 }
97.203
97.204 -#endif
97.205 -#endif
97.206 +#define TIMEZONE_FMRI "svc:/system/timezone:default"
97.207 +#define TIMEZONE_PG "timezone"
97.208 +#define LOCALTIME_PROP "localtime"
97.209 +
97.210 +static void
97.211 +cleanupScf(scf_handle_t *h,
97.212 + scf_snapshot_t *snap,
97.213 + scf_instance_t *inst,
97.214 + scf_propertygroup_t *pg,
97.215 + scf_property_t *prop,
97.216 + scf_value_t *val,
97.217 + char *buf) {
97.218 + if (buf != NULL) {
97.219 + free(buf);
97.220 + }
97.221 + if (snap != NULL) {
97.222 + scf_snapshot_destroy(snap);
97.223 + }
97.224 + if (val != NULL) {
97.225 + scf_value_destroy(val);
97.226 + }
97.227 + if (prop != NULL) {
97.228 + scf_property_destroy(prop);
97.229 + }
97.230 + if (pg != NULL) {
97.231 + scf_pg_destroy(pg);
97.232 + }
97.233 + if (inst != NULL) {
97.234 + scf_instance_destroy(inst);
97.235 + }
97.236 + if (h != NULL) {
97.237 + scf_handle_destroy(h);
97.238 + }
97.239 +}
97.240 +
97.241 +/*
97.242 + * Retruns a zone ID of Solaris when the TZ value is "localtime".
97.243 + * First, it tries scf. If scf fails, it looks for the same file as
97.244 + * /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/.
97.245 + */
97.246 +static char *
97.247 +getSolarisDefaultZoneID() {
97.248 + char *tz = NULL;
97.249 + struct stat statbuf;
97.250 + size_t size;
97.251 + char *buf;
97.252 + int fd;
97.253 + /* scf specific variables */
97.254 + scf_handle_t *h = NULL;
97.255 + scf_snapshot_t *snap = NULL;
97.256 + scf_instance_t *inst = NULL;
97.257 + scf_propertygroup_t *pg = NULL;
97.258 + scf_property_t *prop = NULL;
97.259 + scf_value_t *val = NULL;
97.260 +
97.261 + if ((h = scf_handle_create(SCF_VERSION)) != NULL
97.262 + && scf_handle_bind(h) == 0
97.263 + && (inst = scf_instance_create(h)) != NULL
97.264 + && (snap = scf_snapshot_create(h)) != NULL
97.265 + && (pg = scf_pg_create(h)) != NULL
97.266 + && (prop = scf_property_create(h)) != NULL
97.267 + && (val = scf_value_create(h)) != NULL
97.268 + && scf_handle_decode_fmri(h, TIMEZONE_FMRI, NULL, NULL, inst,
97.269 + NULL, NULL, SCF_DECODE_FMRI_REQUIRE_INSTANCE) == 0
97.270 + && scf_instance_get_snapshot(inst, "running", snap) == 0
97.271 + && scf_instance_get_pg_composed(inst, snap, TIMEZONE_PG, pg) == 0
97.272 + && scf_pg_get_property(pg, LOCALTIME_PROP, prop) == 0
97.273 + && scf_property_get_value(prop, val) == 0) {
97.274 + ssize_t len;
97.275 +
97.276 + /* Gets the length of the zone ID string */
97.277 + len = scf_value_get_astring(val, NULL, 0);
97.278 + if (len != -1) {
97.279 + tz = malloc(++len); /* +1 for a null byte */
97.280 + if (tz != NULL && scf_value_get_astring(val, tz, len) != -1) {
97.281 + cleanupScf(h, snap, inst, pg, prop, val, NULL);
97.282 + return tz;
97.283 + }
97.284 + }
97.285 + }
97.286 + cleanupScf(h, snap, inst, pg, prop, val, tz);
97.287 +
97.288 + if (stat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) {
97.289 + return NULL;
97.290 + }
97.291 + size = (size_t) statbuf.st_size;
97.292 + buf = malloc(size);
97.293 + if (buf == NULL) {
97.294 + return NULL;
97.295 + }
97.296 + if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) {
97.297 + free((void *) buf);
97.298 + return NULL;
97.299 + }
97.300 +
97.301 + if (read(fd, buf, size) != (ssize_t) size) {
97.302 + (void) close(fd);
97.303 + free((void *) buf);
97.304 + return NULL;
97.305 + }
97.306 + (void) close(fd);
97.307 + tz = findZoneinfoFile(buf, size, ZONEINFO_DIR);
97.308 + free((void *) buf);
97.309 + return tz;
97.310 +}
97.311 +#endif /*__solaris__*/
97.312 +#endif /*__linux__*/
97.313
97.314 /*
97.315 * findJavaTZ_md() maps platform time zone ID to Java time zone ID
97.316 @@ -504,10 +634,21 @@
97.317 freetz = tz;
97.318 }
97.319
97.320 + /*
97.321 + * Remove any preceding ':'
97.322 + */
97.323 + if (tz != NULL && *tz == ':') {
97.324 + tz++;
97.325 + }
97.326 +
97.327 +#ifdef __solaris__
97.328 + if (strcmp(tz, "localtime") == 0) {
97.329 + tz = getSolarisDefaultZoneID();
97.330 + freetz = tz;
97.331 + }
97.332 +#endif
97.333 +
97.334 if (tz != NULL) {
97.335 - if (*tz == ':') {
97.336 - tz++;
97.337 - }
97.338 #ifdef __linux__
97.339 /*
97.340 * Ignore "posix/" prefix.
97.341 @@ -525,24 +666,36 @@
97.342 }
97.343
97.344 /**
97.345 - * Returns a GMT-offset-based time zone ID. (e.g., "GMT-08:00")
97.346 + * Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00")
97.347 */
97.348 char *
97.349 getGMTOffsetID()
97.350 {
97.351 time_t offset;
97.352 - char sign, buf[16];
97.353 + char sign, buf[32];
97.354 +#ifdef __solaris__
97.355 + struct tm localtm;
97.356 + time_t currenttime;
97.357
97.358 - if (timezone == 0) {
97.359 + currenttime = time(NULL);
97.360 + if (localtime_r(¤ttime, &localtm) == NULL) {
97.361 + return NULL;
97.362 + }
97.363 +
97.364 + offset = localtm.tm_isdst ? altzone : timezone;
97.365 +#else
97.366 + offset = timezone;
97.367 +#endif /*__linux__*/
97.368 +
97.369 + if (offset == 0) {
97.370 return strdup("GMT");
97.371 }
97.372
97.373 /* Note that the time offset direction is opposite. */
97.374 - if (timezone > 0) {
97.375 - offset = timezone;
97.376 + if (offset > 0) {
97.377 sign = '-';
97.378 } else {
97.379 - offset = -timezone;
97.380 + offset = -offset;
97.381 sign = '+';
97.382 }
97.383 sprintf(buf, (const char *)"GMT%c%02d:%02d",
98.1 --- a/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c Thu Oct 13 10:35:43 2011 -0700
98.2 +++ b/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c Mon Oct 17 19:06:53 2011 -0700
98.3 @@ -1,5 +1,5 @@
98.4 /*
98.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
98.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
98.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
98.8 *
98.9 * This code is free software; you can redistribute it and/or modify it
98.10 @@ -334,6 +334,7 @@
98.11 XDestroyImage(ximage);
98.12 SplashRemoveDecoration(splash);
98.13 XMapWindow(splash->display, splash->window);
98.14 + XFlush(splash->display);
98.15 }
98.16
98.17 void SplashReconfigureNow(Splash * splash) {
99.1 --- a/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java Thu Oct 13 10:35:43 2011 -0700
99.2 +++ b/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java Mon Oct 17 19:06:53 2011 -0700
99.3 @@ -70,7 +70,7 @@
99.4 fd1 = new FileDescriptor();
99.5 try {
99.6 super.create();
99.7 - } catch (IOException e) {
99.8 + } catch (SocketException e) {
99.9 fd1 = null;
99.10 throw e;
99.11 }
99.12 @@ -99,10 +99,11 @@
99.13 }
99.14
99.15 if (optID == SO_BINDADDR) {
99.16 - if (fd != null && fd1 != null) {
99.17 + if ((fd != null && fd1 != null) && !connected) {
99.18 return anyLocalBoundAddr;
99.19 }
99.20 - return socketGetOption(optID);
99.21 + int family = connectedAddress == null ? -1 : connectedAddress.family;
99.22 + return socketLocalAddress(family);
99.23 } else
99.24 return super.getOption(optID);
99.25 }
99.26 @@ -161,6 +162,8 @@
99.27
99.28 protected native void connect0(InetAddress address, int port) throws SocketException;
99.29
99.30 + protected native Object socketLocalAddress(int family) throws SocketException;
99.31 +
99.32 protected native void disconnect0(int family);
99.33
99.34 /**
100.1 --- a/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java Thu Oct 13 10:35:43 2011 -0700
100.2 +++ b/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java Mon Oct 17 19:06:53 2011 -0700
100.3 @@ -26,6 +26,7 @@
100.4
100.5 import java.io.IOException;
100.6 import java.io.FileDescriptor;
100.7 +import sun.net.ResourceManager;
100.8
100.9 /*
100.10 * This class defines the plain SocketImpl that is used for all
100.11 @@ -81,7 +82,12 @@
100.12 */
100.13 protected synchronized void create(boolean stream) throws IOException {
100.14 fd1 = new FileDescriptor();
100.15 - super.create(stream);
100.16 + try {
100.17 + super.create(stream);
100.18 + } catch (IOException e) {
100.19 + fd1 = null;
100.20 + throw e;
100.21 + }
100.22 }
100.23
100.24 /**
100.25 @@ -120,6 +126,9 @@
100.26 protected void close() throws IOException {
100.27 synchronized(fdLock) {
100.28 if (fd != null || fd1 != null) {
100.29 + if (!stream) {
100.30 + ResourceManager.afterUdpClose();
100.31 + }
100.32 if (fdUseCount == 0) {
100.33 if (closePending) {
100.34 return;
101.1 --- a/src/windows/classes/sun/awt/windows/WComponentPeer.java Thu Oct 13 10:35:43 2011 -0700
101.2 +++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java Mon Oct 17 19:06:53 2011 -0700
101.3 @@ -615,6 +615,14 @@
101.4 _dispose();
101.5 }
101.6
101.7 + public void disposeLater() {
101.8 + postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), new Runnable() {
101.9 + public void run() {
101.10 + dispose();
101.11 + }
101.12 + }));
101.13 + }
101.14 +
101.15 public synchronized void setForeground(Color c) {
101.16 foreground = c;
101.17 _setForeground(c.getRGB());
102.1 --- a/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Thu Oct 13 10:35:43 2011 -0700
102.2 +++ b/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Mon Oct 17 19:06:53 2011 -0700
102.3 @@ -2181,30 +2181,6 @@
102.4 return getMulticastInterface(env, this, fd, fd1, opt);
102.5 }
102.6
102.7 - if (opt == java_net_SocketOptions_SO_BINDADDR) {
102.8 - /* find out local IP address */
102.9 - SOCKETADDRESS him;
102.10 - int len = 0;
102.11 - int port;
102.12 - jobject iaObj;
102.13 -
102.14 - len = sizeof (struct sockaddr_in);
102.15 -
102.16 - if (fd == -1) {
102.17 - fd = fd1; /* must be IPv6 only */
102.18 - len = sizeof (struct SOCKADDR_IN6);
102.19 - }
102.20 -
102.21 - if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
102.22 - NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
102.23 - "Error getting socket name");
102.24 - return NULL;
102.25 - }
102.26 - iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
102.27 -
102.28 - return iaObj;
102.29 - }
102.30 -
102.31 /*
102.32 * Map the Java level socket option to the platform specific
102.33 * level and option name.
102.34 @@ -2253,6 +2229,61 @@
102.35 }
102.36
102.37 /*
102.38 + * Returns local address of the socket.
102.39 + *
102.40 + * Class: java_net_TwoStacksPlainDatagramSocketImpl
102.41 + * Method: socketLocalAddress
102.42 + * Signature: (I)Ljava/lang/Object;
102.43 + */
102.44 +JNIEXPORT jobject JNICALL
102.45 +Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress(JNIEnv *env, jobject this,
102.46 + jint family) {
102.47 +
102.48 + int fd=-1, fd1=-1;
102.49 + SOCKETADDRESS him;
102.50 + int len = 0;
102.51 + int port;
102.52 + jobject iaObj;
102.53 + int ipv6_supported = ipv6_available();
102.54 +
102.55 + fd = getFD(env, this);
102.56 + if (ipv6_supported) {
102.57 + fd1 = getFD1(env, this);
102.58 + }
102.59 +
102.60 + if (fd < 0 && fd1 < 0) {
102.61 + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
102.62 + "Socket closed");
102.63 + return NULL;
102.64 + }
102.65 +
102.66 + /* find out local IP address */
102.67 +
102.68 + len = sizeof (struct sockaddr_in);
102.69 +
102.70 + /* family==-1 when socket is not connected */
102.71 + if ((family == IPv6) || (family == -1 && fd == -1)) {
102.72 + fd = fd1; /* must be IPv6 only */
102.73 + len = sizeof (struct SOCKADDR_IN6);
102.74 + }
102.75 +
102.76 + if (fd == -1) {
102.77 + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
102.78 + "Socket closed");
102.79 + return NULL;
102.80 + }
102.81 +
102.82 + if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
102.83 + NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
102.84 + "Error getting socket name");
102.85 + return NULL;
102.86 + }
102.87 + iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
102.88 +
102.89 + return iaObj;
102.90 +}
102.91 +
102.92 +/*
102.93 * Class: java_net_TwoStacksPlainDatagramSocketImpl
102.94 * Method: setTimeToLive
102.95 * Signature: (I)V
103.1 --- a/src/windows/native/sun/windows/awt_Component.cpp Thu Oct 13 10:35:43 2011 -0700
103.2 +++ b/src/windows/native/sun/windows/awt_Component.cpp Mon Oct 17 19:06:53 2011 -0700
103.3 @@ -183,6 +183,7 @@
103.4 jmethodID AwtComponent::getLocationOnScreenMID;
103.5 jmethodID AwtComponent::replaceSurfaceDataMID;
103.6 jmethodID AwtComponent::replaceSurfaceDataLaterMID;
103.7 +jmethodID AwtComponent::disposeLaterMID;
103.8
103.9 HKL AwtComponent::m_hkl = ::GetKeyboardLayout(0);
103.10 LANGID AwtComponent::m_idLang = LOWORD(::GetKeyboardLayout(0));
103.11 @@ -246,6 +247,7 @@
103.12 m_hCursorCache = NULL;
103.13
103.14 m_bSubclassed = FALSE;
103.15 + m_bPauseDestroy = FALSE;
103.16
103.17 m_MessagesProcessing = 0;
103.18 m_wheelRotationAmount = 0;
103.19 @@ -319,6 +321,12 @@
103.20 m_brushBackground = NULL;
103.21 }
103.22
103.23 + if (m_bPauseDestroy) {
103.24 + // AwtComponent::WmNcDestroy could be released now
103.25 + m_bPauseDestroy = FALSE;
103.26 + m_hwnd = NULL;
103.27 + }
103.28 +
103.29 // The component instance is deleted using AwtObject::Dispose() method
103.30 AwtObject::Dispose();
103.31 }
103.32 @@ -1377,6 +1385,7 @@
103.33 case WM_CREATE: mr = WmCreate(); break;
103.34 case WM_CLOSE: mr = WmClose(); break;
103.35 case WM_DESTROY: mr = WmDestroy(); break;
103.36 + case WM_NCDESTROY: mr = WmNcDestroy(); break;
103.37
103.38 case WM_ERASEBKGND:
103.39 mr = WmEraseBkgnd((HDC)wParam, *(BOOL*)&retValue); break;
103.40 @@ -1965,10 +1974,24 @@
103.41 */
103.42 MsgRouting AwtComponent::WmDestroy()
103.43 {
103.44 - // fix for 6259348: we should enter the SyncCall critical section before
103.45 - // disposing the native object, that is value 1 of lParam is intended for
103.46 - if(m_peerObject != NULL) { // is not being terminating
103.47 - AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)m_peerObject, (LPARAM)1);
103.48 + return mrConsume;
103.49 +}
103.50 +
103.51 +/*
103.52 + * This message should only be received when a window is destroyed by
103.53 + * Windows, and not Java. It is sent only after child windows were destroyed.
103.54 + */
103.55 +MsgRouting AwtComponent::WmNcDestroy()
103.56 +{
103.57 + if (m_peerObject != NULL) { // is not being terminating
103.58 + // Stay in this handler until AwtComponent::Dispose is called.
103.59 + m_bPauseDestroy = TRUE;
103.60 +
103.61 + JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.62 + // Post invocation event for WObjectPeer.dispose to EDT
103.63 + env->CallVoidMethod(m_peerObject, AwtComponent::disposeLaterMID);
103.64 + // Wait until AwtComponent::Dispose is called
103.65 + AwtToolkit::GetInstance().PumpToDestroy(this);
103.66 }
103.67
103.68 return mrConsume;
103.69 @@ -6300,6 +6323,7 @@
103.70 env->GetMethodID(peerCls, "replaceSurfaceData", "()V");
103.71 AwtComponent::replaceSurfaceDataLaterMID =
103.72 env->GetMethodID(peerCls, "replaceSurfaceDataLater", "()V");
103.73 + AwtComponent::disposeLaterMID = env->GetMethodID(peerCls, "disposeLater", "()V");
103.74
103.75 DASSERT(AwtComponent::xID);
103.76 DASSERT(AwtComponent::yID);
103.77 @@ -6318,6 +6342,8 @@
103.78 DASSERT(AwtComponent::getLocationOnScreenMID);
103.79 DASSERT(AwtComponent::replaceSurfaceDataMID);
103.80 DASSERT(AwtComponent::replaceSurfaceDataLaterMID);
103.81 + DASSERT(AwtComponent::disposeLaterMID);
103.82 +
103.83
103.84 CATCH_BAD_ALLOC;
103.85 }
104.1 --- a/src/windows/native/sun/windows/awt_Component.h Thu Oct 13 10:35:43 2011 -0700
104.2 +++ b/src/windows/native/sun/windows/awt_Component.h Mon Oct 17 19:06:53 2011 -0700
104.3 @@ -119,6 +119,7 @@
104.4 static jmethodID getLocationOnScreenMID;
104.5 static jmethodID replaceSurfaceDataMID;
104.6 static jmethodID replaceSurfaceDataLaterMID;
104.7 + static jmethodID disposeLaterMID;
104.8
104.9 static const UINT WmAwtIsComponent;
104.10 static jint * masks; //InputEvent mask array
104.11 @@ -490,6 +491,7 @@
104.12 virtual MsgRouting WmCreate() {return mrDoDefault;}
104.13 virtual MsgRouting WmClose() {return mrDoDefault;}
104.14 virtual MsgRouting WmDestroy();
104.15 + virtual MsgRouting WmNcDestroy();
104.16
104.17 virtual MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite)
104.18 {
104.19 @@ -711,6 +713,10 @@
104.20 return m_MessagesProcessing == 0;
104.21 }
104.22
104.23 + BOOL IsDestroyPaused() const {
104.24 + return m_bPauseDestroy;
104.25 + }
104.26 +
104.27 protected:
104.28 static AwtComponent* GetComponentImpl(HWND hWnd);
104.29
104.30 @@ -752,6 +758,7 @@
104.31 UINT m_mouseButtonClickAllowed;
104.32
104.33 BOOL m_bSubclassed;
104.34 + BOOL m_bPauseDestroy;
104.35
104.36 COLORREF m_colorForeground;
104.37 COLORREF m_colorBackground;
105.1 --- a/src/windows/native/sun/windows/awt_Toolkit.cpp Thu Oct 13 10:35:43 2011 -0700
105.2 +++ b/src/windows/native/sun/windows/awt_Toolkit.cpp Mon Oct 17 19:06:53 2011 -0700
105.3 @@ -733,26 +733,13 @@
105.4 return 0;
105.5 }
105.6 case WM_AWT_DISPOSE: {
105.7 - BOOL canDispose = TRUE;
105.8 - CriticalSection &syncCS = AwtToolkit::GetInstance().GetSyncCS();
105.9 - int shouldEnterCriticalSection = (int)lParam;
105.10 - if (shouldEnterCriticalSection == 1) {
105.11 - canDispose = syncCS.TryEnter();
105.12 - }
105.13 - if (canDispose) {
105.14 - if(wParam != NULL) {
105.15 - jobject self = (jobject)wParam;
105.16 - AwtObject *o = (AwtObject *) JNI_GET_PDATA(self);
105.17 - env->DeleteGlobalRef(self);
105.18 - if(o != NULL && theAwtObjectList.Remove(o)) {
105.19 - o->Dispose();
105.20 - }
105.21 - if (shouldEnterCriticalSection) {
105.22 - syncCS.Leave();
105.23 - }
105.24 + if(wParam != NULL) {
105.25 + jobject self = (jobject)wParam;
105.26 + AwtObject *o = (AwtObject *) JNI_GET_PDATA(self);
105.27 + env->DeleteGlobalRef(self);
105.28 + if(o != NULL && theAwtObjectList.Remove(o)) {
105.29 + o->Dispose();
105.30 }
105.31 - } else {
105.32 - AwtToolkit::GetInstance().PostMessage(WM_AWT_DISPOSE, wParam, lParam);
105.33 }
105.34 return 0;
105.35 }
105.36 @@ -1340,25 +1327,46 @@
105.37
105.38 while (!m_breakMessageLoop && (*lpPeekMessageFunc)(msg)) {
105.39 foundOne = TRUE;
105.40 - if (msg.message == WM_QUIT) {
105.41 - m_breakMessageLoop = TRUE;
105.42 - m_messageLoopResult = static_cast<UINT>(msg.wParam);
105.43 - if (m_messageLoopResult == EXIT_ALL_ENCLOSING_LOOPS)
105.44 - ::PostQuitMessage(static_cast<int>(msg.wParam)); // make sure all loops exit
105.45 - break;
105.46 - }
105.47 - else if (msg.message != WM_NULL) {
105.48 - /*
105.49 - * The AWT in standalone mode (that is, dynamically loaded from the
105.50 - * Java VM) doesn't have any translation tables to worry about, so
105.51 - * TranslateAccelerator isn't called.
105.52 - */
105.53 -
105.54 - ::TranslateMessage(&msg);
105.55 - ::DispatchMessage(&msg);
105.56 + ProcessMsg(msg);
105.57 + }
105.58 + return foundOne;
105.59 +}
105.60 +
105.61 +void AwtToolkit::PumpToDestroy(class AwtComponent* p)
105.62 +{
105.63 + MSG msg;
105.64 +
105.65 + DASSERT(AwtToolkit::PrimaryIdleFunc != NULL);
105.66 + DASSERT(AwtToolkit::CommonPeekMessageFunc != NULL);
105.67 +
105.68 + while (p->IsDestroyPaused() && !m_breakMessageLoop) {
105.69 +
105.70 + PrimaryIdleFunc();
105.71 +
105.72 + while (p->IsDestroyPaused() && !m_breakMessageLoop && CommonPeekMessageFunc(msg)) {
105.73 + ProcessMsg(msg);
105.74 }
105.75 }
105.76 - return foundOne;
105.77 +}
105.78 +
105.79 +void AwtToolkit::ProcessMsg(MSG& msg)
105.80 +{
105.81 + if (msg.message == WM_QUIT) {
105.82 + m_breakMessageLoop = TRUE;
105.83 + m_messageLoopResult = static_cast<UINT>(msg.wParam);
105.84 + if (m_messageLoopResult == EXIT_ALL_ENCLOSING_LOOPS)
105.85 + ::PostQuitMessage(static_cast<int>(msg.wParam)); // make sure all loops exit
105.86 + }
105.87 + else if (msg.message != WM_NULL) {
105.88 + /*
105.89 + * The AWT in standalone mode (that is, dynamically loaded from the
105.90 + * Java VM) doesn't have any translation tables to worry about, so
105.91 + * TranslateAccelerator isn't called.
105.92 + */
105.93 +
105.94 + ::TranslateMessage(&msg);
105.95 + ::DispatchMessage(&msg);
105.96 + }
105.97 }
105.98
105.99 VOID CALLBACK
106.1 --- a/src/windows/native/sun/windows/awt_Toolkit.h Thu Oct 13 10:35:43 2011 -0700
106.2 +++ b/src/windows/native/sun/windows/awt_Toolkit.h Mon Oct 17 19:06:53 2011 -0700
106.3 @@ -305,6 +305,8 @@
106.4
106.5 UINT MessageLoop(IDLEPROC lpIdleFunc, PEEKMESSAGEPROC lpPeekMessageFunc);
106.6 BOOL PumpWaitingMessages(PEEKMESSAGEPROC lpPeekMessageFunc);
106.7 + void PumpToDestroy(class AwtComponent* p);
106.8 + void ProcessMsg(MSG& msg);
106.9 BOOL PreProcessMsg(MSG& msg);
106.10 BOOL PreProcessMouseMsg(class AwtComponent* p, MSG& msg);
106.11 BOOL PreProcessKeyMsg(class AwtComponent* p, MSG& msg);
107.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
107.2 +++ b/test/com/sun/jndi/ldap/LdapsReadTimeoutTest.java Mon Oct 17 19:06:53 2011 -0700
107.3 @@ -0,0 +1,118 @@
107.4 +/*
107.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
107.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
107.7 + *
107.8 + * This code is free software; you can redistribute it and/or modify it
107.9 + * under the terms of the GNU General Public License version 2 only, as
107.10 + * published by the Free Software Foundation.
107.11 + *
107.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
107.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
107.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
107.15 + * version 2 for more details (a copy is included in the LICENSE file that
107.16 + * accompanied this code).
107.17 + *
107.18 + * You should have received a copy of the GNU General Public License version
107.19 + * 2 along with this work; if not, write to the Free Software Foundation,
107.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
107.21 + *
107.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
107.23 + * or visit www.oracle.com if you need additional information or have any
107.24 + * questions.
107.25 + */
107.26 +
107.27 +/**
107.28 + * @test
107.29 + * @bug 7094377
107.30 + * @summary Com.sun.jndi.ldap.read.timeout doesn't work with ldaps.
107.31 + */
107.32 +
107.33 +import java.net.Socket;
107.34 +import java.net.ServerSocket;
107.35 +import java.io.*;
107.36 +import javax.naming.*;
107.37 +import javax.naming.directory.*;
107.38 +import java.util.Hashtable;
107.39 +
107.40 +public class LdapsReadTimeoutTest {
107.41 +
107.42 + public static void main(String[] args) throws Exception {
107.43 + boolean passed = false;
107.44 +
107.45 + // create the server
107.46 + try (Server server = Server.create()) {
107.47 + // Set up the environment for creating the initial context
107.48 + Hashtable<String,Object> env = new Hashtable<>(11);
107.49 + env.put(Context.INITIAL_CONTEXT_FACTORY,
107.50 + "com.sun.jndi.ldap.LdapCtxFactory");
107.51 + env.put("com.sun.jndi.ldap.connect.timeout", "1000");
107.52 + env.put("com.sun.jndi.ldap.read.timeout", "1000");
107.53 + env.put(Context.PROVIDER_URL, "ldaps://localhost:" + server.port());
107.54 +
107.55 +
107.56 + // Create initial context
107.57 + DirContext ctx = new InitialDirContext(env);
107.58 + try {
107.59 + System.out.println("LDAP Client: Connected to the Server");
107.60 +
107.61 + SearchControls scl = new SearchControls();
107.62 + scl.setSearchScope(SearchControls.SUBTREE_SCOPE);
107.63 + System.out.println("Performing Search");
107.64 + NamingEnumeration<SearchResult> answer =
107.65 + ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl);
107.66 + } finally {
107.67 + // Close the context when we're done
107.68 + ctx.close();
107.69 + }
107.70 + } catch (NamingException e) {
107.71 + passed = true;
107.72 + e.printStackTrace();
107.73 + }
107.74 +
107.75 + if (!passed) {
107.76 + throw new Exception("Read timeout test failed," +
107.77 + " read timeout exception not thrown");
107.78 + }
107.79 + System.out.println("The test PASSED");
107.80 + }
107.81 +
107.82 + static class Server implements Runnable, Closeable {
107.83 + private final ServerSocket ss;
107.84 + private Socket sref;
107.85 +
107.86 + private Server(ServerSocket ss) {
107.87 + this.ss = ss;
107.88 + }
107.89 +
107.90 + static Server create() throws IOException {
107.91 + Server server = new Server(new ServerSocket(0));
107.92 + new Thread(server).start();
107.93 + return server;
107.94 + }
107.95 +
107.96 + int port() {
107.97 + return ss.getLocalPort();
107.98 + }
107.99 +
107.100 + public void run() {
107.101 + try (Socket s = ss.accept()) {
107.102 + sref = s;
107.103 + System.out.println("Server: Connection accepted");
107.104 + BufferedInputStream bis =
107.105 + new BufferedInputStream(s.getInputStream());
107.106 + byte[] buf = new byte[100];
107.107 + int n;
107.108 + do {
107.109 + n = bis.read(buf);
107.110 + } while (n > 0);
107.111 + } catch (IOException e) {
107.112 + // ignore
107.113 + }
107.114 + }
107.115 +
107.116 + public void close() throws IOException {
107.117 + ss.close();
107.118 + sref.close();
107.119 + }
107.120 + }
107.121 +}
108.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
108.2 +++ b/test/java/net/CookieHandler/NullUriCookieTest.java Mon Oct 17 19:06:53 2011 -0700
108.3 @@ -0,0 +1,80 @@
108.4 +/*
108.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
108.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
108.7 + *
108.8 + * This code is free software; you can redistribute it and/or modify it
108.9 + * under the terms of the GNU General Public License version 2 only, as
108.10 + * published by the Free Software Foundation.
108.11 + *
108.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
108.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
108.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
108.15 + * version 2 for more details (a copy is included in the LICENSE file that
108.16 + * accompanied this code).
108.17 + *
108.18 + * You should have received a copy of the GNU General Public License version
108.19 + * 2 along with this work; if not, write to the Free Software Foundation,
108.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
108.21 + *
108.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
108.23 + * or visit www.oracle.com if you need additional information or have any
108.24 + * questions.
108.25 + */
108.26 +
108.27 +/*
108.28 + * @test
108.29 + * @bug 6953455
108.30 + * @summary CookieStore.add() cannot handle null URI parameter
108.31 + */
108.32 +
108.33 +import java.net.CookieManager;
108.34 +import java.net.CookieStore;
108.35 +import java.net.HttpCookie;
108.36 +import java.net.URI;
108.37 +import java.net.URISyntaxException;
108.38 +import java.util.List;
108.39 +
108.40 +public class NullUriCookieTest {
108.41 + static boolean fail = false;
108.42 +
108.43 + public static void main(String[] args) throws Exception {
108.44 + checkCookieNullUri();
108.45 + }
108.46 +
108.47 + static void checkCookieNullUri() throws Exception {
108.48 + //get a cookie store implementation and add a cookie to the store with null URI
108.49 + CookieStore cookieStore = (new CookieManager()).getCookieStore();
108.50 + HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
108.51 + cookie.setDomain("foo.com");
108.52 + cookieStore.add(null, cookie);
108.53 +
108.54 + //Retrieve added cookie
108.55 + URI uri = new URI("http://foo.com");
108.56 + List<HttpCookie> addedCookieList = cookieStore.get(uri);
108.57 +
108.58 + //Verify CookieStore behaves well
108.59 + if (addedCookieList.size() != 1) {
108.60 + fail = true;
108.61 + }
108.62 + checkFail("Abnormal size of cookie jar");
108.63 +
108.64 + for (HttpCookie chip : addedCookieList) {
108.65 + if (!chip.equals(cookie)) {
108.66 + fail = true;
108.67 + }
108.68 + }
108.69 + checkFail("Cookie not retrieved from Cookie Jar");
108.70 + boolean ret = cookieStore.remove(null,cookie);
108.71 + if (!ret) {
108.72 + fail = true;
108.73 + }
108.74 + checkFail("Abnormal removal behaviour from Cookie Jar");
108.75 + }
108.76 +
108.77 + static void checkFail(String exp) {
108.78 + if (fail) {
108.79 + throw new RuntimeException(exp);
108.80 + }
108.81 + }
108.82 +}
108.83 +
109.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
109.2 +++ b/test/java/net/DatagramSocket/ChangingAddress.java Mon Oct 17 19:06:53 2011 -0700
109.3 @@ -0,0 +1,56 @@
109.4 +/*
109.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
109.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
109.7 + *
109.8 + * This code is free software; you can redistribute it and/or modify it
109.9 + * under the terms of the GNU General Public License version 2 only, as
109.10 + * published by the Free Software Foundation.
109.11 + *
109.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
109.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
109.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
109.15 + * version 2 for more details (a copy is included in the LICENSE file that
109.16 + * accompanied this code).
109.17 + *
109.18 + * You should have received a copy of the GNU General Public License version
109.19 + * 2 along with this work; if not, write to the Free Software Foundation,
109.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
109.21 + *
109.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
109.23 + * or visit www.oracle.com if you need additional information or have any
109.24 + * questions.
109.25 + */
109.26 +
109.27 +/* @test
109.28 + * @bug 7084030
109.29 + * @summary Tests that DatagramSocket.getLocalAddress returns the right local
109.30 + * address after connect/disconnect.
109.31 + */
109.32 +import java.net.*;
109.33 +
109.34 +public class ChangingAddress {
109.35 +
109.36 + static void check(DatagramSocket ds, InetAddress expected) {
109.37 + InetAddress actual = ds.getLocalAddress();
109.38 + if (!expected.equals(actual)) {
109.39 + throw new RuntimeException("Expected:"+expected+" Actual"+
109.40 + actual);
109.41 + }
109.42 + }
109.43 +
109.44 + public static void main(String[] args) throws Exception {
109.45 + InetAddress lh = InetAddress.getLocalHost();
109.46 + SocketAddress remote = new InetSocketAddress(lh, 1234);
109.47 + InetAddress wildcard = InetAddress.getByAddress
109.48 + ("localhost", new byte[]{0,0,0,0});
109.49 + try (DatagramSocket ds = new DatagramSocket()) {
109.50 + check(ds, wildcard);
109.51 +
109.52 + ds.connect(remote);
109.53 + check(ds, lh);
109.54 +
109.55 + ds.disconnect();
109.56 + check(ds, wildcard);
109.57 + }
109.58 + }
109.59 +}
110.1 --- a/test/java/net/URLConnection/Redirect307Test.java Thu Oct 13 10:35:43 2011 -0700
110.2 +++ b/test/java/net/URLConnection/Redirect307Test.java Mon Oct 17 19:06:53 2011 -0700
110.3 @@ -23,7 +23,7 @@
110.4
110.5 /**
110.6 * @test
110.7 - * @bug 4380568
110.8 + * @bug 4380568 7095949
110.9 * @summary HttpURLConnection does not support 307 redirects
110.10 */
110.11 import java.io.*;
110.12 @@ -31,10 +31,9 @@
110.13
110.14 class RedirServer extends Thread {
110.15
110.16 - ServerSocket s;
110.17 - Socket s1;
110.18 - InputStream is;
110.19 - OutputStream os;
110.20 + static final int TIMEOUT = 10 * 1000;
110.21 +
110.22 + ServerSocket ss;
110.23 int port;
110.24
110.25 String reply1Part1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
110.26 @@ -46,10 +45,10 @@
110.27 "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
110.28 "<html>Hello</html>";
110.29
110.30 - RedirServer (ServerSocket y) {
110.31 - s = y;
110.32 - port = s.getLocalPort();
110.33 - System.out.println("Server created listening on " + port);
110.34 + RedirServer (ServerSocket ss) throws IOException {
110.35 + this.ss = ss;
110.36 + this.ss.setSoTimeout(TIMEOUT);
110.37 + port = this.ss.getLocalPort();
110.38 }
110.39
110.40 String reply2 = "HTTP/1.1 200 Ok\r\n" +
110.41 @@ -59,74 +58,63 @@
110.42 "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
110.43 "World";
110.44
110.45 + static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' };
110.46 +
110.47 + // Read until the end of a HTTP request
110.48 + void readOneRequest(InputStream is) throws IOException {
110.49 + int requestEndCount = 0, r;
110.50 + while ((r = is.read()) != -1) {
110.51 + if (r == requestEnd[requestEndCount]) {
110.52 + requestEndCount++;
110.53 + if (requestEndCount == 4) {
110.54 + break;
110.55 + }
110.56 + } else {
110.57 + requestEndCount = 0;
110.58 + }
110.59 + }
110.60 + }
110.61 +
110.62 public void run () {
110.63 try {
110.64 - s1 = s.accept ();
110.65 - is = s1.getInputStream ();
110.66 - os = s1.getOutputStream ();
110.67 - is.read ();
110.68 - String reply = reply1Part1 + port + reply1Part2;
110.69 - os.write (reply.getBytes());
110.70 - os.close();
110.71 + try (Socket s = ss.accept()) {
110.72 + s.setSoTimeout(TIMEOUT);
110.73 + readOneRequest(s.getInputStream());
110.74 + String reply = reply1Part1 + port + reply1Part2;
110.75 + s.getOutputStream().write(reply.getBytes());
110.76 + }
110.77 +
110.78 /* wait for redirected connection */
110.79 - s.setSoTimeout (5000);
110.80 - s1 = s.accept ();
110.81 - is = s1.getInputStream ();
110.82 - os = s1.getOutputStream ();
110.83 - is.read();
110.84 - os.write (reply2.getBytes());
110.85 - os.close();
110.86 - }
110.87 - catch (Exception e) {
110.88 - /* Just need thread to terminate */
110.89 - System.out.println("Server: caught " + e);
110.90 + try (Socket s = ss.accept()) {
110.91 + s.setSoTimeout(TIMEOUT);
110.92 + readOneRequest(s.getInputStream());
110.93 + s.getOutputStream().write(reply2.getBytes());
110.94 + }
110.95 + } catch (Exception e) {
110.96 e.printStackTrace();
110.97 } finally {
110.98 - try { s.close(); } catch (IOException unused) {}
110.99 + try { ss.close(); } catch (IOException unused) {}
110.100 }
110.101 }
110.102 };
110.103
110.104 +public class Redirect307Test {
110.105 + public static void main(String[] args) throws Exception {
110.106 + ServerSocket sock = new ServerSocket(0);
110.107 + int port = sock.getLocalPort();
110.108 + RedirServer server = new RedirServer(sock);
110.109 + server.start();
110.110
110.111 -public class Redirect307Test {
110.112 + URL url = new URL("http://localhost:" + port);
110.113 + URLConnection conURL = url.openConnection();
110.114 + conURL.setDoInput(true);
110.115 + conURL.setAllowUserInteraction(false);
110.116 + conURL.setUseCaches(false);
110.117
110.118 - public static final int DELAY = 10;
110.119 -
110.120 - public static void main(String[] args) throws Exception {
110.121 - int port;
110.122 - RedirServer server;
110.123 - ServerSocket sock;
110.124 -
110.125 - try {
110.126 - sock = new ServerSocket (0);
110.127 - port = sock.getLocalPort ();
110.128 - }
110.129 - catch (Exception e) {
110.130 - System.out.println ("Exception: " + e);
110.131 - return;
110.132 - }
110.133 -
110.134 - server = new RedirServer(sock);
110.135 - server.start ();
110.136 -
110.137 - try {
110.138 -
110.139 - String s = "http://localhost:" + port;
110.140 - URL url = new URL(s);
110.141 - URLConnection conURL = url.openConnection();
110.142 -
110.143 - conURL.setDoInput(true);
110.144 - conURL.setAllowUserInteraction(false);
110.145 - conURL.setUseCaches(false);
110.146 -
110.147 - InputStream in = conURL.getInputStream();
110.148 + try (InputStream in = conURL.getInputStream()) {
110.149 if ((in.read() != (int)'W') || (in.read()!=(int)'o')) {
110.150 throw new RuntimeException ("Unexpected string read");
110.151 }
110.152 }
110.153 - catch(IOException e) {
110.154 - e.printStackTrace();
110.155 - throw new RuntimeException ("Exception caught + " + e);
110.156 - }
110.157 }
110.158 }
111.1 --- a/test/java/net/URLConnection/RedirectLimit.java Thu Oct 13 10:35:43 2011 -0700
111.2 +++ b/test/java/net/URLConnection/RedirectLimit.java Mon Oct 17 19:06:53 2011 -0700
111.3 @@ -23,7 +23,7 @@
111.4
111.5 /**
111.6 * @test
111.7 - * @bug 4458085
111.8 + * @bug 4458085 7095949
111.9 * @summary Redirects Limited to 5
111.10 */
111.11
111.12 @@ -57,29 +57,43 @@
111.13 final ServerSocket ss;
111.14 final int port;
111.15
111.16 - RedirLimitServer(ServerSocket ss) {
111.17 + RedirLimitServer(ServerSocket ss) throws IOException {
111.18 this.ss = ss;
111.19 - port = ss.getLocalPort();
111.20 + port = this.ss.getLocalPort();
111.21 + this.ss.setSoTimeout(TIMEOUT);
111.22 + }
111.23 +
111.24 + static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' };
111.25 +
111.26 + // Read until the end of a HTTP request
111.27 + void readOneRequest(InputStream is) throws IOException {
111.28 + int requestEndCount = 0, r;
111.29 + while ((r = is.read()) != -1) {
111.30 + if (r == requestEnd[requestEndCount]) {
111.31 + requestEndCount++;
111.32 + if (requestEndCount == 4) {
111.33 + break;
111.34 + }
111.35 + } else {
111.36 + requestEndCount = 0;
111.37 + }
111.38 + }
111.39 }
111.40
111.41 public void run() {
111.42 try {
111.43 - ss.setSoTimeout(TIMEOUT);
111.44 for (int i=0; i<NUM_REDIRECTS; i++) {
111.45 try (Socket s = ss.accept()) {
111.46 s.setSoTimeout(TIMEOUT);
111.47 - InputStream is = s.getInputStream();
111.48 - OutputStream os = s.getOutputStream();
111.49 - is.read();
111.50 + readOneRequest(s.getInputStream());
111.51 String reply = reply1 + port + "/redirect" + i + reply2;
111.52 - os.write(reply.getBytes());
111.53 + s.getOutputStream().write(reply.getBytes());
111.54 }
111.55 }
111.56 try (Socket s = ss.accept()) {
111.57 - InputStream is = s.getInputStream();
111.58 - OutputStream os = s.getOutputStream();
111.59 - is.read();
111.60 - os.write(reply3.getBytes());
111.61 + s.setSoTimeout(TIMEOUT);
111.62 + readOneRequest(s.getInputStream());
111.63 + s.getOutputStream().write(reply3.getBytes());
111.64 }
111.65 } catch (Exception e) {
111.66 e.printStackTrace();
111.67 @@ -96,21 +110,17 @@
111.68 RedirLimitServer server = new RedirLimitServer(ss);
111.69 server.start();
111.70
111.71 - InputStream in = null;
111.72 - try {
111.73 - URL url = new URL("http://localhost:" + port);
111.74 - URLConnection conURL = url.openConnection();
111.75 + URL url = new URL("http://localhost:" + port);
111.76 + URLConnection conURL = url.openConnection();
111.77
111.78 - conURL.setDoInput(true);
111.79 - conURL.setAllowUserInteraction(false);
111.80 - conURL.setUseCaches(false);
111.81 + conURL.setDoInput(true);
111.82 + conURL.setAllowUserInteraction(false);
111.83 + conURL.setUseCaches(false);
111.84
111.85 - in = conURL.getInputStream();
111.86 + try (InputStream in = conURL.getInputStream()) {
111.87 if ((in.read() != (int)'W') || (in.read()!=(int)'o')) {
111.88 throw new RuntimeException("Unexpected string read");
111.89 }
111.90 - } finally {
111.91 - if ( in != null ) { in.close(); }
111.92 }
111.93 }
111.94 }
112.1 --- a/test/java/util/Locale/Bug6989440.java Thu Oct 13 10:35:43 2011 -0700
112.2 +++ b/test/java/util/Locale/Bug6989440.java Mon Oct 17 19:06:53 2011 -0700
112.3 @@ -37,26 +37,49 @@
112.4 import sun.util.LocaleServiceProviderPool;
112.5
112.6 public class Bug6989440 {
112.7 - public static void main(String[] args) {
112.8 - TestThread t1 = new TestThread(LocaleNameProvider.class);
112.9 - TestThread t2 = new TestThread(TimeZoneNameProvider.class);
112.10 - TestThread t3 = new TestThread(DateFormatProvider.class);
112.11 + static volatile boolean failed; // false
112.12 + static final int THREADS = 50;
112.13
112.14 - t1.start();
112.15 - t2.start();
112.16 - t3.start();
112.17 + public static void main(String[] args) throws Exception {
112.18 + Thread[] threads = new Thread[THREADS];
112.19 + for (int i=0; i<threads.length; i++)
112.20 + threads[i] = new TestThread();
112.21 + for (int i=0; i<threads.length; i++)
112.22 + threads[i].start();
112.23 + for (int i=0; i<threads.length; i++)
112.24 + threads[i].join();
112.25 +
112.26 + if (failed)
112.27 + throw new RuntimeException("Failed: check output");
112.28 }
112.29
112.30 static class TestThread extends Thread {
112.31 private Class<? extends LocaleServiceProvider> cls;
112.32 + private static int count;
112.33
112.34 public TestThread(Class<? extends LocaleServiceProvider> providerClass) {
112.35 cls = providerClass;
112.36 }
112.37
112.38 + public TestThread() {
112.39 + int which = count++ % 3;
112.40 + switch (which) {
112.41 + case 0 : cls = LocaleNameProvider.class; break;
112.42 + case 1 : cls = TimeZoneNameProvider.class; break;
112.43 + case 2 : cls = DateFormatProvider.class; break;
112.44 + default : throw new AssertionError("Should not reach here");
112.45 + }
112.46 + }
112.47 +
112.48 public void run() {
112.49 - LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls);
112.50 - pool.getAvailableLocales();
112.51 + try {
112.52 + LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls);
112.53 + pool.getAvailableLocales();
112.54 + } catch (Exception e) {
112.55 + System.out.println(e);
112.56 + e.printStackTrace();
112.57 + failed = true;
112.58 + }
112.59 }
112.60 }
112.61 }
113.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
113.2 +++ b/test/javax/swing/JColorChooser/Test6827032.java Mon Oct 17 19:06:53 2011 -0700
113.3 @@ -0,0 +1,86 @@
113.4 +/*
113.5 + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
113.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
113.7 + *
113.8 + * This code is free software; you can redistribute it and/or modify it
113.9 + * under the terms of the GNU General Public License version 2 only, as
113.10 + * published by the Free Software Foundation.
113.11 + *
113.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
113.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
113.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
113.15 + * version 2 for more details (a copy is included in the LICENSE file that
113.16 + * accompanied this code).
113.17 + *
113.18 + * You should have received a copy of the GNU General Public License version
113.19 + * 2 along with this work; if not, write to the Free Software Foundation,
113.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
113.21 + *
113.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
113.23 + * or visit www.oracle.com if you need additional information or have any
113.24 + * questions.
113.25 + */
113.26 +
113.27 +/*
113.28 + * @test
113.29 + * @bug 6827032
113.30 + * @summary Color chooser with drag enabled shouldn't throw NPE
113.31 + * @author Peter Zhelezniakov
113.32 + * @library ../regtesthelpers
113.33 + */
113.34 +
113.35 +import sun.awt.SunToolkit;
113.36 +
113.37 +import java.awt.*;
113.38 +import java.awt.event.*;
113.39 +
113.40 +import javax.swing.*;
113.41 +import javax.swing.plaf.nimbus.NimbusLookAndFeel;
113.42 +
113.43 +
113.44 +public class Test6827032 {
113.45 +
113.46 + private static volatile Point point;
113.47 + private static JColorChooser cc;
113.48 +
113.49 + public static void main(String[] args) throws Exception {
113.50 + UIManager.setLookAndFeel(new NimbusLookAndFeel());
113.51 +
113.52 + Robot robot = new Robot();
113.53 + robot.setAutoDelay(50);
113.54 +
113.55 + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
113.56 +
113.57 + SwingUtilities.invokeAndWait(new Runnable() {
113.58 + public void run() {
113.59 + createAndShowGUI();
113.60 + }
113.61 + });
113.62 +
113.63 + toolkit.realSync();
113.64 +
113.65 + SwingUtilities.invokeAndWait(new Runnable() {
113.66 + public void run() {
113.67 + Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
113.68 + point = previewPanel.getLocationOnScreen();
113.69 + }
113.70 + });
113.71 +
113.72 + point.translate(5, 5);
113.73 +
113.74 + robot.mouseMove(point.x, point.y);
113.75 + robot.mousePress(InputEvent.BUTTON1_MASK);
113.76 + robot.mouseRelease(InputEvent.BUTTON1_MASK);
113.77 + }
113.78 +
113.79 +
113.80 + private static void createAndShowGUI() {
113.81 + JFrame frame = new JFrame(Test6827032.class.getName());
113.82 + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
113.83 + cc = new JColorChooser();
113.84 + cc.setDragEnabled(true);
113.85 + frame.add(cc);
113.86 + frame.pack();
113.87 + frame.setVisible(true);
113.88 + }
113.89 +}
114.1 --- a/test/javax/swing/regtesthelpers/Util.java Thu Oct 13 10:35:43 2011 -0700
114.2 +++ b/test/javax/swing/regtesthelpers/Util.java Mon Oct 17 19:06:53 2011 -0700
114.3 @@ -116,4 +116,28 @@
114.4
114.5 System.out.println("Got OOME");
114.6 }
114.7 +
114.8 + /**
114.9 + * Find a sub component by class name.
114.10 + * Always run this method on the EDT thread
114.11 + */
114.12 + public static Component findSubComponent(Component parent, String className) {
114.13 + String parentClassName = parent.getClass().getName();
114.14 +
114.15 + if (parentClassName.contains(className)) {
114.16 + return parent;
114.17 + }
114.18 +
114.19 + if (parent instanceof Container) {
114.20 + for (Component child : ((Container) parent).getComponents()) {
114.21 + Component subComponent = findSubComponent(child, className);
114.22 +
114.23 + if (subComponent != null) {
114.24 + return subComponent;
114.25 + }
114.26 + }
114.27 + }
114.28 +
114.29 + return null;
114.30 + }
114.31 }
115.1 --- a/test/sun/misc/JarIndex/metaInfFilenames/Basic.java Thu Oct 13 10:35:43 2011 -0700
115.2 +++ b/test/sun/misc/JarIndex/metaInfFilenames/Basic.java Mon Oct 17 19:06:53 2011 -0700
115.3 @@ -154,8 +154,8 @@
115.4 /* run javac <args> */
115.5 static void compile(String... args) {
115.6 debug("Running: javac " + Arrays.toString(args));
115.7 - com.sun.tools.javac.main.Main compiler = new com.sun.tools.javac.main.Main("javac");
115.8 - if (compiler.compile(args) != com.sun.tools.javac.main.Main.Result.OK) {
115.9 + com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main();
115.10 + if (compiler.compile(args) != 0) {
115.11 throw new RuntimeException("javac failed: args=" + Arrays.toString(args));
115.12 }
115.13 }
116.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
116.2 +++ b/test/sun/security/krb5/auto/AcceptorSubKey.java Mon Oct 17 19:06:53 2011 -0700
116.3 @@ -0,0 +1,63 @@
116.4 +/*
116.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
116.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
116.7 + *
116.8 + * This code is free software; you can redistribute it and/or modify it
116.9 + * under the terms of the GNU General Public License version 2 only, as
116.10 + * published by the Free Software Foundation.
116.11 + *
116.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
116.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
116.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
116.15 + * version 2 for more details (a copy is included in the LICENSE file that
116.16 + * accompanied this code).
116.17 + *
116.18 + * You should have received a copy of the GNU General Public License version
116.19 + * 2 along with this work; if not, write to the Free Software Foundation,
116.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
116.21 + *
116.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
116.23 + * or visit www.oracle.com if you need additional information or have any
116.24 + * questions.
116.25 + */
116.26 +
116.27 +/*
116.28 + * @test
116.29 + * @bug 7077646
116.30 + * @summary gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
116.31 + * @compile -XDignore.symbol.file AcceptorSubKey.java
116.32 + * @run main/othervm AcceptorSubKey
116.33 + */
116.34 +
116.35 +import java.util.Arrays;
116.36 +import sun.security.jgss.GSSUtil;
116.37 +
116.38 +// The basic krb5 test skeleton you can copy from
116.39 +public class AcceptorSubKey {
116.40 +
116.41 + public static void main(String[] args) throws Exception {
116.42 +
116.43 + new OneKDC(null).writeJAASConf();
116.44 +
116.45 + Context c, s;
116.46 + c = Context.fromJAAS("client");
116.47 + s = Context.fromJAAS("server");
116.48 +
116.49 + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
116.50 + s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
116.51 +
116.52 + Context.handshake(c, s);
116.53 +
116.54 + byte[] msg = "i say high --".getBytes();
116.55 + byte[] wrapped = s.wrap(msg, false);
116.56 +
116.57 + // FLAG_ACCEPTOR_SUBKEY is 4
116.58 + int flagOn = wrapped[2] & 4;
116.59 + if (flagOn != 0) {
116.60 + throw new Exception("Java GSS should not have set acceptor subkey");
116.61 + }
116.62 +
116.63 + s.dispose();
116.64 + c.dispose();
116.65 + }
116.66 +}
117.1 --- a/test/sun/security/krb5/auto/Context.java Thu Oct 13 10:35:43 2011 -0700
117.2 +++ b/test/sun/security/krb5/auto/Context.java Mon Oct 17 19:06:53 2011 -0700
117.3 @@ -375,6 +375,89 @@
117.4 }
117.5 }
117.6
117.7 + public byte[] wrap(byte[] t, final boolean privacy)
117.8 + throws Exception {
117.9 + return doAs(new Action() {
117.10 + @Override
117.11 + public byte[] run(Context me, byte[] input) throws Exception {
117.12 + System.out.printf("wrap %s privacy from %s: ", privacy?"with":"without", me.name);
117.13 + MessageProp p1 = new MessageProp(0, privacy);
117.14 + byte[] out;
117.15 + if (usingStream) {
117.16 + ByteArrayOutputStream os = new ByteArrayOutputStream();
117.17 + me.x.wrap(new ByteArrayInputStream(input), os, p1);
117.18 + out = os.toByteArray();
117.19 + } else {
117.20 + out = me.x.wrap(input, 0, input.length, p1);
117.21 + }
117.22 + System.out.println(printProp(p1));
117.23 + return out;
117.24 + }
117.25 + }, t);
117.26 + }
117.27 +
117.28 + public byte[] unwrap(byte[] t, final boolean privacy)
117.29 + throws Exception {
117.30 + return doAs(new Action() {
117.31 + @Override
117.32 + public byte[] run(Context me, byte[] input) throws Exception {
117.33 + System.out.printf("unwrap %s privacy from %s: ", privacy?"with":"without", me.name);
117.34 + MessageProp p1 = new MessageProp(0, privacy);
117.35 + byte[] bytes;
117.36 + if (usingStream) {
117.37 + ByteArrayOutputStream os = new ByteArrayOutputStream();
117.38 + me.x.unwrap(new ByteArrayInputStream(input), os, p1);
117.39 + bytes = os.toByteArray();
117.40 + } else {
117.41 + bytes = me.x.unwrap(input, 0, input.length, p1);
117.42 + }
117.43 + System.out.println(printProp(p1));
117.44 + return bytes;
117.45 + }
117.46 + }, t);
117.47 + }
117.48 +
117.49 + public byte[] getMic(byte[] t) throws Exception {
117.50 + return doAs(new Action() {
117.51 + @Override
117.52 + public byte[] run(Context me, byte[] input) throws Exception {
117.53 + MessageProp p1 = new MessageProp(0, true);
117.54 + byte[] bytes;
117.55 + p1 = new MessageProp(0, true);
117.56 + System.out.printf("getMic from %s: ", me.name);
117.57 + if (usingStream) {
117.58 + ByteArrayOutputStream os = new ByteArrayOutputStream();
117.59 + me.x.getMIC(new ByteArrayInputStream(input), os, p1);
117.60 + bytes = os.toByteArray();
117.61 + } else {
117.62 + bytes = me.x.getMIC(input, 0, input.length, p1);
117.63 + }
117.64 + System.out.println(printProp(p1));
117.65 + return bytes;
117.66 + }
117.67 + }, t);
117.68 + }
117.69 +
117.70 + public void verifyMic(byte[] t, final byte[] msg) throws Exception {
117.71 + doAs(new Action() {
117.72 + @Override
117.73 + public byte[] run(Context me, byte[] input) throws Exception {
117.74 + MessageProp p1 = new MessageProp(0, true);
117.75 + System.out.printf("verifyMic from %s: ", me.name);
117.76 + if (usingStream) {
117.77 + me.x.verifyMIC(new ByteArrayInputStream(input),
117.78 + new ByteArrayInputStream(msg), p1);
117.79 + } else {
117.80 + me.x.verifyMIC(input, 0, input.length,
117.81 + msg, 0, msg.length,
117.82 + p1);
117.83 + }
117.84 + System.out.println(printProp(p1));
117.85 + return null;
117.86 + }
117.87 + }, t);
117.88 + }
117.89 +
117.90 /**
117.91 * Transmits a message from one Context to another. The sender wraps the
117.92 * message and sends it to the receiver. The receiver unwraps it, creates
117.93 @@ -390,73 +473,13 @@
117.94 final byte[] messageBytes = message.getBytes();
117.95 System.out.printf("-------------------- TRANSMIT from %s to %s------------------------\n",
117.96 s1.name, s2.name);
117.97 -
117.98 - byte[] t = s1.doAs(new Action() {
117.99 - @Override
117.100 - public byte[] run(Context me, byte[] dummy) throws Exception {
117.101 - System.out.println("wrap");
117.102 - MessageProp p1 = new MessageProp(0, true);
117.103 - byte[] out;
117.104 - if (usingStream) {
117.105 - ByteArrayOutputStream os = new ByteArrayOutputStream();
117.106 - me.x.wrap(new ByteArrayInputStream(messageBytes), os, p1);
117.107 - out = os.toByteArray();
117.108 - } else {
117.109 - out = me.x.wrap(messageBytes, 0, messageBytes.length, p1);
117.110 - }
117.111 - System.out.println(printProp(p1));
117.112 - return out;
117.113 - }
117.114 - }, null);
117.115 -
117.116 - t = s2.doAs(new Action() {
117.117 - @Override
117.118 - public byte[] run(Context me, byte[] input) throws Exception {
117.119 - MessageProp p1 = new MessageProp(0, true);
117.120 - byte[] bytes;
117.121 - if (usingStream) {
117.122 - ByteArrayOutputStream os = new ByteArrayOutputStream();
117.123 - me.x.unwrap(new ByteArrayInputStream(input), os, p1);
117.124 - bytes = os.toByteArray();
117.125 - } else {
117.126 - bytes = me.x.unwrap(input, 0, input.length, p1);
117.127 - }
117.128 - if (!Arrays.equals(messageBytes, bytes))
117.129 - throw new Exception("wrap/unwrap mismatch");
117.130 - System.out.println("unwrap");
117.131 - System.out.println(printProp(p1));
117.132 - p1 = new MessageProp(0, true);
117.133 - System.out.println("getMIC");
117.134 - if (usingStream) {
117.135 - ByteArrayOutputStream os = new ByteArrayOutputStream();
117.136 - me.x.getMIC(new ByteArrayInputStream(messageBytes), os, p1);
117.137 - bytes = os.toByteArray();
117.138 - } else {
117.139 - bytes = me.x.getMIC(messageBytes, 0, messageBytes.length, p1);
117.140 - }
117.141 - System.out.println(printProp(p1));
117.142 - return bytes;
117.143 - }
117.144 - }, t);
117.145 -
117.146 - // Re-unwrap should make p2.isDuplicateToken() returns true
117.147 - s1.doAs(new Action() {
117.148 - @Override
117.149 - public byte[] run(Context me, byte[] input) throws Exception {
117.150 - MessageProp p1 = new MessageProp(0, true);
117.151 - System.out.println("verifyMIC");
117.152 - if (usingStream) {
117.153 - me.x.verifyMIC(new ByteArrayInputStream(input),
117.154 - new ByteArrayInputStream(messageBytes), p1);
117.155 - } else {
117.156 - me.x.verifyMIC(input, 0, input.length,
117.157 - messageBytes, 0, messageBytes.length,
117.158 - p1);
117.159 - }
117.160 - System.out.println(printProp(p1));
117.161 - return null;
117.162 - }
117.163 - }, t);
117.164 + byte[] wrapped = s1.wrap(messageBytes, true);
117.165 + byte[] unwrapped = s2.unwrap(wrapped, true);
117.166 + if (!Arrays.equals(messageBytes, unwrapped)) {
117.167 + throw new Exception("wrap/unwrap mismatch");
117.168 + }
117.169 + byte[] mic = s2.getMic(unwrapped);
117.170 + s1.verifyMic(mic, messageBytes);
117.171 }
117.172
117.173 /**
118.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
118.2 +++ b/test/sun/security/krb5/auto/NoInitNoKeytab.java Mon Oct 17 19:06:53 2011 -0700
118.3 @@ -0,0 +1,66 @@
118.4 +/*
118.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
118.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
118.7 + *
118.8 + * This code is free software; you can redistribute it and/or modify it
118.9 + * under the terms of the GNU General Public License version 2 only, as
118.10 + * published by the Free Software Foundation.
118.11 + *
118.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
118.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
118.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
118.15 + * version 2 for more details (a copy is included in the LICENSE file that
118.16 + * accompanied this code).
118.17 + *
118.18 + * You should have received a copy of the GNU General Public License version
118.19 + * 2 along with this work; if not, write to the Free Software Foundation,
118.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
118.21 + *
118.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
118.23 + * or visit www.oracle.com if you need additional information or have any
118.24 + * questions.
118.25 + */
118.26 +
118.27 +/*
118.28 + * @test
118.29 + * @bug 7089889
118.30 + * @summary Krb5LoginModule.login() throws an exception if used without a keytab
118.31 + * @compile -XDignore.symbol.file NoInitNoKeytab.java
118.32 + * @run main/othervm NoInitNoKeytab
118.33 + */
118.34 +
118.35 +import java.io.FileOutputStream;
118.36 +import sun.security.jgss.GSSUtil;
118.37 +
118.38 +// The basic krb5 test skeleton you can copy from
118.39 +public class NoInitNoKeytab {
118.40 +
118.41 + public static void main(String[] args) throws Exception {
118.42 +
118.43 + new OneKDC(null).writeJAASConf();
118.44 + try (FileOutputStream fos =
118.45 + new FileOutputStream(OneKDC.JAAS_CONF, true)) {
118.46 + fos.write((
118.47 + "noinit {\n" +
118.48 + " com.sun.security.auth.module.Krb5LoginModule required\n" +
118.49 + " principal=\"" + OneKDC.USER + "\"\n" +
118.50 + " useKeyTab=false\n" +
118.51 + " isInitiator=false\n" +
118.52 + " storeKey=true;\n};\n").getBytes());
118.53 + }
118.54 + Context c, s;
118.55 + c = Context.fromJAAS("client");
118.56 + s = Context.fromJAAS("noinit");
118.57 +
118.58 + c.startAsClient(OneKDC.USER, GSSUtil.GSS_SPNEGO_MECH_OID);
118.59 + s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
118.60 +
118.61 + Context.handshake(c, s);
118.62 +
118.63 + Context.transmit("i say high --", c, s);
118.64 + Context.transmit(" you say low", s, c);
118.65 +
118.66 + s.dispose();
118.67 + c.dispose();
118.68 + }
118.69 +}
119.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
119.2 +++ b/test/sun/security/krb5/auto/RRC.java Mon Oct 17 19:06:53 2011 -0700
119.3 @@ -0,0 +1,70 @@
119.4 +/*
119.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
119.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
119.7 + *
119.8 + * This code is free software; you can redistribute it and/or modify it
119.9 + * under the terms of the GNU General Public License version 2 only, as
119.10 + * published by the Free Software Foundation.
119.11 + *
119.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
119.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
119.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
119.15 + * version 2 for more details (a copy is included in the LICENSE file that
119.16 + * accompanied this code).
119.17 + *
119.18 + * You should have received a copy of the GNU General Public License version
119.19 + * 2 along with this work; if not, write to the Free Software Foundation,
119.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
119.21 + *
119.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
119.23 + * or visit www.oracle.com if you need additional information or have any
119.24 + * questions.
119.25 + */
119.26 +
119.27 +/*
119.28 + * @test
119.29 + * @bug 7077640
119.30 + * @summary gss wrap for cfx doesn't handle rrc != 0
119.31 + * @compile -XDignore.symbol.file RRC.java
119.32 + * @run main/othervm RRC
119.33 + */
119.34 +
119.35 +import java.util.Arrays;
119.36 +import sun.security.jgss.GSSUtil;
119.37 +
119.38 +// The basic krb5 test skeleton you can copy from
119.39 +public class RRC {
119.40 +
119.41 + public static void main(String[] args) throws Exception {
119.42 +
119.43 + new OneKDC(null).writeJAASConf();
119.44 +
119.45 + Context c, s;
119.46 + c = Context.fromJAAS("client");
119.47 + s = Context.fromJAAS("server");
119.48 +
119.49 + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
119.50 + s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
119.51 +
119.52 + Context.handshake(c, s);
119.53 +
119.54 + byte[] msg = "i say high --".getBytes();
119.55 + byte[] wrapped = c.wrap(msg, false);
119.56 +
119.57 + // Simulate RRC equals to EC
119.58 + int rrc = wrapped[5];
119.59 + byte[] rotated = new byte[wrapped.length];
119.60 + System.arraycopy(wrapped, 0, rotated, 0, 16);
119.61 + System.arraycopy(wrapped, wrapped.length-rrc, rotated, 16, rrc);
119.62 + System.arraycopy(wrapped, 16, rotated, 16+rrc, wrapped.length-16-rrc);
119.63 + rotated[7] = (byte)rrc;
119.64 +
119.65 + byte[] unwrapped = s.unwrap(rotated, false);
119.66 + if (!Arrays.equals(msg, unwrapped)) {
119.67 + throw new Exception("Failure");
119.68 + }
119.69 +
119.70 + s.dispose();
119.71 + c.dispose();
119.72 + }
119.73 +}