changeset 8544:87f272ff78ef

7088502: Security libraries don't build with javac -Werror Summary: Changes to files in src/share/classes/com/sun/org/apache/xml/internal/security and its subpackages to remove warnings Reviewed-by: mullan Contributed-by: kurchi.subhra.hazra@oracle.com
author mullan
date Thu, 19 Jan 2017 04:02:34 +0000
parents d6c9ad4c9835
children 3595b8ed0309
files make/com/sun/org/apache/xml/Makefile src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
diffstat 38 files changed, 301 insertions(+), 268 deletions(-) [+]
line wrap: on
line diff
--- a/make/com/sun/org/apache/xml/Makefile	Wed Jan 18 03:12:16 2017 +0000
+++ b/make/com/sun/org/apache/xml/Makefile	Thu Jan 19 04:02:34 2017 +0000
@@ -30,6 +30,7 @@
 BUILDDIR = ../../../../..
 PACKAGE = com.sun.org.apache.xml
 PRODUCT = xml
+JAVAC_MAX_WARNINGS = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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/c14n/helper/AttrCompare.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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() };
@@ -363,7 +367,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);
@@ -382,7 +386,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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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(
@@ -307,12 +307,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));
 
     }
 
@@ -326,7 +326,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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java	Thu Jan 19 04:02:34 2017 +0000
@@ -33,8 +33,11 @@
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedSet;
+import java.util.Collection;
 
 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;
@@ -86,9 +89,9 @@
    static final int NODE_BEFORE_DOCUMENT_ELEMENT = -1;
    static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT = 0;
    static final int NODE_AFTER_DOCUMENT_ELEMENT = 1;
-   List nodeFilter;
+   List<NodeFilter> nodeFilter;
    boolean _includeComments;
-   Set _xpathNodeSet = null;
+   Set<Node> _xpathNodeSet = null;
 
    /**
     * The node to be skiped/excluded from the DOM tree
@@ -127,7 +130,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));
@@ -248,7 +251,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()) {
 
@@ -295,11 +298,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);
                                 }
                         }
@@ -391,7 +394,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()) {
 
@@ -461,11 +464,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);
                                 }
                         }
@@ -519,9 +522,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;
                         }
@@ -532,9 +535,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;
                 }
@@ -546,9 +549,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;
                 }
            }
@@ -586,7 +589,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 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
                         return;
@@ -598,9 +601,9 @@
                         parent = parent.getParentNode();
                 }
                 //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;
@@ -618,7 +621,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;
 
    /**
@@ -629,7 +632,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;
@@ -654,7 +657,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(_EQUALS_STR.clone());
@@ -835,6 +838,12 @@
               }
            }
 
+    @SuppressWarnings("unchecked")
+    protected Collection<Attr> getSortedSetAsCollection(SortedSet<Attr> result) {
+        return (Collection<Attr>)(Collection)result;
+    }
+
+
     // The null xmlns definition.
     protected Attr getNullNode(Document ownerDocument) {
         if (nullNode == null) {
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java	Thu Jan 19 04:02:34 2017 +0000
@@ -2774,7 +2774,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;
@@ -2783,7 +2783,7 @@
              * @param algorithm
              */
             public AgreementMethodImpl(String algorithm) {
-                agreementMethodInformation = new LinkedList();
+                agreementMethodInformation = new LinkedList<Element>();
                 URI tmpAlgorithm = null;
                 try {
                     tmpAlgorithm = new URI(algorithm);
@@ -2804,7 +2804,7 @@
             }
 
             /** @inheritDoc */
-            public Iterator getAgreementMethodInformation() {
+            public Iterator<Element> getAgreementMethodInformation() {
                 return (agreementMethodInformation.iterator());
             }
 
@@ -2881,9 +2881,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) {
@@ -3488,7 +3488,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
@@ -3501,7 +3501,7 @@
                     // complain
                 }
                 this.algorithm = tmpAlgorithm.toString();
-                encryptionMethodInformation = new LinkedList();
+                encryptionMethodInformation = new LinkedList<Element>();
             }
             /** @inheritDoc */
             public String getAlgorithm() {
@@ -3524,7 +3524,7 @@
                 oaepParams = params;
             }
             /** @inheritDoc */
-            public Iterator getEncryptionMethodInformation() {
+            public Iterator<Element> getEncryptionMethodInformation() {
                 return (encryptionMethodInformation.iterator());
             }
             /** @inheritDoc */
@@ -3567,8 +3567,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);
@@ -3584,13 +3584,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() {
@@ -3601,7 +3601,7 @@
                 this.id = id;
             }
             /** @inheritDoc */
-            public Iterator getEncryptionProperties() {
+            public Iterator<EncryptionProperty> getEncryptionProperties() {
                 return (encryptionProperties.iterator());
             }
             /** @inheritDoc */
@@ -3627,7 +3627,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());
@@ -3649,15 +3649,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() {
@@ -3694,14 +3694,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 */
@@ -3823,8 +3823,8 @@
         //    </complexType>
         //</element>
         private class ReferenceListImpl implements ReferenceList {
-            private Class sentry;
-            private List references;
+            private Class<?> sentry;
+            private List<Reference> references;
             /**
              *
              * @param type
@@ -3837,7 +3837,7 @@
                 } else {
                     throw new IllegalArgumentException();
                 }
-                references = new LinkedList();
+                references = new LinkedList<Reference>();
             }
             /** @inheritDoc */
             public void add(Reference reference) {
@@ -3862,7 +3862,7 @@
                 return (references.isEmpty());
             }
             /** @inheritDoc */
-            public Iterator getReferences() {
+            public Iterator<Reference> getReferences() {
                 return (references.iterator());
             }
 
@@ -3871,9 +3871,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());
                 }
@@ -3896,18 +3896,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/keyresolver/KeyResolverSpi.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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>
  *  &lt;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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java	Thu Jan 19 04:02:34 2017 +0000
@@ -280,18 +280,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 != null && currentNode.getNodeType() == Node.ELEMENT_NODE) {
                            e=(Element)currentNode;
                            break;
                    }
 
            }
-           List parents=new ArrayList(10);
+           List<Element> parents=new ArrayList<Element>(10);
 
                 //Obtain all the parents of the elemnt
                 while (e != null) {
@@ -303,10 +303,10 @@
                         e=(Element)n;
                 }
                 //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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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;
 
@@ -63,17 +64,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}
@@ -86,7 +87,7 @@
 
       XMLUtils.addReturnToElement(this._constructionElement);
 
-      this._references = new ArrayList();
+      this._references = new ArrayList<Reference>();
    }
 
    /**
@@ -123,7 +124,7 @@
       }
 
       // create Vector
-      this._references = new ArrayList(le);
+      this._references = new ArrayList<Reference>(le);
 
       for (int i = 0; i < le; i++) {
          Element refElem = this._referencesEl[i];
@@ -186,7 +187,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();
          }
@@ -219,7 +220,7 @@
             this._references.set(i, ref);
          }
 
-         return (Reference) this._references.get(i);
+         return this._references.get(i);
 
    }
 
@@ -333,12 +334,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()
@@ -459,7 +460,7 @@
           return;
       }
       if (_perManifestResolvers==null)
-          _perManifestResolvers = new ArrayList();
+          _perManifestResolvers = new ArrayList<ResourceResolver>();
       this._perManifestResolvers.add(resolver);
 
    }
@@ -475,7 +476,7 @@
           return;
       }
       if (_perManifestResolvers==null)
-                  _perManifestResolvers = new ArrayList();
+                  _perManifestResolvers = new ArrayList<ResourceResolver>();
       this._perManifestResolvers.add(new ResourceResolver(resolverSpi));
 
    }
@@ -489,7 +490,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);
    }
@@ -501,7 +502,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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java	Thu Jan 19 04:02:34 2017 +0000
@@ -435,6 +435,7 @@
     *
     * @deprecated use getContentsBeforeTransformation
     */
+   @Deprecated
    public XMLSignatureInput getTransformsInput() throws ReferenceNotInitializedException
         {
                 XMLSignatureInput input=getContentsBeforeTransformation();
@@ -556,7 +557,7 @@
 
       try {
          XMLSignatureInput nodes = this.getNodesetBeforeFirstCanonicalization();
-         Set inclusiveNamespaces = new HashSet();
+         Set<String> inclusiveNamespaces = new HashSet<String>();
 
          {
             Transforms transforms = this.getTransforms();
@@ -709,7 +710,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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java	Thu Jan 19 04:02:34 2017 +0000
@@ -75,7 +75,7 @@
     /**
      * The original NodeSet for this XMLSignatureInput
      */
-    Set _inputNodeSet = null;
+    Set<Node> _inputNodeSet = null;
     /**
      * The original Element
      */
@@ -108,7 +108,7 @@
     /**
      * Node Filter list.
      */
-    List nodeFilters=new ArrayList();
+    List<NodeFilter> nodeFilters=new ArrayList<NodeFilter>();
 
     boolean needsToBeExpanded=false;
     OutputStream outputStream=null;
@@ -165,6 +165,7 @@
      * @deprecated
      * @param inputStr the input String which including XML document or node
      */
+    @Deprecated
     public XMLSignatureInput(String inputStr) {
         this(inputStr.getBytes());
     }
@@ -180,6 +181,7 @@
      * @param encoding the encoding of <code>inputStr</code>
      * @throws UnsupportedEncodingException
      */
+    @Deprecated
     public XMLSignatureInput(String inputStr, String encoding)
            throws UnsupportedEncodingException {
         this(inputStr.getBytes(encoding));
@@ -202,7 +204,7 @@
      * @param inputNodeSet
      * @param usedXPathAPI
      */
-    public XMLSignatureInput(Set inputNodeSet) {
+    public XMLSignatureInput(Set<Node> inputNodeSet) {
         this._inputNodeSet = inputNodeSet;
     }
 
@@ -216,7 +218,7 @@
      * @throws ParserConfigurationException
      * @throws CanonicalizationException
      */
-    public Set getNodeSet() throws CanonicalizationException,
+    public Set<Node> getNodeSet() throws CanonicalizationException,
         ParserConfigurationException, IOException, SAXException {
         return getNodeSet(false);
     }
@@ -232,7 +234,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) {
@@ -243,13 +245,13 @@
             if (circumvent) {
                 XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
             }
-            this._inputNodeSet = new LinkedHashSet();
+            this._inputNodeSet = new LinkedHashSet<Node>();
             XMLUtils.getSet(_subNode,this._inputNodeSet, excludeNode, this.excludeComments);
 
             return this._inputNodeSet;
         } else if (this.isOctetStream()) {
             convertToNodes();
-            LinkedHashSet result = new LinkedHashSet();
+            LinkedHashSet<Node> result = new LinkedHashSet<Node>();
             XMLUtils.getSet(_subNode, result,null,false);
             //this._inputNodeSet=result;
             return result;
@@ -448,7 +450,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,
@@ -585,7 +587,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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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/TransformSpi.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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());
@@ -185,9 +185,9 @@
                 hasIntersectFilter=!intersectNodes.isEmpty();
                 this.intersectNodes=convertNodeListToSet(intersectNodes);
         }
-        Set unionNodes;
-        Set substractNodes;
-        Set intersectNodes;
+        Set<Node> unionNodes;
+        Set<Node> substractNodes;
+        Set<Node> intersectNodes;
 
 
    /**
@@ -267,19 +267,18 @@
     *
     * @return if rooted bye the rootnodes
     */
-   static boolean  rooted(Node currentNode, Set nodeList ) {
+   static boolean  rooted(Node currentNode, Set<Node> nodeList ) {
            if (nodeList.isEmpty()) {
                return false;
            }
            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;
    }
@@ -291,14 +290,14 @@
        *
        * @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);
       }
 
-    private static Set convertNodeListToSet(List l){
-        Set result=new HashSet();
-        for (int j=0;j<l.size();j++) {
-             NodeList rootNodes=(NodeList) l.get(j);
+    private 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);
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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/HelperNodeList.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java	Thu Jan 19 04:02:34 2017 +0000
@@ -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/resolver/implementations/ResolverDirectHTTP.java	Wed Jan 18 03:12:16 2017 +0000
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java	Thu Jan 19 04:02:34 2017 +0000
@@ -289,7 +289,7 @@
     * @inheritDoc
     */
    public String[] engineGetPropertyKeys() {
-      return (String[]) ResolverDirectHTTP.properties.clone();
+      return ResolverDirectHTTP.properties.clone();
    }
 
    private URI getNewURI(String uri, String BaseURI)