Mercurial > hg > icedtea9-forest > jdk
changeset 4815:4788745572ef jdk8-b10
Merge
author | lana |
---|---|
date | Mon, 17 Oct 2011 19:06:53 -0700 |
parents | 7539cc99befe (current diff) eac5d48a6c8e (diff) |
children | 7ab0d613cd1a |
files | |
diffstat | 119 files changed, 1784 insertions(+), 799 deletions(-) [+] |
line wrap: on
line diff
--- a/make/com/sun/org/apache/xml/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/com/sun/org/apache/xml/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -30,6 +30,8 @@ BUILDDIR = ../../../../.. PACKAGE = com.sun.org.apache.xml PRODUCT = xml +JAVAC_MAX_WARNINGS = true +JAVAC_WARNINGS_FATAL = true include $(BUILDDIR)/common/Defs.gmk #
--- a/make/common/Defs-linux.gmk Thu Oct 13 10:35:43 2011 -0700 +++ b/make/common/Defs-linux.gmk Mon Oct 17 19:06:53 2011 -0700 @@ -373,6 +373,7 @@ override LIBPOSIX4 = override LIBSOCKET = override LIBNSL = +override LIBSCF = override LIBTHREAD = override MOOT_PRIORITIES = true override NO_INTERRUPTIBLE_IO = true
--- a/make/common/Defs-solaris.gmk Thu Oct 13 10:35:43 2011 -0700 +++ b/make/common/Defs-solaris.gmk Mon Oct 17 19:06:53 2011 -0700 @@ -711,6 +711,9 @@ # Network Services library LIBNSL = -lnsl +# service configuration facility library +LIBSCF = -lscf + # GLOBAL_KPIC: If set means all libraries are PIC, position independent code # EXCEPT for select compiles # If a .o file is compiled non-PIC then it should be forced
--- a/make/java/java/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/java/java/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -208,7 +208,7 @@ -libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \ shell32.lib delayimp.lib /DELAYLOAD:shell32.dll else -OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \ +OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) $(LIBSCF) -ldl \ -L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH) endif
--- a/make/java/security/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/java/security/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -26,8 +26,8 @@ BUILDDIR = ../.. PACKAGE = java.security PRODUCT = sun -JAVAC_MAX_WARNINGS = false -JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation +JAVAC_MAX_WARNINGS = true +JAVAC_LINT_OPTIONS = -Xlint:all JAVAC_WARNINGS_FATAL = true include $(BUILDDIR)/common/Defs.gmk
--- a/make/javax/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/javax/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -30,7 +30,7 @@ BUILDDIR = .. include $(BUILDDIR)/common/Defs.gmk -SUBDIRS = others +SUBDIRS = others security SUBDIRS_management = management
--- a/make/javax/others/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/javax/others/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -38,10 +38,6 @@ com/sun/naming/internal \ javax/net \ javax/script \ - javax/security/auth \ - javax/security/cert \ - javax/security/sasl \ - javax/smartcardio \ javax/tools \ javax/xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/javax/security/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,49 @@ +# +# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building javax (security classes) +# + +BUILDDIR = ../.. +JAVAC_MAX_WARNINGS = true +JAVAC_WARNINGS_FATAL = true + +include $(BUILDDIR)/common/Defs.gmk + +# +# Files to compile +# +AUTO_FILES_JAVA_DIRS = \ + javax/security/auth \ + javax/security/cert \ + javax/security/sasl \ + javax/smartcardio + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk +
--- a/make/org/ietf/jgss/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/org/ietf/jgss/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -26,6 +26,8 @@ BUILDDIR = ../../.. PACKAGE = org.ietf.jgss PRODUCT = sun +JAVAC_MAX_WARNINGS = true +JAVAC_WARNINGS_FATAL = true include $(BUILDDIR)/common/Defs.gmk #
--- a/make/sun/security/other/Makefile Thu Oct 13 10:35:43 2011 -0700 +++ b/make/sun/security/other/Makefile Mon Oct 17 19:06:53 2011 -0700 @@ -26,7 +26,7 @@ BUILDDIR = ../../.. PACKAGE = sun.security.other PRODUCT = sun -JAVAC_MAX_WARNINGS=false +JAVAC_MAX_WARNINGS=true JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation JAVAC_WARNINGS_FATAL=true include $(BUILDDIR)/common/Defs.gmk
--- a/src/share/classes/com/sun/jndi/ldap/Connection.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/jndi/ldap/Connection.java Mon Oct 17 19:06:53 2011 -0700 @@ -32,6 +32,7 @@ import java.io.OutputStream; import java.io.InputStream; import java.net.Socket; +import javax.net.ssl.SSLSocket; import javax.naming.CommunicationException; import javax.naming.ServiceUnavailableException; @@ -361,6 +362,19 @@ } } + // For LDAP connect timeouts on LDAP over SSL connections must treat + // the SSL handshake following socket connection as part of the timeout. + // So explicitly set a socket read timeout, trigger the SSL handshake, + // then reset the timeout. + if (connectTimeout > 0 && socket instanceof SSLSocket) { + SSLSocket sslSocket = (SSLSocket) socket; + int socketTimeout = sslSocket.getSoTimeout(); + + sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value + sslSocket.startHandshake(); + sslSocket.setSoTimeout(socketTimeout); + } + return socket; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java Mon Oct 17 19:06:53 2011 -0700 @@ -115,9 +115,9 @@ // provider mechanism instead if implementing their own // transform or canonicalization algorithms. // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml"); - InputStream is = (InputStream) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + InputStream is = AccessController.doPrivileged( + new PrivilegedAction<InputStream>() { + public InputStream run() { // String cfile = System.getProperty // ("com.sun.org.apache.xml.internal.security.resource.config"); return getClass().getResourceAsStream
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java Mon Oct 17 19:06:53 2011 -0700 @@ -45,9 +45,9 @@ - private static Map uriToJCEName; + private static Map<String, String> uriToJCEName; - private static Map algorithmsMap; + private static Map<String, Algorithm> algorithmsMap; private static String providerName = null; /** @@ -63,8 +63,8 @@ static void loadAlgorithms( Element algorithmsEl) { Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm"); - uriToJCEName = new HashMap( algorithms.length * 2); - algorithmsMap = new HashMap( algorithms.length * 2); + uriToJCEName = new HashMap<String, String>( algorithms.length * 2); + algorithmsMap = new HashMap<String, Algorithm>( algorithms.length * 2); for (int i = 0 ;i < algorithms.length ;i ++) { Element el = algorithms[i]; String id = el.getAttribute("URI"); @@ -76,7 +76,7 @@ } static Algorithm getAlgorithmMapping(String algoURI) { - return ((Algorithm)algorithmsMap.get(algoURI)); + return algorithmsMap.get(algoURI); } /** @@ -90,7 +90,7 @@ if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI); - String jceName = (String) uriToJCEName.get(AlgorithmURI); + String jceName = uriToJCEName.get(AlgorithmURI); return jceName; } @@ -106,7 +106,7 @@ if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI); - return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass; + return (algorithmsMap.get(AlgorithmURI)).algorithmClass; } /** @@ -116,7 +116,7 @@ * @return The length of the key used in the alogrithm */ public static int getKeyLengthFromURI(String AlgorithmURI) { - return Integer.parseInt(((Algorithm) algorithmsMap.get(AlgorithmURI)).keyLength); + return Integer.parseInt((algorithmsMap.get(AlgorithmURI)).keyLength); } /** @@ -128,7 +128,7 @@ */ public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) { - return ((Algorithm) algorithmsMap.get(AlgorithmURI)).requiredKey; + return (algorithmsMap.get(AlgorithmURI)).requiredKey; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java Mon Oct 17 19:06:53 2011 -0700 @@ -71,9 +71,10 @@ this.algorithm = messageDigest; } - static ThreadLocal instances=new ThreadLocal() { - protected Object initialValue() { - return new HashMap(); + static ThreadLocal<Map<String, MessageDigest>> instances=new + ThreadLocal<Map<String, MessageDigest>>() { + protected Map<String, MessageDigest> initialValue() { + return new HashMap<String, MessageDigest>(); }; }; @@ -92,7 +93,7 @@ } private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException { - MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI); + MessageDigest result= instances.get().get(algorithmURI); if (result!=null) return result; String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI); @@ -121,7 +122,7 @@ throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs); } - ((Map)instances.get()).put(algorithmURI, md); + instances.get().put(algorithmURI, md); return md; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java Mon Oct 17 19:06:53 2011 -0700 @@ -51,28 +51,28 @@ static boolean _alreadyInitialized = false; /** All available algorithm classes are registered here */ - static HashMap _algorithmHash = null; + static Map<String, Class<? extends SignatureAlgorithmSpi>> _algorithmHash = null; - static ThreadLocal instancesSigning=new ThreadLocal() { - protected Object initialValue() { - return new HashMap(); + static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesSigning=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() { + protected Map<String, SignatureAlgorithmSpi> initialValue() { + return new HashMap<String, SignatureAlgorithmSpi>(); }; }; - static ThreadLocal instancesVerify=new ThreadLocal() { - protected Object initialValue() { - return new HashMap(); + static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesVerify=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() { + protected Map<String, SignatureAlgorithmSpi> initialValue() { + return new HashMap<String, SignatureAlgorithmSpi>(); }; }; - static ThreadLocal keysSigning=new ThreadLocal() { - protected Object initialValue() { - return new HashMap(); + static ThreadLocal<Map<String, Key>> keysSigning=new ThreadLocal<Map<String, Key>>() { + protected Map<String, Key> initialValue() { + return new HashMap<String, Key>(); }; }; - static ThreadLocal keysVerify=new ThreadLocal() { - protected Object initialValue() { - return new HashMap(); + static ThreadLocal<Map<String, Key>> keysVerify=new ThreadLocal<Map<String, Key>>() { + protected Map<String, Key> initialValue() { + return new HashMap<String, Key>(); }; }; // boolean isForSigning=false; @@ -105,34 +105,34 @@ .engineGetContextFromElement(this._constructionElement); } private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException { - SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI); + SignatureAlgorithmSpi result= instancesSigning.get().get(algorithmURI); if (result!=null) { result.reset(); return result; } result=buildSigner(algorithmURI, result); - ((Map)instancesSigning.get()).put(algorithmURI,result); + instancesSigning.get().put(algorithmURI,result); return result; } private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException { - SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI); + SignatureAlgorithmSpi result= instancesVerify.get().get(algorithmURI); if (result!=null) { result.reset(); return result; } result=buildSigner(algorithmURI, result); - ((Map)instancesVerify.get()).put(algorithmURI,result); + instancesVerify.get().put(algorithmURI,result); return result; } private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException { try { - Class implementingClass = + Class<? extends SignatureAlgorithmSpi> implementingClass = SignatureAlgorithm.getImplementingClass(algorithmURI); if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \"" + implementingClass + "\""); - result=(SignatureAlgorithmSpi) implementingClass.newInstance(); + result= implementingClass.newInstance(); return result; } catch (IllegalAccessException ex) { Object exArgs[] = { algorithmURI, ex.getMessage() }; @@ -270,7 +270,7 @@ */ public void initSign(Key signingKey) throws XMLSignatureException { initializeAlgorithm(true); - Map map=(Map)keysSigning.get(); + Map<String, Key> map=keysSigning.get(); if (map.get(this.algorithmURI)==signingKey) { return; } @@ -329,7 +329,7 @@ */ public void initVerify(Key verificationKey) throws XMLSignatureException { initializeAlgorithm(false); - Map map=(Map)keysVerify.get(); + Map<String, Key> map=keysVerify.get(); if (map.get(this.algorithmURI)==verificationKey) { return; } @@ -375,7 +375,7 @@ log.log(java.util.logging.Level.FINE, "Init() called"); if (!SignatureAlgorithm._alreadyInitialized) { - SignatureAlgorithm._algorithmHash = new HashMap(10); + SignatureAlgorithm._algorithmHash = new HashMap<String, Class<? extends SignatureAlgorithmSpi>>(10); SignatureAlgorithm._alreadyInitialized = true; } } @@ -388,6 +388,7 @@ * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered * @throws XMLSignatureException */ + @SuppressWarnings("unchecked") public static void register(String algorithmURI, String implementingClass) throws AlgorithmAlreadyRegisteredException,XMLSignatureException { @@ -396,7 +397,7 @@ log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass); // are we already registered? - Class registeredClassClass = + Class<? extends SignatureAlgorithmSpi> registeredClassClass = SignatureAlgorithm.getImplementingClass(algorithmURI); if (registeredClassClass!=null) { String registeredClass = registeredClassClass.getName(); @@ -409,7 +410,7 @@ } } try { - SignatureAlgorithm._algorithmHash.put(algorithmURI, Class.forName(implementingClass)); + SignatureAlgorithm._algorithmHash.put(algorithmURI, (Class <? extends SignatureAlgorithmSpi>)Class.forName(implementingClass)); } catch (ClassNotFoundException ex) { Object exArgs[] = { algorithmURI, ex.getMessage() }; @@ -431,13 +432,13 @@ * @param URI * @return the class that implements the URI */ - private static Class getImplementingClass(String URI) { + private static Class<? extends SignatureAlgorithmSpi> getImplementingClass(String URI) { if (SignatureAlgorithm._algorithmHash == null) { return null; } - return (Class) SignatureAlgorithm._algorithmHash.get(URI); + return SignatureAlgorithm._algorithmHash.get(URI); } /**
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java Mon Oct 17 19:06:53 2011 -0700 @@ -28,6 +28,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException; import org.w3c.dom.Document; @@ -83,7 +84,7 @@ ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments"; static boolean _alreadyInitialized = false; - static Map _canonicalizerHash = null; + static Map<String,Class<? extends CanonicalizerSpi>> _canonicalizerHash = null; protected CanonicalizerSpi canonicalizerSpi = null; @@ -94,7 +95,7 @@ public static void init() { if (!Canonicalizer._alreadyInitialized) { - Canonicalizer._canonicalizerHash = new HashMap(10); + Canonicalizer._canonicalizerHash = new HashMap<String, Class<? extends CanonicalizerSpi>>(10); Canonicalizer._alreadyInitialized = true; } } @@ -109,10 +110,11 @@ throws InvalidCanonicalizerException { try { - Class implementingClass = getImplementingClass(algorithmURI); + Class<? extends CanonicalizerSpi> implementingClass = + getImplementingClass(algorithmURI); this.canonicalizerSpi = - (CanonicalizerSpi) implementingClass.newInstance(); + implementingClass.newInstance(); this.canonicalizerSpi.reset=true; } catch (Exception e) { Object exArgs[] = { algorithmURI }; @@ -144,11 +146,12 @@ * @param implementingClass * @throws AlgorithmAlreadyRegisteredException */ + @SuppressWarnings("unchecked") public static void register(String algorithmURI, String implementingClass) throws AlgorithmAlreadyRegisteredException { // check whether URI is already registered - Class registeredClass = getImplementingClass(algorithmURI); + Class<? extends CanonicalizerSpi> registeredClass = getImplementingClass(algorithmURI); if (registeredClass != null) { Object exArgs[] = { algorithmURI, registeredClass }; @@ -158,7 +161,7 @@ } try { - _canonicalizerHash.put(algorithmURI, Class.forName(implementingClass)); + _canonicalizerHash.put(algorithmURI, (Class<? extends CanonicalizerSpi>) Class.forName(implementingClass)); } catch (ClassNotFoundException e) { throw new RuntimeException("c14n class not found"); } @@ -304,7 +307,7 @@ * @return the result of the c14n. * @throws CanonicalizationException */ - public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet) + public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet) throws CanonicalizationException { return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet); } @@ -317,7 +320,7 @@ * @return the result of the c14n. * @throws CanonicalizationException */ - public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet, + public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException { return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces); @@ -347,8 +350,8 @@ * @param URI * @return the name of the class that implements the given URI */ - private static Class getImplementingClass(String URI) { - return (Class) _canonicalizerHash.get(URI); + private static Class<? extends CanonicalizerSpi> getImplementingClass(String URI) { + return _canonicalizerHash.get(URI); } /**
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java Mon Oct 17 19:06:53 2011 -0700 @@ -28,6 +28,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import org.w3c.dom.Document; @@ -151,7 +152,7 @@ * @return the c14n bytes * @throws CanonicalizationException */ - public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet) + public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet) throws CanonicalizationException; /** @@ -162,7 +163,7 @@ * @return the c14n bytes * @throws CanonicalizationException */ - public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces) + public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException; /**
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java Mon Oct 17 19:06:53 2011 -0700 @@ -41,7 +41,7 @@ * * @author Christian Geuer-Pollmann */ -public class AttrCompare implements Comparator, Serializable { +public class AttrCompare implements Comparator<Attr>, Serializable { private final static long serialVersionUID = -7113259629930576230L; private final static int ATTR0_BEFORE_ATTR1 = -1; @@ -62,16 +62,14 @@ * key (an empty namespace URI is lexicographically least). * </UL> * - * @param obj0 casted Attr - * @param obj1 casted Attr + * @param attr0 + * @param attr1 * @return returns a negative integer, zero, or a positive integer as * obj0 is less than, equal to, or greater than obj1 * */ - public int compare(Object obj0, Object obj1) { + public int compare(Attr attr0, Attr attr1) { - Attr attr0 = (Attr) obj0; - Attr attr1 = (Attr) obj1; String namespaceURI0 = attr0.getNamespaceURI(); String namespaceURI1 = attr1.getNamespaceURI();
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java Mon Oct 17 19:06:53 2011 -0700 @@ -25,6 +25,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -33,6 +34,7 @@ import java.util.SortedSet; import java.util.TreeSet; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -59,7 +61,7 @@ */ public abstract class Canonicalizer11 extends CanonicalizerBase { boolean firstCall = true; - final SortedSet result = new TreeSet(COMPARE); + final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE); static final String XMLNS_URI = Constants.NamespaceSpecNS; static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS; @@ -72,9 +74,9 @@ static class XmlsStackElement { int level; boolean rendered = false; - List nodes = new ArrayList(); + List<Attr> nodes = new ArrayList<Attr>(); }; - List levels = new ArrayList(); + List<XmlsStackElement> levels = new ArrayList<XmlsStackElement>(); void push(int level) { currentLevel = level; if (currentLevel == -1) @@ -86,7 +88,7 @@ lastlevel = 0; return; } - lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level; + lastlevel=(levels.get(levels.size()-1)).level; } } void addXmlnsAttr(Attr n) { @@ -98,7 +100,7 @@ } cur.nodes.add(n); } - void getXmlnsAttr(Collection col) { + void getXmlnsAttr(Collection<Attr> col) { if (cur == null) { cur = new XmlsStackElement(); cur.level = currentLevel; @@ -111,7 +113,7 @@ if (size == -1) { parentRendered = true; } else { - e = (XmlsStackElement) levels.get(size); + e = levels.get(size); if (e.rendered && e.level+1 == currentLevel) parentRendered = true; } @@ -121,17 +123,17 @@ return; } - Map loa = new HashMap(); - List baseAttrs = new ArrayList(); + Map<String, Attr> loa = new HashMap<String, Attr>(); + List<Attr> baseAttrs = new ArrayList<Attr>(); boolean successiveOmitted = true; for (;size>=0;size--) { - e = (XmlsStackElement) levels.get(size); + e = levels.get(size); if (e.rendered) { successiveOmitted = false; } - Iterator it = e.nodes.iterator(); + Iterator<Attr> it = e.nodes.iterator(); while (it.hasNext() && successiveOmitted) { - Attr n = (Attr) it.next(); + Attr n = it.next(); if (n.getLocalName().equals("base")) { if (!e.rendered) { baseAttrs.add(n); @@ -141,11 +143,11 @@ } } if (!baseAttrs.isEmpty()) { - Iterator it = cur.nodes.iterator(); + Iterator<Attr> it = cur.nodes.iterator(); String base = null; Attr baseAttr = null; while (it.hasNext()) { - Attr n = (Attr) it.next(); + Attr n = it.next(); if (n.getLocalName().equals("base")) { base = n.getValue(); baseAttr = n; @@ -154,7 +156,7 @@ } it = baseAttrs.iterator(); while (it.hasNext()) { - Attr n = (Attr) it.next(); + Attr n = it.next(); if (base == null) { base = n.getValue(); baseAttr = n; @@ -202,13 +204,13 @@ * @return the Attr[]s to be outputted * @throws CanonicalizationException */ - Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns) + Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns) throws CanonicalizationException { if (!E.hasAttributes() && !firstCall) { return null; } // result will contain the attrs which have to be outputted - final SortedSet result = this.result; + final SortedSet<Attr> result = this.result; result.clear(); NamedNodeMap attrs = E.getAttributes(); int attrsLength = attrs.getLength(); @@ -236,7 +238,7 @@ if (n != null) { // Render the ns definition - result.add(n); + result.add((Attr)n); if (C14nHelper.namespaceIsRelative(N)) { Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()}; throw new CanonicalizationException( @@ -251,13 +253,15 @@ // to the output. ns.getUnrenderedNodes(result); // output the attributes in the xml namespace. - xmlattrStack.getXmlnsAttr(result); + xmlattrStack.getXmlnsAttr(getSortedSetAsCollection(result)); firstCall = false; } return result.iterator(); } + + /** * Returns the Attr[]s to be outputted for the given element. * <br> @@ -271,7 +275,7 @@ * @return the Attr[]s to be outputted * @throws CanonicalizationException */ - Iterator handleAttributes(Element E, NameSpaceSymbTable ns) + Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns) throws CanonicalizationException { // result will contain the attrs which have to be output xmlattrStack.push(ns.getLevel()); @@ -283,11 +287,11 @@ attrsLength = attrs.getLength(); } - SortedSet result = this.result; + SortedSet<Attr> result = this.result; result.clear(); for (int i = 0; i < attrsLength; i++) { - Attr N = (Attr) attrs.item(i); + Attr N = (Attr)attrs.item(i); String NUri = N.getNamespaceURI(); if (XMLNS_URI != NUri) { @@ -332,7 +336,7 @@ // (NName, NValue, N, isRealVisible); Node n = ns.addMappingAndRender(NName, NValue, N); if (n != null) { - result.add(n); + result.add((Attr)n); if (C14nHelper.namespaceIsRelative(N)) { Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() }; @@ -362,7 +366,7 @@ } // output the xmlns def if needed. if (n != null) { - result.add(n); + result.add((Attr)n); } // Float all xml:* attributes of the unselected parent elements to // this one. addXmlAttributes(E,result); @@ -381,7 +385,7 @@ * @return none it always fails * @throws CanonicalizationException always */ - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException { throw new CanonicalizationException( "c14n.Canonicalizer.UnsupportedOperation");
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java Mon Oct 17 19:06:53 2011 -0700 @@ -57,7 +57,7 @@ */ public abstract class Canonicalizer20010315 extends CanonicalizerBase { boolean firstCall=true; - final SortedSet result= new TreeSet(COMPARE); + final SortedSet<Attr> result= new TreeSet<Attr>(COMPARE); static final String XMLNS_URI=Constants.NamespaceSpecNS; static final String XML_LANG_URI=Constants.XML_LANG_SPACE_SpecNS; static class XmlAttrStack { @@ -67,9 +67,9 @@ static class XmlsStackElement { int level; boolean rendered=false; - List nodes=new ArrayList(); + List<Attr> nodes=new ArrayList<Attr>(); }; - List levels=new ArrayList(); + List<XmlsStackElement> levels=new ArrayList<XmlsStackElement>(); void push(int level) { currentLevel=level; if (currentLevel==-1) @@ -81,7 +81,7 @@ lastlevel=0; return; } - lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level; + lastlevel=(levels.get(levels.size()-1)).level; } } void addXmlnsAttr(Attr n) { @@ -93,7 +93,7 @@ } cur.nodes.add(n); } - void getXmlnsAttr(Collection col) { + void getXmlnsAttr(Collection<Attr> col) { int size=levels.size()-1; if (cur==null) { cur=new XmlsStackElement(); @@ -106,7 +106,7 @@ if (size==-1) { parentRendered=true; } else { - e=(XmlsStackElement)levels.get(size); + e=levels.get(size); if (e.rendered && e.level+1==currentLevel) parentRendered=true; @@ -117,12 +117,12 @@ return; } - Map loa = new HashMap(); + Map<String,Attr> loa = new HashMap<String,Attr>(); for (;size>=0;size--) { - e=(XmlsStackElement)levels.get(size); - Iterator it=e.nodes.iterator(); + e=levels.get(size); + Iterator<Attr> it=e.nodes.iterator(); while (it.hasNext()) { - Attr n=(Attr)it.next(); + Attr n=it.next(); if (!loa.containsKey(n.getName())) loa.put(n.getName(),n); } @@ -161,13 +161,13 @@ * @return the Attr[]s to be outputted * @throws CanonicalizationException */ - Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns ) + Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException { if (!E.hasAttributes() && !firstCall) { return null; } // result will contain the attrs which have to be outputted - final SortedSet result = this.result; + final SortedSet<Attr> result = this.result; result.clear(); NamedNodeMap attrs = E.getAttributes(); int attrsLength = attrs.getLength(); @@ -194,7 +194,7 @@ if (n!=null) { //Render the ns definition - result.add(n); + result.add((Attr)n); if (C14nHelper.namespaceIsRelative(N)) { Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() }; throw new CanonicalizationException( @@ -206,7 +206,7 @@ if (firstCall) { //It is the first node of the subtree //Obtain all the namespaces defined in the parents, and added to the output. - ns.getUnrenderedNodes(result); + ns.getUnrenderedNodes(getSortedSetAsCollection(result)); //output the attributes in the xml namespace. xmlattrStack.getXmlnsAttr(result); firstCall=false; @@ -227,7 +227,7 @@ * @return the Attr[]s to be outputted * @throws CanonicalizationException */ - Iterator handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException { + Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException { // result will contain the attrs which have to be outputted xmlattrStack.push(ns.getLevel()); boolean isRealVisible=isVisibleDO(E,ns.getLevel())==1; @@ -239,7 +239,7 @@ } - SortedSet result = this.result; + SortedSet<Attr> result = this.result; result.clear(); for (int i = 0; i < attrsLength; i++) { @@ -277,7 +277,7 @@ //Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible); Node n=ns.addMappingAndRender(NName,NValue,N); if (n!=null) { - result.add(n); + result.add((Attr)n); if (C14nHelper.namespaceIsRelative(N)) { Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() }; throw new CanonicalizationException( @@ -306,12 +306,12 @@ } //output the xmlns def if needed. if (n!=null) { - result.add(n); + result.add((Attr)n); } //Float all xml:* attributes of the unselected parent elements to this one. //addXmlAttributes(E,result); xmlattrStack.getXmlnsAttr(result); - ns.getUnrenderedNodes(result); + ns.getUnrenderedNodes(getSortedSetAsCollection(result)); } @@ -325,7 +325,7 @@ * @return none it always fails * @throws CanonicalizationException always */ - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces) + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException { /** $todo$ well, should we throw UnsupportedOperationException ? */
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java Mon Oct 17 19:06:53 2011 -0700 @@ -61,9 +61,9 @@ * This Set contains the names (Strings like "xmlns" or "xmlns:foo") of * the inclusive namespaces. */ - TreeSet _inclusiveNSSet = new TreeSet(); + TreeSet<String> _inclusiveNSSet = new TreeSet<String>(); static final String XMLNS_URI=Constants.NamespaceSpecNS; - final SortedSet result = new TreeSet(COMPARE); + final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE); /** * Constructor Canonicalizer20010315Excl * @@ -106,8 +106,7 @@ */ public byte[] engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces,Node excl) throws CanonicalizationException { - this._inclusiveNSSet = (TreeSet)InclusiveNamespaces - .prefixStr2Set(inclusiveNamespaces); + this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces); return super.engineCanonicalizeSubTree(rootNode,excl); } /** @@ -117,10 +116,10 @@ * @return the rootNode c14n. * @throws CanonicalizationException */ + @SuppressWarnings("unchecked") public byte[] engineCanonicalize(XMLSignatureInput rootNode, String inclusiveNamespaces) throws CanonicalizationException { - this._inclusiveNSSet = (TreeSet)InclusiveNamespaces - .prefixStr2Set(inclusiveNamespaces); + this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces); return super.engineCanonicalize(rootNode); } @@ -130,12 +129,12 @@ * @param E * @throws CanonicalizationException */ - Iterator handleAttributesSubtree(Element E,NameSpaceSymbTable ns) + Iterator<Attr> handleAttributesSubtree(Element E,NameSpaceSymbTable ns) throws CanonicalizationException { // System.out.println("During the traversal, I encountered " + // XMLUtils.getXPath(E)); // result will contain the attrs which have to be outputted - SortedSet result = this.result; + SortedSet<Attr> result = this.result; result.clear(); NamedNodeMap attrs=null; @@ -145,7 +144,7 @@ attrsLength = attrs.getLength(); } //The prefix visibly utilized(in the attribute or in the name) in the element - SortedSet visiblyUtilized =(SortedSet) _inclusiveNSSet.clone(); + SortedSet<String> visiblyUtilized = getNSSetClone(); for (int i = 0; i < attrsLength; i++) { Attr N = (Attr) attrs.item(i); @@ -187,9 +186,9 @@ visiblyUtilized.add(prefix); //This can be optimezed by I don't have time - Iterator it=visiblyUtilized.iterator(); + Iterator<String> it=visiblyUtilized.iterator(); while (it.hasNext()) { - String s=(String)it.next(); + String s=it.next(); Attr key=ns.getMapping(s); if (key==null) { continue; @@ -207,25 +206,35 @@ * @param inclusiveNamespaces * @throws CanonicalizationException */ - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException { - - this._inclusiveNSSet = (TreeSet)InclusiveNamespaces - .prefixStr2Set(inclusiveNamespaces); + this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces); return super.engineCanonicalizeXPathNodeSet(xpathNodeSet); } + @SuppressWarnings("unchecked") + private TreeSet<String> getInclusiveNameSpace(String inclusiveNameSpaces) { + return (TreeSet<String>)InclusiveNamespaces.prefixStr2Set(inclusiveNameSpaces); + } + + + @SuppressWarnings("unchecked") + private SortedSet<String> getNSSetClone() { + return (SortedSet<String>) this._inclusiveNSSet.clone(); + } + + /** * @inheritDoc * @param E * @throws CanonicalizationException */ - final Iterator handleAttributes(Element E, NameSpaceSymbTable ns) + final Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns) throws CanonicalizationException { // result will contain the attrs which have to be outputted - SortedSet result = this.result; + SortedSet<Attr> result = this.result; result.clear(); NamedNodeMap attrs = null; int attrsLength = 0; @@ -234,11 +243,11 @@ attrsLength = attrs.getLength(); } //The prefix visibly utilized(in the attribute or in the name) in the element - Set visiblyUtilized =null; + Set<String> visiblyUtilized =null; //It's the output selected. boolean isOutputElement=isVisibleDO(E,ns.getLevel())==1; if (isOutputElement) { - visiblyUtilized = (Set) this._inclusiveNSSet.clone(); + visiblyUtilized = getNSSetClone(); } for (int i = 0; i < attrsLength; i++) { @@ -272,7 +281,7 @@ if (!isOutputElement && isVisible(N) && _inclusiveNSSet.contains(NName) && !ns.removeMappingIfRender(NName)) { Node n=ns.addMappingAndRender(NName,NNodeValue,N); if (n!=null) { - result.add(n); + result.add((Attr)n); if (C14nHelper.namespaceIsRelative(N)) { Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() }; throw new CanonicalizationException( @@ -315,9 +324,9 @@ } //This can be optimezed by I don't have time //visiblyUtilized.addAll(this._inclusiveNSSet); - Iterator it=visiblyUtilized.iterator(); + Iterator<String> it=visiblyUtilized.iterator(); while (it.hasNext()) { - String s=(String)it.next(); + String s=it.next(); Attr key=ns.getMapping(s); if (key==null) { continue;
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java Mon Oct 17 19:06:53 2011 -0700 @@ -33,9 +33,12 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; +import java.util.SortedSet; +import java.util.Collection; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; import com.sun.org.apache.xml.internal.security.c14n.CanonicalizerSpi; @@ -94,10 +97,10 @@ } } - List nodeFilter; + List<NodeFilter> nodeFilter; boolean _includeComments; - Set _xpathNodeSet = null; + Set<Node> _xpathNodeSet = null; /** * The node to be skiped/excluded from the DOM tree * in subtree canonicalizations. @@ -130,7 +133,7 @@ * @param xpathNodeSet * @throws CanonicalizationException */ - public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet) + public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet) throws CanonicalizationException { this._xpathNodeSet = xpathNodeSet; return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet)); @@ -251,7 +254,7 @@ final OutputStream writer=this._writer; final Node excludeNode=this._excludeNode; final boolean includeComments=this._includeComments; - Map cache=new HashMap(); + Map<String, byte[]> cache=new HashMap<String, byte[]>(); do { switch (currentNode.getNodeType()) { @@ -298,11 +301,11 @@ String name=currentElement.getTagName(); UtfHelpper.writeByte(name,writer,cache); - Iterator attrs = this.handleAttributesSubtree(currentElement,ns); + Iterator<Attr> attrs = this.handleAttributesSubtree(currentElement,ns); if (attrs!=null) { //we output all Attrs which are available while (attrs.hasNext()) { - Attr attr = (Attr) attrs.next(); + Attr attr = attrs.next(); outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache); } } @@ -394,7 +397,7 @@ Node parentNode=null; OutputStream writer=this._writer; int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT; - Map cache=new HashMap(); + Map<String, byte[]> cache=new HashMap<String,byte[]>(); do { switch (currentNode.getNodeType()) { @@ -464,11 +467,11 @@ ns.push(); } - Iterator attrs = handleAttributes(currentElement,ns); + Iterator<Attr> attrs = handleAttributes(currentElement,ns); if (attrs!=null) { //we output all Attrs which are available while (attrs.hasNext()) { - Attr attr = (Attr) attrs.next(); + Attr attr = attrs.next(); outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache); } } @@ -522,9 +525,9 @@ } int isVisibleDO(Node currentNode,int level) { if (nodeFilter!=null) { - Iterator it=nodeFilter.iterator(); + Iterator<NodeFilter> it=nodeFilter.iterator(); while (it.hasNext()) { - int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level); + int i=(it.next()).isNodeIncludeDO(currentNode,level); if (i!=1) return i; } @@ -535,9 +538,9 @@ } int isVisibleInt(Node currentNode) { if (nodeFilter!=null) { - Iterator it=nodeFilter.iterator(); + Iterator<NodeFilter> it=nodeFilter.iterator(); while (it.hasNext()) { - int i=((NodeFilter)it.next()).isNodeInclude(currentNode); + int i=(it.next()).isNodeInclude(currentNode); if (i!=1) return i; } @@ -549,9 +552,9 @@ boolean isVisible(Node currentNode) { if (nodeFilter!=null) { - Iterator it=nodeFilter.iterator(); + Iterator<NodeFilter> it=nodeFilter.iterator(); while (it.hasNext()) { - if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1) + if ((it.next()).isNodeInclude(currentNode)!=1) return false; } } @@ -589,7 +592,7 @@ * @param ns */ final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) { - List parents=new ArrayList(10); + List<Element> parents=new ArrayList<Element>(10); Node n1=el.getParentNode(); if (!(n1 instanceof Element)) { return; @@ -605,9 +608,9 @@ parent=(Element)n; } //Visit them in reverse order. - ListIterator it=parents.listIterator(parents.size()); + ListIterator<Element> it=parents.listIterator(parents.size()); while (it.hasPrevious()) { - Element ele=(Element)it.previous(); + Element ele=it.previous(); handleParent(ele, ns); } Attr nsprefix; @@ -624,7 +627,7 @@ * @return the attributes nodes to output. * @throws CanonicalizationException */ - abstract Iterator handleAttributes(Element E, NameSpaceSymbTable ns ) + abstract Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException; /** @@ -635,7 +638,7 @@ * @return the attributes nodes to output. * @throws CanonicalizationException */ - abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns) + abstract Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns) throws CanonicalizationException; abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException; @@ -660,7 +663,7 @@ * @throws IOException */ static final void outputAttrToWriter(final String name, final String value, final OutputStream writer, - final Map cache) throws IOException { + final Map<String, byte[]> cache) throws IOException { writer.write(' '); UtfHelpper.writeByte(name,writer,cache); writer.write(equalsStr); @@ -841,4 +844,10 @@ } } + @SuppressWarnings("unchecked") + protected Collection<Attr> getSortedSetAsCollection(SortedSet<Attr> result) { + return (Collection<Attr>)(Collection)result; + } + + }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java Mon Oct 17 19:06:53 2011 -0700 @@ -44,7 +44,7 @@ /**The level of nameSpaces (for Inclusive visibility).*/ int nameSpaces=0; /**The stacks for removing the definitions when doing pop.*/ - List level; + List<SymbMap> level; boolean cloned=true; static final String XMLNS="xmlns"; final static SymbMap initialMap=new SymbMap(); @@ -57,7 +57,7 @@ * Default constractor **/ public NameSpaceSymbTable() { - level = new ArrayList(10); + level = new ArrayList<SymbMap>(10); //Insert the default binding for xmlns. symb=(SymbMap) initialMap.clone(); } @@ -67,11 +67,11 @@ * For Inclusive rendering * @param result the list where to fill the unrendered xmlns definitions. **/ - public void getUnrenderedNodes(Collection result) { + public void getUnrenderedNodes(Collection<Attr> result) { //List result=new ArrayList(); - Iterator it=symb.entrySet().iterator(); + Iterator<NameSpaceSymbEntry> it=symb.entrySet().iterator(); while (it.hasNext()) { - NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next()); + NameSpaceSymbEntry n= it.next(); //put them rendered? if ((!n.rendered) && (n.n!=null)) { n=(NameSpaceSymbEntry) n.clone(); @@ -339,8 +339,8 @@ } } - List entrySet() { - List a=new ArrayList(); + List<NameSpaceSymbEntry> entrySet() { + List<NameSpaceSymbEntry> a=new ArrayList<NameSpaceSymbEntry>(); for (int i=0;i<entries.length;i++) { if ((entries[i]!=null) && !("".equals(entries[i].uri))) { a.add(entries[i]);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java Mon Oct 17 19:06:53 2011 -0700 @@ -6,8 +6,8 @@ public class UtfHelpper { - final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException { - byte []result=(byte[]) cache.get(str); + final static void writeByte(final String str,final OutputStream out,Map<String,byte[]> cache) throws IOException { + byte []result= cache.get(str); if (result==null) { result=getStringInUtf8(str); cache.put(str,result);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java Mon Oct 17 19:06:53 2011 -0700 @@ -95,7 +95,7 @@ * Returns aditional information regarding the <code>AgreementMethod</code>. * @return */ - Iterator getAgreementMethodInformation(); + Iterator<Element> getAgreementMethodInformation(); /** * Adds additional <code>AgreementMethod</code> information.
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java Mon Oct 17 19:06:53 2011 -0700 @@ -89,7 +89,7 @@ * @return an <code>Iterator</code> over all the additional infomation * about the <code>EncryptionMethod</code>. */ - Iterator getEncryptionMethodInformation(); + Iterator<Element> getEncryptionMethodInformation(); /** * Adds encryption method information.
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java Mon Oct 17 19:06:53 2011 -0700 @@ -67,7 +67,7 @@ * * @return an <code>Iterator</code> over all the encryption properties. */ - Iterator getEncryptionProperties(); + Iterator<EncryptionProperty> getEncryptionProperties(); /** * Adds an <code>EncryptionProperty</code>.
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java Mon Oct 17 19:06:53 2011 -0700 @@ -101,7 +101,7 @@ * @return an <code>Iterator</code> over all the addiitonal encryption * information contained in this class. */ - Iterator getEncryptionInformation(); + Iterator<Element> getEncryptionInformation(); /** * Adds encryption information.
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java Mon Oct 17 19:06:53 2011 -0700 @@ -74,7 +74,7 @@ * * @return child elements. */ - Iterator getElementRetrievalInformation(); + Iterator<Element> getElementRetrievalInformation(); /** * Adds retrieval information.
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java Mon Oct 17 19:06:53 2011 -0700 @@ -87,7 +87,7 @@ * * @return Iterator. */ - public Iterator getReferences(); + public Iterator<Reference> getReferences(); /** * <code>DataReference</code> factory method. Returns a
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java Mon Oct 17 19:06:53 2011 -0700 @@ -2772,7 +2772,7 @@ // </complexType> private class AgreementMethodImpl implements AgreementMethod { private byte[] kaNonce = null; - private List agreementMethodInformation = null; + private List<Element> agreementMethodInformation = null; private KeyInfo originatorKeyInfo = null; private KeyInfo recipientKeyInfo = null; private String algorithmURI = null; @@ -2781,7 +2781,7 @@ * @param algorithm */ public AgreementMethodImpl(String algorithm) { - agreementMethodInformation = new LinkedList(); + agreementMethodInformation = new LinkedList<Element>(); URI tmpAlgorithm = null; try { tmpAlgorithm = new URI(algorithm); @@ -2802,7 +2802,7 @@ } /** @inheritDoc */ - public Iterator getAgreementMethodInformation() { + public Iterator<Element> getAgreementMethodInformation() { return (agreementMethodInformation.iterator()); } @@ -2879,9 +2879,9 @@ _contextDocument.createTextNode(new String(kaNonce))); } if (!agreementMethodInformation.isEmpty()) { - Iterator itr = agreementMethodInformation.iterator(); + Iterator<Element> itr = agreementMethodInformation.iterator(); while (itr.hasNext()) { - result.appendChild((Element) itr.next()); + result.appendChild(itr.next()); } } if (null != originatorKeyInfo) { @@ -3486,7 +3486,7 @@ private String algorithm = null; private int keySize = Integer.MIN_VALUE; private byte[] oaepParams = null; - private List encryptionMethodInformation = null; + private List<Element> encryptionMethodInformation = null; /** * * @param algorithm @@ -3499,7 +3499,7 @@ // complain } this.algorithm = tmpAlgorithm.toString(); - encryptionMethodInformation = new LinkedList(); + encryptionMethodInformation = new LinkedList<Element>(); } /** @inheritDoc */ public String getAlgorithm() { @@ -3522,7 +3522,7 @@ oaepParams = params; } /** @inheritDoc */ - public Iterator getEncryptionMethodInformation() { + public Iterator<Element> getEncryptionMethodInformation() { return (encryptionMethodInformation.iterator()); } /** @inheritDoc */ @@ -3565,8 +3565,8 @@ new String(oaepParams)))); } if (!encryptionMethodInformation.isEmpty()) { - Iterator itr = encryptionMethodInformation.iterator(); - result.appendChild((Element) itr.next()); + Iterator<Element> itr = encryptionMethodInformation.iterator(); + result.appendChild(itr.next()); } return (result); @@ -3582,13 +3582,13 @@ // </complexType> private class EncryptionPropertiesImpl implements EncryptionProperties { private String id = null; - private List encryptionProperties = null; + private List<EncryptionProperty> encryptionProperties = null; /** * * */ public EncryptionPropertiesImpl() { - encryptionProperties = new LinkedList(); + encryptionProperties = new LinkedList<EncryptionProperty>(); } /** @inheritDoc */ public String getId() { @@ -3599,7 +3599,7 @@ this.id = id; } /** @inheritDoc */ - public Iterator getEncryptionProperties() { + public Iterator<EncryptionProperty> getEncryptionProperties() { return (encryptionProperties.iterator()); } /** @inheritDoc */ @@ -3625,7 +3625,7 @@ if (null != id) { result.setAttributeNS(null, EncryptionConstants._ATT_ID, id); } - Iterator itr = getEncryptionProperties(); + Iterator<EncryptionProperty> itr = getEncryptionProperties(); while (itr.hasNext()) { result.appendChild(((EncryptionPropertyImpl) itr.next()).toElement()); @@ -3647,15 +3647,15 @@ private class EncryptionPropertyImpl implements EncryptionProperty { private String target = null; private String id = null; - private HashMap attributeMap = new HashMap(); - private List encryptionInformation = null; + private HashMap<String,String> attributeMap = new HashMap<String,String>(); + private List<Element> encryptionInformation = null; /** * * */ public EncryptionPropertyImpl() { - encryptionInformation = new LinkedList(); + encryptionInformation = new LinkedList<Element>(); } /** @inheritDoc */ public String getTarget() { @@ -3692,14 +3692,14 @@ } /** @inheritDoc */ public String getAttribute(String attribute) { - return (String) attributeMap.get(attribute); + return attributeMap.get(attribute); } /** @inheritDoc */ public void setAttribute(String attribute, String value) { attributeMap.put(attribute, value); } /** @inheritDoc */ - public Iterator getEncryptionInformation() { + public Iterator<Element> getEncryptionInformation() { return (encryptionInformation.iterator()); } /** @inheritDoc */ @@ -3821,8 +3821,8 @@ // </complexType> //</element> private class ReferenceListImpl implements ReferenceList { - private Class sentry; - private List references; + private Class<?> sentry; + private List<Reference> references; /** * * @param type @@ -3835,7 +3835,7 @@ } else { throw new IllegalArgumentException(); } - references = new LinkedList(); + references = new LinkedList<Reference>(); } /** @inheritDoc */ public void add(Reference reference) { @@ -3860,7 +3860,7 @@ return (references.isEmpty()); } /** @inheritDoc */ - public Iterator getReferences() { + public Iterator<Reference> getReferences() { return (references.iterator()); } @@ -3869,9 +3869,9 @@ _contextDocument, EncryptionConstants.EncryptionSpecNS, EncryptionConstants._TAG_REFERENCELIST); - Iterator eachReference = references.iterator(); + Iterator<Reference> eachReference = references.iterator(); while (eachReference.hasNext()) { - Reference reference = (Reference) eachReference.next(); + Reference reference = eachReference.next(); result.appendChild( ((ReferenceImpl) reference).toElement()); } @@ -3894,18 +3894,18 @@ */ private abstract class ReferenceImpl implements Reference { private String uri; - private List referenceInformation; + private List<Element> referenceInformation; ReferenceImpl(String _uri) { this.uri = _uri; - referenceInformation = new LinkedList(); + referenceInformation = new LinkedList<Element>(); } /** @inheritDoc */ public String getURI() { return (uri); } /** @inheritDoc */ - public Iterator getElementRetrievalInformation() { + public Iterator<Element> getElementRetrievalInformation() { return (referenceInformation.iterator()); } /** @inheritDoc */
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java Mon Oct 17 19:06:53 2011 -0700 @@ -97,12 +97,12 @@ /** {@link java.util.logging} logging facility */ static java.util.logging.Logger log = java.util.logging.Logger.getLogger(KeyInfo.class.getName()); - List x509Datas=null; - List encryptedKeys=null; + List<X509Data> x509Datas=null; + List<EncryptedKey> encryptedKeys=null; - static final List nullList; + static final List<StorageResolver> nullList; static { - List list = new ArrayList(); + List<StorageResolver> list = new ArrayList<StorageResolver>(1); list.add(null); nullList = Collections.unmodifiableList(list); } @@ -297,7 +297,7 @@ */ public void add(X509Data x509data) { if (x509Datas==null) - x509Datas=new ArrayList(); + x509Datas=new ArrayList<X509Data>(); x509Datas.add(x509data); this._constructionElement.appendChild(x509data.getElement()); XMLUtils.addReturnToElement(this._constructionElement); @@ -313,7 +313,7 @@ public void add(EncryptedKey encryptedKey) throws XMLEncryptionException { if (encryptedKeys==null) - encryptedKeys=new ArrayList(); + encryptedKeys=new ArrayList<EncryptedKey>(); encryptedKeys.add(encryptedKey); XMLCipher cipher = XMLCipher.getInstance(); this._constructionElement.appendChild(cipher.martial(encryptedKey)); @@ -541,7 +541,7 @@ */ public X509Data itemX509Data(int i) throws XMLSecurityException { if (x509Datas!=null) { - return (X509Data) x509Datas.get(i); + return x509Datas.get(i); } Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(), Constants._TAG_X509DATA,i); @@ -562,7 +562,7 @@ public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException { if (encryptedKeys!=null) { - return (EncryptedKey) encryptedKeys.get(i); + return encryptedKeys.get(i); } Element e = XMLUtils.selectXencNode(this._constructionElement.getFirstChild(), @@ -728,16 +728,16 @@ PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException { int length=KeyResolver.length(); int storageLength=this._storageResolvers.size(); - Iterator it= KeyResolver.iterator(); + Iterator<KeyResolverSpi> it= KeyResolver.iterator(); for (int i = 0; i < length; i++) { - KeyResolverSpi keyResolver = (KeyResolverSpi) it.next(); + KeyResolverSpi keyResolver = it.next(); Node currentChild=this._constructionElement.getFirstChild(); String uri= this.getBaseURI(); while (currentChild!=null) { if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (int k = 0; k < storageLength; k++) { StorageResolver storage = - (StorageResolver) this._storageResolvers.get(k); + this._storageResolvers.get(k); PublicKey pk = keyResolver.engineLookupAndResolvePublicKey((Element) currentChild, @@ -776,7 +776,7 @@ if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (int k = 0; k < storageLength; k++) { StorageResolver storage = - (StorageResolver) this._storageResolvers.get(k); + this._storageResolvers.get(k); PublicKey pk = keyResolver .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage); @@ -845,9 +845,9 @@ String uri=this.getBaseURI(); int length= KeyResolver.length(); int storageLength=this._storageResolvers.size(); - Iterator it = KeyResolver.iterator(); + Iterator<KeyResolverSpi> it = KeyResolver.iterator(); for (int i = 0; i <length; i++) { - KeyResolverSpi keyResolver = (KeyResolverSpi) it.next(); + KeyResolverSpi keyResolver = it.next(); X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver); if (cert!=null) { KeyResolver.hit(it); @@ -863,7 +863,7 @@ if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (int k = 0; k < storageLength; k++) { StorageResolver storage = - (StorageResolver) this._storageResolvers.get(k); + this._storageResolvers.get(k); X509Certificate cert = keyResolver .engineLookupResolveX509Certificate((Element) currentChild, uri, @@ -944,9 +944,9 @@ SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException { final int length=KeyResolver.length(); int storageLength=this._storageResolvers.size(); - Iterator it = KeyResolver.iterator(); + Iterator<KeyResolverSpi> it = KeyResolver.iterator(); for (int i = 0; i < length; i++) { - KeyResolverSpi keyResolver = (KeyResolverSpi) it.next(); + KeyResolverSpi keyResolver = it.next(); Node currentChild=this._constructionElement.getFirstChild(); String uri=this.getBaseURI(); @@ -954,7 +954,7 @@ if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (int k = 0; k < storageLength; k++) { StorageResolver storage = - (StorageResolver) this._storageResolvers.get(k); + this._storageResolvers.get(k); SecretKey sk = keyResolver.engineLookupAndResolveSecretKey((Element) currentChild, @@ -992,7 +992,7 @@ if (currentChild.getNodeType() == Node.ELEMENT_NODE) { for (int k = 0; k < storageLength; k++) { StorageResolver storage = - (StorageResolver) this._storageResolvers.get(k); + this._storageResolvers.get(k); SecretKey sk = keyResolver .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage); @@ -1012,7 +1012,7 @@ /** * Stores the individual (per-KeyInfo) {@link KeyResolver}s */ - List _internalKeyResolvers = null; + List<KeyResolverSpi> _internalKeyResolvers = null; /** * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo @@ -1022,7 +1022,7 @@ */ public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) { if (_internalKeyResolvers==null) { - _internalKeyResolvers=new ArrayList(); + _internalKeyResolvers=new ArrayList<KeyResolverSpi>(); } this._internalKeyResolvers.add(realKeyResolver); } @@ -1044,11 +1044,11 @@ * @return the KeyResolverSpi for the index. */ KeyResolverSpi itemInternalKeyResolver(int i) { - return (KeyResolverSpi) this._internalKeyResolvers.get(i); + return this._internalKeyResolvers.get(i); } /** Field _storageResolvers */ - List _storageResolvers = nullList; + List<StorageResolver> _storageResolvers = nullList; /** * Method addStorageResolver @@ -1057,7 +1057,7 @@ */ public void addStorageResolver(StorageResolver storageResolver) { if (_storageResolvers == nullList ){ - _storageResolvers=new ArrayList(); + _storageResolvers=new ArrayList<StorageResolver>(); } this._storageResolvers.add(storageResolver);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -52,7 +52,7 @@ static boolean _alreadyInitialized = false; /** Field _resolverVector */ - static List _resolverVector = null; + static List<KeyResolver> _resolverVector = null; /** Field _resolverSpi */ protected KeyResolverSpi _resolverSpi = null; @@ -85,12 +85,12 @@ return KeyResolver._resolverVector.size(); } - public static void hit(Iterator hintI) { + public static void hit(Iterator<KeyResolverSpi> hintI) { ResolverIterator hint = (ResolverIterator) hintI; int i = hint.i; if (i!=1 && hint.res ==_resolverVector) { - List resolverVector=(List)((ArrayList)_resolverVector).clone(); - Object ob=resolverVector.remove(i-1); + List<KeyResolver> resolverVector=getResolverVectorClone(); + KeyResolver ob=resolverVector.remove(i-1); resolverVector.add(0,ob); _resolverVector=resolverVector; } else { @@ -113,12 +113,9 @@ throws KeyResolverException { // use the old vector to not be hit by updates - List resolverVector = KeyResolver._resolverVector; - for (int i = 0; i < resolverVector.size(); i++) { - KeyResolver resolver= - (KeyResolver) resolverVector.get(i); - - if (resolver==null) { + List<KeyResolver> resolverVector = KeyResolver._resolverVector; + for (KeyResolver resolver : resolverVector) { + if (resolver==null) { Object exArgs[] = { (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE)) @@ -157,10 +154,8 @@ Element element, String BaseURI, StorageResolver storage) throws KeyResolverException { - List resolverVector = KeyResolver._resolverVector; - for (int i = 0; i < resolverVector.size(); i++) { - KeyResolver resolver= - (KeyResolver) resolverVector.get(i); + List<KeyResolver> resolverVector = KeyResolver._resolverVector; + for (KeyResolver resolver : resolverVector) { if (resolver==null) { Object exArgs[] = { @@ -176,11 +171,11 @@ PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage); if (cert!=null) { - if (i!=0 && resolverVector==_resolverVector) { + if (resolverVector.indexOf(resolver)!=0 && resolverVector==_resolverVector) { //update resolver. - resolverVector=(List)((ArrayList)_resolverVector).clone(); - Object ob=resolverVector.remove(i); - resolverVector.add(0,ob); + resolverVector=getResolverVectorClone(); + resolverVector.remove(resolver); + resolverVector.add(0,resolver); _resolverVector=resolverVector; } return cert; @@ -195,13 +190,19 @@ throw new KeyResolverException("utils.resolver.noClass", exArgs); } + + @SuppressWarnings("unchecked") + private static List<KeyResolver> getResolverVectorClone() { + return (List<KeyResolver>)((ArrayList<KeyResolver>)_resolverVector).clone(); + } + /** * The init() function is called by com.sun.org.apache.xml.internal.security.Init.init() */ public static void init() { if (!KeyResolver._alreadyInitialized) { - KeyResolver._resolverVector = new ArrayList(10); + KeyResolver._resolverVector = new ArrayList<KeyResolver>(10); _alreadyInitialized = true; } } @@ -230,8 +231,8 @@ * * @param className */ - public static void registerAtStart(String className) { - KeyResolver._resolverVector.add(0, className); + public static void registerAtStart(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException { + register(className); } /** @@ -322,11 +323,11 @@ return this._resolverSpi.getClass().getName(); } - static class ResolverIterator implements Iterator { - List res; - Iterator it; + static class ResolverIterator implements Iterator<KeyResolverSpi> { + List<KeyResolver> res; + Iterator<KeyResolver> it; int i; - public ResolverIterator(List list) { + public ResolverIterator(List<KeyResolver> list) { res = list; it = res.iterator(); } @@ -335,9 +336,9 @@ return it.hasNext(); } - public Object next() { + public KeyResolverSpi next() { i++; - KeyResolver resolver = (KeyResolver) it.next(); + KeyResolver resolver = it.next(); if (resolver==null) { throw new RuntimeException("utils.resolver.noClass"); } @@ -351,7 +352,7 @@ } }; - public static Iterator iterator() { + public static Iterator<KeyResolverSpi> iterator() { return new ResolverIterator(_resolverVector); } }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java Mon Oct 17 19:06:53 2011 -0700 @@ -32,7 +32,7 @@ /** * This class is abstract class for a child KeyInfo Elemnet. * - * If you want the your KeyResolver, at firstly you must extand this class, and register + * If you want your KeyResolver, at first you must extend this class, and register * as following in config.xml * <PRE> * <KeyResolver URI="http://www.w3.org/2000/09/xmldsig#KeyValue" @@ -177,7 +177,7 @@ } /** Field _properties */ - protected java.util.Map _properties = null; + protected java.util.Map<String,String> _properties = null; protected boolean globalResolver=false; @@ -189,7 +189,7 @@ */ public void engineSetProperty(String key, String value) { if (_properties==null) - _properties=new HashMap(); + _properties=new HashMap<String,String>(); this._properties.put(key, value); } @@ -203,7 +203,7 @@ if (_properties==null) return null; - return (String) this._properties.get(key); + return this._properties.get(key); } /**
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -278,18 +278,18 @@ return null; } - static Element getDocumentElement(Set set) { - Iterator it=set.iterator(); + static Element getDocumentElement(Set<Node> set) { + Iterator<Node> it=set.iterator(); Element e=null; while (it.hasNext()) { - Node currentNode=(Node)it.next(); + Node currentNode=it.next(); if (currentNode instanceof Element) { e=(Element)currentNode; break; } } - List parents=new ArrayList(10); + List<Element> parents=new ArrayList<Element>(10); //Obtain all the parents of the elemnt do { @@ -301,10 +301,10 @@ e=(Element)n; } while (e!=null); //Visit them in reverse order. - ListIterator it2=parents.listIterator(parents.size()-1); + ListIterator<Element> it2=parents.listIterator(parents.size()-1); Element ele=null; while (it2.hasPrevious()) { - ele=(Element)it2.previous(); + ele=it2.previous(); if (set.contains(ele)) { return ele; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -42,10 +42,10 @@ java.util.logging.Logger.getLogger(StorageResolver.class.getName()); /** Field _storageResolvers */ - List _storageResolvers = null; + List<Object> _storageResolvers = null; /** Field _iterator */ - Iterator _iterator = null; + Iterator<Object> _iterator = null; /** * Constructor StorageResolver @@ -69,7 +69,7 @@ */ public void add(StorageResolverSpi resolver) { if (_storageResolvers==null) - _storageResolvers=new ArrayList(); + _storageResolvers=new ArrayList<Object>(); this._storageResolvers.add(resolver); this._iterator = null; @@ -121,11 +121,11 @@ * @return the iterator for the resolvers. * */ - public Iterator getIterator() { + public Iterator<Object> getIterator() { if (this._iterator == null) { if (_storageResolvers==null) - _storageResolvers=new ArrayList(); + _storageResolvers=new ArrayList<Object>(); this._iterator = new StorageResolverIterator(this._storageResolvers.iterator()); } @@ -141,7 +141,7 @@ if (this._iterator == null) { if (_storageResolvers==null) - _storageResolvers=new ArrayList(); + _storageResolvers=new ArrayList<Object>(); this._iterator = new StorageResolverIterator(this._storageResolvers.iterator()); } @@ -163,17 +163,17 @@ * @author $Author: mullan $ * @version $Revision: 1.5 $ */ - static class StorageResolverIterator implements Iterator { + static class StorageResolverIterator implements Iterator<Object> { /** Field _resolvers */ - Iterator _resolvers = null; + Iterator<Object> _resolvers = null; /** * Constructor FilesystemIterator * * @param resolvers */ - public StorageResolverIterator(Iterator resolvers) { + public StorageResolverIterator(Iterator<Object> resolvers) { this._resolvers = resolvers; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java Mon Oct 17 19:06:53 2011 -0700 @@ -36,5 +36,5 @@ * * @return the iterator for the storage */ - public abstract Iterator getIterator(); + public abstract Iterator<?> getIterator(); }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -54,10 +54,10 @@ String _merlinsCertificatesDir = null; /** Field _certs */ - private List _certs = new ArrayList(); + private List<X509Certificate> _certs = new ArrayList<X509Certificate>(); /** Field _iterator */ - Iterator _iterator = null; + Iterator<X509Certificate> _iterator = null; /** * @@ -83,7 +83,7 @@ private void readCertsFromHarddrive() throws StorageResolverException { File certDir = new File(this._merlinsCertificatesDir); - ArrayList al = new ArrayList(); + ArrayList<String> al = new ArrayList<String>(); String[] names = certDir.list(); for (int i = 0; i < names.length; i++) { @@ -108,7 +108,7 @@ for (int i = 0; i < al.size(); i++) { String filename = certDir.getAbsolutePath() + File.separator - + (String) al.get(i); + + al.get(i); File file = new File(filename); boolean added = false; String dn = null; @@ -146,7 +146,7 @@ } /** @inheritDoc */ - public Iterator getIterator() { + public Iterator<X509Certificate> getIterator() { return this._iterator; } @@ -156,10 +156,10 @@ * @author $Author: mullan $ * @version $Revision: 1.5 $ */ - private static class FilesystemIterator implements Iterator { + private static class FilesystemIterator implements Iterator<X509Certificate> { /** Field _certs */ - List _certs = null; + List<X509Certificate> _certs = null; /** Field _i */ int _i; @@ -169,7 +169,7 @@ * * @param certs */ - public FilesystemIterator(List certs) { + public FilesystemIterator(List<X509Certificate> certs) { this._certs = certs; this._i = 0; } @@ -180,7 +180,7 @@ } /** @inheritDoc */ - public Object next() { + public X509Certificate next() { return this._certs.get(this._i++); } @@ -206,8 +206,8 @@ new CertsInFilesystemDirectoryResolver( "data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs"); - for (Iterator i = krs.getIterator(); i.hasNext(); ) { - X509Certificate cert = (X509Certificate) i.next(); + for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) { + X509Certificate cert = i.next(); byte[] ski = com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI .getSKIBytesFromCert(cert);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -42,7 +42,7 @@ KeyStore _keyStore = null; /** Field _iterator */ - Iterator _iterator = null; + Iterator<X509Certificate> _iterator = null; /** * Constructor KeyStoreResolver @@ -56,7 +56,7 @@ } /** @inheritDoc */ - public Iterator getIterator() { + public Iterator<X509Certificate> getIterator() { return this._iterator; } @@ -66,13 +66,13 @@ * @author $Author: mullan $ * @version $Revision: 1.5 $ */ - static class KeyStoreIterator implements Iterator { + static class KeyStoreIterator implements Iterator<X509Certificate> { /** Field _keyStore */ KeyStore _keyStore = null; /** Field _aliases */ - Enumeration _aliases = null; + Enumeration<String> _aliases = null; /** * Constructor KeyStoreIterator @@ -97,12 +97,13 @@ } /** @inheritDoc */ - public Object next() { + @SuppressWarnings("unchecked") + public X509Certificate next() { - String alias = (String) this._aliases.nextElement(); + String alias = this._aliases.nextElement(); try { - return this._keyStore.getCertificate(alias); + return (X509Certificate)this._keyStore.getCertificate(alias); } catch (KeyStoreException ex) { return null; } @@ -135,8 +136,8 @@ KeyStoreResolver krs = new KeyStoreResolver(ks); - for (Iterator i = krs.getIterator(); i.hasNext(); ) { - X509Certificate cert = (X509Certificate) i.next(); + for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) { + X509Certificate cert = i.next(); byte[] ski = com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI .getSKIBytesFromCert(cert);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -38,7 +38,7 @@ X509Certificate _certificate = null; /** Field _iterator */ - Iterator _iterator = null; + Iterator<X509Certificate> _iterator = null; /** * @@ -51,7 +51,7 @@ } /** @inheritDoc */ - public Iterator getIterator() { + public Iterator<X509Certificate> getIterator() { return this._iterator; } @@ -61,7 +61,7 @@ * @author $Author: mullan $ * @version $Revision: 1.5 $ */ - static class InternalIterator implements Iterator { + static class InternalIterator implements Iterator<X509Certificate> { /** Field _alreadyReturned */ boolean _alreadyReturned = false; @@ -84,7 +84,7 @@ } /** @inheritDoc */ - public Object next() { + public X509Certificate next() { this._alreadyReturned = true;
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java Mon Oct 17 19:06:53 2011 -0700 @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.Map; import javax.xml.parsers.ParserConfigurationException; @@ -62,17 +63,17 @@ java.util.logging.Logger.getLogger(Manifest.class.getName()); /** Field _references */ - List _references; + List<Reference> _references; Element[] _referencesEl; /** Field verificationResults[] */ private boolean verificationResults[] = null; /** Field _resolverProperties */ - HashMap _resolverProperties = null; + Map<String,String> _resolverProperties = null; /** Field _perManifestResolvers */ - List _perManifestResolvers = null; + List<ResourceResolver> _perManifestResolvers = null; /** * Consturts {@link Manifest} @@ -85,7 +86,7 @@ XMLUtils.addReturnToElement(this._constructionElement); - this._references = new ArrayList(); + this._references = new ArrayList<Reference>(); } /** @@ -117,7 +118,7 @@ } // create Vector - this._references = new ArrayList(le); + this._references = new ArrayList<Reference>(le); for (int i = 0; i < le; i++) { this._references.add(null); @@ -175,7 +176,7 @@ for (int i = 0; i < this.getLength(); i++) { // update the cached Reference object, the Element content is automatically updated - Reference currentRef = (Reference) this._references.get(i); + Reference currentRef = this._references.get(i); currentRef.generateDigestValue(); } @@ -208,7 +209,7 @@ this._references.set(i, ref); } - return (Reference) this._references.get(i); + return this._references.get(i); } @@ -323,12 +324,12 @@ try { XMLSignatureInput signedManifestNodes = currentRef.dereferenceURIandPerformTransforms(null); - Set nl = signedManifestNodes.getNodeSet(); + Set<Node> nl = signedManifestNodes.getNodeSet(); Manifest referencedManifest = null; - Iterator nlIterator = nl.iterator(); + Iterator<Node> nlIterator = nl.iterator(); findManifest: while (nlIterator.hasNext()) { - Node n = (Node) nlIterator.next(); + Node n = nlIterator.next(); if ((n.getNodeType() == Node.ELEMENT_NODE) && ((Element) n) .getNamespaceURI() @@ -449,7 +450,7 @@ return; } if (_perManifestResolvers==null) - _perManifestResolvers = new ArrayList(); + _perManifestResolvers = new ArrayList<ResourceResolver>(); this._perManifestResolvers.add(resolver); } @@ -465,7 +466,7 @@ return; } if (_perManifestResolvers==null) - _perManifestResolvers = new ArrayList(); + _perManifestResolvers = new ArrayList<ResourceResolver>(); this._perManifestResolvers.add(new ResourceResolver(resolverSpi)); } @@ -479,7 +480,7 @@ */ public void setResolverProperty(String key, String value) { if (_resolverProperties==null) { - _resolverProperties=new HashMap(10); + _resolverProperties=new HashMap<String, String>(10); } this._resolverProperties.put(key, value); } @@ -491,7 +492,7 @@ * @return the value */ public String getResolverProperty(String key) { - return (String) this._resolverProperties.get(key); + return this._resolverProperties.get(key); } /**
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java Mon Oct 17 19:06:53 2011 -0700 @@ -436,6 +436,7 @@ * * @deprecated use getContentsBeforeTransformation */ + @Deprecated public XMLSignatureInput getTransformsInput() throws ReferenceNotInitializedException { XMLSignatureInput input=getContentsBeforeTransformation(); @@ -557,7 +558,7 @@ try { XMLSignatureInput nodes = this.getNodesetBeforeFirstCanonicalization(); - Set inclusiveNamespaces = new HashSet(); + Set<String> inclusiveNamespaces = new HashSet<String>(); { Transforms transforms = this.getTransforms(); @@ -710,7 +711,7 @@ XMLSignatureInput output=this.dereferenceURIandPerformTransforms(os); // if signing and c14n11 property == true explicitly add // C14N11 transform if needed - if (this.useC14N11 && !validating && + if (Reference.useC14N11 && !validating && !output.isOutputStreamSet() && !output.isOctetStream()) { if (transforms == null) { transforms = new Transforms(this._doc);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java Mon Oct 17 19:06:53 2011 -0700 @@ -74,7 +74,7 @@ /** * The original NodeSet for this XMLSignatureInput */ - Set _inputNodeSet = null; + Set<Node> _inputNodeSet = null; /** * The original Element */ @@ -107,7 +107,7 @@ /** * Node Filter list. */ - List nodeFilters=new ArrayList(); + List<NodeFilter> nodeFilters=new ArrayList<NodeFilter>(); boolean needsToBeExpanded=false; OutputStream outputStream=null; @@ -164,6 +164,7 @@ * @deprecated * @param inputStr the input String which including XML document or node */ + @Deprecated public XMLSignatureInput(String inputStr) { this(inputStr.getBytes()); } @@ -179,6 +180,7 @@ * @param encoding the encoding of <code>inputStr</code> * @throws UnsupportedEncodingException */ + @Deprecated public XMLSignatureInput(String inputStr, String encoding) throws UnsupportedEncodingException { this(inputStr.getBytes(encoding)); @@ -201,7 +203,7 @@ * @param inputNodeSet * @param usedXPathAPI */ - public XMLSignatureInput(Set inputNodeSet) { + public XMLSignatureInput(Set<Node> inputNodeSet) { this._inputNodeSet = inputNodeSet; } @@ -215,7 +217,7 @@ * @throws ParserConfigurationException * @throws CanonicalizationException */ - public Set getNodeSet() throws CanonicalizationException, + public Set<Node> getNodeSet() throws CanonicalizationException, ParserConfigurationException, IOException, SAXException { return getNodeSet(false); } @@ -231,7 +233,7 @@ * @throws ParserConfigurationException * @throws CanonicalizationException */ - public Set getNodeSet(boolean circumvent) + public Set<Node> getNodeSet(boolean circumvent) throws ParserConfigurationException, IOException, SAXException, CanonicalizationException { if (this._inputNodeSet!=null) { @@ -242,13 +244,13 @@ if (circumvent) { XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode)); } - this._inputNodeSet = new HashSet(); + this._inputNodeSet = new HashSet<Node>(); XMLUtils.getSet(_subNode,this._inputNodeSet, excludeNode, this.excludeComments); return this._inputNodeSet; } else if (this.isOctetStream()) { convertToNodes(); - HashSet result=new HashSet(); + HashSet<Node> result=new HashSet<Node>(); XMLUtils.getSet(_subNode, result,null,false); //this._inputNodeSet=result; return result; @@ -447,7 +449,7 @@ * @throws XMLSignatureException * @return The HTML representation for this XMLSignature */ - public String getHTMLRepresentation(Set inclusiveNamespaces) + public String getHTMLRepresentation(Set<String> inclusiveNamespaces) throws XMLSignatureException { XMLSignatureInputDebugger db = new XMLSignatureInputDebugger( this, @@ -584,7 +586,7 @@ /** * @return the node filters */ - public List getNodeFilters() { + public List<NodeFilter> getNodeFilters() { // TODO Auto-generated method stub return nodeFilters; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java Mon Oct 17 19:06:53 2011 -0700 @@ -47,9 +47,9 @@ /** Field _xmlSignatureInput */ - private Set _xpathNodeSet; + private Set<Node> _xpathNodeSet; - private Set _inclusiveNamespaces; + private Set<String> _inclusiveNamespaces; /** Field _doc */ private Document _doc = null; @@ -159,7 +159,7 @@ * @param inclusiveNamespace */ public XMLSignatureInputDebugger( - XMLSignatureInput xmlSignatureInput, Set inclusiveNamespace) { + XMLSignatureInput xmlSignatureInput, Set<String> inclusiveNamespace) { this(xmlSignatureInput); @@ -182,7 +182,7 @@ { // get only a single node as anchor to fetch the owner document - Node n = (Node) this._xpathNodeSet.iterator().next(); + Node n = this._xpathNodeSet.iterator().next(); this._doc = XMLUtils.getOwnerDocument(n); } @@ -341,10 +341,10 @@ // we output all Attrs which are available NamedNodeMap attrs = currentElement.getAttributes(); int attrsLength = attrs.getLength(); - Object attrs2[] = new Object[attrsLength]; + Attr attrs2[] = new Attr[attrsLength]; for (int i = 0; i < attrsLength; i++) { - attrs2[i] = attrs.item(i); + attrs2[i] = (Attr)attrs.item(i); } Arrays.sort(attrs2, ATTR_COMPARE);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java Mon Oct 17 19:06:53 2011 -0700 @@ -25,6 +25,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; +import java.util.Map; import javax.xml.parsers.ParserConfigurationException; import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; @@ -65,9 +66,9 @@ private static boolean alreadyInitialized = false; /** All available Transform classes are registered here */ - private static HashMap transformClassHash = null; + private static Map<String, Class<?>> transformClassHash = null; - private static HashMap transformSpiHash = new HashMap(); + private static Map<String, TransformSpi> transformSpiHash = new HashMap<String, TransformSpi>(); private TransformSpi transformSpi = null; @@ -209,7 +210,7 @@ */ public static void init() { if (!alreadyInitialized) { - transformClassHash = new HashMap(10); + transformClassHash = new HashMap<String,Class<?>>(10); // make sure builtin algorithms are all registered first com.sun.org.apache.xml.internal.security.Init.init(); alreadyInitialized = true; @@ -231,7 +232,7 @@ throws AlgorithmAlreadyRegisteredException { // are we already registered? - Class registeredClass = getImplementingClass(algorithmURI); + Class<? extends TransformSpi> registeredClass = getImplementingClass(algorithmURI); if ((registeredClass != null) ) { Object exArgs[] = { algorithmURI, registeredClass }; throw new AlgorithmAlreadyRegisteredException( @@ -331,20 +332,21 @@ * @param URI * @return The name of the class implementing the URI. */ - private static Class getImplementingClass(String URI) { - return (Class) transformClassHash.get(URI); + @SuppressWarnings("unchecked") + private static Class<? extends TransformSpi> getImplementingClass(String URI) { + return (Class<? extends TransformSpi>)transformClassHash.get(URI); } private static TransformSpi getTransformSpi(String URI) throws InvalidTransformException { try { - Object value = transformSpiHash.get(URI); + TransformSpi value = transformSpiHash.get(URI); if (value != null) { - return (TransformSpi) value; + return value; } - Class cl = (Class) transformClassHash.get(URI); + Class<? extends TransformSpi> cl = getImplementingClass(URI); if (cl != null) { - TransformSpi tr = (TransformSpi) cl.newInstance(); + TransformSpi tr = cl.newInstance(); transformSpiHash.put(URI, tr); return tr; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java Mon Oct 17 19:06:53 2011 -0700 @@ -41,6 +41,7 @@ * For API compatibility not thread safe. * @deprecated */ + @Deprecated protected Transform _transformObject = null; /** * Set the transform object. @@ -48,6 +49,7 @@ * @param transform the Transform * @deprecated */ + @Deprecated protected void setTransform(Transform transform) { this._transformObject = transform; } @@ -120,6 +122,7 @@ * @throws SAXException * @throws TransformationException */ + @Deprecated protected XMLSignatureInput enginePerformTransform( XMLSignatureInput input) throws IOException,
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java Mon Oct 17 19:06:53 2011 -0700 @@ -154,6 +154,7 @@ * @param vars * @param globalsSize */ + @SuppressWarnings("rawtypes") public void fixupVariables(java.util.Vector vars, int globalsSize) { // do nothing
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java Mon Oct 17 19:06:53 2011 -0700 @@ -96,9 +96,9 @@ throws TransformationException { CachedXPathAPIHolder.setDoc(_transformObject.getElement().getOwnerDocument()); try { - List unionNodes=new ArrayList(); - List substractNodes=new ArrayList(); - List intersectNodes=new ArrayList(); + List<NodeList> unionNodes=new ArrayList<NodeList>(); + List<NodeList> substractNodes=new ArrayList<NodeList>(); + List<NodeList> intersectNodes=new ArrayList<NodeList>(); CachedXPathFuncHereAPI xPathFuncHereAPI = new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI()); @@ -170,18 +170,15 @@ throw new TransformationException("empty", ex); } } - static Set convertNodeListToSet(List l){ - Set result=new HashSet(); - for (int j=0;j<l.size();j++) { - NodeList rootNodes=(NodeList) l.get(j); + static Set<Node> convertNodeListToSet(List<NodeList> l){ + Set<Node> result=new HashSet<Node>(); + + for (NodeList rootNodes : l) { int length = rootNodes.getLength(); - for (int i = 0; i < length; i++) { Node rootNode = rootNodes.item(i); result.add(rootNode); - } - } return result; } @@ -191,8 +188,8 @@ boolean hasUnionNodes; boolean hasSubstractNodes; boolean hasIntersectNodes; - XPath2NodeFilter(Set unionNodes, Set substractNodes, - Set intersectNodes) { + XPath2NodeFilter(Set<Node> unionNodes, Set<Node> substractNodes, + Set<Node> intersectNodes) { this.unionNodes=unionNodes; hasUnionNodes=!unionNodes.isEmpty(); this.substractNodes=substractNodes; @@ -200,9 +197,9 @@ this.intersectNodes=intersectNodes; hasIntersectNodes=!intersectNodes.isEmpty(); } - Set unionNodes; - Set substractNodes; - Set intersectNodes; + Set<Node> unionNodes; + Set<Node> substractNodes; + Set<Node> intersectNodes; /** @@ -282,16 +279,15 @@ * * @return if rooted bye the rootnodes */ - static boolean rooted(Node currentNode, Set nodeList ) { + static boolean rooted(Node currentNode, Set<Node> nodeList ) { if (nodeList.contains(currentNode)) { return true; } - Iterator it=nodeList.iterator(); - while (it.hasNext()) { - Node rootNode = (Node) it.next(); - if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) { - return true; - } + + for(Node rootNode : nodeList) { + if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) { + return true; + } } return false; } @@ -303,7 +299,7 @@ * * @return if rooted bye the rootnodes */ - static boolean inList(Node currentNode, Set nodeList ) { + static boolean inList(Node currentNode, Set<Node> nodeList ) { return nodeList.contains(currentNode); } }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java Mon Oct 17 19:06:53 2011 -0700 @@ -62,14 +62,6 @@ static final String defaultXSLTSpecNSprefix = "xslt"; static final String XSLTSTYLESHEET = "stylesheet"; - // check for secure processing feature - private static Class xClass = null; - static { - try { - xClass = Class.forName("javax.xml.XMLConstants"); - } catch (Exception e) {} - } - static java.util.logging.Logger log = java.util.logging.Logger.getLogger( TransformXSLT.class.getName()); @@ -101,10 +93,6 @@ protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream baos, Transform _transformObject) throws IOException, TransformationException { - if (xClass == null) { - Object exArgs[] = { "SECURE_PROCESSING_FEATURE not supported" }; - throw new TransformationException("generic.EmptyMessage", exArgs); - } try { Element transformElement = _transformObject.getElement(); @@ -119,11 +107,9 @@ } TransformerFactory tFactory = TransformerFactory.newInstance(); - Class c = tFactory.getClass(); - Method m = c.getMethod("setFeature", new Class[] {String.class, boolean.class}); + // Process XSLT stylesheets in a secure manner - m.invoke(tFactory, new Object[] {"http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE}); - + tFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE); /* * This transform requires an octet stream as input. If the actual * input is an XPath node-set, then the signature application should @@ -193,18 +179,6 @@ Object exArgs[] = { ex.getMessage() }; throw new TransformationException("generic.EmptyMessage", exArgs, ex); - } catch (NoSuchMethodException ex) { - Object exArgs[] = { ex.getMessage() }; - - throw new TransformationException("generic.EmptyMessage", exArgs, ex); - } catch (IllegalAccessException ex) { - Object exArgs[] = { ex.getMessage() }; - - throw new TransformationException("generic.EmptyMessage", exArgs, ex); - } catch (java.lang.reflect.InvocationTargetException ex) { - Object exArgs[] = { ex.getMessage() }; - - throw new TransformationException("generic.EmptyMessage", exArgs, ex); } } }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java Mon Oct 17 19:06:53 2011 -0700 @@ -74,19 +74,16 @@ * @param doc * @param prefixes */ - public InclusiveNamespaces(Document doc, Set prefixes) { + public InclusiveNamespaces(Document doc, Set<String> prefixes) { super(doc); StringBuffer sb = new StringBuffer(); - SortedSet prefixList = new TreeSet(prefixes); + SortedSet<String> prefixList = new TreeSet<String>(prefixes); - Iterator it = prefixList.iterator(); - while (it.hasNext()) { - String prefix = (String) it.next(); - + for (String prefix : prefixList) { if (prefix.equals("xmlns")) { sb.append("#default "); } else { @@ -138,9 +135,9 @@ * @param inclusiveNamespaces * @return A set to string */ - public static SortedSet prefixStr2Set(String inclusiveNamespaces) { + public static SortedSet<String> prefixStr2Set(String inclusiveNamespaces) { - SortedSet prefixes = new TreeSet(); + SortedSet<String> prefixes = new TreeSet<String>(); if ((inclusiveNamespaces == null) || (inclusiveNamespaces.length() == 0)) {
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java Mon Oct 17 19:06:53 2011 -0700 @@ -28,8 +28,8 @@ */ public class CachedXPathAPIHolder { - static ThreadLocal local=new ThreadLocal(); - static ThreadLocal localDoc=new ThreadLocal(); + static ThreadLocal<CachedXPathAPI> local=new ThreadLocal<CachedXPathAPI>(); + static ThreadLocal<Document> localDoc=new ThreadLocal<Document>(); /** * Sets the doc for the xpath transformation. Resets the cache if needed @@ -37,7 +37,7 @@ */ public static void setDoc(Document doc) { if (localDoc.get()!=doc) { - CachedXPathAPI cx=(CachedXPathAPI)local.get(); + CachedXPathAPI cx=local.get(); if (cx==null) { cx=new CachedXPathAPI(); local.set(cx); @@ -54,7 +54,7 @@ * @return the cachexpathapi for this thread */ public static CachedXPathAPI getCachedXPathAPI() { - CachedXPathAPI cx=(CachedXPathAPI)local.get(); + CachedXPathAPI cx=local.get(); if (cx==null) { cx=new CachedXPathAPI(); local.set(cx);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java Mon Oct 17 19:06:53 2011 -0700 @@ -173,6 +173,7 @@ * @throws TransformerException * @deprecated */ + @Deprecated public NodeIterator selectNodeIterator( Node contextNode, Node xpathnode, Node namespaceNode) throws TransformerException { @@ -195,6 +196,7 @@ * @throws TransformerException * @deprecated */ + @Deprecated public NodeList selectNodeList(Node contextNode, Node xpathnode) throws TransformerException { return selectNodeList(contextNode, xpathnode, getStrFromNode(xpathnode), contextNode); @@ -239,6 +241,7 @@ * @throws TransformerException * @deprecated */ + @Deprecated public XObject eval(Node contextNode, Node xpathnode) throws TransformerException { return eval(contextNode, xpathnode, getStrFromNode(xpathnode),contextNode); @@ -375,12 +378,12 @@ private XPath createXPath(String str, PrefixResolver prefixResolver) throws TransformerException { XPath xpath = null; - Class[] classes = new Class[]{String.class, SourceLocator.class, PrefixResolver.class, int.class, + Class<?>[] classes = new Class<?>[]{String.class, SourceLocator.class, PrefixResolver.class, int.class, ErrorListener.class, FunctionTable.class}; Object[] objects = new Object[]{str, null, prefixResolver, new Integer(XPath.SELECT), null, _funcTable}; try { - Constructor constructor = XPath.class.getConstructor(classes); - xpath = (XPath) constructor.newInstance(objects); + Constructor<XPath> constructor = XPath.class.getConstructor(classes); + xpath = constructor.newInstance(objects); } catch (Throwable t) { } if (xpath == null) {
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java Mon Oct 17 19:06:53 2011 -0700 @@ -24,6 +24,7 @@ import java.math.BigInteger; import java.util.HashMap; +import java.util.Map; import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; @@ -370,6 +371,7 @@ * @return the bytes * @throws XMLSecurityException */ + @Deprecated public byte[] getBytesFromChildElement(String localname, String namespace) throws XMLSecurityException { @@ -392,14 +394,12 @@ */ public String getTextFromChildElement(String localname, String namespace) { - Text t = - (Text) XMLUtils.selectNode( - this._constructionElement.getFirstChild(), - namespace, - localname, - 0).getFirstChild(); + return XMLUtils.selectNode( + this._constructionElement.getFirstChild(), + namespace, + localname, + 0).getFirstChild().getNodeValue(); - return t.getData(); } /** @@ -493,8 +493,8 @@ } /** Field _prefixMappings */ - static HashMap _prefixMappings = new HashMap(); - static HashMap _prefixMappingsBindings = new HashMap(); + static Map<String, String> _prefixMappings = new HashMap<String,String>(); + static Map<String, String> _prefixMappingsBindings = new HashMap<String,String>(); /** * Method setDefaultPrefix @@ -533,10 +533,10 @@ * @return the default prefix bind to this element. */ public static String getDefaultPrefix(String namespace) { - return (String) ElementProxy._prefixMappings.get(namespace); + return ElementProxy._prefixMappings.get(namespace); } public static String getDefaultPrefixBindings(String namespace) { - return (String) ElementProxy._prefixMappingsBindings.get(namespace); + return ElementProxy._prefixMappingsBindings.get(namespace); } }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java Mon Oct 17 19:06:53 2011 -0700 @@ -21,6 +21,7 @@ package com.sun.org.apache.xml.internal.security.utils; import java.util.ArrayList; +import java.util.List; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -34,7 +35,7 @@ public class HelperNodeList implements NodeList { /** Field nodes */ - ArrayList nodes = new ArrayList(20); + List<Node> nodes = new ArrayList<Node>(20); boolean _allNodesMustHaveSameParent = false; /** @@ -62,7 +63,7 @@ // log.log(java.util.logging.Level.FINE, "item(" + index + ") of " + this.getLength() + " nodes"); - return (Node) nodes.get(index); + return nodes.get(index); } /**
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -23,6 +23,7 @@ import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.WeakHashMap; +import java.util.Map; import org.w3c.dom.Attr; import org.w3c.dom.Document; @@ -52,7 +53,8 @@ private static java.util.logging.Logger log = java.util.logging.Logger.getLogger(IdResolver.class.getName()); - private static WeakHashMap docMap = new WeakHashMap(); + private static Map<Document, Map<String, WeakReference<Element>>> docMap = + new WeakHashMap<Document, Map<String, WeakReference<Element>>>(); /** * Constructor IdResolver @@ -70,15 +72,15 @@ */ public static void registerElementById(Element element, String idValue) { Document doc = element.getOwnerDocument(); - WeakHashMap elementMap; + Map<String, WeakReference<Element>> elementMap; synchronized (docMap) { - elementMap = (WeakHashMap) docMap.get(doc); + elementMap = docMap.get(doc); if (elementMap == null) { - elementMap = new WeakHashMap(); + elementMap = new WeakHashMap<String, WeakReference<Element>>(); docMap.put(doc, elementMap); } } - elementMap.put(idValue, new WeakReference(element)); + elementMap.put(idValue, new WeakReference<Element>(element)); } /** @@ -156,20 +158,20 @@ private static Element getElementByIdType(Document doc, String id) { if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id); - WeakHashMap elementMap; + Map<String, WeakReference<Element>> elementMap; synchronized (docMap) { - elementMap = (WeakHashMap) docMap.get(doc); + elementMap = docMap.get(doc); } if (elementMap != null) { - WeakReference weakReference = (WeakReference) elementMap.get(id); + WeakReference<Element> weakReference = elementMap.get(id); if (weakReference != null) { - return (Element) weakReference.get(); + return weakReference.get(); } } return null; } - private static java.util.List names; + private static java.util.List<String> names; private static int namesLength; static { String namespaces[]={
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java Mon Oct 17 19:06:53 2011 -0700 @@ -33,8 +33,8 @@ final byte[] buf; static final int size=8*1024; - private static ThreadLocal bufCahce = new ThreadLocal() { - protected synchronized Object initialValue() { + private static ThreadLocal<byte[]> bufCahce = new ThreadLocal<byte[]>() { + protected synchronized byte[] initialValue() { return new byte[size]; } }; @@ -44,7 +44,7 @@ * @param out the outputstream to buffer */ public UnsyncBufferedOutputStream(OutputStream out) { - buf=(byte[])bufCahce.get(); + buf=bufCahce.get(); this.out=out; }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Mon Oct 17 19:06:53 2011 -0700 @@ -29,8 +29,8 @@ */ public class UnsyncByteArrayOutputStream extends OutputStream { private static final int INITIAL_SIZE = 8192; - private static ThreadLocal bufCache = new ThreadLocal() { - protected synchronized Object initialValue() { + private static ThreadLocal<byte[]> bufCache = new ThreadLocal<byte[]>() { + protected synchronized byte[] initialValue() { return new byte[INITIAL_SIZE]; } }; @@ -40,7 +40,7 @@ private int pos = 0; public UnsyncByteArrayOutputStream() { - buf = (byte[])bufCache.get(); + buf = bufCache.get(); } public void write(byte[] arg0) {
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java Mon Oct 17 19:06:53 2011 -0700 @@ -82,13 +82,15 @@ * @param exclude * @param com wheather comments or not */ - public static void getSet(Node rootNode,Set result,Node exclude ,boolean com) { + public static void getSet(Node rootNode,Set<Node> result,Node exclude ,boolean com) { if ((exclude!=null) && isDescendantOrSelf(exclude,rootNode)){ return; } getSetRec(rootNode,result,exclude,com); } - static final void getSetRec(final Node rootNode,final Set result, + + @SuppressWarnings("fallthrough") + static final void getSetRec(final Node rootNode,final Set<Node> result, final Node exclude ,final boolean com) { //Set result = new HashSet(); if (rootNode==exclude) { @@ -104,7 +106,7 @@ result.add(nl.item(i)); } } - //no return keep working + //no return keep working - ignore fallthrough warning case Node.DOCUMENT_NODE: for (Node r=rootNode.getFirstChild();r!=null;r=r.getNextSibling()){ if (r.getNodeType()==Node.TEXT_NODE) { @@ -230,7 +232,7 @@ static String dsPrefix=null; - static Map namePrefixes=new HashMap(); + static Map<String, String> namePrefixes=new HashMap<String, String>(); /** * Creates an Element in the XML Signature specification namespace. * @@ -248,7 +250,7 @@ if ((dsPrefix == null) || (dsPrefix.length() == 0)) { return doc.createElementNS(Constants.SignatureSpecNS, elementName); } - String namePrefix=(String) namePrefixes.get(elementName); + String namePrefix= namePrefixes.get(elementName); if (namePrefix==null) { StringBuffer tag=new StringBuffer(dsPrefix); tag.append(':'); @@ -318,11 +320,9 @@ * @param xpathNodeSet * @return the owner document */ - public static Document getOwnerDocument(Set xpathNodeSet) { + public static Document getOwnerDocument(Set<Node> xpathNodeSet) { NullPointerException npe = null; - Iterator iterator = xpathNodeSet.iterator(); - while(iterator.hasNext()) { - Node node = (Node) iterator.next(); + for (Node node : xpathNodeSet) { int nodeType =node.getNodeType(); if (nodeType == Node.DOCUMENT_NODE) { return (Document) node; @@ -397,14 +397,14 @@ * @param xpathNodeSet * @return the set with the nodelist */ - public static Set convertNodelistToSet(NodeList xpathNodeSet) { + public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet) { if (xpathNodeSet == null) { - return new HashSet(); + return new HashSet<Node>(); } int length = xpathNodeSet.getLength(); - Set set = new HashSet(length); + Set<Node> set = new HashSet<Node>(length); for (int i = 0; i < length; i++) { set.add(xpathNodeSet.item(i)); @@ -446,6 +446,7 @@ * @param node * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">Namespace axis resolution is not XPath compliant </A> */ + @SuppressWarnings("fallthrough") private static void circumventBug2650internal(Node node) { Node parent=null; Node sibling=null; @@ -642,12 +643,12 @@ * @param inputSet * @return nodes with the constrain */ - public static Set excludeNodeFromSet(Node signatureElement, Set inputSet) { - Set resultSet = new HashSet(); - Iterator iterator = inputSet.iterator(); + public static Set<Node> excludeNodeFromSet(Node signatureElement, Set<Node> inputSet) { + Set<Node> resultSet = new HashSet<Node>(); + Iterator<Node> iterator = inputSet.iterator(); while (iterator.hasNext()) { - Node inputNode = (Node) iterator.next(); + Node inputNode = iterator.next(); if (!XMLUtils .isDescendantOrSelf(signatureElement, inputNode)) {
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java Mon Oct 17 19:06:53 2011 -0700 @@ -56,7 +56,7 @@ static boolean _alreadyInitialized = false; /** these are the system-wide resolvers */ - static List _resolverVector = null; + static List<ResourceResolver> _resolverVector = null; static boolean allThreadSafeInList=true; @@ -102,7 +102,7 @@ int length=ResourceResolver._resolverVector.size(); for (int i = 0; i < length; i++) { ResourceResolver resolver = - (ResourceResolver) ResourceResolver._resolverVector.get(i); + ResourceResolver._resolverVector.get(i); ResourceResolver resolverTmp=null; try { resolverTmp = allThreadSafeInList || resolver._resolverSpi.engineIsThreadSafe() ? resolver : @@ -120,7 +120,7 @@ if (i!=0) { //update resolver. //System.out.println("Swaping"); - List resolverVector=(List)((ArrayList)_resolverVector).clone(); + List<ResourceResolver> resolverVector=getResolverVectorClone(); resolverVector.remove(i); resolverVector.add(0,resolver); _resolverVector=resolverVector; @@ -139,6 +139,17 @@ throw new ResourceResolverException("utils.resolver.noClass", exArgs, uri, BaseURI); } + + /** + * Method getResolverVectorClone + * + * @return clone of _resolverVector + */ + @SuppressWarnings("unchecked") + private static List<ResourceResolver> getResolverVectorClone() { + return (List<ResourceResolver>)((ArrayList<ResourceResolver>)_resolverVector).clone(); + } + /** * Method getInstance * @@ -150,7 +161,7 @@ * @throws ResourceResolverException */ public static final ResourceResolver getInstance( - Attr uri, String BaseURI, List individualResolvers) + Attr uri, String BaseURI, List<ResourceResolver> individualResolvers) throws ResourceResolverException { if (log.isLoggable(java.util.logging.Level.FINE)) { @@ -163,7 +174,7 @@ if ((individualResolvers != null) && ((size=individualResolvers.size()) > 0)) { for (int i = 0; i < size; i++) { ResourceResolver resolver = - (ResourceResolver) individualResolvers.get(i); + individualResolvers.get(i); if (resolver != null) { String currentClass = resolver._resolverSpi.getClass().getName(); @@ -186,7 +197,7 @@ public static void init() { if (!ResourceResolver._alreadyInitialized) { - ResourceResolver._resolverVector = new ArrayList(10); + ResourceResolver._resolverVector = new ArrayList<ResourceResolver>(10); _alreadyInitialized = true; } } @@ -288,7 +299,7 @@ * * @param properties */ - public void addProperties(Map properties) { + public void addProperties(Map<String,String> properties) { this._resolverSpi.engineAddProperies(properties); }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java Mon Oct 17 19:06:53 2011 -0700 @@ -41,7 +41,7 @@ ResourceResolverSpi.class.getName()); /** Field _properties */ - protected java.util.Map _properties = null; + protected java.util.Map<String,String> _properties = null; /** * This is the workhorse method used to resolve resources. @@ -63,7 +63,7 @@ */ public void engineSetProperty(String key, String value) { if (_properties==null) { - _properties=new HashMap(); + _properties=new HashMap<String,String>(); } this._properties.put(key, value); } @@ -78,17 +78,17 @@ if (_properties==null) { return null; } - return (String) this._properties.get(key); + return this._properties.get(key); } /** * * @param properties */ - public void engineAddProperies(Map properties) { + public void engineAddProperies(Map<String,String> properties) { if (properties!=null) { if (_properties==null) { - _properties=new HashMap(); + _properties=new HashMap<String,String>(); } this._properties.putAll(properties); }
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java Mon Oct 17 19:06:53 2011 -0700 @@ -289,7 +289,7 @@ * @inheritDoc */ public String[] engineGetPropertyKeys() { - return (String[]) ResolverDirectHTTP.properties.clone(); + return ResolverDirectHTTP.properties.clone(); } private URI getNewURI(String uri, String BaseURI)
--- a/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java Mon Oct 17 19:06:53 2011 -0700 @@ -725,7 +725,7 @@ cred = builder.action().getCreds(); } if (storeKey) { - encKeys = builder.getKeys(); + encKeys = builder.getKeys(isInitiator); // When encKeys is empty, the login actually fails. // For compatibility, exception is thrown in commit(). }
--- a/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java Mon Oct 17 19:06:53 2011 -0700 @@ -44,7 +44,7 @@ int timeout = 0; boolean connected = false; private int trafficClass = 0; - private InetAddress connectedAddress = null; + protected InetAddress connectedAddress = null; private int connectedPort = -1; /* cached socket options */
--- a/src/share/classes/java/net/AbstractPlainSocketImpl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/java/net/AbstractPlainSocketImpl.java Mon Oct 17 19:06:53 2011 -0700 @@ -71,7 +71,7 @@ /* whether this Socket is a stream (TCP) socket or not (UDP) */ - private boolean stream; + protected boolean stream; /** * Load net library into runtime. @@ -86,10 +86,11 @@ * is a stream socket (true) or an unconnected UDP socket (false). */ protected synchronized void create(boolean stream) throws IOException { - fd = new FileDescriptor(); this.stream = stream; if (!stream) { ResourceManager.beforeUdpCreate(); + // only create the fd after we know we will be able to create the socket + fd = new FileDescriptor(); try { socketCreate(false); } catch (IOException ioe) { @@ -98,6 +99,7 @@ throw ioe; } } else { + fd = new FileDescriptor(); socketCreate(true); } if (socket != null)
--- a/src/share/classes/java/net/DatagramSocket.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/java/net/DatagramSocket.java Mon Oct 17 19:06:53 2011 -0700 @@ -287,7 +287,7 @@ AccessController.doPrivileged( new PrivilegedExceptionAction<Void>() { public Void run() throws NoSuchMethodException { - Class[] cl = new Class[1]; + Class<?>[] cl = new Class<?>[1]; cl[0] = DatagramPacket.class; impl.getClass().getDeclaredMethod("peekData", cl); return null;
--- a/src/share/classes/java/net/InMemoryCookieStore.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/java/net/InMemoryCookieStore.java Mon Oct 17 19:06:53 2011 -0700 @@ -91,8 +91,10 @@ if (cookie.getDomain() != null) { addIndex(domainIndex, cookie.getDomain(), cookie); } - // add it to uri index, too - addIndex(uriIndex, getEffectiveURI(uri), cookie); + if (uri != null) { + // add it to uri index, too + addIndex(uriIndex, getEffectiveURI(uri), cookie); + } } } finally { lock.unlock();
--- a/src/share/classes/java/security/Signature.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/java/security/Signature.java Mon Oct 17 19:06:53 2011 -0700 @@ -899,6 +899,7 @@ * and its original parent (Object). */ + @SuppressWarnings("deprecation") private static class Delegate extends Signature { // The provider implementation (delegate) @@ -1203,6 +1204,7 @@ } // adapter for RSA/ECB/PKCS1Padding ciphers + @SuppressWarnings("deprecation") private static class CipherAdapter extends SignatureSpi { private final Cipher cipher;
--- a/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/PrivateCredentialPermission.java Mon Oct 17 19:06:53 2011 -0700 @@ -117,7 +117,7 @@ * The set contains elements of type, * <code>PrivateCredentialPermission.CredOwner</code>. */ - private Set principals; // ignored - kept around for compatibility + private Set<Principal> principals; // ignored - kept around for compatibility private transient CredOwner[] credOwners; /**
--- a/src/share/classes/javax/security/auth/Subject.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/Subject.java Mon Oct 17 19:06:53 2011 -0700 @@ -1291,6 +1291,7 @@ oos.writeFields(); } + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { @@ -1329,6 +1330,7 @@ } } + @SuppressWarnings("unchecked") /*To suppress warning from line 1374*/ private void populateSet() { final Iterator<?> iterator; switch(which) {
--- a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java Mon Oct 17 19:06:53 2011 -0700 @@ -56,6 +56,7 @@ sun.security.util.Debug.getInstance("combiner", "\t[SubjectDomainCombiner]"); + @SuppressWarnings("deprecation") // Note: check only at classloading time, not dynamically during combine() private static final boolean useJavaxPolicy = javax.security.auth.Policy.isCustomPolicySet(debug); @@ -300,6 +301,7 @@ if (!allowCaching) { java.security.AccessController.doPrivileged (new PrivilegedAction<Void>() { + @SuppressWarnings("deprecation") public Void run() { // Call refresh only caching is disallowed javax.security.auth.Policy.getPolicy().refresh(); @@ -308,6 +310,7 @@ }); } + int cLen = (currentDomains == null ? 0 : currentDomains.length); int aLen = (assignedDomains == null ? 0 : assignedDomains.length); @@ -348,13 +351,13 @@ // get the original perms Permissions perms = new Permissions(); PermissionCollection coll = pd.getPermissions(); - java.util.Enumeration e; + java.util.Enumeration<Permission> e; if (coll != null) { synchronized (coll) { e = coll.elements(); while (e.hasMoreElements()) { Permission newPerm = - (Permission)e.nextElement(); + e.nextElement(); perms.add(newPerm); } } @@ -367,6 +370,7 @@ PermissionCollection newPerms = java.security.AccessController.doPrivileged (new PrivilegedAction<PermissionCollection>() { + @SuppressWarnings("deprecation") public PermissionCollection run() { return javax.security.auth.Policy.getPolicy().getPermissions @@ -379,7 +383,7 @@ synchronized (newPerms) { e = newPerms.elements(); while (e.hasMoreElements()) { - Permission newPerm = (Permission)e.nextElement(); + Permission newPerm = e.nextElement(); if (!perms.implies(newPerm)) { perms.add(newPerm); if (debug != null)
--- a/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java Mon Oct 17 19:06:53 2011 -0700 @@ -375,6 +375,7 @@ /* * Reads in a Vector of DelegationPermissions and saves them in the perms field. */ + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Don't call defaultReadObject()
--- a/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Mon Oct 17 19:06:53 2011 -0700 @@ -583,6 +583,7 @@ /* * Reads in a Vector of ServicePermissions and saves them in the perms field. */ + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Don't call defaultReadObject()
--- a/src/share/classes/javax/security/auth/login/LoginContext.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/login/LoginContext.java Mon Oct 17 19:06:53 2011 -0700 @@ -214,14 +214,14 @@ private boolean subjectProvided = false; private boolean loginSucceeded = false; private CallbackHandler callbackHandler; - private Map state = new HashMap(); + private Map<String,?> state = new HashMap<String,Object>(); private Configuration config; private boolean configProvided = false; private AccessControlContext creatorAcc = null; private ModuleInfo[] moduleStack; private ClassLoader contextClassLoader = null; - private static final Class[] PARAMS = { }; + private static final Class<?>[] PARAMS = { }; // state saved in the event a user-specified asynchronous exception // was specified and thrown @@ -306,7 +306,7 @@ (DEFAULT_HANDLER); if (defaultHandler == null || defaultHandler.length() == 0) return null; - Class c = Class.forName(defaultHandler, + Class<?> c = Class.forName(defaultHandler, true, finalLoader); return (CallbackHandler)c.newInstance(); @@ -743,12 +743,12 @@ } else { // instantiate the LoginModule - Class c = Class.forName + Class<?> c = Class.forName (moduleStack[i].entry.getLoginModuleName(), true, contextClassLoader); - Constructor constructor = c.getConstructor(PARAMS); + Constructor<?> constructor = c.getConstructor(PARAMS); Object[] args = { }; // allow any object to be a LoginModule
--- a/src/share/classes/javax/security/auth/x500/X500Principal.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/auth/x500/X500Principal.java Mon Oct 17 19:06:53 2011 -0700 @@ -118,7 +118,7 @@ * is improperly specified */ public X500Principal(String name) { - this(name, (Map<String, String>) Collections.EMPTY_MAP); + this(name, Collections.<String, String>emptyMap()); } /**
--- a/src/share/classes/javax/security/cert/CertificateEncodingException.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/cert/CertificateEncodingException.java Mon Oct 17 19:06:53 2011 -0700 @@ -41,6 +41,7 @@ */ public class CertificateEncodingException extends CertificateException { + private static final long serialVersionUID = -8187642723048403470L; /** * Constructs a CertificateEncodingException with no detail message. A * detail message is a String that describes this particular
--- a/src/share/classes/javax/security/cert/CertificateException.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/cert/CertificateException.java Mon Oct 17 19:06:53 2011 -0700 @@ -41,6 +41,7 @@ */ public class CertificateException extends Exception { + private static final long serialVersionUID = -5757213374030785290L; /** * Constructs a certificate exception with no detail message. A detail * message is a String that describes this particular exception.
--- a/src/share/classes/javax/security/cert/CertificateExpiredException.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/cert/CertificateExpiredException.java Mon Oct 17 19:06:53 2011 -0700 @@ -43,6 +43,7 @@ */ public class CertificateExpiredException extends CertificateException { + private static final long serialVersionUID = 5091601212177261883L; /** * Constructs a CertificateExpiredException with no detail message. A * detail message is a String that describes this particular
--- a/src/share/classes/javax/security/cert/CertificateNotYetValidException.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/cert/CertificateNotYetValidException.java Mon Oct 17 19:06:53 2011 -0700 @@ -43,6 +43,7 @@ */ public class CertificateNotYetValidException extends CertificateException { + private static final long serialVersionUID = -8976172474266822818L; /** * Constructs a CertificateNotYetValidException with no detail message. A * detail message is a String that describes this particular
--- a/src/share/classes/javax/security/cert/CertificateParsingException.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/cert/CertificateParsingException.java Mon Oct 17 19:06:53 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,8 @@ */ public class CertificateParsingException extends CertificateException { + private static final long serialVersionUID = -8449352422951136229L; + /** * Constructs a CertificateParsingException with no detail message. A * detail message is a String that describes this particular
--- a/src/share/classes/javax/security/cert/X509Certificate.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/cert/X509Certificate.java Mon Oct 17 19:06:53 2011 -0700 @@ -219,11 +219,11 @@ className = "com.sun.security.cert.internal.x509.X509V1CertImpl"; } try { - Class[] params = null; + Class<?>[] params = null; if (value instanceof InputStream) { - params = new Class[] { InputStream.class }; + params = new Class<?>[] { InputStream.class }; } else if (value instanceof byte[]) { - params = new Class[] { value.getClass() }; + params = new Class<?>[] { value.getClass() }; } else throw new CertificateException("Unsupported argument type"); Class<?> certClass = Class.forName(className);
--- a/src/share/classes/javax/security/sasl/Sasl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/security/sasl/Sasl.java Mon Oct 17 19:06:53 2011 -0700 @@ -395,7 +395,7 @@ * will be thrown. */ ClassLoader cl = p.getClass().getClassLoader(); - Class implClass; + Class<?> implClass; implClass = Class.forName(className, true, cl); return implClass.newInstance(); } catch (ClassNotFoundException e) { @@ -576,7 +576,7 @@ classes.clear(); // Check the keys for each provider. - for (Enumeration e = providers[i].keys(); e.hasMoreElements(); ) { + for (Enumeration<Object> e = providers[i].keys(); e.hasMoreElements(); ) { String currentKey = (String)e.nextElement(); if (currentKey.startsWith(serviceName)) { // We should skip the currentKey if it contains a
--- a/src/share/classes/javax/smartcardio/TerminalFactory.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/smartcardio/TerminalFactory.java Mon Oct 17 19:06:53 2011 -0700 @@ -113,7 +113,7 @@ type = "PC/SC"; Provider sun = Security.getProvider("SunPCSC"); if (sun == null) { - Class clazz = Class.forName("sun.security.smartcardio.SunPCSC"); + Class<?> clazz = Class.forName("sun.security.smartcardio.SunPCSC"); sun = (Provider)clazz.newInstance(); } factory = TerminalFactory.getInstance(type, null, sun); @@ -131,6 +131,8 @@ } private static final class NoneProvider extends Provider { + + private static final long serialVersionUID = 2745808869881593918L; final static Provider INSTANCE = new NoneProvider(); private NoneProvider() { super("None", 1.0d, "none");
--- a/src/share/classes/javax/swing/BufferStrategyPaintManager.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/javax/swing/BufferStrategyPaintManager.java Mon Oct 17 19:06:53 2011 -0700 @@ -24,20 +24,17 @@ */ package javax.swing; -import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.lang.reflect.*; import java.lang.ref.WeakReference; -import java.security.AccessController; import java.util.*; import com.sun.java.swing.SwingUtilities3; import sun.awt.SubRegionShowable; import sun.java2d.SunGraphics2D; -import sun.security.action.GetPropertyAction; import sun.java2d.pipe.hw.ExtendedBufferCapabilities; import sun.awt.SunToolkit; import sun.util.logging.PlatformLogger; @@ -120,10 +117,6 @@ */ private JComponent rootJ; /** - * Parent Applet/Window for the current paint/copyArea - */ - private Container root; - /** * Location of component being painted relative to root. */ private int xOffset; @@ -278,7 +271,9 @@ public boolean paint(JComponent paintingComponent, JComponent bufferComponent, Graphics g, int x, int y, int w, int h) { - if (prepare(paintingComponent, true, x, y, w, h)) { + Container root = fetchRoot(paintingComponent); + + if (prepare(paintingComponent, root, true, x, y, w, h)) { if ((g instanceof SunGraphics2D) && ((SunGraphics2D)g).getDestination() == root) { // BufferStrategy may have already constrained the Graphics. To @@ -319,7 +314,9 @@ // // If the buffer isn't in sync there is no point in doing a copyArea, // it has garbage. - if (prepare(c, false, 0, 0, 0, 0) && bufferInfo.isInSync()) { + Container root = fetchRoot(c); + + if (prepare(c, root, false, 0, 0, 0, 0) && bufferInfo.isInSync()) { if (clip) { Rectangle cBounds = c.getVisibleRect(); int relX = xOffset + x; @@ -500,14 +497,14 @@ * * @return true if should use buffering per window in painting. */ - private boolean prepare(JComponent c, boolean isPaint, int x, int y, + private boolean prepare(JComponent c, Container root, boolean isPaint, int x, int y, int w, int h) { if (bsg != null) { bsg.dispose(); bsg = null; } bufferStrategy = null; - if (fetchRoot(c)) { + if (root != null) { boolean contentsLost = false; BufferInfo bufferInfo = getBufferInfo(root); if (bufferInfo == null) { @@ -567,10 +564,10 @@ return false; } - private boolean fetchRoot(JComponent c) { + private Container fetchRoot(JComponent c) { boolean encounteredHW = false; rootJ = c; - root = c; + Container root = c; xOffset = yOffset = 0; while (root != null && (!(root instanceof Window) && @@ -597,7 +594,7 @@ // heavyweights. If we didn't do this when we // went to show the descendants of the nested hw // you would see nothing, so, we bail out here. - return false; + return null; } } } @@ -613,11 +610,11 @@ // bit tricky with Swing. This gives a good approximation // of the various ways to turn on double buffering for // components. - return true; + return root; } } // Don't do true double buffering. - return false; + return null; } /**
--- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Mon Oct 17 19:06:53 2011 -0700 @@ -1661,7 +1661,7 @@ public IOException run() throws Exception { return (IOException) rememberedException.getClass() - .getConstructor(new Class[] { String.class }) + .getConstructor(new Class<?>[] { String.class }) .newInstance(args); } });
--- a/src/share/classes/sun/security/ec/ECPublicKeyImpl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/ec/ECPublicKeyImpl.java Mon Oct 17 19:06:53 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,6 +51,7 @@ * Construct a key from its components. Used by the * ECKeyFactory and SunPKCS11. */ + @SuppressWarnings("deprecation") public ECPublicKeyImpl(ECPoint w, ECParameterSpec params) throws InvalidKeyException { this.w = w; @@ -85,6 +86,7 @@ // Internal API to get the encoded point. Currently used by SunPKCS11. // This may change/go away depending on what we do with the public API. + @SuppressWarnings("deprecation") public byte[] getEncodedPublicValue() { return key.clone(); } @@ -92,6 +94,7 @@ /** * Parse the key. Called by X509Key. */ + @SuppressWarnings("deprecation") protected void parseKeyBits() throws InvalidKeyException { try { AlgorithmParameters algParams = this.algid.getParameters();
--- a/src/share/classes/sun/security/jgss/krb5/AcceptSecContextToken.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/jgss/krb5/AcceptSecContextToken.java Mon Oct 17 19:06:53 2011 -0700 @@ -94,7 +94,7 @@ */ EncryptionKey subKey = apRep.getSubKey(); if (subKey != null) { - context.setKey(subKey); + context.setKey(Krb5Context.ACCEPTOR_SUBKEY, subKey); /* System.out.println("\n\nSub-Session key from AP-REP is: " + getHexBytes(subKey.getBytes()) + "\n");
--- a/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java Mon Oct 17 19:06:53 2011 -0700 @@ -74,9 +74,9 @@ EncryptionKey subKey = apReq.getSubKey(); if (subKey != null) - context.setKey(subKey); + context.setKey(Krb5Context.INITIATOR_SUBKEY, subKey); else - context.setKey(serviceTicket.getSessionKey()); + context.setKey(Krb5Context.SESSION_KEY, serviceTicket.getSessionKey()); if (!mutualRequired) context.resetPeerSequenceNumber(0); @@ -117,13 +117,13 @@ EncryptionKey subKey = apReq.getSubKey(); if (subKey != null) { - context.setKey(subKey); + context.setKey(Krb5Context.INITIATOR_SUBKEY, subKey); /* System.out.println("Sub-Session key from authenticator is: " + getHexBytes(subKey.getBytes()) + "\n"); */ } else { - context.setKey(sessionKey); + context.setKey(Krb5Context.SESSION_KEY, sessionKey); //System.out.println("Sub-Session Key Missing in Authenticator.\n"); }
--- a/src/share/classes/sun/security/jgss/krb5/Krb5Context.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/jgss/krb5/Krb5Context.java Mon Oct 17 19:06:53 2011 -0700 @@ -67,6 +67,10 @@ private int state = STATE_NEW; + public static final int SESSION_KEY = 0; + public static final int INITIATOR_SUBKEY = 1; + public static final int ACCEPTOR_SUBKEY = 2; + /* * Optional features that the application can set and their default * values. @@ -82,6 +86,7 @@ private int mySeqNumber; private int peerSeqNumber; + private int keySrc; private TokenTracker peerTokenTracker; private CipherHelper cipherHelper = null; @@ -384,12 +389,17 @@ } } - final void setKey(EncryptionKey key) throws GSSException { + final void setKey(int keySrc, EncryptionKey key) throws GSSException { this.key = key; + this.keySrc = keySrc; // %%% to do: should clear old cipherHelper first cipherHelper = new CipherHelper(key); // Need to use new key } + public final int getKeySrc() { + return keySrc; + } + private final EncryptionKey getKey() { return key; }
--- a/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java Mon Oct 17 19:06:53 2011 -0700 @@ -141,6 +141,7 @@ // Context properties private boolean confState = true; private boolean initiator = true; + private boolean have_acceptor_subkey = false; /* cipher instance used by the corresponding GSSContext */ CipherHelper cipherHelper = null; @@ -233,7 +234,6 @@ } if (tokenId == Krb5Token.WRAP_ID_v2) { - // Does non-confidential data needs a rotate? rotate(); } @@ -312,8 +312,7 @@ } // Create a new gss token header as defined in RFC 4121 - tokenHeader = new MessageTokenHeader(tokenId, - prop.getPrivacy(), true); + tokenHeader = new MessageTokenHeader(tokenId, prop.getPrivacy()); // debug("\n\t Message Header = " + // getHexBytes(tokenHeader.getBytes(), tokenHeader.getBytes().length)); @@ -421,10 +420,12 @@ int conf_flag = tokenHeaderBytes[TOKEN_FLAG_POS] & FLAG_WRAP_CONFIDENTIAL; - // clear EC in token header for checksum calculation + // clear EC and RRC in token header for checksum calculation if ((conf_flag == 0) && (tokenId == WRAP_ID_v2)) { tokenHeaderBytes[4] = 0; tokenHeaderBytes[5] = 0; + tokenHeaderBytes[6] = 0; + tokenHeaderBytes[7] = 0; } return cipherHelper.calculateChecksum(tokenHeaderBytes, data, offset, len, key_usage); @@ -460,6 +461,8 @@ this.initiator = context.isInitiator(); + this.have_acceptor_subkey = context.getKeySrc() == Krb5Context.ACCEPTOR_SUBKEY; + this.cipherHelper = context.getCipherHelper(null); // debug("In MessageToken.Cons"); } @@ -500,8 +503,7 @@ private byte[] bytes = new byte[TOKEN_HEADER_SIZE]; // Writes a new token header - public MessageTokenHeader(int tokenId, boolean conf, - boolean have_acceptor_subkey) throws GSSException { + public MessageTokenHeader(int tokenId, boolean conf) throws GSSException { this.tokenId = tokenId;
--- a/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java Mon Oct 17 19:06:53 2011 -0700 @@ -144,15 +144,18 @@ /** * Retrieves an array of secret keys for the client. This is used when - * the client supplies password but need keys to act as an acceptor - * (in JAAS words, isInitiator=true and storeKey=true) + * the client supplies password but need keys to act as an acceptor. For + * an initiator, it must be called after AS-REQ is performed (state is OK). + * For an acceptor, it can be called when this KrbAsReqBuilder object is + * constructed (state is INIT). + * @param isInitiator if the caller is an initiator * @return generated keys from password. PA-DATA from server might be used. * All "default_tkt_enctypes" keys will be generated, Never null. * @throws IllegalStateException if not constructed from a password * @throws KrbException */ - public EncryptionKey[] getKeys() throws KrbException { - checkState(State.REQ_OK, "Cannot get keys"); + public EncryptionKey[] getKeys(boolean isInitiator) throws KrbException { + checkState(isInitiator?State.REQ_OK:State.INIT, "Cannot get keys"); if (password != null) { int[] eTypes = EType.getDefaults("default_tkt_enctypes"); EncryptionKey[] result = new EncryptionKey[eTypes.length];
--- a/src/share/classes/sun/security/pkcs11/SunPKCS11.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/pkcs11/SunPKCS11.java Mon Oct 17 19:06:53 2011 -0700 @@ -1335,10 +1335,10 @@ return null; } - Class c = Class.forName - (defaultHandler, - true, - Thread.currentThread().getContextClassLoader()); + Class<?> c = Class.forName + (defaultHandler, + true, + Thread.currentThread().getContextClassLoader()); return (CallbackHandler)c.newInstance(); } });
--- a/src/share/classes/sun/security/validator/PKIXValidator.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/validator/PKIXValidator.java Mon Oct 17 19:06:53 2011 -0700 @@ -327,6 +327,7 @@ * Set the check date (for debugging). */ private void setDate(PKIXBuilderParameters params) { + @SuppressWarnings("deprecation") Date date = validationDate; if (date != null) { params.setDate(date);
--- a/src/share/classes/sun/security/validator/SimpleValidator.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/validator/SimpleValidator.java Mon Oct 17 19:06:53 2011 -0700 @@ -131,6 +131,7 @@ // make sure chain includes a trusted cert chain = buildTrustedChain(chain); + @SuppressWarnings("deprecation") Date date = validationDate; if (date == null) { date = new Date();
--- a/src/share/classes/sun/security/x509/X509CertImpl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/security/x509/X509CertImpl.java Mon Oct 17 19:06:53 2011 -0700 @@ -1323,7 +1323,7 @@ for (Extension ex : exts.getAllExtensions()) { ObjectIdentifier inCertOID = ex.getExtensionId(); - if (inCertOID.equals(findOID)) { + if (inCertOID.equals((Object)findOID)) { certExt = ex; break; }
--- a/src/share/classes/sun/util/LocaleServiceProviderPool.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/share/classes/sun/util/LocaleServiceProviderPool.java Mon Oct 17 19:06:53 2011 -0700 @@ -40,6 +40,7 @@ import java.util.ServiceLoader; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.spi.LocaleServiceProvider; import sun.util.logging.PlatformLogger; @@ -57,8 +58,8 @@ * A Map that holds singleton instances of this class. Each instance holds a * set of provider implementations of a particular locale sensitive service. */ - private static Map<Class, LocaleServiceProviderPool> poolOfPools = - new ConcurrentHashMap<Class, LocaleServiceProviderPool>(); + private static ConcurrentMap<Class, LocaleServiceProviderPool> poolOfPools = + new ConcurrentHashMap<>(); /** * A Set containing locale service providers that implement the @@ -109,7 +110,7 @@ if (pool == null) { LocaleServiceProviderPool newPool = new LocaleServiceProviderPool(providerClass); - pool = poolOfPools.put(providerClass, newPool); + pool = poolOfPools.putIfAbsent(providerClass, newPool); if (pool == null) { pool = newPool; } @@ -257,10 +258,11 @@ synchronized (LocaleServiceProviderPool.class) { if (availableJRELocales == null) { Locale[] allLocales = LocaleData.getAvailableLocales(); - availableJRELocales = new ArrayList<Locale>(allLocales.length); + List<Locale> tmpList = new ArrayList<>(allLocales.length); for (Locale locale : allLocales) { - availableJRELocales.add(getLookupLocale(locale)); + tmpList.add(getLookupLocale(locale)); } + availableJRELocales = tmpList; } } }
--- a/src/solaris/bin/java_md.c Thu Oct 13 10:35:43 2011 -0700 +++ b/src/solaris/bin/java_md.c Mon Oct 17 19:06:53 2011 -0700 @@ -820,7 +820,6 @@ jboolean LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) { - Dl_info dlinfo; void *libjvm; JLI_TraceLauncher("JVM path is %s\n", jvmpath);
--- a/src/solaris/native/java/util/TimeZone_md.c Thu Oct 13 10:35:43 2011 -0700 +++ b/src/solaris/native/java/util/TimeZone_md.c Mon Oct 17 19:06:53 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,13 +30,13 @@ #include <limits.h> #include <errno.h> #include <stddef.h> - -#ifdef __linux__ +#include <sys/stat.h> +#include <sys/types.h> #include <string.h> #include <dirent.h> -#include <sys/stat.h> -#include <sys/types.h> #include <unistd.h> +#ifdef __solaris__ +#include <libscf.h> #endif #include "jvm.h" @@ -54,17 +54,22 @@ static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime"; +#else +static const char *SYS_INIT_FILE = "/etc/default/init"; +static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo"; +static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime"; +#endif /*__linux__*/ /* - * Returns a point to the zone ID portion of the given zoneinfo file - * name. + * Returns a pointer to the zone ID portion of the given zoneinfo file + * name, or NULL if the given string doesn't contain "zoneinfo/". */ static char * getZoneName(char *str) { static const char *zidir = "zoneinfo/"; - char * pos = strstr((const char *)str, zidir); + char *pos = strstr((const char *)str, zidir); if (pos == NULL) { return NULL; } @@ -74,7 +79,7 @@ /* * Returns a path name created from the given 'dir' and 'name' under * UNIX. This function allocates memory for the pathname calling - * malloc(). + * malloc(). NULL is returned if malloc() fails. */ static char * getPathName(const char *dir, const char *name) { @@ -89,19 +94,18 @@ /* * Scans the specified directory and its subdirectories to find a - * zoneinfo file which has the same content as /etc/localtime given in - * 'buf'. Returns a zone ID if found, otherwise, NULL is returned. + * zoneinfo file which has the same content as /etc/localtime on Linux + * or /usr/share/lib/zoneinfo/localtime (most likely a symbolic link) + * on Solaris given in 'buf'. Returns a zone ID if found, otherwise, + * NULL is returned. */ static char * findZoneinfoFile(char *buf, size_t size, const char *dir) { DIR *dirp = NULL; struct stat statbuf; - union { - struct dirent d; - char b[offsetof (struct dirent, d_name) + NAME_MAX + 1]; - } entry; - struct dirent *dp; + struct dirent *dp = NULL; + struct dirent *entry = NULL; char *pathname = NULL; int fd = -1; char *dbuf = NULL; @@ -112,7 +116,19 @@ return NULL; } - while (readdir_r(dirp, &entry.d, &dp) == 0 && dp != NULL) { + entry = (struct dirent *) malloc((size_t) pathconf(dir, _PC_NAME_MAX)); + if (entry == NULL) { + (void) closedir(dirp); + return NULL; + } + +#if defined(__linux__) || (defined(__solaris__) && (defined(_POSIX_PTHREAD_SEMANTICS) || \ + defined(_LP64))) + while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) { +#else + while ((dp = readdir_r(dirp, entry)) != NULL) { +#endif + /* * Skip '.' and '..' (and possibly other .* files) */ @@ -121,11 +137,17 @@ } /* - * Skip "ROC", "posixrules", and "localtime" since Java doesn't - * support them. + * Skip "ROC", "posixrules", and "localtime". */ if ((strcmp(dp->d_name, "ROC") == 0) || (strcmp(dp->d_name, "posixrules") == 0) +#ifdef __solaris__ + /* + * Skip the "src" and "tab" directories on Solaris. + */ + || (strcmp(dp->d_name, "src") == 0) + || (strcmp(dp->d_name, "tab") == 0) +#endif || (strcmp(dp->d_name, "localtime") == 0)) { continue; } @@ -149,7 +171,6 @@ break; } if ((fd = open(pathname, O_RDONLY)) == -1) { - fd = 0; break; } if (read(fd, dbuf, size) != (ssize_t) size) { @@ -165,19 +186,22 @@ free((void *) dbuf); dbuf = NULL; (void) close(fd); - fd = 0; + fd = -1; } free((void *) pathname); pathname = NULL; } + if (entry != NULL) { + free((void *) entry); + } if (dirp != NULL) { (void) closedir(dirp); } if (pathname != NULL) { free((void *) pathname); } - if (fd != 0) { + if (fd != -1) { (void) close(fd); } if (dbuf != NULL) { @@ -186,8 +210,10 @@ return tz; } +#ifdef __linux__ + /* - * Performs libc implementation specific mapping and returns a zone ID + * Performs Linux specific mapping and returns a zone ID * if found. Otherwise, NULL is returned. */ static char * @@ -408,12 +434,11 @@ } #endif /* not __sparcv9 */ -static const char *sys_init_file = "/etc/default/init"; /* - * Performs libc implementation dependent mapping. Returns a zone ID - * if found. Otherwise, NULL is returned. Solaris libc looks up - * "/etc/default/init" to get a default TZ value if TZ is not defined + * Performs Solaris dependent mapping. Returns a zone ID if + * found. Otherwise, NULL is returned. Solaris libc looks up + * "/etc/default/init" to get the default TZ value if TZ is not defined * as an environment variable. */ static char * @@ -425,7 +450,7 @@ /* * Try the TZ entry in /etc/default/init. */ - if ((fp = fileopen(sys_init_file, "r")) != NULL) { + if ((fp = fileopen(SYS_INIT_FILE, "r")) != NULL) { char line[256]; char quote = '\0'; @@ -473,8 +498,113 @@ return tz; } -#endif -#endif +#define TIMEZONE_FMRI "svc:/system/timezone:default" +#define TIMEZONE_PG "timezone" +#define LOCALTIME_PROP "localtime" + +static void +cleanupScf(scf_handle_t *h, + scf_snapshot_t *snap, + scf_instance_t *inst, + scf_propertygroup_t *pg, + scf_property_t *prop, + scf_value_t *val, + char *buf) { + if (buf != NULL) { + free(buf); + } + if (snap != NULL) { + scf_snapshot_destroy(snap); + } + if (val != NULL) { + scf_value_destroy(val); + } + if (prop != NULL) { + scf_property_destroy(prop); + } + if (pg != NULL) { + scf_pg_destroy(pg); + } + if (inst != NULL) { + scf_instance_destroy(inst); + } + if (h != NULL) { + scf_handle_destroy(h); + } +} + +/* + * Retruns a zone ID of Solaris when the TZ value is "localtime". + * First, it tries scf. If scf fails, it looks for the same file as + * /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/. + */ +static char * +getSolarisDefaultZoneID() { + char *tz = NULL; + struct stat statbuf; + size_t size; + char *buf; + int fd; + /* scf specific variables */ + scf_handle_t *h = NULL; + scf_snapshot_t *snap = NULL; + scf_instance_t *inst = NULL; + scf_propertygroup_t *pg = NULL; + scf_property_t *prop = NULL; + scf_value_t *val = NULL; + + if ((h = scf_handle_create(SCF_VERSION)) != NULL + && scf_handle_bind(h) == 0 + && (inst = scf_instance_create(h)) != NULL + && (snap = scf_snapshot_create(h)) != NULL + && (pg = scf_pg_create(h)) != NULL + && (prop = scf_property_create(h)) != NULL + && (val = scf_value_create(h)) != NULL + && scf_handle_decode_fmri(h, TIMEZONE_FMRI, NULL, NULL, inst, + NULL, NULL, SCF_DECODE_FMRI_REQUIRE_INSTANCE) == 0 + && scf_instance_get_snapshot(inst, "running", snap) == 0 + && scf_instance_get_pg_composed(inst, snap, TIMEZONE_PG, pg) == 0 + && scf_pg_get_property(pg, LOCALTIME_PROP, prop) == 0 + && scf_property_get_value(prop, val) == 0) { + ssize_t len; + + /* Gets the length of the zone ID string */ + len = scf_value_get_astring(val, NULL, 0); + if (len != -1) { + tz = malloc(++len); /* +1 for a null byte */ + if (tz != NULL && scf_value_get_astring(val, tz, len) != -1) { + cleanupScf(h, snap, inst, pg, prop, val, NULL); + return tz; + } + } + } + cleanupScf(h, snap, inst, pg, prop, val, tz); + + if (stat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) { + return NULL; + } + size = (size_t) statbuf.st_size; + buf = malloc(size); + if (buf == NULL) { + return NULL; + } + if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) { + free((void *) buf); + return NULL; + } + + if (read(fd, buf, size) != (ssize_t) size) { + (void) close(fd); + free((void *) buf); + return NULL; + } + (void) close(fd); + tz = findZoneinfoFile(buf, size, ZONEINFO_DIR); + free((void *) buf); + return tz; +} +#endif /*__solaris__*/ +#endif /*__linux__*/ /* * findJavaTZ_md() maps platform time zone ID to Java time zone ID @@ -504,10 +634,21 @@ freetz = tz; } + /* + * Remove any preceding ':' + */ + if (tz != NULL && *tz == ':') { + tz++; + } + +#ifdef __solaris__ + if (strcmp(tz, "localtime") == 0) { + tz = getSolarisDefaultZoneID(); + freetz = tz; + } +#endif + if (tz != NULL) { - if (*tz == ':') { - tz++; - } #ifdef __linux__ /* * Ignore "posix/" prefix. @@ -525,24 +666,36 @@ } /** - * Returns a GMT-offset-based time zone ID. (e.g., "GMT-08:00") + * Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00") */ char * getGMTOffsetID() { time_t offset; - char sign, buf[16]; + char sign, buf[32]; +#ifdef __solaris__ + struct tm localtm; + time_t currenttime; - if (timezone == 0) { + currenttime = time(NULL); + if (localtime_r(¤ttime, &localtm) == NULL) { + return NULL; + } + + offset = localtm.tm_isdst ? altzone : timezone; +#else + offset = timezone; +#endif /*__linux__*/ + + if (offset == 0) { return strdup("GMT"); } /* Note that the time offset direction is opposite. */ - if (timezone > 0) { - offset = timezone; + if (offset > 0) { sign = '-'; } else { - offset = -timezone; + offset = -offset; sign = '+'; } sprintf(buf, (const char *)"GMT%c%02d:%02d",
--- a/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c Thu Oct 13 10:35:43 2011 -0700 +++ b/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c Mon Oct 17 19:06:53 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -334,6 +334,7 @@ XDestroyImage(ximage); SplashRemoveDecoration(splash); XMapWindow(splash->display, splash->window); + XFlush(splash->display); } void SplashReconfigureNow(Splash * splash) {
--- a/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java Mon Oct 17 19:06:53 2011 -0700 @@ -70,7 +70,7 @@ fd1 = new FileDescriptor(); try { super.create(); - } catch (IOException e) { + } catch (SocketException e) { fd1 = null; throw e; } @@ -99,10 +99,11 @@ } if (optID == SO_BINDADDR) { - if (fd != null && fd1 != null) { + if ((fd != null && fd1 != null) && !connected) { return anyLocalBoundAddr; } - return socketGetOption(optID); + int family = connectedAddress == null ? -1 : connectedAddress.family; + return socketLocalAddress(family); } else return super.getOption(optID); } @@ -161,6 +162,8 @@ protected native void connect0(InetAddress address, int port) throws SocketException; + protected native Object socketLocalAddress(int family) throws SocketException; + protected native void disconnect0(int family); /**
--- a/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java Mon Oct 17 19:06:53 2011 -0700 @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.FileDescriptor; +import sun.net.ResourceManager; /* * This class defines the plain SocketImpl that is used for all @@ -81,7 +82,12 @@ */ protected synchronized void create(boolean stream) throws IOException { fd1 = new FileDescriptor(); - super.create(stream); + try { + super.create(stream); + } catch (IOException e) { + fd1 = null; + throw e; + } } /** @@ -120,6 +126,9 @@ protected void close() throws IOException { synchronized(fdLock) { if (fd != null || fd1 != null) { + if (!stream) { + ResourceManager.afterUdpClose(); + } if (fdUseCount == 0) { if (closePending) { return;
--- a/src/windows/classes/sun/awt/windows/WComponentPeer.java Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java Mon Oct 17 19:06:53 2011 -0700 @@ -615,6 +615,14 @@ _dispose(); } + public void disposeLater() { + postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), new Runnable() { + public void run() { + dispose(); + } + })); + } + public synchronized void setForeground(Color c) { foreground = c; _setForeground(c.getRGB());
--- a/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Mon Oct 17 19:06:53 2011 -0700 @@ -2181,30 +2181,6 @@ return getMulticastInterface(env, this, fd, fd1, opt); } - if (opt == java_net_SocketOptions_SO_BINDADDR) { - /* find out local IP address */ - SOCKETADDRESS him; - int len = 0; - int port; - jobject iaObj; - - len = sizeof (struct sockaddr_in); - - if (fd == -1) { - fd = fd1; /* must be IPv6 only */ - len = sizeof (struct SOCKADDR_IN6); - } - - if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) { - NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", - "Error getting socket name"); - return NULL; - } - iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port); - - return iaObj; - } - /* * Map the Java level socket option to the platform specific * level and option name. @@ -2253,6 +2229,61 @@ } /* + * Returns local address of the socket. + * + * Class: java_net_TwoStacksPlainDatagramSocketImpl + * Method: socketLocalAddress + * Signature: (I)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL +Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress(JNIEnv *env, jobject this, + jint family) { + + int fd=-1, fd1=-1; + SOCKETADDRESS him; + int len = 0; + int port; + jobject iaObj; + int ipv6_supported = ipv6_available(); + + fd = getFD(env, this); + if (ipv6_supported) { + fd1 = getFD1(env, this); + } + + if (fd < 0 && fd1 < 0) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "Socket closed"); + return NULL; + } + + /* find out local IP address */ + + len = sizeof (struct sockaddr_in); + + /* family==-1 when socket is not connected */ + if ((family == IPv6) || (family == -1 && fd == -1)) { + fd = fd1; /* must be IPv6 only */ + len = sizeof (struct SOCKADDR_IN6); + } + + if (fd == -1) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "Socket closed"); + return NULL; + } + + if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) { + NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", + "Error getting socket name"); + return NULL; + } + iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port); + + return iaObj; +} + +/* * Class: java_net_TwoStacksPlainDatagramSocketImpl * Method: setTimeToLive * Signature: (I)V
--- a/src/windows/native/sun/windows/awt_Component.cpp Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/native/sun/windows/awt_Component.cpp Mon Oct 17 19:06:53 2011 -0700 @@ -183,6 +183,7 @@ jmethodID AwtComponent::getLocationOnScreenMID; jmethodID AwtComponent::replaceSurfaceDataMID; jmethodID AwtComponent::replaceSurfaceDataLaterMID; +jmethodID AwtComponent::disposeLaterMID; HKL AwtComponent::m_hkl = ::GetKeyboardLayout(0); LANGID AwtComponent::m_idLang = LOWORD(::GetKeyboardLayout(0)); @@ -246,6 +247,7 @@ m_hCursorCache = NULL; m_bSubclassed = FALSE; + m_bPauseDestroy = FALSE; m_MessagesProcessing = 0; m_wheelRotationAmount = 0; @@ -319,6 +321,12 @@ m_brushBackground = NULL; } + if (m_bPauseDestroy) { + // AwtComponent::WmNcDestroy could be released now + m_bPauseDestroy = FALSE; + m_hwnd = NULL; + } + // The component instance is deleted using AwtObject::Dispose() method AwtObject::Dispose(); } @@ -1377,6 +1385,7 @@ case WM_CREATE: mr = WmCreate(); break; case WM_CLOSE: mr = WmClose(); break; case WM_DESTROY: mr = WmDestroy(); break; + case WM_NCDESTROY: mr = WmNcDestroy(); break; case WM_ERASEBKGND: mr = WmEraseBkgnd((HDC)wParam, *(BOOL*)&retValue); break; @@ -1965,10 +1974,24 @@ */ MsgRouting AwtComponent::WmDestroy() { - // fix for 6259348: we should enter the SyncCall critical section before - // disposing the native object, that is value 1 of lParam is intended for - if(m_peerObject != NULL) { // is not being terminating - AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)m_peerObject, (LPARAM)1); + return mrConsume; +} + +/* + * This message should only be received when a window is destroyed by + * Windows, and not Java. It is sent only after child windows were destroyed. + */ +MsgRouting AwtComponent::WmNcDestroy() +{ + if (m_peerObject != NULL) { // is not being terminating + // Stay in this handler until AwtComponent::Dispose is called. + m_bPauseDestroy = TRUE; + + JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); + // Post invocation event for WObjectPeer.dispose to EDT + env->CallVoidMethod(m_peerObject, AwtComponent::disposeLaterMID); + // Wait until AwtComponent::Dispose is called + AwtToolkit::GetInstance().PumpToDestroy(this); } return mrConsume; @@ -6300,6 +6323,7 @@ env->GetMethodID(peerCls, "replaceSurfaceData", "()V"); AwtComponent::replaceSurfaceDataLaterMID = env->GetMethodID(peerCls, "replaceSurfaceDataLater", "()V"); + AwtComponent::disposeLaterMID = env->GetMethodID(peerCls, "disposeLater", "()V"); DASSERT(AwtComponent::xID); DASSERT(AwtComponent::yID); @@ -6318,6 +6342,8 @@ DASSERT(AwtComponent::getLocationOnScreenMID); DASSERT(AwtComponent::replaceSurfaceDataMID); DASSERT(AwtComponent::replaceSurfaceDataLaterMID); + DASSERT(AwtComponent::disposeLaterMID); + CATCH_BAD_ALLOC; }
--- a/src/windows/native/sun/windows/awt_Component.h Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/native/sun/windows/awt_Component.h Mon Oct 17 19:06:53 2011 -0700 @@ -119,6 +119,7 @@ static jmethodID getLocationOnScreenMID; static jmethodID replaceSurfaceDataMID; static jmethodID replaceSurfaceDataLaterMID; + static jmethodID disposeLaterMID; static const UINT WmAwtIsComponent; static jint * masks; //InputEvent mask array @@ -490,6 +491,7 @@ virtual MsgRouting WmCreate() {return mrDoDefault;} virtual MsgRouting WmClose() {return mrDoDefault;} virtual MsgRouting WmDestroy(); + virtual MsgRouting WmNcDestroy(); virtual MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite) { @@ -711,6 +713,10 @@ return m_MessagesProcessing == 0; } + BOOL IsDestroyPaused() const { + return m_bPauseDestroy; + } + protected: static AwtComponent* GetComponentImpl(HWND hWnd); @@ -752,6 +758,7 @@ UINT m_mouseButtonClickAllowed; BOOL m_bSubclassed; + BOOL m_bPauseDestroy; COLORREF m_colorForeground; COLORREF m_colorBackground;
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/native/sun/windows/awt_Toolkit.cpp Mon Oct 17 19:06:53 2011 -0700 @@ -733,26 +733,13 @@ return 0; } case WM_AWT_DISPOSE: { - BOOL canDispose = TRUE; - CriticalSection &syncCS = AwtToolkit::GetInstance().GetSyncCS(); - int shouldEnterCriticalSection = (int)lParam; - if (shouldEnterCriticalSection == 1) { - canDispose = syncCS.TryEnter(); - } - if (canDispose) { - if(wParam != NULL) { - jobject self = (jobject)wParam; - AwtObject *o = (AwtObject *) JNI_GET_PDATA(self); - env->DeleteGlobalRef(self); - if(o != NULL && theAwtObjectList.Remove(o)) { - o->Dispose(); - } - if (shouldEnterCriticalSection) { - syncCS.Leave(); - } + if(wParam != NULL) { + jobject self = (jobject)wParam; + AwtObject *o = (AwtObject *) JNI_GET_PDATA(self); + env->DeleteGlobalRef(self); + if(o != NULL && theAwtObjectList.Remove(o)) { + o->Dispose(); } - } else { - AwtToolkit::GetInstance().PostMessage(WM_AWT_DISPOSE, wParam, lParam); } return 0; } @@ -1340,25 +1327,46 @@ while (!m_breakMessageLoop && (*lpPeekMessageFunc)(msg)) { foundOne = TRUE; - if (msg.message == WM_QUIT) { - m_breakMessageLoop = TRUE; - m_messageLoopResult = static_cast<UINT>(msg.wParam); - if (m_messageLoopResult == EXIT_ALL_ENCLOSING_LOOPS) - ::PostQuitMessage(static_cast<int>(msg.wParam)); // make sure all loops exit - break; - } - else if (msg.message != WM_NULL) { - /* - * The AWT in standalone mode (that is, dynamically loaded from the - * Java VM) doesn't have any translation tables to worry about, so - * TranslateAccelerator isn't called. - */ - - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); + ProcessMsg(msg); + } + return foundOne; +} + +void AwtToolkit::PumpToDestroy(class AwtComponent* p) +{ + MSG msg; + + DASSERT(AwtToolkit::PrimaryIdleFunc != NULL); + DASSERT(AwtToolkit::CommonPeekMessageFunc != NULL); + + while (p->IsDestroyPaused() && !m_breakMessageLoop) { + + PrimaryIdleFunc(); + + while (p->IsDestroyPaused() && !m_breakMessageLoop && CommonPeekMessageFunc(msg)) { + ProcessMsg(msg); } } - return foundOne; +} + +void AwtToolkit::ProcessMsg(MSG& msg) +{ + if (msg.message == WM_QUIT) { + m_breakMessageLoop = TRUE; + m_messageLoopResult = static_cast<UINT>(msg.wParam); + if (m_messageLoopResult == EXIT_ALL_ENCLOSING_LOOPS) + ::PostQuitMessage(static_cast<int>(msg.wParam)); // make sure all loops exit + } + else if (msg.message != WM_NULL) { + /* + * The AWT in standalone mode (that is, dynamically loaded from the + * Java VM) doesn't have any translation tables to worry about, so + * TranslateAccelerator isn't called. + */ + + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } } VOID CALLBACK
--- a/src/windows/native/sun/windows/awt_Toolkit.h Thu Oct 13 10:35:43 2011 -0700 +++ b/src/windows/native/sun/windows/awt_Toolkit.h Mon Oct 17 19:06:53 2011 -0700 @@ -305,6 +305,8 @@ UINT MessageLoop(IDLEPROC lpIdleFunc, PEEKMESSAGEPROC lpPeekMessageFunc); BOOL PumpWaitingMessages(PEEKMESSAGEPROC lpPeekMessageFunc); + void PumpToDestroy(class AwtComponent* p); + void ProcessMsg(MSG& msg); BOOL PreProcessMsg(MSG& msg); BOOL PreProcessMouseMsg(class AwtComponent* p, MSG& msg); BOOL PreProcessKeyMsg(class AwtComponent* p, MSG& msg);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/jndi/ldap/LdapsReadTimeoutTest.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7094377 + * @summary Com.sun.jndi.ldap.read.timeout doesn't work with ldaps. + */ + +import java.net.Socket; +import java.net.ServerSocket; +import java.io.*; +import javax.naming.*; +import javax.naming.directory.*; +import java.util.Hashtable; + +public class LdapsReadTimeoutTest { + + public static void main(String[] args) throws Exception { + boolean passed = false; + + // create the server + try (Server server = Server.create()) { + // Set up the environment for creating the initial context + Hashtable<String,Object> env = new Hashtable<>(11); + env.put(Context.INITIAL_CONTEXT_FACTORY, + "com.sun.jndi.ldap.LdapCtxFactory"); + env.put("com.sun.jndi.ldap.connect.timeout", "1000"); + env.put("com.sun.jndi.ldap.read.timeout", "1000"); + env.put(Context.PROVIDER_URL, "ldaps://localhost:" + server.port()); + + + // Create initial context + DirContext ctx = new InitialDirContext(env); + try { + System.out.println("LDAP Client: Connected to the Server"); + + SearchControls scl = new SearchControls(); + scl.setSearchScope(SearchControls.SUBTREE_SCOPE); + System.out.println("Performing Search"); + NamingEnumeration<SearchResult> answer = + ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl); + } finally { + // Close the context when we're done + ctx.close(); + } + } catch (NamingException e) { + passed = true; + e.printStackTrace(); + } + + if (!passed) { + throw new Exception("Read timeout test failed," + + " read timeout exception not thrown"); + } + System.out.println("The test PASSED"); + } + + static class Server implements Runnable, Closeable { + private final ServerSocket ss; + private Socket sref; + + private Server(ServerSocket ss) { + this.ss = ss; + } + + static Server create() throws IOException { + Server server = new Server(new ServerSocket(0)); + new Thread(server).start(); + return server; + } + + int port() { + return ss.getLocalPort(); + } + + public void run() { + try (Socket s = ss.accept()) { + sref = s; + System.out.println("Server: Connection accepted"); + BufferedInputStream bis = + new BufferedInputStream(s.getInputStream()); + byte[] buf = new byte[100]; + int n; + do { + n = bis.read(buf); + } while (n > 0); + } catch (IOException e) { + // ignore + } + } + + public void close() throws IOException { + ss.close(); + sref.close(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/CookieHandler/NullUriCookieTest.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6953455 + * @summary CookieStore.add() cannot handle null URI parameter + */ + +import java.net.CookieManager; +import java.net.CookieStore; +import java.net.HttpCookie; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +public class NullUriCookieTest { + static boolean fail = false; + + public static void main(String[] args) throws Exception { + checkCookieNullUri(); + } + + static void checkCookieNullUri() throws Exception { + //get a cookie store implementation and add a cookie to the store with null URI + CookieStore cookieStore = (new CookieManager()).getCookieStore(); + HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE"); + cookie.setDomain("foo.com"); + cookieStore.add(null, cookie); + + //Retrieve added cookie + URI uri = new URI("http://foo.com"); + List<HttpCookie> addedCookieList = cookieStore.get(uri); + + //Verify CookieStore behaves well + if (addedCookieList.size() != 1) { + fail = true; + } + checkFail("Abnormal size of cookie jar"); + + for (HttpCookie chip : addedCookieList) { + if (!chip.equals(cookie)) { + fail = true; + } + } + checkFail("Cookie not retrieved from Cookie Jar"); + boolean ret = cookieStore.remove(null,cookie); + if (!ret) { + fail = true; + } + checkFail("Abnormal removal behaviour from Cookie Jar"); + } + + static void checkFail(String exp) { + if (fail) { + throw new RuntimeException(exp); + } + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/DatagramSocket/ChangingAddress.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 7084030 + * @summary Tests that DatagramSocket.getLocalAddress returns the right local + * address after connect/disconnect. + */ +import java.net.*; + +public class ChangingAddress { + + static void check(DatagramSocket ds, InetAddress expected) { + InetAddress actual = ds.getLocalAddress(); + if (!expected.equals(actual)) { + throw new RuntimeException("Expected:"+expected+" Actual"+ + actual); + } + } + + public static void main(String[] args) throws Exception { + InetAddress lh = InetAddress.getLocalHost(); + SocketAddress remote = new InetSocketAddress(lh, 1234); + InetAddress wildcard = InetAddress.getByAddress + ("localhost", new byte[]{0,0,0,0}); + try (DatagramSocket ds = new DatagramSocket()) { + check(ds, wildcard); + + ds.connect(remote); + check(ds, lh); + + ds.disconnect(); + check(ds, wildcard); + } + } +}
--- a/test/java/net/URLConnection/Redirect307Test.java Thu Oct 13 10:35:43 2011 -0700 +++ b/test/java/net/URLConnection/Redirect307Test.java Mon Oct 17 19:06:53 2011 -0700 @@ -23,7 +23,7 @@ /** * @test - * @bug 4380568 + * @bug 4380568 7095949 * @summary HttpURLConnection does not support 307 redirects */ import java.io.*; @@ -31,10 +31,9 @@ class RedirServer extends Thread { - ServerSocket s; - Socket s1; - InputStream is; - OutputStream os; + static final int TIMEOUT = 10 * 1000; + + ServerSocket ss; int port; String reply1Part1 = "HTTP/1.1 307 Temporary Redirect\r\n" + @@ -46,10 +45,10 @@ "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + "<html>Hello</html>"; - RedirServer (ServerSocket y) { - s = y; - port = s.getLocalPort(); - System.out.println("Server created listening on " + port); + RedirServer (ServerSocket ss) throws IOException { + this.ss = ss; + this.ss.setSoTimeout(TIMEOUT); + port = this.ss.getLocalPort(); } String reply2 = "HTTP/1.1 200 Ok\r\n" + @@ -59,74 +58,63 @@ "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + "World"; + static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' }; + + // Read until the end of a HTTP request + void readOneRequest(InputStream is) throws IOException { + int requestEndCount = 0, r; + while ((r = is.read()) != -1) { + if (r == requestEnd[requestEndCount]) { + requestEndCount++; + if (requestEndCount == 4) { + break; + } + } else { + requestEndCount = 0; + } + } + } + public void run () { try { - s1 = s.accept (); - is = s1.getInputStream (); - os = s1.getOutputStream (); - is.read (); - String reply = reply1Part1 + port + reply1Part2; - os.write (reply.getBytes()); - os.close(); + try (Socket s = ss.accept()) { + s.setSoTimeout(TIMEOUT); + readOneRequest(s.getInputStream()); + String reply = reply1Part1 + port + reply1Part2; + s.getOutputStream().write(reply.getBytes()); + } + /* wait for redirected connection */ - s.setSoTimeout (5000); - s1 = s.accept (); - is = s1.getInputStream (); - os = s1.getOutputStream (); - is.read(); - os.write (reply2.getBytes()); - os.close(); - } - catch (Exception e) { - /* Just need thread to terminate */ - System.out.println("Server: caught " + e); + try (Socket s = ss.accept()) { + s.setSoTimeout(TIMEOUT); + readOneRequest(s.getInputStream()); + s.getOutputStream().write(reply2.getBytes()); + } + } catch (Exception e) { e.printStackTrace(); } finally { - try { s.close(); } catch (IOException unused) {} + try { ss.close(); } catch (IOException unused) {} } } }; - public class Redirect307Test { - - public static final int DELAY = 10; - public static void main(String[] args) throws Exception { - int port; - RedirServer server; - ServerSocket sock; + ServerSocket sock = new ServerSocket(0); + int port = sock.getLocalPort(); + RedirServer server = new RedirServer(sock); + server.start(); - try { - sock = new ServerSocket (0); - port = sock.getLocalPort (); - } - catch (Exception e) { - System.out.println ("Exception: " + e); - return; - } - - server = new RedirServer(sock); - server.start (); + URL url = new URL("http://localhost:" + port); + URLConnection conURL = url.openConnection(); + conURL.setDoInput(true); + conURL.setAllowUserInteraction(false); + conURL.setUseCaches(false); - try { - - String s = "http://localhost:" + port; - URL url = new URL(s); - URLConnection conURL = url.openConnection(); - - conURL.setDoInput(true); - conURL.setAllowUserInteraction(false); - conURL.setUseCaches(false); - - InputStream in = conURL.getInputStream(); + try (InputStream in = conURL.getInputStream()) { if ((in.read() != (int)'W') || (in.read()!=(int)'o')) { throw new RuntimeException ("Unexpected string read"); } } - catch(IOException e) { - e.printStackTrace(); - throw new RuntimeException ("Exception caught + " + e); - } } }
--- a/test/java/net/URLConnection/RedirectLimit.java Thu Oct 13 10:35:43 2011 -0700 +++ b/test/java/net/URLConnection/RedirectLimit.java Mon Oct 17 19:06:53 2011 -0700 @@ -23,7 +23,7 @@ /** * @test - * @bug 4458085 + * @bug 4458085 7095949 * @summary Redirects Limited to 5 */ @@ -57,29 +57,43 @@ final ServerSocket ss; final int port; - RedirLimitServer(ServerSocket ss) { + RedirLimitServer(ServerSocket ss) throws IOException { this.ss = ss; - port = ss.getLocalPort(); + port = this.ss.getLocalPort(); + this.ss.setSoTimeout(TIMEOUT); + } + + static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' }; + + // Read until the end of a HTTP request + void readOneRequest(InputStream is) throws IOException { + int requestEndCount = 0, r; + while ((r = is.read()) != -1) { + if (r == requestEnd[requestEndCount]) { + requestEndCount++; + if (requestEndCount == 4) { + break; + } + } else { + requestEndCount = 0; + } + } } public void run() { try { - ss.setSoTimeout(TIMEOUT); for (int i=0; i<NUM_REDIRECTS; i++) { try (Socket s = ss.accept()) { s.setSoTimeout(TIMEOUT); - InputStream is = s.getInputStream(); - OutputStream os = s.getOutputStream(); - is.read(); + readOneRequest(s.getInputStream()); String reply = reply1 + port + "/redirect" + i + reply2; - os.write(reply.getBytes()); + s.getOutputStream().write(reply.getBytes()); } } try (Socket s = ss.accept()) { - InputStream is = s.getInputStream(); - OutputStream os = s.getOutputStream(); - is.read(); - os.write(reply3.getBytes()); + s.setSoTimeout(TIMEOUT); + readOneRequest(s.getInputStream()); + s.getOutputStream().write(reply3.getBytes()); } } catch (Exception e) { e.printStackTrace(); @@ -96,21 +110,17 @@ RedirLimitServer server = new RedirLimitServer(ss); server.start(); - InputStream in = null; - try { - URL url = new URL("http://localhost:" + port); - URLConnection conURL = url.openConnection(); + URL url = new URL("http://localhost:" + port); + URLConnection conURL = url.openConnection(); - conURL.setDoInput(true); - conURL.setAllowUserInteraction(false); - conURL.setUseCaches(false); + conURL.setDoInput(true); + conURL.setAllowUserInteraction(false); + conURL.setUseCaches(false); - in = conURL.getInputStream(); + try (InputStream in = conURL.getInputStream()) { if ((in.read() != (int)'W') || (in.read()!=(int)'o')) { throw new RuntimeException("Unexpected string read"); } - } finally { - if ( in != null ) { in.close(); } } } }
--- a/test/java/util/Locale/Bug6989440.java Thu Oct 13 10:35:43 2011 -0700 +++ b/test/java/util/Locale/Bug6989440.java Mon Oct 17 19:06:53 2011 -0700 @@ -37,26 +37,49 @@ import sun.util.LocaleServiceProviderPool; public class Bug6989440 { - public static void main(String[] args) { - TestThread t1 = new TestThread(LocaleNameProvider.class); - TestThread t2 = new TestThread(TimeZoneNameProvider.class); - TestThread t3 = new TestThread(DateFormatProvider.class); + static volatile boolean failed; // false + static final int THREADS = 50; - t1.start(); - t2.start(); - t3.start(); + public static void main(String[] args) throws Exception { + Thread[] threads = new Thread[THREADS]; + for (int i=0; i<threads.length; i++) + threads[i] = new TestThread(); + for (int i=0; i<threads.length; i++) + threads[i].start(); + for (int i=0; i<threads.length; i++) + threads[i].join(); + + if (failed) + throw new RuntimeException("Failed: check output"); } static class TestThread extends Thread { private Class<? extends LocaleServiceProvider> cls; + private static int count; public TestThread(Class<? extends LocaleServiceProvider> providerClass) { cls = providerClass; } + public TestThread() { + int which = count++ % 3; + switch (which) { + case 0 : cls = LocaleNameProvider.class; break; + case 1 : cls = TimeZoneNameProvider.class; break; + case 2 : cls = DateFormatProvider.class; break; + default : throw new AssertionError("Should not reach here"); + } + } + public void run() { - LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls); - pool.getAvailableLocales(); + try { + LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls); + pool.getAvailableLocales(); + } catch (Exception e) { + System.out.println(e); + e.printStackTrace(); + failed = true; + } } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JColorChooser/Test6827032.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6827032 + * @summary Color chooser with drag enabled shouldn't throw NPE + * @author Peter Zhelezniakov + * @library ../regtesthelpers + */ + +import sun.awt.SunToolkit; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + + +public class Test6827032 { + + private static volatile Point point; + private static JColorChooser cc; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel"); + point = previewPanel.getLocationOnScreen(); + } + }); + + point.translate(5, 5); + + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + + + private static void createAndShowGUI() { + JFrame frame = new JFrame(Test6827032.class.getName()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + cc = new JColorChooser(); + cc.setDragEnabled(true); + frame.add(cc); + frame.pack(); + frame.setVisible(true); + } +}
--- a/test/javax/swing/regtesthelpers/Util.java Thu Oct 13 10:35:43 2011 -0700 +++ b/test/javax/swing/regtesthelpers/Util.java Mon Oct 17 19:06:53 2011 -0700 @@ -116,4 +116,28 @@ System.out.println("Got OOME"); } + + /** + * Find a sub component by class name. + * Always run this method on the EDT thread + */ + public static Component findSubComponent(Component parent, String className) { + String parentClassName = parent.getClass().getName(); + + if (parentClassName.contains(className)) { + return parent; + } + + if (parent instanceof Container) { + for (Component child : ((Container) parent).getComponents()) { + Component subComponent = findSubComponent(child, className); + + if (subComponent != null) { + return subComponent; + } + } + } + + return null; + } }
--- a/test/sun/misc/JarIndex/metaInfFilenames/Basic.java Thu Oct 13 10:35:43 2011 -0700 +++ b/test/sun/misc/JarIndex/metaInfFilenames/Basic.java Mon Oct 17 19:06:53 2011 -0700 @@ -154,8 +154,8 @@ /* run javac <args> */ static void compile(String... args) { debug("Running: javac " + Arrays.toString(args)); - com.sun.tools.javac.main.Main compiler = new com.sun.tools.javac.main.Main("javac"); - if (compiler.compile(args) != com.sun.tools.javac.main.Main.Result.OK) { + com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main(); + if (compiler.compile(args) != 0) { throw new RuntimeException("javac failed: args=" + Arrays.toString(args)); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/krb5/auto/AcceptorSubKey.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7077646 + * @summary gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY + * @compile -XDignore.symbol.file AcceptorSubKey.java + * @run main/othervm AcceptorSubKey + */ + +import java.util.Arrays; +import sun.security.jgss.GSSUtil; + +// The basic krb5 test skeleton you can copy from +public class AcceptorSubKey { + + public static void main(String[] args) throws Exception { + + new OneKDC(null).writeJAASConf(); + + Context c, s; + c = Context.fromJAAS("client"); + s = Context.fromJAAS("server"); + + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID); + s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID); + + Context.handshake(c, s); + + byte[] msg = "i say high --".getBytes(); + byte[] wrapped = s.wrap(msg, false); + + // FLAG_ACCEPTOR_SUBKEY is 4 + int flagOn = wrapped[2] & 4; + if (flagOn != 0) { + throw new Exception("Java GSS should not have set acceptor subkey"); + } + + s.dispose(); + c.dispose(); + } +}
--- a/test/sun/security/krb5/auto/Context.java Thu Oct 13 10:35:43 2011 -0700 +++ b/test/sun/security/krb5/auto/Context.java Mon Oct 17 19:06:53 2011 -0700 @@ -375,6 +375,89 @@ } } + public byte[] wrap(byte[] t, final boolean privacy) + throws Exception { + return doAs(new Action() { + @Override + public byte[] run(Context me, byte[] input) throws Exception { + System.out.printf("wrap %s privacy from %s: ", privacy?"with":"without", me.name); + MessageProp p1 = new MessageProp(0, privacy); + byte[] out; + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.wrap(new ByteArrayInputStream(input), os, p1); + out = os.toByteArray(); + } else { + out = me.x.wrap(input, 0, input.length, p1); + } + System.out.println(printProp(p1)); + return out; + } + }, t); + } + + public byte[] unwrap(byte[] t, final boolean privacy) + throws Exception { + return doAs(new Action() { + @Override + public byte[] run(Context me, byte[] input) throws Exception { + System.out.printf("unwrap %s privacy from %s: ", privacy?"with":"without", me.name); + MessageProp p1 = new MessageProp(0, privacy); + byte[] bytes; + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.unwrap(new ByteArrayInputStream(input), os, p1); + bytes = os.toByteArray(); + } else { + bytes = me.x.unwrap(input, 0, input.length, p1); + } + System.out.println(printProp(p1)); + return bytes; + } + }, t); + } + + public byte[] getMic(byte[] t) throws Exception { + return doAs(new Action() { + @Override + public byte[] run(Context me, byte[] input) throws Exception { + MessageProp p1 = new MessageProp(0, true); + byte[] bytes; + p1 = new MessageProp(0, true); + System.out.printf("getMic from %s: ", me.name); + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.getMIC(new ByteArrayInputStream(input), os, p1); + bytes = os.toByteArray(); + } else { + bytes = me.x.getMIC(input, 0, input.length, p1); + } + System.out.println(printProp(p1)); + return bytes; + } + }, t); + } + + public void verifyMic(byte[] t, final byte[] msg) throws Exception { + doAs(new Action() { + @Override + public byte[] run(Context me, byte[] input) throws Exception { + MessageProp p1 = new MessageProp(0, true); + System.out.printf("verifyMic from %s: ", me.name); + if (usingStream) { + me.x.verifyMIC(new ByteArrayInputStream(input), + new ByteArrayInputStream(msg), p1); + } else { + me.x.verifyMIC(input, 0, input.length, + msg, 0, msg.length, + p1); + } + System.out.println(printProp(p1)); + return null; + } + }, t); + } + /** * Transmits a message from one Context to another. The sender wraps the * message and sends it to the receiver. The receiver unwraps it, creates @@ -390,73 +473,13 @@ final byte[] messageBytes = message.getBytes(); System.out.printf("-------------------- TRANSMIT from %s to %s------------------------\n", s1.name, s2.name); - - byte[] t = s1.doAs(new Action() { - @Override - public byte[] run(Context me, byte[] dummy) throws Exception { - System.out.println("wrap"); - MessageProp p1 = new MessageProp(0, true); - byte[] out; - if (usingStream) { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - me.x.wrap(new ByteArrayInputStream(messageBytes), os, p1); - out = os.toByteArray(); - } else { - out = me.x.wrap(messageBytes, 0, messageBytes.length, p1); - } - System.out.println(printProp(p1)); - return out; - } - }, null); - - t = s2.doAs(new Action() { - @Override - public byte[] run(Context me, byte[] input) throws Exception { - MessageProp p1 = new MessageProp(0, true); - byte[] bytes; - if (usingStream) { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - me.x.unwrap(new ByteArrayInputStream(input), os, p1); - bytes = os.toByteArray(); - } else { - bytes = me.x.unwrap(input, 0, input.length, p1); - } - if (!Arrays.equals(messageBytes, bytes)) - throw new Exception("wrap/unwrap mismatch"); - System.out.println("unwrap"); - System.out.println(printProp(p1)); - p1 = new MessageProp(0, true); - System.out.println("getMIC"); - if (usingStream) { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - me.x.getMIC(new ByteArrayInputStream(messageBytes), os, p1); - bytes = os.toByteArray(); - } else { - bytes = me.x.getMIC(messageBytes, 0, messageBytes.length, p1); - } - System.out.println(printProp(p1)); - return bytes; - } - }, t); - - // Re-unwrap should make p2.isDuplicateToken() returns true - s1.doAs(new Action() { - @Override - public byte[] run(Context me, byte[] input) throws Exception { - MessageProp p1 = new MessageProp(0, true); - System.out.println("verifyMIC"); - if (usingStream) { - me.x.verifyMIC(new ByteArrayInputStream(input), - new ByteArrayInputStream(messageBytes), p1); - } else { - me.x.verifyMIC(input, 0, input.length, - messageBytes, 0, messageBytes.length, - p1); - } - System.out.println(printProp(p1)); - return null; - } - }, t); + byte[] wrapped = s1.wrap(messageBytes, true); + byte[] unwrapped = s2.unwrap(wrapped, true); + if (!Arrays.equals(messageBytes, unwrapped)) { + throw new Exception("wrap/unwrap mismatch"); + } + byte[] mic = s2.getMic(unwrapped); + s1.verifyMic(mic, messageBytes); } /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/krb5/auto/NoInitNoKeytab.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7089889 + * @summary Krb5LoginModule.login() throws an exception if used without a keytab + * @compile -XDignore.symbol.file NoInitNoKeytab.java + * @run main/othervm NoInitNoKeytab + */ + +import java.io.FileOutputStream; +import sun.security.jgss.GSSUtil; + +// The basic krb5 test skeleton you can copy from +public class NoInitNoKeytab { + + public static void main(String[] args) throws Exception { + + new OneKDC(null).writeJAASConf(); + try (FileOutputStream fos = + new FileOutputStream(OneKDC.JAAS_CONF, true)) { + fos.write(( + "noinit {\n" + + " com.sun.security.auth.module.Krb5LoginModule required\n" + + " principal=\"" + OneKDC.USER + "\"\n" + + " useKeyTab=false\n" + + " isInitiator=false\n" + + " storeKey=true;\n};\n").getBytes()); + } + Context c, s; + c = Context.fromJAAS("client"); + s = Context.fromJAAS("noinit"); + + c.startAsClient(OneKDC.USER, GSSUtil.GSS_SPNEGO_MECH_OID); + s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID); + + Context.handshake(c, s); + + Context.transmit("i say high --", c, s); + Context.transmit(" you say low", s, c); + + s.dispose(); + c.dispose(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/krb5/auto/RRC.java Mon Oct 17 19:06:53 2011 -0700 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7077640 + * @summary gss wrap for cfx doesn't handle rrc != 0 + * @compile -XDignore.symbol.file RRC.java + * @run main/othervm RRC + */ + +import java.util.Arrays; +import sun.security.jgss.GSSUtil; + +// The basic krb5 test skeleton you can copy from +public class RRC { + + public static void main(String[] args) throws Exception { + + new OneKDC(null).writeJAASConf(); + + Context c, s; + c = Context.fromJAAS("client"); + s = Context.fromJAAS("server"); + + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID); + s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID); + + Context.handshake(c, s); + + byte[] msg = "i say high --".getBytes(); + byte[] wrapped = c.wrap(msg, false); + + // Simulate RRC equals to EC + int rrc = wrapped[5]; + byte[] rotated = new byte[wrapped.length]; + System.arraycopy(wrapped, 0, rotated, 0, 16); + System.arraycopy(wrapped, wrapped.length-rrc, rotated, 16, rrc); + System.arraycopy(wrapped, 16, rotated, 16+rrc, wrapped.length-16-rrc); + rotated[7] = (byte)rrc; + + byte[] unwrapped = s.unwrap(rotated, false); + if (!Arrays.equals(msg, unwrapped)) { + throw new Exception("Failure"); + } + + s.dispose(); + c.dispose(); + } +}